Changeset 1953:c3e851963891
- Timestamp:
- 09/18/13 22:48:53 (12 years ago)
- Branch:
- default
- Location:
- admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/categories.php
r1760 r1953 16 16 17 17 # Remove a categories 18 if (!empty($_POST['categories']) && !empty($_POST['delete'])) { 18 if (!empty($_POST['delete'])) { 19 $keys = array_keys($_POST['delete']); 20 $cat_id = (int) $keys[0]; 21 22 # Check if category to delete exists 23 $c = $core->blog->getCategory((integer) $cat_id); 24 if ($c->isEmpty()) { 25 http::redirect('categories.php?unknown=1'); 26 } 27 unset($c); 28 29 try { 30 # Delete category 31 $core->blog->delCategory($cat_id); 32 http::redirect('categories.php?del=1'); 33 } catch (Exception $e) { 34 $core->error->add($e->getMessage()); 35 } 36 } 37 38 # move post into a category 39 if (!empty($_POST['mov']) && !empty($_POST['mov_cat'])) { 19 40 try { 20 41 # Check if category where to move posts exists 21 $mov_cat = (int) $_POST['mov_cat']; 42 $keys = array_keys($_POST['mov']); 43 $cat_id = (int) $keys[0]; 44 $mov_cat = (int) $_POST['mov_cat'][$cat_id]; 45 22 46 $mov_cat = $mov_cat ? $mov_cat : null; 23 47 if ($mov_cat !== null) { … … 27 51 } 28 52 unset($c); 29 30 if (in_array($mov_cat, $_POST['categories'])) { 31 throw new Exception(__('The entries cannot be moved to the category you choose to delete.')); 32 } 33 } 34 35 foreach ($_POST['categories'] as $cat_id) { 36 # Check if category to delete exists 37 $c = $core->blog->getCategory((integer) $cat_id); 38 if ($c->isEmpty()) { 39 continue; 40 } 41 unset($c); 42 43 # Move posts 44 if ($mov_cat != $cat_id) { 45 $core->blog->changePostsCategory($cat_id,$mov_cat); 46 } 47 48 # Delete category 49 $core->blog->delCategory($cat_id); 50 } 51 http::redirect('categories.php?del='.count($_POST['categories'])); 53 } 54 # Move posts 55 if ($mov_cat != $cat_id) { 56 $core->blog->changePostsCategory($cat_id,$mov_cat); 57 } 58 http::redirect('categories.php?move=1'); 52 59 } catch (Exception $e) { 53 60 $core->error->add($e->getMessage()); … … 105 112 106 113 if (!empty($_GET['del'])) { 107 dcPage::success(__('The category has been successfully removed.', 108 'The categories have been successfully removed.', 109 (int) $_GET['del'] 110 ) 111 ); 114 dcPage::success(__('The category has been successfully removed.')); 112 115 } 113 116 if (!empty($_GET['reord'])) { 114 117 dcPage::success(__('Categories have been successfully reordered.')); 115 118 } 119 if (!empty($_GET['unknown'])) { 120 dcPage::success(__('This category does not exist.')); 121 } 122 if (!empty($_GET['move'])) { 123 dcPage::success(__('Entries have been successfully moved to the category you choose.')); 124 } 125 116 126 $categories_combo = dcAdminCombos::getCategoriesCombo($rs); 117 127 … … 147 157 148 158 echo 149 '<p>'. 150 form::checkbox(array('categories[]','cat-'.$rs->cat_id),$rs->cat_id,null,$rs->nb_total>0?'notempty':''). 159 '<p>'. 151 160 '<label class="classic" for="cat-'.$rs->cat_id.'"><a href="category.php?id='.$rs->cat_id.'">'.html::escapeHTML($rs->cat_title).'</a></label>'. 152 161 ' (<a href="posts.php?cat_id='.$rs->cat_id.'">'. 153 162 sprintf(($rs->nb_post > 1 ? __('%d entries') : __('%d entry') ),$rs->nb_post).'</a>'. 154 163 ', '.__('total:').' '.$rs->nb_total.') '. 155 '<span class="cat-url">'.__('URL:').' <code>'.html::escapeHTML($rs->cat_url).'</code></span></p>'; 164 '<span class="cat-url">'.__('URL:').' <code>'.html::escapeHTML($rs->cat_url).'</code></span>'; 165 166 if ($rs->nb_total>0) { 167 // remove current category 168 echo 169 form::combo('mov_cat['.$rs->cat_id.']',array_filter($categories_combo, function($cat) use ($rs) {return ($cat->value!=$rs->cat_id);}),'',''). 170 '<input type="submit" class="" name="mov['.$rs->cat_id.']" value="'.__('Ok').'"/>'; 171 172 $attr_disabled = ' disabled="disabled"'; 173 $input_class = 'disabled '; 174 } else { 175 $attr_disabled = ''; 176 $input_class = ''; 177 } 178 echo 179 '<input type="submit"'.$attr_disabled.' class="'.$input_class.'delete" name="delete['.$rs->cat_id.']" value="'.__('Delete category').'"/>'. 180 '</p>'; 156 181 157 182 $level = $rs->level; … … 162 187 } 163 188 echo 164 '</div>';165 166 echo167 '<div class="two-cols">'.168 '<p class="col checkboxes-helpers"></p>'.169 '<p class="col right" id="mov-cat">'.170 '<label for="mov_cat" class="classic">'.__('Category where entries of deleted categories will be moved:').'</label> '.171 form::combo('mov_cat',$categories_combo,'','').172 '</p>'.173 '<p class="right">'.174 '<input type="submit" class="delete" name="delete" value="'.__('Delete selected categories').'"/>'.175 '</p>'.176 189 '</div>'; 177 190 -
admin/js/_categories.js
r1595 r1953 14 14 } 15 15 16 $('.checkboxes-helpers').each(function() { 17 dotclear.checkboxesHelpers(this); 18 }); 19 20 $('input[name="delete"]').click(function() { 21 var nb_ckecked = $('input[name="categories[]"]:checked').length; 22 if (nb_ckecked==0) { 23 return false; 24 } 25 26 return window.confirm(dotclear.msg.confirm_delete_categories.replace('%s',nb_ckecked)); 16 $('input[name^="delete"]').click(function() { 17 return window.confirm(dotclear.msg.confirm_delete_category.replace('%s',$(this).parent().find('label a').text())); 27 18 }); 28 19
Note: See TracChangeset
for help on using the changeset viewer.