[ 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 27 auth::checkAuth(PX_AUTH_ADMIN); 28 29 $m = new Manager(); 30 $_px_theme = $m->user->getTheme(); 31 32 if (empty($_REQUEST['site_id']) && empty($_REQUEST['op'])) { 33 $display_add_site = true; 34 } else { 35 $display_add_site = false; 36 } 37 //full right to modify the current site and add. Only the root user. 38 $is_full_editable = auth::asLevel(PX_AUTH_ROOT); 39 40 if ($is_full_editable) { 41 $px_submenu->addItem(__('New site'), 'sites.php?op=add', 42 'themes/'.$_px_theme.'/images/ico_new.png', 43 false, $display_add_site); 44 } 45 $px_submenu->addItem(__('Back to the list of the sites'), 'sites.php', 46 'themes/'.$_px_theme.'/images/ico_back.png', false, 47 !$display_add_site); 48 49 /* ========================================================================= * 50 * Process block * 51 * ========================================================================= */ 52 53 // partial rights to modify the current website, see a partial 54 // list of websites (only the one with some rights) 55 $is_editable = true; 56 $update = false; 57 // switched to true only if the form to create a new site was submitted 58 // and the data in the form were ok to start the creation. A page with 59 // the log of the creation is then displayed. 60 $is_new_site = false; 61 62 if (empty($_REQUEST['op']) && empty($_REQUEST['site_id'])) { 63 // list the sites 64 $px_sites = $m->getSites(); 65 } else { 66 // edit a website 67 // set default values 68 $px_id = ''; 69 $px_name = __('New website name'); 70 $px_website_address = ''; 71 $px_xmedia_name = 'xmedia'; 72 $px_website_path = ''; 73 $px_description = __('Description of the __new website__.'); 74 $px_sitelang = $m->user->lang; 75 $px_comment_status = 1; 76 $px_comment_support = 1; 77 $arry_langs = l10n::getIsoCodes(true); 78 79 if (!empty($_REQUEST['site_id']) && empty($_REQUEST['op'])) { 80 // see if the website exists or not 81 $px_site = $m->getSites($_REQUEST['site_id']); 82 if (strlen($px_site->f('website_id')) == 0) { 83 // site does not exist error 84 $m->setMessage(__('This site is not available.')); 85 header('Location: sites.php'); 86 exit; 87 } 88 if (!auth::asLevel(PX_AUTH_ADMIN, $px_site->f('website_id'))) { 89 // No rights 90 $m->setMessage(__('No rights to edit this website.')); 91 header('Location: sites.php'); 92 exit; 93 } 94 if (file_exists($_PX_config['manager_path'].'/conf/configweb_'.$px_site->f('website_id').'.php')) { 95 include($_PX_config['manager_path'].'/conf/configweb_'.$px_site->f('website_id').'.php'); 96 if (!is_writable($_PX_config['manager_path'].'/conf/configweb_'.$px_site->f('website_id').'.php')) { 97 $is_editable = false; 98 $m->setError( __('Error: Permissions of the configuration prevent the addition or modification of the sites.'), 500); 99 } 100 } else { 101 $m->setError(sprintf( __('Error: Configuration file of the website(<strong>%s</strong>) not available.'), files::real_path($_PX_config['manager_path'].'/conf/configweb_'.$px_site->f('website_id').'.php')), 500); 102 $is_editable = false; 103 } 104 105 if ((false === $m->error(true, false)) && $is_editable) { 106 $px_id = $px_site->f('website_id'); 107 $px_name = $px_site->f('website_name'); 108 $px_website_address = 'http'.(($_PX_website_config['secure']) ? 's': '').'://'.$_PX_website_config['domain'].$_PX_website_config['rel_url']; 109 $px_xmedia_name = trim(str_replace('/', '', substr($_PX_website_config['rel_url_files'], strlen($_PX_website_config['rel_url'])))); 110 $px_description = $px_site->f('website_description'); 111 $px_sitelang = $_PX_website_config['lang']; 112 $px_website_path = substr(files::real_path($_PX_website_config['xmedia_root']), 0, (-1 - strlen($px_xmedia_name))); 113 $px_comment_status = $_PX_website_config['comment_default_status']; 114 $px_comment_support = $_PX_website_config['comment_support']; 115 $update = true; 116 } 117 } 118 if (!$is_full_editable && (!empty($_REQUEST['op']) && 'add' == $_REQUEST['op'])) { 119 // No rights 120 $m->setMessage(__('No rights to add a website.')); 121 header('Location: sites.php'); 122 exit; 123 } 124 if (!empty($_SESSION['log_new_site']) && (!empty($_REQUEST['op']) && 'log' == $_REQUEST['op'])) { 125 $px_new_site = $_SESSION['log_new_site']; 126 $is_new_site = true; 127 } 128 } 129 130 131 /*================================================= 132 Save the data 133 =================================================*/ 134 if ($is_editable && (!empty($_POST['save']))) { 135 // get data from form 136 $px_name = form::getPostField('s_name'); 137 $px_description = form::getPostField('s_description'); 138 $px_sitelang = form::getPostField('s_sitelang'); 139 $px_comment_status = form::getPostField('s_comment_status'); 140 $px_comment_support = form::getPostField('s_comment_support'); 141 142 if ($is_full_editable) { 143 $px_website_address = form::getPostField('s_website_address'); 144 $px_website_path = form::getPostField('s_website_path'); 145 $px_xmedia_name = form::getPostField('s_xmedia_name'); 146 } 147 $px_log_new_site = ''; //updated through a reference 148 if (!empty($px_id)) { 149 if (false !== $m->saveSite($px_id, $px_name, $px_description, 150 $px_sitelang, $px_website_address, 151 $px_website_path, $px_xmedia_name, 152 $px_comment_support, $px_comment_status, 153 $px_log_new_site)) { 154 $m->setMessage(sprintf(__('Site <strong>%s</strong> successfully saved.'), $px_name)); 155 header('Location: sites.php'); 156 exit; 157 } 158 } else { 159 if (false !== $m->saveSite($px_id, $px_name, $px_description, 160 $px_sitelang, $px_website_address, 161 $px_website_path, $px_xmedia_name, 162 $px_comment_support, $px_comment_status, 163 $px_log_new_site)) { 164 $m->setMessage(sprintf(__('Site <strong>%s</strong> successfully added.'), $px_name)); 165 //Save the log in the session 166 //the header is to prevent a double "addition". 167 $_SESSION['log_new_site'] = $px_log_new_site; 168 header('Location: sites.php?op=log'); 169 exit; 170 } 171 } 172 } 173 174 if ($is_editable && (!empty($_POST['delete']))) { 175 if (false !== $m->delSite($px_id)) { 176 $m->setMessage(__('Site successfully deleted. No file were removed from the document root.')); 177 header('Location: sites.php'); 178 exit; 179 } 180 } 181 182 if ($is_editable && strlen(form::getField('switchtheme')) > 0) { 183 if (false !== $m->switchSiteTheme($px_id, form::getField('switchtheme'))) { 184 $m->setMessage(__('The theme of the site has been successfully changed. You may need to copy the style files in the xmedia folder.')); 185 header('Location: sites.php?site_id='.$px_id); 186 exit; 187 } 188 } 189 190 /* ========================================================================= * 191 * Display block * 192 * ========================================================================= */ 193 /* ================================================= * 194 * Set title of the page, and load common top page * 195 * ================================================== */ 196 $px_title = __('Sites'); 197 include dirname(__FILE__).'/mtemplates/_top.php'; 198 199 echo '<h1>'.__('Sites')."</h1>\n\n"; 200 201 if($is_new_site) { 202 /*================================================= 203 Show the log of the creation of a new website 204 =================================================*/ 205 echo '<h2>'.__('New site')."</h2>\n\n"; 206 207 echo '<p>'.__('Log of the installation:').'</p>'."\n\n"; 208 209 echo $px_new_site; 210 211 echo '<p>'.__('If you see warnings, check them carefully and look at the online documentation to see the impact. You may need to complete the installation manually.').'</p>'."\n\n"; 212 213 echo '<p>'.__('To see the new website in the manager, you need to logout and login again.').'</p>'."\n\n"; 214 215 echo '<p>'.__('If you are using the nice url option, you need to configure the webserver to use these url with this new website.').'</p>'."\n\n"; 216 217 } elseif (empty($_REQUEST['op']) && empty($_REQUEST['site_id'])) { 218 /*================================================= 219 Show the list of websites. 220 =================================================*/ 221 while(!$px_sites->EOF()) { 222 if (auth::asLevel(PX_AUTH_ADMIN, $px_sites->f('website_id'))) { 223 echo '<div class="line" id="p'.$px_sites->f('website_id').'"><p>'; 224 echo '<a href="'.$px_sites->f('website_url').'"><strong>'.$px_sites->f('website_name').'</strong></a>'; 225 echo ' <span class="small">('.$px_sites->f('website_id').')</span> '; 226 echo '[<strong><a href="sites.php?site_id='.$px_sites->f('website_id').'">'. __('edit').'</a></strong>]<br />'; 227 echo $px_sites->f('website_description'); 228 echo "</p>\n\n"; 229 echo '<p>'.sprintf(__('<a href="%s">Manage the subtypes of resources</a>.'), 'subtypes.php').'</p>'."\n\n"; 230 echo "\n</div>\n\n"; 231 } 232 $px_sites->moveNext(); 233 } 234 } elseif (($is_editable && !empty($_REQUEST['site_id'])) or ((!empty($_REQUEST['op']) && 'add' == $_REQUEST['op']) && $is_full_editable)) { 235 /*================================================= 236 Show the page to edit/create a website 237 =================================================*/ 238 if (!empty($_REQUEST['op']) && 'add' == $_REQUEST['op']) { 239 echo '<h2>'. __('New site')."</h2>\n\n"; 240 } 241 ?> 242 243 <form action="sites.php" method="post" id="formPost"> 244 <?php 245 if (empty($_REQUEST['op']) or 'add' != $_REQUEST['op']) { 246 ?> 247 <p class="field"><label class="float" for="s_site_id" style="display:inline"><strong><?php echo __('Site id:'); ?></strong></label> 248 <strong><?php echo $px_id; ?></strong></p> 249 <?php 250 } 251 ?> 252 <p class="field"><label class="float" for="s_name" style="display:inline"><strong><?php echo __('Site name:'); ?></strong></label> 253 <?php echo form::textField('s_name', 30, 255, $px_name, '', ''); ?> 254 </p> 255 <?php 256 // in case of addition of a new website, we ask where the "index.php" folder is 257 if ($is_full_editable or (!empty($_REQUEST['op']) && 'add' == $_REQUEST['op'])): 258 ?> 259 <p class="field"><label class="float" for="s_website_address" style="display:inline"><strong><?php echo __('Website address:'); ?></strong></label> 260 <?php echo form::textField('s_website_address', 50, 255, $px_website_address, '', ''); ?><br /> 261 <?php echo __('For example put <em>https://www.mydomain.com/mysite/</em> or <em>http://www.mydomain.com/</em>. Do not forget the <em>http(s)</em>.'); ?> 262 </p> 263 264 <p class="field"><label class="float" for="s_website_path" style="display:inline"><strong><?php echo __('Path to the document root of the website:'); ?></strong></label> 265 <?php echo form::textField('s_website_path', 30, 255, $px_website_path, '', ''); 266 267 if (!empty($_REQUEST['op']) && 'add' == $_REQUEST['op']): 268 echo '<br />'."\n".__('Path on the server side. For example <em>/home/login/www</em> or <em>c:/http</em>. The document root is the folder where the <em>index.php</em> will be placed.'); 269 endif; 270 271 echo "\n".'</p>'."\n"; 272 endif; 273 ?> 274 275 <?php if ($is_full_editable): ?> 276 <p class="field"><label class="float" for="s_xmedia_name" style="display:inline"><strong><?php echo __('Name of the file and image folder:'); ?></strong></label> 277 <?php echo form::textField('s_xmedia_name', 15, 255, $px_xmedia_name, '', ''); ?><br /> 278 <?php echo __('For example put <em>xmedia</em> or <em>documents</em>.'); ?> 279 </p> 280 <?php endif; ?> 281 282 <p class="field"><label class="float" for="s_sitelang" style="display:inline"><strong><?php echo __('Main language of the website:'); ?></strong></label> 283 <?php echo form::comboBox('s_sitelang', $arry_langs, $px_sitelang); ?> 284 </p> 285 286 <p> 287 <label for="s_description"><strong><?php echo __('Description:'); ?></strong></label> 288 <?php 289 echo form::textArea('s_description', 60, 4, $px_description, '', ''); 290 ?> 291 </p> 292 293 294 <p class="field"><label class="float" for="s_comment_support" style="display:inline"><strong><?php echo __('Support of the comments:'); ?></strong></label> 295 <?php echo form::comboBox('s_comment_support', 296 array(__('Comments open') => 1, 297 __('Defined for each individual resource') => 2, 298 __('Comments closed') => 3), $px_comment_support); ?> 299 </p> 300 301 302 <p class="field"><label class="float" for="s_comment_status" style="display:inline"><strong><?php echo __('Default status of the comments:'); ?></strong></label> 303 <?php echo form::comboBox('s_comment_status', array(__('Need validation') => 5, __('Online') =>1 ), $px_comment_status); ?> 304 </p> 305 306 <?php 307 if ($update) { 308 echo form::hidden('site_id',$px_id); 309 ?><p> <input name="save" type="submit" class="submit" value="<?php echo __('Save [s]'); ?>" accesskey="s" /> 310 <?php 311 } else { 312 echo form::hidden('op','add'); 313 echo "\n".'<p>'.__('If all the information you provided are valid, the system will copy the required files in the right folders. The complete log of those files will be shown to you. No file already available on the system will be overwritten.').'</p>'."\n\n"; 314 ?> <p> <input name="save" type="submit" class="submit" value="<?php echo __('Create the new website'); ?>" accesskey="s" /> 315 <?php 316 } 317 ?> 318 <?php 319 if ($update && (false === $m->getEarlierDate('m', '', '', $px_id))) { 320 echo ' <input name="delete" type="submit" class="submit" '. 321 'value="'. __('Delete').'" onclick="return '. 322 'window.confirm(\''.addslashes( __('Are you sure you want to delete this site?')).'\')" />'; 323 } 324 echo "\n".'</p></form>'; 325 326 if ($update) { 327 // get the available themes 328 require_once dirname(__FILE__).'/extinc/class.plugins.php'; 329 $themes_root = dirname(__FILE__).'/templates/'; 330 $objPlugins = new plugins($themes_root); 331 $themes_list = $objPlugins->getPlugins('theme'); 332 333 if (count($themes_list) >= 1) { 334 echo '<hr class="soft" />'."\n"; 335 echo '<h2>'.__('Website Themes').'</h2>'."\n"; 336 echo '<dl class="themes-list">'."\n"; 337 reset($themes_list); 338 foreach($themes_list as $theme) { 339 echo '<dt><img alt="" src="templates/'.$theme['name'].'/preview.png"> <strong>'.$theme['label'].'</strong> '.__('by').' '.$theme['author'].'</dt>'."\n"; 340 echo '<dd>'.$theme['desc'].' - '.__('version:').' '.$theme['version']; 341 if (config::f('theme_id') != $theme['name']) { 342 echo '<br /><a href="sites.php?switchtheme='.$theme['name'].'&site_id='.$px_id.'"><strong>'.__('Use this theme').'</strong></a>'; 343 } 344 echo '</dd>'."\n\n"; 345 } 346 echo '</dl>'."\n"; 347 } 348 } 349 350 } 351 352 /*================================================= 353 Load common bottom page 354 =================================================*/ 355 include dirname(__FILE__).'/mtemplates/_bottom.php'; 356 357 ?>
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 |
![]() |