categorie.php 3.8 KB

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