[ Index ] |
|
Code source de Plume CMS 1.2.2 |
1 <?php 2 /* 3 # ***** BEGIN LICENSE BLOCK ***** 4 # This file is part of Plume CMS, a website management application. 5 # Copyright (C) 2001-2005 Loic d'Anterroches and contributors. 6 # 7 # Plume CMS 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 # Plume CMS 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 this program; if not, write to the Free Software 19 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 # 21 # ***** END LICENSE BLOCK ***** */ 22 23 24 require_once 'path.php'; 25 require_once $_PX_config['manager_path'].'/prepend.php'; 26 27 auth::checkAuth(PX_AUTH_ADMIN); 28 29 /*================================================= 30 Create the manager object, load the libs and class 31 =================================================*/ 32 33 $m = new Manager(); 34 $_px_theme = $m->user->getTheme(); 35 36 /*================================================= 37 Submenu info 38 =================================================*/ 39 $px_submenu->addItem(__('Back to the list of resources'), 'index.php', 40 'themes/'.$_px_theme.'/images/ico_back.png', false); 41 $px_submenu->addItem(__('List the types'), 'subtypes.php', 42 'themes/'.$_px_theme.'/images/ico_subtype.png', false); 43 $px_submenu->addItem(__('New type'), 'subtypes.php?op=add', 44 'themes/'.$_px_theme.'/images/ico_new.png', false); 45 46 /*================================================= 47 Set all the default values 48 =================================================*/ 49 $px_id = ''; 50 $px_type_id = ''; 51 $px_name = ''; 52 $px_website_id = ''; 53 $px_template = ''; 54 $px_cachetime = ''; 55 $px_extra1 = ''; 56 $px_extra2 = ''; 57 $px_inuse = true; 58 59 /*============================================================================== 60 Process block 61 ==============================================================================*/ 62 // get list of subtypes 63 if (empty($_REQUEST['op']) && empty($_REQUEST['s_id'])) { 64 $px_subtypes = $m->getSubTypes(); 65 } 66 67 // get data for requested subtype 68 if (!empty($_REQUEST['s_id'])) { 69 if (false !== ($px_subtype = $m->getSubTypes($_REQUEST['s_id']))) { 70 $px_id = $px_subtype->f('subtype_id'); 71 $px_type_id = $px_subtype->f('type_id'); 72 $px_name = $px_subtype->f('subtype_name'); 73 $px_template = $px_subtype->f('subtype_template'); 74 $px_cachetime = $px_subtype->f('subtype_cachetime'); 75 $px_extra1 = $px_subtype->f('subtype_extra1'); 76 $px_extra2 = $px_subtype->f('subtype_extra2'); 77 78 $px_inuse = $m->isSubTypeUsed($px_id); 79 } 80 } 81 82 /*================================================= 83 Save/Add the type 84 =================================================*/ 85 if (!empty($_POST['save'])) { 86 87 $px_type_id = trim($_POST['s_type_id']); 88 $px_name = trim($_POST['s_name']); 89 $px_template = trim($_POST['s_template']); 90 $px_cachetime = trim($_POST['s_cachetime']); 91 $px_extra1 = (isset($_POST['s_extra1'])) ? trim($_POST['s_extra1']) : '' ; 92 $px_extra2 = (isset($_POST['s_extra2'])) ? trim($_POST['s_extra2']) : '' ; 93 94 if (false !== ($id = $m->saveType($px_id, $px_type_id, $px_name, $px_template, $px_cachetime, $px_extra1, $px_extra2))) { 95 $m->setMessage(__('The type was successfully saved.')); 96 header('Location: subtypes.php'); 97 exit; 98 } 99 } 100 101 if (!empty($_POST['delete'])) { 102 if (false !== ($id = $m->deleteType($px_id))) { 103 $m->setMessage(__('The type of resource was successfully deleted.')); 104 header('Location: subtypes.php'); 105 exit; 106 } 107 } 108 109 110 $arry_templates = $m->getTemplates('resource'); 111 /*============================================================================== 112 Display block 113 ==============================================================================*/ 114 115 /*================================================= 116 Set title of the page, and load common top page 117 =================================================*/ 118 $px_title = __('Resource types'); 119 include dirname(__FILE__).'/mtemplates/_top.php'; 120 121 echo '<h1>'. __('Resource types')."</h1>\n\n"; 122 123 /*================================================= 124 Add/Edit a subtype 125 =================================================*/ 126 if (!empty($_REQUEST['s_id']) or !empty($_REQUEST['op'])): 127 ?> 128 129 <form action="subtypes.php" method="post" id="formPost"> 130 <p class="field"><label class="float" for="s_type_id" style="display:inline"><strong><?php echo __('Type of:'); ?></strong></label> 131 <?php echo form::combobox('s_type_id', array( __('Article') => 'articles', __('News') => 'news'), $px_type_id,'','', '',"onChange=\"openCloseBlockIf('p_extra1','s_type_id','news',1,-1);\""); ?></span> 132 </p> 133 134 <p class="field"><label class="float" for="s_name" style="display:inline"><strong><?php echo __('Name of the type:'); ?></strong></label> 135 <?php echo form::textField('s_name', 30, 30, $px_name, '', ''); ?> 136 </p> 137 138 <p class="field"><label class="float" for="s_template" style="display:inline"><strong><?php echo __('Template:'); ?></strong></label> 139 <?php echo form::combobox('s_template', $arry_templates, $px_template); ?></span> 140 </p> 141 142 <p class="field"><label class="float" for="s_cachetime" style="display:inline"><strong><?php echo __('Cache time in seconds:'); ?></strong></label> 143 <?php echo form::textField('s_cachetime', 10, 20, $px_cachetime, '', ''); ?> 144 </p> 145 146 <?php $p_extra1_style = ($px_type_id == 'news') ? '' : ' style="display: none"'; ?> 147 148 <p class="field" id="p_extra1"<?php echo $p_extra1_style; ?>><label class="float" for="s_extra1" style="display:inline"><strong><?php echo __('Have associated link to news items:'); ?></strong></label> 149 <?php echo form::combobox('s_extra1', array( __('Yes') => '1', __('No') => '0'), $px_extra1); ?></span> 150 </p> 151 152 <?php 153 if (!empty($px_id)) { 154 echo form::hidden('s_id',$px_id); 155 } else { 156 echo form::hidden('op','add'); 157 } 158 ?> 159 <p> <input name="save" type="submit" class="submit" value="<?php echo __('Save [s]'); ?>" 160 accesskey="s" /> 161 <?php 162 if (!$px_inuse) { 163 echo ' <input name="delete" type="submit" class="submit" '. 164 'value="'. __('Delete').'" onclick="return '. 165 'window.confirm(\''.addslashes( __('Are you sure you want to delete this type of resource?')).'\')" />'; 166 167 } 168 ?> 169 </p> 170 </form> 171 172 <?php 173 endif; 174 175 /*================================================= 176 Display the list of subtypes 177 =================================================*/ 178 if (empty($_REQUEST['op']) && empty($_REQUEST['s_id'])): 179 180 $px_news_title = '<h2>'. __('Types of news').'</h2>'."\n"; 181 $px_articles_title = '<h2>'. __('Type of articles').'</h2>'."\n"; 182 183 $current = ''; //$px_subtypes->f('type_id'); 184 185 if ($px_subtypes->nbRow() == 0) { 186 echo '<p>'.sprintf( __('You need to <a href="%s">add 2 types of resource</a>, one for the articles and one for the news.'), 'subtypes.php?op=add').'</p>'; 187 } 188 189 while (!$px_subtypes->EOF()) { 190 if ($current != $px_subtypes->f('type_id')) { 191 if ($px_subtypes->getIndex() != 0) { 192 echo "</ul>\n"; 193 } 194 $current = $px_subtypes->f('type_id'); 195 if ($current == 'articles') { 196 echo $px_articles_title; 197 } else { 198 echo $px_news_title; 199 } 200 echo "<ul>\n"; 201 } 202 echo '<li><a href="subtypes.php?s_id='.$px_subtypes->f('subtype_id').'">'.$px_subtypes->f('subtype_name').'</a></li>'."\n"; 203 204 $px_subtypes->moveNext(); 205 } 206 echo "</ul>\n"; 207 endif; 208 209 /*================================================= 210 Load common bottom page 211 =================================================*/ 212 include dirname(__FILE__).'/mtemplates/_bottom.php'; 213 ?>
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 |
![]() |