Changeset 3733:ee69b09370ec for plugins
- Timestamp:
- 03/15/18 11:48:54 (8 years ago)
- Branch:
- default
- Location:
- plugins/tags
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/tags/_define.php
r3731 r3733 16 16 "Tags for posts", // Description 17 17 "Olivier Meunier", // Author 18 '1. 4', // Version18 '1.5', // Version 19 19 array( 20 20 'permissions' => 'usage,contentadmin', -
plugins/tags/_public.php
r3731 r3733 94 94 $limit = isset($attr['limit']) ? (integer) $attr['limit'] : 'null'; 95 95 96 $combo = array('meta_id_lower', 'count', 'latest', 'oldest'); 97 96 98 $sortby = 'meta_id_lower'; 97 if (isset($attr['sortby']) && $attr['sortby'] == 'count') {98 $sortby = 'count';99 if (isset($attr['sortby']) && in_array($attr['sortby'], $combo)) { 100 $sortby = strtolower($attr['sortby']); 99 101 } 100 102 … … 107 109 "<?php\n" . 108 110 "\$_ctx->meta = \$core->meta->computeMetaStats(\$core->meta->getMetadata(array('meta_type'=>'" 109 . $type . "','limit'=>" . $limit . "))); " . 111 . $type . "','limit'=>" . $limit . 112 ($sortby != 'meta_id_lower' ? ",'order'=>'" . $sortby . ' ' . ($order == 'asc' ? 'ASC' : 'DESC' ) : '') . "'" . 113 "))); " . 110 114 "\$_ctx->meta->sort('" . $sortby . "','" . $order . "'); " . 111 115 '?>'; … … 138 142 $type = isset($attr['type']) ? addslashes($attr['type']) : 'tag'; 139 143 144 $combo = array('meta_id_lower', 'count', 'latest', 'oldest'); 145 140 146 $sortby = 'meta_id_lower'; 141 if (isset($attr['sortby']) && $attr['sortby'] == 'count') {142 $sortby = 'count';147 if (isset($attr['sortby']) && in_array($attr['sortby'], $combo)) { 148 $sortby = strtolower($attr['sortby']); 143 149 } 144 150 … … 239 245 } 240 246 241 $params = array('meta_type' => 'tag'); 242 243 if ($w->limit !== '') { 244 $params['limit'] = abs((integer) $w->limit); 245 } 246 247 $rs = $core->meta->computeMetaStats( 248 $core->meta->getMetadata($params)); 249 250 if ($rs->isEmpty()) { 251 return; 252 } 247 $combo = array('meta_id_lower', 'count', 'latest', 'oldest'); 253 248 254 249 $sort = $w->sortby; 255 if (!in_array($sort, array('meta_id_lower', 'count'))) {250 if (!in_array($sort, $combo)) { 256 251 $sort = 'meta_id_lower'; 257 252 } … … 262 257 } 263 258 264 $rs->sort($sort, $order); 259 $params = array('meta_type' => 'tag'); 260 261 if ($sort != 'meta_id_lower') { 262 // As optional limit may restrict result, we should set order (if not computed after) 263 $params['order'] = $sort . ' ' . ($order == 'asc' ? 'ASC' : 'DESC'); 264 } 265 266 if ($w->limit !== '') { 267 $params['limit'] = abs((integer) $w->limit); 268 } 269 270 $rs = $core->meta->computeMetaStats( 271 $core->meta->getMetadata($params)); 272 273 if ($rs->isEmpty()) { 274 return; 275 } 276 277 if ($sort == 'meta_id_lower') { 278 // Sort resulting recordset on cleaned id 279 $rs->sort($sort, $order); 280 } 265 281 266 282 $res = -
plugins/tags/_widgets.php
r3731 r3733 19 19 public static function initWidgets($w) 20 20 { 21 $combo = array( 22 __('Tag name') => 'meta_id_lower', 23 __('Entries count') => 'count', 24 __('Newest entry') => 'latest', 25 __('Oldest entry') => 'oldest' 26 ); 27 21 28 $w->create('tags', __('Tags'), array('tplTags', 'tagsWidget'), null, 'Tags cloud'); 22 29 $w->tags->setting('title', __('Title (optional)') . ' :', __('Tags')); 23 30 $w->tags->setting('limit', __('Limit (empty means no limit):'), '20'); 24 $w->tags->setting('sortby', __('Order by:'), 'meta_id_lower', 'combo', 25 array(__('Tag name') => 'meta_id_lower', __('Entries count') => 'count') 26 ); 31 $w->tags->setting('sortby', __('Order by:'), 'meta_id_lower', 'combo', $combo); 27 32 $w->tags->setting('orderby', __('Sort:'), 'asc', 'combo', 28 33 array(__('Ascending') => 'asc', __('Descending') => 'desc')
Note: See TracChangeset
for help on using the changeset viewer.