[ Index ]
 

Code source de Dotclear 1.2.5

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

title

Body

[fermer]

/ecrire/ -> cat_list.php (source)

   1  <?php
   2  # ***** BEGIN LICENSE BLOCK *****
   3  # This file is part of DotClear.
   4  # Copyright (c) 2004 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/prepend.php';
  24  
  25  $auth->check(5);
  26  
  27  include dirname(__FILE__).'/inc/connexion.php';
  28  
  29  $err = '';
  30  
  31  # Reord
  32  if (!empty($_GET['reord']))
  33  {
  34      if ($blog->reordCats(false,true) === false) {
  35          $err = $blog->error(1);
  36      } else {
  37          header('Location: cat_list.php');
  38          exit;
  39      }
  40  }
  41  
  42  # Classic ord
  43  if (isset($_POST['catOrd']) && is_array($_POST['catOrd']))
  44  {
  45      if ($blog->ordCats($_POST['catOrd']) === false) {
  46          $err = $blog->error(1);
  47      } else {
  48          header('Location: cat_list.php');
  49          exit;
  50      }
  51  }
  52  
  53  # DragNdrop
  54  if (!empty($_POST['dndSort']))
  55  {
  56      $catOrd = array();
  57      foreach (explode(';',$_POST['dndSort']) as $k => $v) {
  58          $catOrd[substr($v,3)] = $k;
  59      }
  60      
  61      if ($blog->ordCats($catOrd) === false) {
  62          $err = $blog->error(1);
  63      } else {
  64          header('Location: cat_list.php');
  65          exit;
  66      }
  67  }
  68  
  69  $mySubMenu->addItem('<strong>'.__('New category').'</strong>','categorie.php','images/ico_new.png',false);
  70  
  71  openPage(__('Categories list'),
  72  '  <script type="text/javascript" src="js/drag.js"></script>'.
  73  '  <script type="text/javascript" src="js/dragsort.js"></script>'.
  74  '  <script type="text/javascript">'."\n".
  75  '  if (document.getElementById) { '."\n".
  76  '    window.onload = function() { '."\n".
  77  '    dragSort.dest = document.getElementById(\'dndSort\');'."\n".
  78  '    dragSort.makeElementSortable(document.getElementById(\'sortcat\'));'."\n".
  79  '    };'."\n".
  80  '  }'."\n".
  81  '</script>');
  82  ?>
  83  <h2><?php echo __('Categories list'); ?></h2>
  84  
  85  <?php
  86  if ($err != '')
  87  {
  88      echo '<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.
  89          $err.'</div>';
  90  }
  91  
  92  $rsCat = $blog->getCat('','cat_ord');
  93  
  94  if ($rsCat->isEmpty())
  95  {
  96      echo '<p>'.__('No category yet').'</p>';
  97  }
  98  else
  99  {
 100      echo '<p>'.__('Drag items to change their positions.').'</p>';
 101      echo '<form action="cat_list.php" method="post">';
 102      
 103      echo '<div id="sortcat">';
 104      while(!$rsCat->EOF())
 105      {
 106          $cat_id = $rsCat->field('cat_id');
 107          $cat_ord = $rsCat->field('cat_ord');
 108          $cat_libelle = $rsCat->field('cat_libelle');
 109          $cat_nb_post = (integer) $rsCat->field('nb_post');
 110          
 111          echo
 112          '<div class="sort" id="dnd'.$cat_id.'">'.
 113          '<p><strong><a href="categorie.php?cat_id='.$cat_id.'">'.
 114          $cat_libelle.'</a></strong> - ';
 115          
 116          if ($cat_nb_post > 0)
 117          {
 118              echo '<a href="index.php?cat_id='.$cat_id.'">'.
 119              (($cat_nb_post>1) ? sprintf(__('%d entries'),$cat_nb_post) : sprintf(__('%d entry'),$cat_nb_post)).
 120              '</a>';
 121          }
 122          else
 123          {
 124              echo '<a href="categorie.php?cat_id='.$cat_id.'&amp;del=1" '.
 125              ' onclick="return window.confirm(\''.__('Are you sure you want to delete this category?').'\')">'.
 126              __('delete').'</a>';
 127          }
 128          
 129          echo
 130          '</p>'.
 131          '<p class="nojsfield"><label for="catOrd'.$cat_id.'" class="inline">'.__('Position').' : </label>'.
 132          form::field(array('catOrd['.$cat_id.']','catOrd'.$cat_id),3,3,$cat_ord).'</p>'.
 133          '</div>';
 134          
 135          $rsCat->moveNext();
 136      }
 137      
 138      echo
 139      '</div>'.
 140      '<p><input type="hidden" id="dndSort" name="dndSort" value="" />'.
 141      '<input type="submit" class="submit" value="'.__('save order').'" /></p>'.
 142      '</form>';
 143      
 144      echo '<p><a href="cat_list.php?reord=1">'.__('Reorder categories').'</a></p>';
 145  }
 146  ?>
 147  <?php closePage(); ?>


Généré le : Fri Feb 23 21:40:15 2007 par Balluche grâce à PHPXref 0.7