Dotclear

Changeset 1531:18a9e84c04e3


Ignore:
Timestamp:
08/23/13 11:15:23 (11 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
default
Message:

Issue #1541 : categories with entries could be deleted and entries can be moved to another category.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • admin/categories.php

    r1525 r1531  
    1717# Remove a categories 
    1818if (!empty($_POST['categories'])) { 
    19      $error = false; 
    20      foreach ($_POST['categories'] as $cat_id) { 
    21           # Check if category to delete exists 
    22           $c = $core->blog->getCategory((integer) $cat_id); 
    23           if ($c->isEmpty()) { 
    24                continue; 
     19     try { 
     20          # Check if category where to move posts exists 
     21          $mov_cat = (int) $_POST['mov_cat']; 
     22          $mov_cat = $mov_cat ? $mov_cat : null; 
     23          if ($mov_cat !== null) { 
     24               $c = $core->blog->getCategory($mov_cat); 
     25               if ($c->isEmpty()) { 
     26                    throw new Exception(__('Category where to move posts does not exist')); 
     27               } 
     28               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               } 
    2533          } 
    26           unset($c); 
    2734 
    28           try { 
     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 
    2948               # Delete category 
    3049               $core->blog->delCategory($cat_id); 
    31           } catch (Exception $e) { 
    32                $error = true; 
    3350          } 
    34      } 
    35      if (!$error) { 
    3651          http::redirect('categories.php?del='.count($_POST['categories'])); 
     52     } catch (Exception $e) { 
     53          $core->error->add($e->getMessage()); 
    3754     } 
    3855} 
     
    5875} 
    5976 
    60 # --BEHAVIOR-- adminCategoriesActionsCombo 
    61 $core->callBehavior('adminCategoriesActionsCombo',array(&$combo_action)); 
    62  
    6377 
    6478/* Display 
     
    7488); 
    7589 
    76 if (!empty($_GET['add'])) { 
    77      dcPage::message(__('The category has been successfully created.')); 
    78 } 
    7990if (!empty($_GET['del'])) { 
    80   dcPage::message(__('The category has been successfully removed.', 
    81                'The categories have been successfully removed.', 
    82                (int) $_GET['del'] 
    83                ) 
    84             ); 
     91        dcPage::message(__('The category has been successfully removed.', 
     92                  'The categories have been successfully removed.', 
     93                  (int) $_GET['del'] 
     94                  ) 
     95               ); 
    8596} 
    8697if (!empty($_GET['reord'])) { 
    8798     dcPage::message(__('Categories have been successfully reordered.')); 
    88 } 
    89 if (!empty($_GET['moved'])) { 
    90      dcPage::message(__('The category has been successfully moved.')); 
    9199} 
    92100 
     
    139147 
    140148          echo 
    141           '<p>'; 
    142           if ($rs->nb_total == 0) { 
    143                echo form::checkbox(array('categories[]'),$rs->cat_id); 
    144           } 
    145  
    146           echo 
     149          '<p>'. 
     150          form::checkbox(array('categories[]'),$rs->cat_id). 
    147151          '<strong><a href="category.php?id='.$rs->cat_id.'">'.html::escapeHTML($rs->cat_title).'</a></strong>'. 
    148152          ' (<a href="posts.php?cat_id='.$rs->cat_id.'">'. 
     
    164168           '<div class="two-cols">'. 
    165169           '<p class="col checkboxes-helpers"></p>'. 
     170           '<p class="col right"><label for="mov_cat">'.__('And choose the category which will receive its entries:').'</label> '. 
     171           form::combo('mov_cat',array_merge(array(__('(No cat)') => ''),$categories_combo),'','maximal').'</p> '. 
    166172           '<p class="col right"><label for="action" class="classic">'.__('Selected categories action:').'</label> '. 
    167173           form::combo('action',$combo_action). 
  • admin/js/_categories.js

    r1525 r1531  
    33     $('.checkboxes-helpers').each(function() { 
    44          dotclear.checkboxesHelpers(this); 
     5     }); 
     6 
     7     $('#mov_cat').parent().hide(); 
     8     $('input[name="categories[]"]').click(function() { 
     9          $('#mov_cat').parent().parent().removeClass('two-cols').addClass('three-cols'); 
     10          $('#mov_cat').parent().show(); 
    511     }); 
    612 
  • locales/fr/main.po

    r1529 r1531  
    601601 
    602602msgid "The category has been successfully removed." 
    603 msgstr "Catégorie supprimée avec succès." 
     603msgid_plural "The categories have been successfully removed." 
     604msgstr[0] "Catégorie supprimée avec succès." 
     605msgstr[1] "Catégories supprimées avec succès." 
    604606 
    605607msgid "Categories have been successfully reordered." 
Note: See TracChangeset for help on using the changeset viewer.

Sites map