1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
<?php
# -- BEGIN LICENSE BLOCK ---------------------------------------
#
# This file is part of Dotclear 2.
#
# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK -----------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { return; }
require dirname(__FILE__).'/class.themeEditor.php';
$file_default = $file = array('c'=>null, 'w'=>false, 'type'=>null, 'f'=>null, 'default_file'=>false);
# Get interface setting
$core->auth->user_prefs->addWorkspace('interface');
$user_ui_colorsyntax = $core->auth->user_prefs->interface->colorsyntax;
# Loading themes
$core->themes = new dcThemes($core);
$core->themes->loadModules($core->blog->themes_path,null);
$T = $core->themes->getModules($core->blog->settings->system->theme);
$o = new dcThemeEditor($core);
try
{
try
{
if (!empty($_REQUEST['tpl'])) {
$file = $o->getFileContent('tpl',$_REQUEST['tpl']);
} elseif (!empty($_REQUEST['css'])) {
$file = $o->getFileContent('css',$_REQUEST['css']);
} elseif (!empty($_REQUEST['js'])) {
$file = $o->getFileContent('js',$_REQUEST['js']);
} elseif (!empty($_REQUEST['po'])) {
$file = $o->getFileContent('po',$_REQUEST['po']);
}
}
catch (Exception $e)
{
$file = $file_default;
throw $e;
}
# Write file
if (!empty($_POST['write']))
{
$file['c'] = $_POST['file_content'];
$o->writeFile($file['type'],$file['f'],$file['c']);
}
}
catch (Exception $e)
{
$core->error->add($e->getMessage());
}
?>
<html>
<head>
<title><?php echo __('Edit theme files'); ?></title>
<link rel="stylesheet" type="text/css" href="index.php?pf=themeEditor/style.css" />
<script type="text/javascript">
//<![CDATA[
<?php echo dcPage::jsVar('dotclear.msg.saving_document',__("Saving document...")); ?>
<?php echo dcPage::jsVar('dotclear.msg.document_saved',__("Document saved")); ?>
<?php echo dcPage::jsVar('dotclear.msg.error_occurred',__("An error occurred:")); ?>
<?php echo dcPage::jsVar('dotclear.colorsyntax',$user_ui_colorsyntax); ?>
//]]>
</script>
<script type="text/javascript" src="index.php?pf=themeEditor/script.js"></script>
<?php if ($user_ui_colorsyntax) { ?>
<link rel="stylesheet" type="text/css" href="index.php?pf=themeEditor/codemirror/codemirror.css" />
<link rel="stylesheet" type="text/css" href="index.php?pf=themeEditor/codemirror.css" />
<script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/codemirror.js"></script>
<script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/multiplex.js"></script>
<script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/xml.js"></script>
<script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/javascript.js"></script>
<script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/css.js"></script>
<script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/php.js"></script>
<script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/htmlmixed.js"></script>
<?php } ?>
</head>
<body>
<?php
echo dcPage::breadcrumb(
array(
html::escapeHTML($core->blog->name) => '',
__('Blog appearance') => 'blog_theme.php',
__('Edit theme files') => ''
)).
dcPage::notices();
?>
<p><strong><?php echo sprintf(__('Your current theme on this blog is "%s".'),html::escapeHTML($T['name'])); ?></strong></p>
<?php if ($core->blog->settings->system->theme == 'default') { ?>
<div class="error"><p><?php echo __("You can't edit default theme."); ?></p></div>
</body></html>
<?php } ?>
<div id="file-box">
<div id="file-editor">
<?php
if ($file['c'] === null)
{
echo '<p>'.__('Please select a file to edit.').'</p>';
}
else
{
echo
'<form id="file-form" action="'.$p_url.'" method="post">'.
'<fieldset><legend>'.__('File editor').'</legend>'.
'<p><label for="file_content">'.sprintf(__('Editing file %s'),'<strong>'.$file['f']).'</strong></label></p>'.
'<p>'.form::textarea('file_content',72,25,html::escapeHTML($file['c']),'maximal','',!$file['w']).'</p>';
if ($file['w'])
{
echo
'<p><input type="submit" name="write" value="'.__('Save').' (s)" accesskey="s" /> '.
$core->formNonce().
($file['type'] ? form::hidden(array($file['type']),$file['f']) : '').
'</p>';
}
else
{
echo '<p>'.__('This file is not writable. Please check your theme files permissions.').'</p>';
}
echo
'</fieldset></form>';
if ($user_ui_colorsyntax) {
$editorMode =
(!empty($_REQUEST['css']) ? "css" :
(!empty($_REQUEST['js']) ? "javascript" :
(!empty($_REQUEST['po']) ? "text/plain" : "text/html")));
echo
'<script>
window.CodeMirror.defineMode("dotclear", function(config) {
return CodeMirror.multiplexingMode(
CodeMirror.getMode(config, "'.$editorMode.'"),
{open: "{{tpl:", close: "}}",
mode: CodeMirror.getMode(config, "text/plain"),
delimStyle: "delimit"},
{open: "<tpl:", close: ">",
mode: CodeMirror.getMode(config, "text/plain"),
delimStyle: "delimit"},
{open: "</tpl:", close: ">",
mode: CodeMirror.getMode(config, "text/plain"),
delimStyle: "delimit"}
);
});
var editor = CodeMirror.fromTextArea(document.getElementById("file_content"), {
mode: "dotclear",
tabMode: "indent",
lineWrapping: "true",
lineNumbers: "true",
matchBrackets: "true"
});
</script>';
}
}
?>
</div>
</div>
<div id="file-chooser">
<h3><?php echo __('Templates files'); ?></h3>
<?php echo $o->filesList('tpl','<a href="'.$p_url.'&tpl=%2$s" class="tpl-link">%1$s</a>'); ?>
<h3><?php echo __('CSS files'); ?></h3>
<?php echo $o->filesList('css','<a href="'.$p_url.'&css=%2$s" class="css-link">%1$s</a>'); ?>
<h3><?php echo __('JavaScript files'); ?></h3>
<?php echo $o->filesList('js','<a href="'.$p_url.'&js=%2$s" class="js-link">%1$s</a>'); ?>
<h3><?php echo __('Locales files'); ?></h3>
<?php echo $o->filesList('po','<a href="'.$p_url.'&po=%2$s" class="po-link">%1$s</a>'); ?>
</div>
<?php dcPage::helpBlock('themeEditor'); ?>
</body>
</html>
|