20 include dirname( dirname( dirname( __FILE__ ) ) ) .
'/header.php';
22 if (!defined(
'XOOPS_ROOT_PATH')) { die(
'Error'); }
29 if ( file_exists(
"./../../language/".
$xoopsConfig[
'language'].
"/admin/tplsets.php") ) {
30 include_once(
"./../../language/".
$xoopsConfig[
'language'].
"/admin/tplsets.php");
32 include_once(
"./../../language/english/admin/tplsets.php");
45 case "tpls_display_folder":
48 if( file_exists($root .
$_REQUEST[
'dir']) ) {
49 $files = scandir($root . $_REQUEST[
'dir']);
51 if( count($files) > 2 ) {
52 echo
"<ul class=\"jqueryFileTree\" style=\"display: none;\">";
54 foreach( $files as
$file ) {
56 if( file_exists($root . $_REQUEST[
'dir'] . $file) && $file !=
'.' && $file !=
'..' && is_dir($root . $_REQUEST[
'dir'] . $file) ) {
58 $file_no_valid = array(
'.svn',
'icons',
'img',
'images',
'language');
60 if(!in_array($file, $file_no_valid))
62 echo
"<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . htmlentities($_REQUEST[
'dir'] . $file) .
"/\">" . htmlentities($file) .
"</a></li>";
67 foreach( $files as $file )
69 if( file_exists($root . $_REQUEST[
'dir'] . $file) && $file !=
'.' && $file !=
'..' && !is_dir($root . $_REQUEST[
'dir'] . $file) && $file !=
'index.html' ) {
70 $ext = preg_replace(
'/^.*\./',
'', $file);
72 $extensions = array(
'.html',
'.htm',
'.css');
73 $extension_verif = strrchr($file,
'.');
75 if(in_array($extension_verif, $extensions)) {
76 echo
"<li class=\"file ext_$ext\"><a href=\"#\" onclick=\"tpls_edit_file('".htmlentities($_REQUEST[
'dir'].$file).
"', '".htmlentities($_REQUEST[
'dir']).
"', '".htmlentities($file).
"', '".
$ext.
"');\" rel=\"tpls_edit_file('".htmlentities($_REQUEST[
'dir'].$file).
"', '".htmlentities($_REQUEST[
'dir']).
"', '".htmlentities($file).
"', '".
$ext.
"');\">" . htmlentities($file) .
"</a></li>";
88 case 'tpls_edit_file':
89 $path_file = realpath(XOOPS_ROOT_PATH.
'/themes'.trim($_REQUEST[
'path_file']));
90 $path_file = str_replace(
'\\',
'/',$path_file);
93 if(file_exists($path_file.
'.back')){
94 $restore =
'<button class="ui-corner-all tooltip" type="button" onclick="tpls_restore(\''.$path_file.
'\')
" value="'._AM_SYSTEM_TEMPLATES_RESTORE.'" title="'._AM_SYSTEM_TEMPLATES_RESTORE.'">
95 <img src="'.system_AdminIcons('revert.png
').'" alt="'._AM_SYSTEM_TEMPLATES_RESTORE.'" />
100 xoops_load('XoopsFile');
101 XoopsFile::load('file');
103 $file = XoopsFile::getHandler('file', $path_file);
104 $content = $file->read();
105 if(empty($content)) {
106 echo _AM_SYSTEM_TEMPLATES_EMPTY_FILE;
108 $ext = preg_replace('/^.*\./', '', $_REQUEST['path_file']);
110 echo '<form name="back
" action="admin.php?fct=tplsets&op=tpls_save
" method="POST
">
114 <div class="xo-btn-actions
">
115 <div class="xo-buttons
">
116 <button class="ui-corner-all tooltip
" type="submit
" value="'._AM_SYSTEM_TEMPLATES_SAVE.'" title="'._AM_SYSTEM_TEMPLATES_SAVE.'">
117 <img src="'.system_AdminIcons('save.png
').'" alt="'._AM_SYSTEM_TEMPLATES_SAVE.'" />
120 <button class="ui-corner-all tooltip
" type="button
" onclick="$(\
'#display_contenu\').hide();$(\'#display_form\').fadeIn(\'fast\');" title="'._AM_SYSTEM_TEMPLATES_CANCEL.
'">
123 <div class="clear"></div>
129 <td><textarea id="code_mirror" name="templates" rows=24 cols=110>'.
$content.
'</textarea></td>
132 echo
'<input type="hidden" name="path_file" value="'.$path_file.
'"><input type="hidden" name="file" value="'.trim($_REQUEST[
'file']).
'"><input type="hidden" name="ext" value="'.
$ext.
'"></form>';
137 $extensions = array(
'.html',
'.htm',
'.css');
140 $valid_dir = stristr(realpath($_REQUEST[
'path_file']), realpath(XOOPS_ROOT_PATH .
'/themes'));
142 $old_file = $_REQUEST[
'path_file'].
'.back';
143 $new_file = $_REQUEST[
'path_file'];
145 $extension_verif = strrchr($new_file,
'.');
146 if($valid_dir && in_array($extension_verif, $extensions) && file_exists($old_file) && file_exists($new_file) )
148 if(unlink($new_file))
150 if(rename($old_file, $new_file))