Dotclear

source: plugins/themeEditor/index.php @ 2744:6bdf43663468

Revision 2744:6bdf43663468, 6.5 KB checked in by franck <carnet.franck.paul@…>, 11 years ago (diff)

Typo in message, fixes #1947

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
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 -----------------------------------------
12if (!defined('DC_CONTEXT_ADMIN')) { return; }
13
14require dirname(__FILE__).'/class.themeEditor.php';
15
16$file_default = $file = array('c'=>null, 'w'=>false, 'type'=>null, 'f'=>null, 'default_file'=>false);
17
18# Get interface setting
19$core->auth->user_prefs->addWorkspace('interface');
20$user_ui_colorsyntax = $core->auth->user_prefs->interface->colorsyntax;
21
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
28try
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']);
38          } elseif (!empty($_REQUEST['po'])) {
39               $file = $o->getFileContent('po',$_REQUEST['po']);
40          }
41     }
42     catch (Exception $e)
43     {
44          $file = $file_default;
45          throw $e;
46     }
47
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     }
54
55     # Delete file
56     if (!empty($_POST['delete']))
57     {
58          $o->deleteFile($file['type'],$file['f']);
59          dcPage::addSuccessNotice(__('The file has been reset.'));
60          http::redirect($p_url.'&'.$file['type'].'='.$file['f']);
61     }
62}
63catch (Exception $e)
64{
65     $core->error->add($e->getMessage());
66}
67?>
68
69<html>
70<head>
71  <title><?php echo __('Edit theme files'); ?></title>
72  <link rel="stylesheet" type="text/css" href="index.php?pf=themeEditor/style.css" />
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:")); ?>
78  <?php echo dcPage::jsVar('dotclear.msg.confirm_reset_file',__("Are you sure you want to reset this file?")); ?>
79  <?php echo dcPage::jsVar('dotclear.colorsyntax',$user_ui_colorsyntax); ?>
80  //]]>
81  </script>
82  <script type="text/javascript" src="index.php?pf=themeEditor/script.js"></script>
83<?php if ($user_ui_colorsyntax) { ?>
84  <link rel="stylesheet" type="text/css" href="index.php?pf=themeEditor/codemirror/codemirror.css" />
85  <link rel="stylesheet" type="text/css" href="index.php?pf=themeEditor/codemirror.css" />
86  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/codemirror.js"></script>
87  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/multiplex.js"></script>
88  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/xml.js"></script>
89  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/javascript.js"></script>
90  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/css.js"></script>
91  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/php.js"></script>
92  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/htmlmixed.js"></script>
93<?php } ?>
94</head>
95
96<body>
97<?php
98echo dcPage::breadcrumb(
99     array(
100          html::escapeHTML($core->blog->name) => '',
101          __('Blog appearance') => 'blog_theme.php',
102          __('Edit theme files') => ''
103     )).
104     dcPage::notices();
105?>
106
107<p><strong><?php echo sprintf(__('Your current theme on this blog is "%s".'),html::escapeHTML($T['name'])); ?></strong></p>
108
109<?php if ($core->blog->settings->system->theme == 'default') { ?>
110     <div class="error"><p><?php echo __("You can't edit default theme."); ?></p></div>
111     </body></html>
112<?php } ?>
113
114<div id="file-box">
115<div id="file-editor">
116<?php
117if ($file['c'] === null)
118{
119     echo '<p>'.__('Please select a file to edit.').'</p>';
120}
121else
122{
123     echo
124     '<form id="file-form" action="'.$p_url.'" method="post">'.
125     '<fieldset><legend>'.__('File editor').'</legend>'.
126     '<p><label for="file_content">'.sprintf(__('Editing file %s'),'<strong>'.$file['f']).'</strong></label></p>'.
127     '<p>'.form::textarea('file_content',72,25,html::escapeHTML($file['c']),'maximal','',!$file['w']).'</p>';
128
129     if ($file['w'])
130     {
131          echo
132          '<p><input type="submit" name="write" value="'.__('Save').' (s)" accesskey="s" /> '.
133          ($o->deletableFile($file['type'],$file['f']) ? '<input type="submit" name="delete" class="delete" value="'.__('Reset').'" />' : '').
134          $core->formNonce().
135          ($file['type'] ? form::hidden(array($file['type']),$file['f']) : '').
136          '</p>';
137     }
138     else
139     {
140          echo '<p>'.__('This file is not writable. Please check your theme files permissions.').'</p>';
141     }
142
143     echo
144     '</fieldset></form>';
145
146     if ($user_ui_colorsyntax) {
147          $editorMode =
148               (!empty($_REQUEST['css']) ? "css" :
149               (!empty($_REQUEST['js']) ? "javascript" :
150               (!empty($_REQUEST['po']) ? "text/plain" : "text/html")));
151          echo
152          '<script>
153               window.CodeMirror.defineMode("dotclear", function(config) {
154                    return CodeMirror.multiplexingMode(
155                         CodeMirror.getMode(config, "'.$editorMode.'"),
156                         {open: "{{tpl:", close: "}}",
157                          mode: CodeMirror.getMode(config, "text/plain"),
158                          delimStyle: "delimit"},
159                         {open: "<tpl:", close: ">",
160                          mode: CodeMirror.getMode(config, "text/plain"),
161                          delimStyle: "delimit"},
162                         {open: "</tpl:", close: ">",
163                          mode: CodeMirror.getMode(config, "text/plain"),
164                          delimStyle: "delimit"}
165                         );
166               });
167          var editor = CodeMirror.fromTextArea(document.getElementById("file_content"), {
168               mode: "dotclear",
169                    tabMode: "indent",
170                    lineWrapping: "true",
171                    lineNumbers: "true",
172                    matchBrackets: "true"
173               });
174         </script>';
175     }
176}
177?>
178</div>
179</div>
180
181<div id="file-chooser">
182<h3><?php echo __('Templates files'); ?></h3>
183<?php echo $o->filesList('tpl','<a href="'.$p_url.'&amp;tpl=%2$s" class="tpl-link">%1$s</a>'); ?>
184
185<h3><?php echo __('CSS files'); ?></h3>
186<?php echo $o->filesList('css','<a href="'.$p_url.'&amp;css=%2$s" class="css-link">%1$s</a>'); ?>
187
188<h3><?php echo __('JavaScript files'); ?></h3>
189<?php echo $o->filesList('js','<a href="'.$p_url.'&amp;js=%2$s" class="js-link">%1$s</a>'); ?>
190
191<h3><?php echo __('Locales files'); ?></h3>
192<?php echo $o->filesList('po','<a href="'.$p_url.'&amp;po=%2$s" class="po-link">%1$s</a>'); ?>
193</div>
194
195<?php dcPage::helpBlock('themeEditor'); ?>
196</body>
197</html>
Note: See TracBrowser for help on using the repository browser.

Sites map