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