Dotclear

source: plugins/themeEditor/index.php @ 1179:a43a29427ef3

Revision 1179:a43a29427ef3, 6.0 KB checked in by franck <carnet.franck.paul@…>, 12 years ago (diff)

Update copyright notice

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}
55catch (Exception $e)
56{
57     $core->error->add($e->getMessage());
58}
59?>
60
61<html>
62<head>
63  <title><?php echo __('Theme Editor'); ?></title>
64  <link rel="stylesheet" type="text/css" href="index.php?pf=themeEditor/style.css" />
65  <script type="text/javascript">
66  //<![CDATA[
67  <?php echo dcPage::jsVar('dotclear.msg.saving_document',__("Saving document...")); ?>
68  <?php echo dcPage::jsVar('dotclear.msg.document_saved',__("Document saved")); ?>
69  <?php echo dcPage::jsVar('dotclear.msg.error_occurred',__("An error occurred:")); ?>
70  <?php echo dcPage::jsVar('dotclear.colorsyntax',$user_ui_colorsyntax); ?>
71  //]]>
72  </script>
73  <script type="text/javascript" src="index.php?pf=themeEditor/script.js"></script>
74<?php if ($user_ui_colorsyntax) { ?>
75  <link rel="stylesheet" type="text/css" href="index.php?pf=themeEditor/codemirror/codemirror.css" />
76  <link rel="stylesheet" type="text/css" href="index.php?pf=themeEditor/codemirror.css" />
77  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/codemirror.js"></script>
78  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/multiplex.js"></script>
79  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/xml.js"></script>
80  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/javascript.js"></script>
81  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/css.js"></script>
82  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/php.js"></script>
83  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/htmlmixed.js"></script>
84<?php } ?>
85</head>
86
87<body>
88<?php echo '<h2>'.html::escapeHTML($core->blog->name).
89' &rsaquo; <a href="blog_theme.php">'.__('Blog appearance').'</a> &rsaquo; <span class="page-title">'.__('Theme Editor').'</span></h2>'; ?>
90
91<p><strong><?php echo sprintf(__('Your current theme on this blog is "%s".'),html::escapeHTML($T['name'])); ?></strong></p>
92
93<?php if ($core->blog->settings->system->theme == 'default') { ?>
94     <div class="error"><p><?php echo __("You can't edit default theme."); ?></p></div>
95     </body></html>
96<?php } ?>
97
98<div id="file-box">
99<div id="file-editor">
100<?php
101if ($file['c'] === null)
102{
103     echo '<p>'.__('Please select a file to edit.').'</p>';
104}
105else
106{
107     echo
108     '<form id="file-form" action="'.$p_url.'" method="post">'.
109     '<fieldset><legend>'.__('File editor').'</legend>'.
110     '<p><label for="file_content">'.sprintf(__('Editing file %s'),'<strong>'.$file['f']).'</strong></label></p>'.
111     '<p>'.form::textarea('file_content',72,25,html::escapeHTML($file['c']),'maximal','',!$file['w']).'</p>';
112     
113     if ($file['w'])
114     {
115          echo
116          '<p><input type="submit" name="write" value="'.__('Save').' (s)" accesskey="s" /> '.
117          $core->formNonce().
118          ($file['type'] ? form::hidden(array($file['type']),$file['f']) : '').
119          '</p>';
120     }
121     else
122     {
123          echo '<p>'.__('This file is not writable. Please check your theme files permissions.').'</p>';
124     }
125     
126     echo
127     '</fieldset></form>';
128
129     if ($user_ui_colorsyntax) {
130          $editorMode = 
131               (!empty($_REQUEST['css']) ? "css" :
132               (!empty($_REQUEST['js']) ? "javascript" :
133               (!empty($_REQUEST['po']) ? "text/plain" : "text/html")));
134          echo 
135          '<script>
136               window.CodeMirror.defineMode("dotclear", function(config) {
137                    return CodeMirror.multiplexingMode(
138                         CodeMirror.getMode(config, "'.$editorMode.'"),
139                         {open: "{{tpl:", close: "}}",
140                          mode: CodeMirror.getMode(config, "text/plain"),
141                          delimStyle: "delimit"},
142                         {open: "<tpl:", close: ">",
143                          mode: CodeMirror.getMode(config, "text/plain"),
144                          delimStyle: "delimit"},
145                         {open: "</tpl:", close: ">",
146                          mode: CodeMirror.getMode(config, "text/plain"),
147                          delimStyle: "delimit"}
148                         );
149               });
150          var editor = CodeMirror.fromTextArea(document.getElementById("file_content"), {
151               mode: "dotclear",
152                    tabMode: "indent",
153                    lineWrapping: "true",
154                    lineNumbers: "true",
155                    matchBrackets: "true"
156               });
157         </script>';
158     }
159}
160?>
161</div>
162</div>
163
164<div id="file-chooser">
165<h3><?php echo __('Templates files'); ?></h3>
166<?php echo $o->filesList('tpl','<a href="'.$p_url.'&amp;tpl=%2$s" class="tpl-link">%1$s</a>'); ?>
167
168<h3><?php echo __('CSS files'); ?></h3>
169<?php echo $o->filesList('css','<a href="'.$p_url.'&amp;css=%2$s" class="css-link">%1$s</a>'); ?>
170
171<h3><?php echo __('JavaScript files'); ?></h3>
172<?php echo $o->filesList('js','<a href="'.$p_url.'&amp;js=%2$s" class="js-link">%1$s</a>'); ?>
173
174<h3><?php echo __('Locales files'); ?></h3>
175<?php echo $o->filesList('po','<a href="'.$p_url.'&amp;po=%2$s" class="po-link">%1$s</a>'); ?>
176</div>
177
178<?php dcPage::helpBlock('themeEditor'); ?>
179</body>
180</html>
Note: See TracBrowser for help on using the repository browser.

Sites map