Changeset 1107:3943962d69b8 for plugins/widgets
- Timestamp:
- 02/27/13 11:48:32 (13 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. - Location:
- plugins/widgets
- Files:
-
- 4 edited
-
_default_widgets.php (modified) (2 diffs)
-
_default_widgets.php (modified) (4 diffs)
-
_widgets_functions.php (modified) (23 diffs)
-
_widgets_functions.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/widgets/_default_widgets.php
r851 r1107 18 18 $__widgets = new dcWidgets; 19 19 20 $__widgets->create('search',__('Search engine'),array('defaultWidgets','search') );20 $__widgets->create('search',__('Search engine'),array('defaultWidgets','search'),null,'Search engine form'); 21 21 $__widgets->search->setting('title',__('Title:'),__('Search')); 22 $__widgets->search->setting('homeonly',__('Display on:'),0,'combo', 23 array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); 24 $__widgets->search->setting('content_only',__('Content only'),0,'check'); 25 $__widgets->search->setting('class',__('CSS class:'),''); 22 26 23 $__widgets->create('navigation',__('Navigation links'),array('defaultWidgets','navigation') );27 $__widgets->create('navigation',__('Navigation links'),array('defaultWidgets','navigation'),null,'List of navigation links'); 24 28 $__widgets->navigation->setting('title',__('Title:'),''); 29 $__widgets->navigation->setting('homeonly',__('Display on:'),0,'combo', 30 array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); 31 $__widgets->navigation->setting('content_only',__('Content only'),0,'check'); 32 $__widgets->navigation->setting('class',__('CSS class:'),''); 25 33 26 $__widgets->create('bestof',__('Selected entries'),array('defaultWidgets','bestof') );34 $__widgets->create('bestof',__('Selected entries'),array('defaultWidgets','bestof'),null,'List of selected entries'); 27 35 $__widgets->bestof->setting('title',__('Title:'),__('Best of me')); 28 36 $__widgets->bestof->setting('orderby',__('Sort:'),'asc','combo',array(__('Ascending') => 'asc', __('Descending') => 'desc')); 29 $__widgets->bestof->setting('homeonly',__('Home page only'),1,'check'); 37 $__widgets->bestof->setting('homeonly',__('Display on:'),1,'combo', 38 array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); 39 $__widgets->bestof->setting('content_only',__('Content only'),0,'check'); 40 $__widgets->bestof->setting('class',__('CSS class:'),''); 30 41 31 $__widgets->create('langs',__('Blog languages'),array('defaultWidgets','langs') );42 $__widgets->create('langs',__('Blog languages'),array('defaultWidgets','langs'),null,'List of available languages'); 32 43 $__widgets->langs->setting('title',__('Title:'),__('Languages')); 33 $__widgets->langs->setting('homeonly',__('Home page only'),1,'check'); 44 $__widgets->langs->setting('homeonly',__('Display on:'),1,'combo', 45 array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); 46 $__widgets->langs->setting('content_only',__('Content only'),0,'check'); 47 $__widgets->langs->setting('class',__('CSS class:'),''); 34 48 35 $__widgets->create('subscribe',__('Subscribe links'),array('defaultWidgets','subscribe')); 49 50 $__widgets->create('subscribe',__('Subscribe links'),array('defaultWidgets','subscribe'),null,'RSS or Atom feed subscription links'); 36 51 $__widgets->subscribe->setting('title',__('Title:'),__('Subscribe')); 37 52 $__widgets->subscribe->setting('type',__('Feeds type:'),'atom','combo',array('Atom' => 'atom', 'RSS' => 'rss2')); 38 $__widgets->subscribe->setting('homeonly',__('Home page only'),0,'check'); 53 $__widgets->subscribe->setting('homeonly',__('Display on:'),1,'combo', 54 array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); 55 $__widgets->subscribe->setting('content_only',__('Content only'),0,'check'); 56 $__widgets->subscribe->setting('class',__('CSS class:'),''); 39 57 40 $__widgets->create('feed',__('Feed reader'),array('defaultWidgets','feed') );58 $__widgets->create('feed',__('Feed reader'),array('defaultWidgets','feed'),null,'Last entries from feed'); 41 59 $__widgets->feed->setting('title',__('Title:'),__('Somewhere else')); 42 60 $__widgets->feed->setting('url',__('Feed URL:'),''); 43 61 $__widgets->feed->setting('limit',__('Entries limit:'),10); 44 $__widgets->feed->setting('homeonly',__('Home page only'),1,'check'); 62 $__widgets->feed->setting('homeonly',__('Display on:'),1,'combo', 63 array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); 64 $__widgets->feed->setting('content_only',__('Content only'),0,'check'); 65 $__widgets->feed->setting('class',__('CSS class:'),''); 45 66 46 $__widgets->create('text',__('Text'),array('defaultWidgets','text') );67 $__widgets->create('text',__('Text'),array('defaultWidgets','text'),null,'Simple text'); 47 68 $__widgets->text->setting('title',__('Title:'),''); 48 69 $__widgets->text->setting('text',__('Text:'),'','textarea'); 49 $__widgets->text->setting('homeonly',__('Home page only'),0,'check'); 70 $__widgets->text->setting('homeonly',__('Display on:'),0,'combo', 71 array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); 72 $__widgets->text->setting('content_only',__('Content only'),0,'check'); 73 $__widgets->text->setting('class',__('CSS class:'),''); 50 74 51 $__widgets->create('lastposts',__('Last entries'),array('defaultWidgets','lastposts') );75 $__widgets->create('lastposts',__('Last entries'),array('defaultWidgets','lastposts'),null,'List of last entries published'); 52 76 $__widgets->lastposts->setting('title',__('Title:'),__('Last entries')); 53 77 if ($core->plugins->moduleExists('tags')) { … … 55 79 } 56 80 $__widgets->lastposts->setting('limit',__('Entries limit:'),10); 57 $__widgets->lastposts->setting('homeonly',__('Home page only'),1,'check'); 81 $__widgets->lastposts->setting('homeonly',__('Display on:'),1,'combo', 82 array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); 83 $__widgets->lastposts->setting('content_only',__('Content only'),0,'check'); 84 $__widgets->lastposts->setting('class',__('CSS class:'),''); 58 85 59 60 $__widgets->create('lastcomments',__('Last comments'),array('defaultWidgets','lastcomments'));61 $__widgets->lastcomments->setting('title',__('Title:'),__('Last comments'));62 $__widgets->lastcomments->setting('limit',__('Comments limit:'),10);63 $__widgets->lastcomments->setting('homeonly',__('Home page only'),1,'check');64 86 65 87 # --BEHAVIOR-- initWidgets -
plugins/widgets/_default_widgets.php
r1063 r1107 47 47 $__widgets->langs->setting('class',__('CSS class:'),''); 48 48 49 $__widgets->create('categories',__('Categories list'),array('defaultWidgets','categories'),null,'List of categories');50 $__widgets->categories->setting('title',__('Title:'),__('Categories'));51 $__widgets->categories->setting('postcount',__('With entries counts'),0,'check');52 $__widgets->categories->setting('homeonly',__('Display on:'),0,'combo',53 array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2));54 $__widgets->categories->setting('content_only',__('Content only'),0,'check');55 $__widgets->categories->setting('class',__('CSS class:'),'');56 49 57 50 $__widgets->create('subscribe',__('Subscribe links'),array('defaultWidgets','subscribe'),null,'RSS or Atom feed subscription links'); … … 82 75 $__widgets->create('lastposts',__('Last entries'),array('defaultWidgets','lastposts'),null,'List of last entries published'); 83 76 $__widgets->lastposts->setting('title',__('Title:'),__('Last entries')); 84 $rs = $core->blog->getCategories(array('post_type'=>'post'));85 $categories = array('' => '', __('Uncategorized') => 'null');86 while ($rs->fetch()) {87 $categories[str_repeat(' ',$rs->level-1).($rs->level-1 == 0 ? '' : '• ').html::escapeHTML($rs->cat_title)] = $rs->cat_id;88 }89 $__widgets->lastposts->setting('category',__('Category:'),'','combo',$categories);90 unset($rs,$categories);91 77 if ($core->plugins->moduleExists('tags')) { 92 78 $__widgets->lastposts->setting('tag',__('Tag:'),''); … … 98 84 $__widgets->lastposts->setting('class',__('CSS class:'),''); 99 85 100 $__widgets->create('lastcomments',__('Last comments'),array('defaultWidgets','lastcomments'),null,'List of last comments posted');101 $__widgets->lastcomments->setting('title',__('Title:'),__('Last comments'));102 $__widgets->lastcomments->setting('limit',__('Comments limit:'),10);103 $__widgets->lastcomments->setting('homeonly',__('Display on:'),1,'combo',104 array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2));105 $__widgets->lastcomments->setting('content_only',__('Content only'),0,'check');106 $__widgets->lastcomments->setting('class',__('CSS class:'),'');107 86 108 87 # --BEHAVIOR-- initWidgets … … 116 95 $__default_widgets['nav']->append($__widgets->navigation); 117 96 $__default_widgets['nav']->append($__widgets->bestof); 118 $__default_widgets['nav']->append($__widgets->categories);119 97 $__default_widgets['extra']->append($__widgets->subscribe); 120 98 -
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.
