Changeset 1107:3943962d69b8 for plugins/widgets/_widgets_functions.php
- Timestamp:
- 02/27/13 11:48:32 (12 years ago)
- Branch:
- sexy
- Parents:
- 880:02c78f56f430 (diff), 1105:ce855d61f9ce (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/widgets/_widgets_functions.php
r851 r1107 18 18 global $core; 19 19 20 if (($w->homeonly == 1 && $core->url->type != 'default') || 21 ($w->homeonly == 2 && $core->url->type == 'default')) { 22 return; 23 } 24 20 25 $value = isset($GLOBALS['_search']) ? html::escapeHTML($GLOBALS['_search']) : ''; 21 26 22 27 return 23 '<div id="search">'.28 ($w->content_only ? '' : '<div id="search"'.($w->class ? ' class="'.html::escapeHTML($w->class).'"' : '').'>'). 24 29 ($w->title ? '<h2><label for="q">'.html::escapeHTML($w->title).'</label></h2>' : ''). 25 30 '<form action="'.$core->blog->url.'" method="get">'. … … 29 34 '</fieldset>'. 30 35 '</form>'. 31 '</div>';36 ($w->content_only ? '' : '</div>'); 32 37 } 33 38 … … 36 41 global $core; 37 42 38 $res = 39 '<div id="topnav">'. 43 if (($w->homeonly == 1 && $core->url->type != 'default') || 44 ($w->homeonly == 2 && $core->url->type == 'default')) { 45 return; 46 } 47 48 $res = 49 ($w->content_only ? '' : '<div id="topnav"'.($w->class ? ' class="'.html::escapeHTML($w->class).'"' : '').'>'). 40 50 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 41 51 '<ul>'; … … 53 63 __('Archives').'</a></li>'. 54 64 '</ul>'. 55 '</div>'; 56 57 return $res; 58 } 59 65 ($w->content_only ? '' : '</div>'); 66 67 return $res; 68 } 69 70 60 71 public static function bestof($w) 61 72 { 62 73 global $core; 63 74 64 if ($w->homeonly && $core->url->type != 'default') { 75 if (($w->homeonly == 1 && $core->url->type != 'default') || 76 ($w->homeonly == 2 && $core->url->type == 'default')) { 65 77 return; 66 78 } … … 79 91 80 92 $res = 81 '<div class="selected">'.93 ($w->content_only ? '' : '<div class="selected'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 82 94 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 83 95 '<ul>'; … … 87 99 } 88 100 89 $res .= '</ul> </div>';101 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 90 102 91 103 return $res; … … 96 108 global $core, $_ctx; 97 109 98 if ($w->homeonly && $core->url->type != 'default' && $core->url->type != 'lang') { 110 if (($w->homeonly == 1 && $core->url->type != 'default' && $core->url->type != 'lang') || 111 ($w->homeonly == 2 && ($core->url->type == 'default' || $core->url->type == 'lang'))) { 99 112 return; 100 113 } … … 108 121 $langs = l10n::getISOcodes(); 109 122 $res = 110 '<div class="langs">'.123 ($w->content_only ? '' : '<div class="langs'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 111 124 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 112 125 '<ul>'; … … 127 140 } 128 141 129 $res .= '</ul> </div>';142 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 130 143 131 144 return $res; … … 136 149 global $core; 137 150 138 if ($w->homeonly && $core->url->type != 'default') { 151 if (($w->homeonly == 1 && $core->url->type != 'default') || 152 ($w->homeonly == 2 && $core->url->type == 'default')) { 139 153 return; 140 154 } … … 144 158 145 159 $p_title = __('This blog\'s entries %s feed'); 146 $c_title = __('This blog\'s comments %s feed'); 147 148 $res = 149 '<div class="syndicate">'. 160 161 $res = 162 ($w->content_only ? '' : '<div class="syndicate'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 150 163 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 151 164 '<ul>'; … … 157 170 __('Entries feed').'</a></li>'; 158 171 159 if ($core->blog->settings->system->allow_comments || $core->blog->settings->system->allow_trackbacks) 160 { 161 $res .= 162 '<li><a type="'.$mime.'" '. 163 'href="'.$core->blog->url.$core->url->getURLFor('feed',$type.'/comments').'" '. 164 'title="'.sprintf($c_title,($type == 'atom' ? 'Atom' : 'RSS')).'" class="feed">'. 165 __('Comments feed').'</a></li>'; 166 } 167 168 $res .= '</ul></div>'; 172 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 169 173 170 174 return $res; … … 179 183 global $core; 180 184 181 if ($w->homeonly && $core->url->type != 'default') { 185 if (($w->homeonly == 1 && $core->url->type != 'default') || 186 ($w->homeonly == 2 && $core->url->type == 'default')) { 182 187 return; 183 188 } … … 195 200 196 201 $res = 197 '<div class="feed">'.202 ($w->content_only ? '' : '<div class="feed'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 198 203 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 199 204 '<ul>'; … … 201 206 $i = 0; 202 207 foreach ($feed->items as $item) { 203 $li = isset($item->link) ? '<a href="'.html::escapeHTML($item->link).'">'.$item->title.'</a>' : $item->title; 208 $title = isset($item->title) && strlen(trim($item->title)) ? $item->title : ''; 209 $link = isset($item->link) && strlen(trim($item->link)) ? $item->link : ''; 210 211 if (!$link && !$title) { 212 continue; 213 } 214 215 if (!$title) { 216 $title = substr($link,0,25).'...'; 217 } 218 219 $li = $link ? '<a href="'.html::escapeHTML($item->link).'">'.$title.'</a>' : $title; 204 220 $res .= ' <li>'.$li.'</li> '; 205 221 $i++; … … 209 225 } 210 226 211 $res .= '</ul> </div>';227 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 212 228 213 229 return $res; … … 218 234 global $core; 219 235 220 if ($w->homeonly && $core->url->type != 'default') { 221 return; 222 } 223 224 $res = 225 '<div class="text">'. 236 if (($w->homeonly == 1 && $core->url->type != 'default') || 237 ($w->homeonly == 2 && $core->url->type == 'default')) { 238 return; 239 } 240 241 $res = 242 ($w->content_only ? '' : '<div class="text'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 226 243 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 227 244 $w->text. 228 '</div>';245 ($w->content_only ? '' : '</div>'); 229 246 230 247 return $res; … … 235 252 global $core; 236 253 237 if ($w->homeonly && $core->url->type != 'default') { 254 if (($w->homeonly == 1 && $core->url->type != 'default') || 255 ($w->homeonly == 2 && $core->url->type == 'default')) { 238 256 return; 239 257 } … … 258 276 259 277 $res = 260 '<div class="lastposts">'.278 ($w->content_only ? '' : '<div class="lastposts'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 261 279 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 262 280 '<ul>'; … … 267 285 } 268 286 269 $res .= '</ul> </div>';287 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 270 288 271 289 return $res; … … 276 294 global $core; 277 295 278 if ($w->homeonly && $core->url->type != 'default') { 296 if (($w->homeonly == 1 && $core->url->type != 'default') || 297 ($w->homeonly == 2 && $core->url->type == 'default')) { 279 298 return; 280 299 } … … 288 307 } 289 308 290 $res = '<div class="lastcomments">'.309 $res = ($w->content_only ? '' : '<div class="lastcomments'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). 291 310 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 292 311 '<ul>'; … … 302 321 } 303 322 304 $res .= '</ul> </div>';323 $res .= '</ul>'.($w->content_only ? '' : '</div>'); 305 324 306 325 return $res; -
plugins/widgets/_widgets_functions.php
r1063 r1107 68 68 } 69 69 70 public static function categories($w)71 {72 global $core, $_ctx;73 74 if (($w->homeonly == 1 && $core->url->type != 'default') ||75 ($w->homeonly == 2 && $core->url->type == 'default')) {76 return;77 }78 70 79 $rs = $core->blog->getCategories(array('post_type'=>'post'));80 if ($rs->isEmpty()) {81 return;82 }83 84 $res =85 ($w->content_only ? '' : '<div class="categories'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">').86 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : '');87 88 $ref_level = $level = $rs->level-1;89 while ($rs->fetch())90 {91 $class = '';92 if (($core->url->type == 'category' && $_ctx->categories instanceof record && $_ctx->categories->cat_id == $rs->cat_id)93 || ($core->url->type == 'post' && $_ctx->posts instanceof record && $_ctx->posts->cat_id == $rs->cat_id)) {94 $class = ' class="category-current"';95 }96 97 if ($rs->level > $level) {98 $res .= str_repeat('<ul><li'.$class.'>',$rs->level - $level);99 } elseif ($rs->level < $level) {100 $res .= str_repeat('</li></ul>',-($rs->level - $level));101 }102 103 if ($rs->level <= $level) {104 $res .= '</li><li'.$class.'>';105 }106 107 $res .=108 '<a href="'.$core->blog->url.$core->url->getURLFor('category', $rs->cat_url).'">'.109 html::escapeHTML($rs->cat_title).'</a>'.110 ($w->postcount ? ' <span>('.$rs->nb_post.')</span>' : '');111 112 113 $level = $rs->level;114 }115 116 if ($ref_level - $level < 0) {117 $res .= str_repeat('</li></ul>',-($ref_level - $level));118 }119 $res .= ($w->content_only ? '' : '</div>');120 121 return $res;122 }123 124 71 public static function bestof($w) 125 72 { … … 211 158 212 159 $p_title = __('This blog\'s entries %s feed'); 213 $c_title = __('This blog\'s comments %s feed');214 160 215 161 $res = … … 223 169 'title="'.sprintf($p_title,($type == 'atom' ? 'Atom' : 'RSS')).'" class="feed">'. 224 170 __('Entries feed').'</a></li>'; 225 226 if ($core->blog->settings->system->allow_comments || $core->blog->settings->system->allow_trackbacks)227 {228 $res .=229 '<li><a type="'.$mime.'" '.230 'href="'.$core->blog->url.$core->url->getURLFor('feed',$type.'/comments').'" '.231 'title="'.sprintf($c_title,($type == 'atom' ? 'Atom' : 'RSS')).'" class="feed">'.232 __('Comments feed').'</a></li>';233 }234 171 235 172 $res .= '</ul>'.($w->content_only ? '' : '</div>'); … … 323 260 $params['order'] = 'post_dt desc'; 324 261 $params['no_content'] = true; 325 326 if ($w->category)327 {328 if ($w->category == 'null') {329 $params['sql'] = ' AND P.cat_id IS NULL ';330 } elseif (is_numeric($w->category)) {331 $params['cat_id'] = (integer) $w->category;332 } else {333 $params['cat_url'] = $w->category;334 }335 }336 262 337 263 if ($w->tag)
Note: See TracChangeset
for help on using the changeset viewer.