[ Index ] |
|
Code source de Plume CMS 1.2.2 |
1 <?php 2 /* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 3 /* 4 # ***** BEGIN LICENSE BLOCK ***** 5 # This file is part of Plume CMS, a website management application. 6 # Copyright (C) 2001-2005 Loic d'Anterroches and contributors. 7 # 8 # Plume CMS is free software; you can redistribute it and/or modify 9 # it under the terms of the GNU General Public License as published by 10 # the Free Software Foundation; either version 2 of the License, or 11 # (at your option) any later version. 12 # 13 # Plume CMS is distributed in the hope that it will be useful, 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 # GNU General Public License for more details. 17 # 18 # You should have received a copy of the GNU General Public License 19 # along with this program; if not, write to the Free Software 20 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 # 22 # ***** END LICENSE BLOCK ***** */ 23 24 require_once 'path.php'; 25 require_once $_PX_config['manager_path'].'/prepend.php'; 26 auth::checkAuth(PX_AUTH_ADVANCED); 27 28 $m = new Manager(); 29 $_px_theme = $m->user->getTheme(); 30 31 32 if (!empty($_REQUEST['category_id']) || !empty($_REQUEST['op'])) { 33 $display_list_cat = true; 34 } else { 35 $display_list_cat = false; 36 } 37 38 $px_submenu->addItem(__('Categories'), 'categories.php', 39 'themes/'.$_px_theme.'/images/ico_cat.png', 40 false, $display_list_cat); 41 $px_submenu->addItem(__('New category'), 'categories.php?op=add', 42 'themes/'.$_px_theme.'/images/ico_new.png', false); 43 44 /* =============================================================== * 45 * Process of the data * 46 * =============================================================== */ 47 /* ================================================= * 48 * Set default values / Load requested category * 49 * ================================================= */ 50 $is_editable = true; 51 $cat = new Category(); 52 if (!empty($_REQUEST['category_id']) || !empty($_REQUEST['op'])) { 53 $cat->setDefaults($m->user); 54 55 if (!empty($_REQUEST['category_id'])) { 56 if (false === $m->loadCategory($cat, $_REQUEST['category_id'])) { 57 $m->setError(__('Error: The requested category is not available.'), 58 400); 59 $is_editable = false; 60 } 61 } 62 } 63 64 if ((!empty($_POST['preview']) || !empty($_POST['publish']) 65 || !empty($_POST['transform']) || !empty($_POST['increase']) 66 || !empty($_POST['increase_x']) || !empty($_POST['decrease']) 67 || !empty($_POST['decrease_x']) || !empty($_POST['delete'])) 68 && $is_editable) { 69 $cat->set(form::getPostField('c_parentid'), 70 form::getPostField('c_name'), 71 form::getPostField('c_description'), 72 form::getPostField('c_format'), 73 form::getPostField('c_keywords'), 74 form::getPostField('c_path'), 75 form::getPostField('c_template'), 76 3600); 77 78 if (!empty($_POST['transform'])) { 79 $cat->setField('category_description', 80 '=html'."\n" 81 .$cat->getFormattedContent('category_description', 82 'html')); 83 } 84 85 if (!empty($_POST['increase']) || !empty($_POST['increase_x'])) { 86 $m->user->increase('category_textarea'); 87 } 88 if (!empty($_POST['decrease']) || !empty($_POST['decrease_x'])) { 89 $m->user->decrease('category_textarea'); 90 } 91 92 if (!empty($_POST['publish'])) { 93 if (false !== $m->saveCategory($cat)) { 94 $m->setMessage(__('Category successfully saved.')); 95 header('Location: categories.php'); 96 exit; 97 } 98 } else if (!empty($_POST['delete'])) { 99 if ($m->delCategory($cat) !== false) { 100 $m->setMessage(__('The category was successfully deleted.')); 101 header('Location: categories.php'); 102 exit; 103 } 104 } else if (!empty($_POST['preview'])) { 105 $m->check($cat); // Provide the error feedback 106 } 107 108 109 } 110 111 if ($is_editable) { 112 $cats = $m->getCategories(); 113 $arry_cat = array(); 114 $arry_cat_js = array(); 115 while (!$cats->EOF()) { 116 $name = $cats->f('category_name'); 117 $name .= ' ('.$cats->f('category_path').')'; 118 if (isGhostCat($cats->f('category_path'))) $name .= ' ['. __('Hidden category').']'; 119 if ($cats->f('category_id') != $cat->f('category_id')) { 120 $arry_cat[$name] = $cats->f('category_id'); 121 } 122 $cats->moveNext(); 123 } 124 $arry_templates = $m->getTemplates('category'); 125 } 126 127 /* ================================================= 128 * List the categories 129 * ================================================= */ 130 if (empty($_REQUEST['category_id']) && empty($_REQUEST['op'])) { 131 $cats = $m->getCategories(); 132 } 133 134 135 /*=============================================================== 136 Display of the data 137 ===============================================================*/ 138 /*================================================= 139 title of the page 140 =================================================*/ 141 142 $px_title = __('Categories'); // used in _top.php 143 include dirname(__FILE__).'/mtemplates/_top.php'; 144 145 echo '<h1>'.__('Categories').'</h1>'."\n\n"; 146 147 /*================================================= 148 add/edit a category 149 =================================================*/ 150 if ($is_editable 151 && (!empty($_REQUEST['op']) || !empty($_REQUEST['category_id'])) 152 ) { 153 /*================================================= 154 * Preview of the content if some content is available 155 *=================================================*/ 156 if (strlen($cat->getUnformattedContent('category_description'))) { 157 echo '<div class="preview">'; 158 159 echo '<h3>'.$cat->getTextContent('category_name').'</h3>'; 160 echo $cat->getFormattedContent('category_description', 'html'); 161 162 echo "<hr class='invisible' id=\"zoubida\"/></div>\n\n"; 163 } 164 165 echo '<script type="text/javascript">'."\n". 166 "<!--\n". 167 "var js_pathlist = new Array();\n"; 168 $cats->moveStart(); 169 while (!$cats->EOF()) { 170 echo "js_pathlist[".$cats->f('category_id')."] = '".$cats->f('category_path')."';\n"; 171 $cats->moveNext(); 172 } 173 echo "//-->\n". "</script>\n"; 174 175 echo '<form action="categories.php" method="post" id="formPost" ' 176 .'name="formPost">'."\n"; 177 echo "<p>\n"; 178 if (($cat->f('category_path') != '/' && strlen($cat->f('category_id'))) 179 || '' == $cat->f('category_id') 180 ) { 181 echo '<span class="nowrap"><label for="c_parentid" ' 182 .'style="display:inline">'.__('Parent category:').'</label> '; 183 echo form::combobox('c_parentid', $arry_cat, 184 $cat->f('category_parentid'), '', '', 185 'onChange="catChangePath(js_pathlist);"'); 186 echo '</span>'."\n"; 187 } else { 188 echo form::hidden('c_parentid', $cat->f('category_parentid')); 189 } 190 191 echo '<span class="nowrap"><label for="c_format" ' 192 .'style="display:inline">'.__('Format:').'</label>'."\n"; 193 echo form::combobox('c_format', array('HTML'=>'html','Wiki'=>'wiki'), 194 $cat->getContentFormat('category_description'), 195 $m->user->getPref('content_format')); 196 echo '</span>'."\n"; 197 echo '</p>'."\n"; 198 199 echo '<p><label for="c_name"><strong>'.__('Title:').'</strong></label> '; 200 echo form::textField('c_name', 30, 255, $cat->f('category_name'), '', 201 'style="width:100%" onkeyup="setUrl(\'c_name\', \'c_path\', \'cat\', js_pathlist)"'); 202 echo "</p>\n<p>\n"; 203 echo '<span id="insert-img" class="bloc-droite"><img src="themes/'.$_px_theme 204 .'/images/ico_image.png" alt="" /> '; 205 echo '<strong><a href="xmedia.php" ' 206 .'onclick="popup(this.href+\'?mode=popup\'); return false;">' 207 .__('Insert an image or a file').'</a></strong></span>'."\n"; 208 echo '<label for="c_description"><strong>'.__('Description:') 209 .'</strong></label>'."\n"; 210 echo form::textArea('c_description', 60, 211 $m->user->getPref('category_textarea'), 212 $cat->getUnformattedContent('category_description'), 213 '', 'style="width:100%"'); 214 echo "\n".'<span id="size-control" class="size-control"> ' 215 .'<input type="image" alt="'.__('shrink textarea') 216 .'" name="decrease" value="-" src="themes/'.$_px_theme 217 .'/images/ico_shrink.png" accesskey="-" class="size-control" /> ' 218 .'<input type="image" alt="'.__('grow textarea') 219 .'" name="increase" value="+" src="themes/'.$_px_theme 220 .'/images/ico_grow.png" accesskey="+" class="size-control" /> '; 221 echo '</span>'."\n"; 222 echo "</p>\n"; 223 echo '<p><label for="c_keywords">'.__('Keywords:').'</label> '; 224 echo form::textArea('c_keywords', 60, 2, $cat->f('category_keywords'), 225 '', 'style="width:100%"'); 226 echo "</p>\n"; 227 echo '<p><label for="c_path"><strong>' 228 .__('Path <span class="small">(/category/ or /cat/subcat/)</span>:') 229 .'</strong></label> '; 230 if ($cat->f('category_path') == '/' 231 && strlen($cat->f('category_id'))) { 232 echo '<strong>/</strong>'; 233 } else { 234 echo form::textField('c_path', 30, 255, $cat->f('category_path'), 235 '', 'style="width:100%"'); 236 } 237 echo "</p>\n<p>\n"; 238 echo '<span class="nowrap"> '; 239 echo '<label for="c_template" style="display:inline"><strong>' 240 .__('Template:').'</strong></label> '; 241 echo form::combobox('c_template', $arry_templates, 242 $cat->f('category_template')); 243 echo '</span>'."\n"; 244 echo '</p>'."\n"; 245 246 echo '<p><input name="preview" type="submit" class="submit" ' 247 .'value="'.__('Visualize [v]').'" accesskey="v" /> ' 248 .'<input name="publish" type="submit" class="submit" ' 249 .'value="'.__('Save [s]').'" accesskey="s" /> '; 250 251 if (strlen($cat->f('category_id')) 252 && $cat->getContentFormat('category_description') == 'wiki') { 253 echo ' <input name="transform" type="submit" class="submit" ' 254 .'value="'. __('Transform in XHTML').'" />'; 255 } 256 257 if (strlen($cat->f('category_id')) && $cat->f('category_path') != '/') { 258 echo ' <input name="delete" type="submit" class="submit" ' 259 .'value="'. __('Delete').'" onclick="return ' 260 .'window.confirm(\'' 261 .addslashes( __('Are you sure you want to delete this category?')) 262 .'\')" />'; 263 } 264 if (strlen($cat->f('category_id'))) { 265 echo form::hidden('category_id', $cat->f('category_id')); 266 } else { 267 echo form::hidden('op','add'); 268 } 269 echo form::hidden('quirk_category_path', strlen($cat->f('category_path'))); 270 echo '</p>'; 271 echo '</form>'."\n\n"; 272 echo '<h3><a onclick="openClose(\'wikihelp\',0); return false" ' 273 .'href="#"><img alt="'.__('show/hide').'" id="img_wikihelp" ' 274 .'src="themes/'.$_px_theme.'/images/plus.png" /></a> ' 275 .__('Wiki syntax').'</h3>'."\n"; 276 echo '<div id="wikihelp" style="display: none;"> '; 277 echo $m->getHelp('wiki-inline'); 278 echo '</div>'."\n"; 279 echo '<script type="text/javascript"><!--'."\n" 280 .'openClose(\'wikihelp\',-1);'."\n" 281 .'//--></script>'; 282 } //end of $is_editable 283 284 /* ================================================= * 285 * list categories * 286 * ================================================= */ 287 if (empty($_REQUEST['category_id']) && empty($_REQUEST['op'])) { 288 289 if ($cats->isEmpty()) { 290 echo '<p>'.__('No categories.').'</p>'."\n\n"; 291 } else { 292 echo '<script type="text/javascript">'."\n" 293 ."<!--\n" 294 ."var js_post_ids = new Array('" 295 .implode("','",$cats->getIDs('category_id', 'content'))."');\n" 296 ."//-->\n" 297 ."</script>\n"; 298 299 echo '<p class="small"><a href="#" onclick="mOpenClose(js_post_ids,1); return false;">'.__('Show all').'</a>' 300 .' - <a href="#" onclick="mOpenClose(js_post_ids,-1); return false;">'.__('Hide all').'</a></p>'; 301 302 303 while (!$cats->EOF()) { 304 305 echo '<div class="line" id="p'.$cats->f('category_id').'">'. 306 '<p><a href="#" onclick="openClose(\'content'.$cats->f('category_id').'\',0); return false;">'. 307 '<img src="themes/'.$_px_theme.'/images/plus.png" id="img_content'.$cats->f('category_id').'" '. 308 'alt="'. __('show/hide').'" /></a> '; 309 310 echo '<a href="index.php?cat_id='.$cats->f('category_id').'"><strong>'.$cats->f('category_name').'</strong></a> <span class="small">'.$cats->f('category_path').'</span> [<a href="categories.php?category_id='.$cats->f('category_id').'"><strong>'. __('edit').'</strong></a>]'; 311 312 echo "</p>\n\n"; 313 echo '<div id="content'.$cats->f('category_id').'" style="display:none;">'; 314 echo '<p>'.text::parseContent($cats->f('category_description'))."</p>\n"; 315 echo "<p><span class='small'>". __('Id to use in the templates:').' '.$cats->f('category_id')."</span></p>"; 316 echo "\n<hr class='invisible' /></div></div>\n\n"; 317 318 $cats->moveNext(); 319 } 320 } 321 } 322 323 include config::f('manager_path').'/mtemplates/_bottom.php'; 324 325 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 11:57:01 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |