[ Index ]
 

Code source de Dotclear 1.2.5

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

title

Body

[fermer]

/ecrire/ -> categorie.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  $cat_libelle = '';
  31  $cat_libelle_url = '';
  32  $cat_desc = '';
  33  
  34  # Edition d'une catégorie
  35  if (!empty($_REQUEST['cat_id']))
  36  {
  37      $rsCat = $blog->getCat($_REQUEST['cat_id']);
  38      
  39      $cat_libelle = $rsCat->field('cat_libelle');
  40      $cat_libelle_url = $rsCat->field('cat_libelle_url');
  41      $cat_desc = $rsCat->field('cat_desc');
  42      $cat_id = $rsCat->field('cat_id');
  43      
  44      # Suppression
  45      if (!empty($_GET['del']))
  46      {
  47          if ($blog->delCat($cat_id) !== false) {
  48              $msg = __('Category has been deleted');
  49              header('Location: cat_list.php?msg='.rawurlencode($msg));
  50              exit;
  51          } else {
  52              $msg = __('Cannot delete category');
  53              header('Location: cat_list.php?msg='.rawurlencode($msg));
  54          }
  55      }
  56      
  57      # Modification
  58      if (!empty($_POST['submit']) && $cat_id)
  59      {
  60          $cat_libelle = $_POST['cat_libelle'];
  61          $cat_libelle_url = $_POST['cat_libelle_url'];
  62          $cat_desc = $_POST['cat_desc'];
  63          
  64          if ($blog->updCat($cat_id,$cat_libelle,$cat_desc,$cat_libelle_url) !== false) {
  65              $msg = __('Category has been updated');
  66              header('Location: cat_list.php?msg='.rawurlencode($msg));
  67              exit;
  68          } else {
  69              $err = $blog->error(1);
  70          }
  71      }
  72  }
  73  # Ajout d'une catégorie
  74  elseif (!empty($_POST['submit']))
  75  {
  76      $cat_libelle = $_POST['cat_libelle'];
  77      $cat_libelle_url = $_POST['cat_libelle_url'];
  78      $cat_desc = $_POST['cat_desc'];
  79      
  80      if ($blog->addCat($cat_libelle,$cat_desc,$cat_libelle_url) !== false) {
  81              $msg = __('Category has been created');
  82              header('Location: cat_list.php?msg='.rawurlencode($msg));
  83              exit;
  84          } else {
  85              $err = $blog->error(1);
  86          }
  87  }
  88  
  89  openPage(__('Category'));
  90  
  91  if ($err != '')
  92  {
  93      echo '<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.
  94          $err.'</div>';
  95  }
  96  
  97  echo
  98  '<p><strong><a href="cat_list.php">'.__('Back').'</a></strong></p>'.
  99  '<h2>'.__('Category').'</h2>'.
 100  
 101  '<form action="categorie.php" method="post">'.
 102  '<p><label for="cat_libelle"><strong>'.__('Title').'&nbsp;: </strong> '.
 103  helpLink('category','title').'</label>'.
 104  form::field('cat_libelle',40,255,$cat_libelle,'','class="max"').'</p>'.
 105  
 106  '<p><label for="cat_libelle_url"><strong>'.__('URLed title').'</strong>&nbsp;: '.
 107  helpLink('category','title_url').' <a href="#" '.
 108  'onclick="document.forms[0].cat_libelle_url.value=str2url(document.forms[0].cat_libelle.value,\''.dc_encoding.'\',1); return false;">'.
 109  __('Use').'</a></label>'.
 110  form::field('cat_libelle_url',40,255,$cat_libelle_url,'','class="max"').'</p>'.
 111  
 112  '<p><label for="cat_desc">'.__('Description').' ('.__('optional').')&nbsp;: '.
 113  helpLink('category','description').'</label>'.
 114  form::textArea('cat_desc',60,8,htmlspecialchars($cat_desc),'','class="max"').
 115  '</p>'.
 116  
 117  '<p><input class="submit" type="submit" name="submit" value="'.__('save').'" />'.
 118  ((!empty($cat_id)) ? form::hidden('cat_id',$cat_id) : '').
 119  '</p>'.
 120  '</form>';
 121  
 122  closePage(); ?>


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