Changeset 2565:b4e45fdd906b
- Timestamp:
- 11/16/13 19:33:23 (12 years ago)
- Branch:
- 2.6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/widgets/_widgets_functions.php
r2198 r2565 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 12 13 if (!defined('DC_RC_PATH')) { return; } 13 14 … … 17 18 { 18 19 global $core; 19 20 20 21 if (($w->homeonly == 1 && $core->url->type != 'default') || 21 22 ($w->homeonly == 2 && $core->url->type == 'default')) { … … 24 25 25 26 $value = isset($GLOBALS['_search']) ? html::escapeHTML($GLOBALS['_search']) : ''; 26 27 27 28 return 28 29 ($w->content_only ? '' : '<div id="search"'.($w->class ? ' class="'.html::escapeHTML($w->class).'"' : '').'>'). … … 36 37 ($w->content_only ? '' : '</div>'); 37 38 } 38 39 39 40 public static function navigation($w) 40 41 { 41 42 global $core; 42 43 43 44 if (($w->homeonly == 1 && $core->url->type != 'default') || 44 45 ($w->homeonly == 2 && $core->url->type == 'default')) { … … 50 51 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 51 52 '<ul>'; 52 53 53 54 if ($core->url->type != 'default') { 54 55 $res .= … … 57 58 '<span> - </span></li>'; 58 59 } 59 60 60 61 $res .= 61 62 '<li class="topnav-arch">'. … … 64 65 '</ul>'. 65 66 ($w->content_only ? '' : '</div>'); 66 67 return $res; 68 } 69 67 68 return $res; 69 } 70 70 71 public static function categories($w) 71 72 { 72 73 global $core, $_ctx; 73 74 74 75 if (($w->homeonly == 1 && $core->url->type != 'default') || 75 76 ($w->homeonly == 2 && $core->url->type == 'default')) { … … 81 82 return; 82 83 } 83 84 84 85 $res = 85 86 ($w->content_only ? '' : '<div class="categories'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 86 87 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''); 87 88 88 89 $ref_level = $level = $rs->level-1; 89 90 while ($rs->fetch()) … … 94 95 $class = ' class="category-current"'; 95 96 } 96 97 97 98 if ($rs->level > $level) { 98 99 $res .= str_repeat('<ul><li'.$class.'>',$rs->level - $level); … … 100 101 $res .= str_repeat('</li></ul>',-($rs->level - $level)); 101 102 } 102 103 103 104 if ($rs->level <= $level) { 104 105 $res .= '</li><li'.$class.'>'; 105 106 } 106 107 107 108 $res .= 108 109 '<a href="'.$core->blog->url.$core->url->getURLFor('category', $rs->cat_url).'">'. 109 110 html::escapeHTML($rs->cat_title).'</a>'. 110 111 ($w->postcount ? ' <span>('.($w->subcatscount ? $rs->nb_total : $rs->nb_post).')</span>' : ''); 111 112 112 113 113 114 $level = $rs->level; 114 115 } 115 116 116 117 if ($ref_level - $level < 0) { 117 118 $res .= str_repeat('</li></ul>',-($ref_level - $level)); 118 119 } 119 120 $res .= ($w->content_only ? '' : '</div>'); 120 121 return $res; 122 } 123 121 122 return $res; 123 } 124 124 125 public static function bestof($w) 125 126 { 126 127 global $core; 127 128 if (($w->homeonly == 1 && $core->url->type != 'default') || 129 ($w->homeonly == 2 && $core->url->type == 'default')) { 130 return; 131 } 132 128 129 if (($w->homeonly == 1 && $core->url->type != 'default') || 130 ($w->homeonly == 2 && $core->url->type == 'default')) { 131 return; 132 } 133 133 134 $params = array( 134 135 'post_selected' => true, … … 136 137 'order' => 'post_dt '.strtoupper($w->orderby) 137 138 ); 138 139 139 140 $rs = $core->blog->getPosts($params); 140 141 141 142 if ($rs->isEmpty()) { 142 143 return; 143 144 } 144 145 145 146 $res = 146 147 ($w->content_only ? '' : '<div class="selected'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 147 148 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 148 149 '<ul>'; 149 150 150 151 while ($rs->fetch()) { 151 152 $res .= ' <li><a href="'.$rs->getURL().'">'.html::escapeHTML($rs->post_title).'</a></li> '; 152 153 } 153 154 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 155 156 return $res; 157 } 158 154 155 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 156 157 return $res; 158 } 159 159 160 public static function langs($w) 160 161 { 161 162 global $core, $_ctx; 162 163 163 164 if (($w->homeonly == 1 && $core->url->type != 'default' && $core->url->type != 'lang') || 164 165 ($w->homeonly == 2 && ($core->url->type == 'default' || $core->url->type == 'lang'))) { 165 166 return; 166 167 } 167 168 168 169 $rs = $core->blog->getLangs(); 169 170 170 171 if ($rs->count() <= 1) { 171 172 return; 172 173 } 173 174 174 175 $langs = l10n::getISOcodes(); 175 176 $res = … … 177 178 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 178 179 '<ul>'; 179 180 180 181 while ($rs->fetch()) 181 182 { 182 183 $l = ($_ctx->cur_lang == $rs->post_lang) ? '<strong>%s</strong>' : '%s'; 183 184 184 185 $lang_name = isset($langs[$rs->post_lang]) ? $langs[$rs->post_lang] : $rs->post_lang; 185 186 186 187 $res .= 187 188 ' <li>'. 188 189 sprintf($l, 189 '<a href="'.$core-> url->getURLFor('lang',$rs->post_lang).'" '.190 '<a href="'.$core->blog->url.$core->url->getURLFor('lang',$rs->post_lang).'" '. 190 191 'class="lang-'.$rs->post_lang.'">'. 191 192 $lang_name.'</a>'). 192 193 ' </li>'; 193 194 } 194 195 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 196 197 return $res; 198 } 199 195 196 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 197 198 return $res; 199 } 200 200 201 public static function subscribe($w) 201 202 { 202 203 global $core; 203 204 if (($w->homeonly == 1 && $core->url->type != 'default') || 205 ($w->homeonly == 2 && $core->url->type == 'default')) { 206 return; 207 } 208 204 205 if (($w->homeonly == 1 && $core->url->type != 'default') || 206 ($w->homeonly == 2 && $core->url->type == 'default')) { 207 return; 208 } 209 209 210 $type = ($w->type == 'atom' || $w->type == 'rss2') ? $w->type : 'rss2'; 210 211 $mime = $type == 'rss2' ? 'application/rss+xml' : 'application/atom+xml'; 211 212 212 213 $p_title = __('This blog\'s entries %s feed'); 213 214 $c_title = __('This blog\'s comments %s feed'); 214 215 215 216 $res = 216 217 ($w->content_only ? '' : '<div class="syndicate'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 217 218 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 218 219 '<ul>'; 219 220 220 221 $res .= 221 222 '<li><a type="'.$mime.'" '. … … 223 224 'title="'.sprintf($p_title,($type == 'atom' ? 'Atom' : 'RSS')).'" class="feed">'. 224 225 __('Entries feed').'</a></li>'; 225 226 226 227 if ($core->blog->settings->system->allow_comments || $core->blog->settings->system->allow_trackbacks) 227 228 { … … 232 233 __('Comments feed').'</a></li>'; 233 234 } 234 235 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 236 237 return $res; 238 } 239 235 236 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 237 238 return $res; 239 } 240 240 241 public static function feed($w) 241 242 { … … 243 244 return; 244 245 } 245 246 global $core; 247 248 if (($w->homeonly == 1 && $core->url->type != 'default') || 249 ($w->homeonly == 2 && $core->url->type == 'default')) { 250 return; 251 } 252 246 247 global $core; 248 249 if (($w->homeonly == 1 && $core->url->type != 'default') || 250 ($w->homeonly == 2 && $core->url->type == 'default')) { 251 return; 252 } 253 253 254 $limit = abs((integer) $w->limit); 254 255 255 256 try { 256 257 $feed = feedReader::quickParse($w->url,DC_TPL_CACHE); … … 261 262 return; 262 263 } 263 264 264 265 $res = 265 266 ($w->content_only ? '' : '<div class="feed'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 266 267 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 267 268 '<ul>'; 268 269 269 270 $i = 0; 270 271 foreach ($feed->items as $item) { 271 272 $title = isset($item->title) && strlen(trim($item->title)) ? $item->title : ''; 272 273 $link = isset($item->link) && strlen(trim($item->link)) ? $item->link : ''; 273 274 274 275 if (!$link && !$title) { 275 276 continue; 276 277 } 277 278 278 279 if (!$title) { 279 280 $title = substr($link,0,25).'...'; 280 281 } 281 282 282 283 $li = $link ? '<a href="'.html::escapeHTML($item->link).'">'.$title.'</a>' : $title; 283 284 $res .= ' <li>'.$li.'</li> '; … … 287 288 } 288 289 } 289 290 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 291 292 return $res; 293 } 294 290 291 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 292 293 return $res; 294 } 295 295 296 public static function text($w) 296 297 { 297 298 global $core; 298 299 if (($w->homeonly == 1 && $core->url->type != 'default') || 300 ($w->homeonly == 2 && $core->url->type == 'default')) { 301 return; 302 } 303 299 300 if (($w->homeonly == 1 && $core->url->type != 'default') || 301 ($w->homeonly == 2 && $core->url->type == 'default')) { 302 return; 303 } 304 304 305 $res = 305 306 ($w->content_only ? '' : '<div class="text'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). … … 307 308 $w->text. 308 309 ($w->content_only ? '' : '</div>'); 309 310 return $res; 311 } 312 310 311 return $res; 312 } 313 313 314 public static function lastposts($w) 314 315 { 315 316 global $core; 316 317 if (($w->homeonly == 1 && $core->url->type != 'default') || 318 ($w->homeonly == 2 && $core->url->type == 'default')) { 319 return; 320 } 321 317 318 if (($w->homeonly == 1 && $core->url->type != 'default') || 319 ($w->homeonly == 2 && $core->url->type == 'default')) { 320 return; 321 } 322 322 323 $params['limit'] = abs((integer) $w->limit); 323 324 $params['order'] = 'post_dt desc'; 324 325 $params['no_content'] = true; 325 326 326 327 if ($w->category) 327 328 { … … 334 335 } 335 336 } 336 337 337 338 if ($w->tag) 338 339 { … … 344 345 $rs = $core->blog->getPosts($params); 345 346 } 346 347 347 348 if ($rs->isEmpty()) { 348 349 return; 349 350 } 350 351 351 352 $res = 352 353 ($w->content_only ? '' : '<div class="lastposts'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 353 354 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 354 355 '<ul>'; 355 356 356 357 while ($rs->fetch()) { 357 358 $res .= '<li><a href="'.$rs->getURL().'">'. 358 359 html::escapeHTML($rs->post_title).'</a></li>'; 359 360 } 360 361 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 362 363 return $res; 364 } 365 361 362 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 363 364 return $res; 365 } 366 366 367 public static function lastcomments($w) 367 368 { 368 369 global $core; 369 370 if (($w->homeonly == 1 && $core->url->type != 'default') || 371 ($w->homeonly == 2 && $core->url->type == 'default')) { 372 return; 373 } 374 370 371 if (($w->homeonly == 1 && $core->url->type != 'default') || 372 ($w->homeonly == 2 && $core->url->type == 'default')) { 373 return; 374 } 375 375 376 $params['limit'] = abs((integer) $w->limit); 376 377 $params['order'] = 'comment_dt desc'; 377 378 $rs = $core->blog->getComments($params); 378 379 379 380 if ($rs->isEmpty()) { 380 381 return; 381 382 } 382 383 383 384 $res = ($w->content_only ? '' : '<div class="lastcomments'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 384 385 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 385 386 '<ul>'; 386 387 387 388 while ($rs->fetch()) 388 389 { … … 394 395 '</a></li>'; 395 396 } 396 397 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 398 397 398 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 399 399 400 return $res; 400 401 } 401 402 } 402 ?>
Note: See TracChangeset
for help on using the changeset viewer.