[ Index ]
 

Code source de Dotclear 2.0-beta6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/admin/ -> categories.php (source)

   1  <?php
   2  # ***** BEGIN LICENSE BLOCK *****
   3  # This file is part of DotClear.
   4  # Copyright (c) 2005 Olivier Meunier and contributors. All rights
   5  # reserved.
   6  #
   7  # DotClear is free software; you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation; either version 2 of the License, or
  10  # (at your option) any later version.
  11  # 
  12  # DotClear is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  # 
  17  # You should have received a copy of the GNU General Public License
  18  # along with DotClear; if not, write to the Free Software
  19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20  #
  21  # ***** END LICENSE BLOCK *****
  22  
  23  require dirname(__FILE__).'/../inc/admin/prepend.php';
  24  
  25  dcPage::check('categories');
  26  
  27  # Remove categories
  28  if (!empty($_POST['removeaction']) && !empty($_POST['remove']) && is_array($_POST['remove']))
  29  {
  30      foreach ($_POST['remove'] as $v)
  31      {
  32          try {
  33              $core->blog->delCategory($v);
  34          } catch (Exception $e) {
  35              $core->error->add($e->getMessage());
  36              break;
  37          }
  38      }
  39      
  40      if (!$core->error->flag()) {
  41          http::redirect('categories.php?del=1');
  42      }
  43  }
  44  
  45  # Order
  46  $order = array();
  47  if (empty($_POST['categories_order']) && !empty($_POST['order'])) {
  48      $order = $_POST['order'];
  49      asort($order);
  50      $order = array_keys($order);
  51  } elseif (!empty($_POST['categories_order'])) {
  52      $order = explode(',',$_POST['categories_order']);
  53  }
  54  
  55  if (!empty($_POST['saveorder']) && !empty($order))
  56  {
  57      foreach ($order as $pos => $c) {
  58          $pos = ((integer) $pos)+1;
  59          
  60          try {
  61              $core->blog->updCategoryOrder($c,$pos);
  62          } catch (Exception $e) {
  63              $core->error->add($e->getMessage());
  64          }
  65      }
  66      
  67      if (!$core->error->flag()) {
  68          http::redirect('categories.php?neworder=1');
  69      }
  70  }
  71  
  72  try {
  73      $rs = $core->blog->getCategories();
  74  } catch (Exception $e) {
  75      $core->error->add($e->getMessage());
  76  }
  77  
  78  /* Display
  79  -------------------------------------------------------- */
  80  dcPage::open(__('categories'),
  81      dcPage::jsConfirmClose('form-categories').
  82      dcPage::jsToolMan()."\n".
  83      dcPage::jsLoad('js/_categories.js').
  84      dcPage::jsLoad('js/confirmClose.js')
  85  );
  86  
  87  if (!$core->error->flag())
  88  {
  89      if (!empty($_GET['neworder'])) {
  90          echo '<p class="message">'.__('Category order has been successfully updated.').'</p>';
  91      }
  92      
  93      if (!empty($_GET['add'])) {
  94          echo '<p class="message">'.__('The category has been successfully created.').'</p>';
  95      }
  96      
  97      if (!empty($_GET['del'])) {
  98          echo '<p class="message">'.__('Categories have been successfully removed.').'</p>';
  99      }
 100      
 101      echo '<h2>'.html::escapeHTML($core->blog->name).' &gt; '.__('categories').'</h2>';
 102      
 103      echo
 104      '<form action="category.php" method="post">'.
 105      '<p><label class="classic">'.__('Title:').
 106      dcPage::help('categories','cat_new_title').
 107      form::field('cat_title',20,255,'','',2).
 108      '</label> '.
 109      '<input type="submit" value="'.__('Create new category').'" /></p>'.
 110      '</form>';
 111      
 112      if ($rs->isEmpty())
 113      {
 114          echo '<p>'.__('No category.').'</p>';
 115      }
 116      else
 117      {
 118          echo
 119          '<form action="categories.php" method="post" id="form-categories">'.
 120          '<table class="dragable">'.
 121          '<thead><tr><th colspan="3">'.__('Name').'</th>'.
 122          '<th>'.__('Entries').'</th>'.
 123          '</tr></thead>'.
 124          '<tbody id="categories-list">';
 125          
 126          while ($rs->fetch())
 127          {
 128              $deletable = false;
 129              
 130              $posts_link = '<a href="posts.php?cat_id=%s">%s</a>';
 131              
 132              switch ($rs->nb_post) {
 133                  case 0:
 134                      $nb_post = __('No entry');
 135                      $deletable = true;
 136                      break;
 137                  case 1:
 138                      $nb_post = sprintf($posts_link,$rs->cat_id,__('1 entry'));
 139                      break;
 140                  default:
 141                      $nb_post = sprintf($posts_link,$rs->cat_id,
 142                      sprintf(__('%d entries'),$rs->nb_post));
 143                      break;
 144              }
 145              
 146              $position = (string) $rs->index()+1;
 147              
 148              echo
 149              '<tr class="line" id="c_'.$rs->cat_id.'">'.
 150              '<td class="handle">'.form::field(array('order['.$rs->cat_id.']'),2,5,$position).'</td>'.
 151              '<td>'.($rs->nb_post==0 ? form::checkbox(array('remove[]'),$rs->cat_id) : '').'</td>'.
 152              '<td class="maximal"><a href="category.php?id='.$rs->cat_id.'">'.
 153              html::escapeHTML($rs->cat_title).'</a></td>'.
 154              '<td class="nowrap">'.$nb_post.'</td>'.
 155              '</tr>';
 156          }
 157          
 158          echo
 159          '</tbody></table>'.
 160          
 161          '<div class="two-cols">'.
 162          '<p class="col">'.form::hidden('categories_order','').
 163          '<input type="submit" name="saveorder" value="'.__('Save order').'" />'.
 164          dcPage::help('categories','cat_order').'</p>'.
 165          
 166          '<p class="col right"><input type="submit" name="removeaction" '.
 167          'value="'.__('Delete selected categories').'" /></p>'.
 168          '</div>'.
 169          '</form>';
 170      }
 171  }
 172  dcPage::close(); ?>


Généré le : Fri Feb 23 22:16:06 2007 par Balluche grâce à PHPXref 0.7