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

Documentation generated on Thu, 20 Mar 2014 16:47:56 +0100 by phpDocumentor 1.4.1