[ Index ]
 

Code source de Dotclear 2.0-beta6

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

title

Body

[fermer]

/admin/ -> category.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  $cat_id = '';
  28  $cat_title = '';
  29  $cat_url = '';
  30  $cat_desc = '';
  31  $cat_position = '';
  32  
  33  # Getting existing category
  34  if (!empty($_REQUEST['id']))
  35  {
  36      try {
  37          $rs = $core->blog->getCategory($_REQUEST['id']);
  38      } catch (Exception $e) {
  39          $core->error->add($e->getMessage());
  40      }
  41      
  42      if (!$core->error->flag() && !$rs->isEmpty())
  43      {
  44          $cat_id = $rs->cat_id;
  45          $cat_title = $rs->cat_title;
  46          $cat_url = $rs->cat_url;
  47          $cat_desc = $rs->cat_desc;
  48          $cat_position = $rs->cat_position;
  49      }
  50  }
  51  
  52  # Remove category
  53  if (!empty($_POST['id']) && $cat_id && !empty($_POST['delete']))
  54  {
  55      try {
  56          $core->blog->delCategory($_POST['id']);
  57      } catch (Exception $e) {
  58          $core->error->add($e->getMessage());
  59      }
  60      
  61      if (!$core->error->flag()) {
  62          http::redirect('categories.php');
  63      }
  64  }
  65  
  66  # Create or update a category
  67  if (!empty($_POST))
  68  {
  69      $cur = $core->con->openCursor($core->prefix.'category');
  70      
  71      $cur->cat_title = $cat_title = $_POST['cat_title'];
  72      
  73      if (isset($_POST['cat_desc'])) {
  74          $cur->cat_desc = $cat_desc = $_POST['cat_desc'];
  75      }
  76      
  77      if (isset($_POST['cat_url'])) {
  78          $cur->cat_url = $cat_url = $_POST['cat_url'];
  79      } else {
  80          $cur->cat_url = $cat_url;
  81      }
  82      
  83      # Update category
  84      if ($cat_id)
  85      {
  86          try {
  87              $core->blog->updCategory($_POST['id'],$cur);
  88              http::redirect('category.php?id='.$_POST['id'].'&upd=1');
  89          } catch (Exception $e) {
  90              $core->error->add($e->getMessage());
  91          }
  92      }
  93      # Create category
  94      else
  95      {
  96          try {
  97              $id = $core->blog->addCategory($cur);
  98              http::redirect('categories.php?add=1');
  99          } catch (Exception $e) {
 100              $core->error->add($e->getMessage());
 101          }
 102      }
 103  }
 104  
 105  
 106  
 107  $title = $cat_id ? __('Edit category') : __('New category');
 108  
 109  dcPage::open($title,
 110      dcPage::jsConfirmClose('category-form').    
 111      dcPage::jsToolBar().
 112      dcPage::jsLoad('js/_category.js')
 113  );
 114  
 115  if (!empty($_GET['upd'])) {
 116          echo '<p class="message">'.__('Category has been successfully updated.').'</p>';
 117  }
 118  
 119  echo
 120  '<h2>'.html::escapeHTML($core->blog->name).' &gt; <a href="categories.php">'.
 121  __('Categories').'</a> &gt; '.$title.'</h2>'.
 122  
 123  '<form action="category.php" method="post" id="category-form">'.
 124  '<fieldset class="constrained">'.
 125  '<p><label class="required" title="'.__('Required field').'">'.__('Title:').' '.
 126  dcPage::help('categories','cat_title').
 127  form::field('cat_title',20,255,html::escapeHTML($cat_title),'',2).
 128  '</label></p>'.
 129  
 130  '<div class="lockable">'.
 131  '<p><label>'.__('URL:').' '.dcPage::help('categories','cat_url').
 132  form::field('cat_url',20,255,html::escapeHTML($cat_url),'',3).
 133  '</label></p>'.
 134  '<p class="form-note warn" id="note-cat-url">'.
 135  __('Warning: If you set the URL manually, it may conflict with another category.').'</p>'.
 136  '</div>'.
 137  
 138  '<p class="area"><label for="cat_desc">'.__('Description:').
 139  dcPage::help('categories','cat_url').'</label> '.
 140  form::textarea('cat_desc',50,8,html::escapeHTML($cat_desc),'',4).
 141  '</p>'.
 142  
 143  '<p><input type="submit" accesskey="s" value="'.__('Save').'" tabindex="5" />'.
 144  ($cat_id ? form::hidden('id',$cat_id) : '').
 145  '</p>'.
 146  '</fieldset>'.
 147  '</form>';
 148  
 149  dcPage::close();
 150  ?>


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