Changeset 1595:0b564d837a35
- Timestamp:
- 08/26/13 22:23:05 (10 years ago)
- Branch:
- default
- Location:
- admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/categories.php
r1594 r1595 56 56 57 57 # Update order 58 if (!empty($_POST['save_order'])) 59 { 60 if (!empty($_POST['categories_order'])) { // js is enable 61 $categories = json_decode($_POST['categories_order']); 62 63 foreach ($categories as $category) { 64 if (!empty($category->item_id)) { 65 $core->blog->updCategoryPosition($category->item_id, $category->left, $category->right); 66 } 67 } 68 } elseif (!empty($_POST['cat_rank'])) { 69 function countChildren($t, $id) { 70 $c = 0; 71 foreach ($t as $k => $v) { 72 if (preg_match('`^'.$id.'\..*`', $k)) { 73 $c++; 74 } 75 } 76 77 return $c; 78 } 79 80 $i = 1; 81 $ranks = array_flip($_POST['cat_rank']); 82 uksort($ranks, 'version_compare'); 83 foreach ($ranks as $str => $id) { 84 $core->blog->updCategoryPosition($id, $i, ($i + 2 * countChildren($ranks, $str) + 1)); 85 $i = $i+2; 58 if (!empty($_POST['save_order']) && !empty($_POST['categories_order'])) { 59 $categories = json_decode($_POST['categories_order']); 60 61 foreach ($categories as $category) { 62 if (!empty($category->item_id)) { 63 $core->blog->updCategoryPosition($category->item_id, $category->left, $category->right); 86 64 } 87 65 } … … 165 143 166 144 $ref_level = $level = $rs->level-1; 167 $parts = array();168 145 while ($rs->fetch()) 169 146 { … … 172 149 if ($rs->level > $level) { 173 150 echo str_repeat('<ul><li '.$attr.'>',$rs->level - $level); 174 $parts[] = 1;175 151 } elseif ($rs->level < $level) { 176 152 echo str_repeat('</li></ul>',-($rs->level - $level)); 177 $parts = array_slice($parts,0,(count($parts) - ($level - $rs->level)));178 $parts[count($parts)-1]++;179 } else {180 $parts[count($parts)-1]++;181 153 } 182 154 … … 185 157 } 186 158 187 $cat_rank = implode('.',$parts);188 159 echo 189 160 '<p>'. … … 193 164 sprintf(($rs->nb_post > 1 ? __('%d entries') : __('%d entry') ),$rs->nb_post).'</a>'. 194 165 ', '.__('total:').' '.$rs->nb_total.') '. 195 '<span class="cat-url">'.__('URL:').' <code>'.html::escapeHTML($rs->cat_url).'</code></span>'. 196 form::field('cat_rank['.$rs->cat_id.']',10,10,$cat_rank,'cat-rank'). 197 '</p>'; 166 '<span class="cat-url">'.__('URL:').' <code>'.html::escapeHTML($rs->cat_url).'</code></span></p>'; 198 167 199 168 $level = $rs->level; -
admin/js/_categories.js
r1594 r1595 1 1 $(function() { 2 2 if ($.fn['nestedSortable']!==undefined) { 3 $('.dragdrop-hidden, .cat-rank').hide();4 3 $('#categories ul li').css('cursor','move'); 5 4 $('#save-set-order').prop('disabled',true).addClass('disabled');
Note: See TracChangeset
for help on using the changeset viewer.