linea21-core
[ class tree: linea21-core ] [ index: linea21-core ] [ all elements ]

Source for file edit.php

Documentation is available at edit.php

  1. <?php
  2. /**
  3.  * @package linea21.core
  4.  * @subpackage system
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11. //////////// Check Inclusion de pages ////////////
  12. if (!function_exists('AuthenthificationProcess')) {
  13.   include_once ("../lib/lib_common.php");
  14.   ReloadIndex('admin');
  15. }
  16. include_once('../lib/input_helpers.php');
  17.  
  18. // @todo handle files to exclude from theme.xml
  19.  
  20. if (isset($_REQUEST['file']&& !empty($_REQUEST['file'])) {
  21.   $file $_REQUEST['file'];
  22.   $file_path THEME_PUBLIC_PATH$file;
  23. else {
  24.   $file 'index.php';
  25.   $file_path THEME_PUBLIC_PATH$file;
  26. }
  27.  
  28. $edit_link=$rub_link."&amp;todo=edit_files&amp;file=";
  29. $link_confirm="confirm.php?rub=".$rub."&todo=".$todo.'&file='.$file;
  30.  
  31. if(isset($_POST['save'])) {
  32.   if (get_magic_quotes_gpc()) {
  33.     $savecontent stripslashes($_POST['file_content']);
  34.   }
  35.   else {
  36.     $savecontent $_POST['file_content'];
  37.   }
  38.  
  39.   if(!is_writable($file_path)) {
  40.     $user_msg array('class' => 'error''msg' => _t('sys_theme''not_writable'));
  41.   else {
  42.     $r file_put_contents($file_path$savecontentLOCK_EX);
  43.  
  44.     if(is_numeric($r)) header("Location: ".$link_confirm);
  45.     else  system_error();
  46.   }
  47. }
  48.  
  49. // we get current file content for edit
  50. $content '';
  51. if(file_exists($file_path&& is_readable($file_path)) {
  52.   $content file_get_contents($file_path);
  53. else {
  54.   $user_msg array('class' => 'error''msg' => _t('sys_theme''not_accessible'));
  55. }
  56. if(!is_writable($file_path)) {
  57.   $user_msg array('class' => 'error''msg' => _t('sys_theme''not_writable'));
  58. }
  59.  
  60. // we get all editables files
  61. $editables GetAllFiles(THEME_PUBLIC_PATH,array('php''css''js''txt')true);
  62. // and populate the container
  63. $edit_files '<ul>';
  64. foreach ($editables as &$item{
  65.     $shortname str_replace(THEME_PUBLIC_PATH.'/'''$item);
  66.     if($shortname == $file{
  67.       $class="active";
  68.     else {
  69.       $class='';
  70.     }
  71.     $edit_files .= '<li><a href="'.$edit_link$shortname.'" title="'_t('sys_theme''edit_file').' : ' .$shortname.'" class="'.$class.'">'$shortname"</a></li>";
  72. }
  73. $edit_files .= '</ul>';
  74.  
  75. ?>
  76.  
  77. <div id="chemin">
  78. <ul>
  79.     <li><a href="index.php" class="chemin_home"><?php echo _t('way','home'?></a>
  80.     </li>
  81.     <li><a href="<?php echo $rub_link?>" id="chemin_<?php echo $rub?>" class="chemin_rub"><?php echo _t('menu','system')?></a></li>
  82.     <li><span><?php echo _t('sys_theme','theme_editor'?></span></li>
  83. </ul>
  84. </div>
  85.  
  86. <!--end barre haute -->
  87. <?php
  88. include_once(THEME_ADMIN_PATH."quickicons.php");
  89. ?>
  90. <div class="contentcontainer">
  91. <?php include_once($dir "/menurub.php");?>
  92. <div id="content">
  93. <h2><?php echo _t('sys_theme','theme_editor')?></h2>
  94. <h3><?php echo _t('sys_theme','current_file')' : ' .$file?></h3>
  95. <?php
  96. // we display user message if needed
  97. if(isset($user_msg)) {
  98.   echo '<p class="'.$user_msg['class'].'">'.$user_msg['msg'].'</p>';
  99. }
  100. ?>
  101. <div id="filelinks">
  102.   <h3><?php echo _t('sys_theme','files')?> : </h3>
  103.   <?php echo $edit_files?>
  104. </div>
  105. <form id="edit_file" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  106.   <textarea id="file_content" name="file_content" cols="90" rows="35"><?php echo $content?></textarea>
  107.   <div>
  108.     <input name="file" type="hidden" value="<?php echo $file?>" id="file" />
  109.     <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  110.     <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" /> 
  111.     <?php echo cancel_button('?rub=system&amp;todo=list')?>
  112.     <input name="save" type="submit" value="<?php echo _t('btn','save'?>" class="button" id="save" />
  113.   </div>
  114. </form>
  115. </div>
  116. <?php include_once($dir "/help.php");?></div>

Documentation generated on Thu, 03 May 2012 15:04:30 +0200 by phpDocumentor 1.4.1