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 ----------------------------------------- |
---|
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 | |
---|
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 | |
---|
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']); |
---|
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 | catch (Exception $e) |
---|
56 | { |
---|
57 | $core->error->add($e->getMessage()); |
---|
58 | } |
---|
59 | ?> |
---|
60 | |
---|
61 | <html> |
---|
62 | <head> |
---|
63 | <title><?php echo __('Edit theme files'); ?></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 |
---|
89 | echo dcPage::breadcrumb( |
---|
90 | array( |
---|
91 | html::escapeHTML($core->blog->name) => '', |
---|
92 | __('Blog appearance') => 'blog_theme.php', |
---|
93 | '<span class="page-title">'.__('Edit theme files').'</span>' => '' |
---|
94 | )); |
---|
95 | ?> |
---|
96 | |
---|
97 | <p><strong><?php echo sprintf(__('Your current theme on this blog is "%s".'),html::escapeHTML($T['name'])); ?></strong></p> |
---|
98 | |
---|
99 | <?php if ($core->blog->settings->system->theme == 'default') { ?> |
---|
100 | <div class="error"><p><?php echo __("You can't edit default theme."); ?></p></div> |
---|
101 | </body></html> |
---|
102 | <?php } ?> |
---|
103 | |
---|
104 | <div id="file-box"> |
---|
105 | <div id="file-editor"> |
---|
106 | <?php |
---|
107 | if ($file['c'] === null) |
---|
108 | { |
---|
109 | echo '<p>'.__('Please select a file to edit.').'</p>'; |
---|
110 | } |
---|
111 | else |
---|
112 | { |
---|
113 | echo |
---|
114 | '<form id="file-form" action="'.$p_url.'" method="post">'. |
---|
115 | '<fieldset><legend>'.__('File editor').'</legend>'. |
---|
116 | '<p><label for="file_content">'.sprintf(__('Editing file %s'),'<strong>'.$file['f']).'</strong></label></p>'. |
---|
117 | '<p>'.form::textarea('file_content',72,25,html::escapeHTML($file['c']),'maximal','',!$file['w']).'</p>'; |
---|
118 | |
---|
119 | if ($file['w']) |
---|
120 | { |
---|
121 | echo |
---|
122 | '<p><input type="submit" name="write" value="'.__('Save').' (s)" accesskey="s" /> '. |
---|
123 | $core->formNonce(). |
---|
124 | ($file['type'] ? form::hidden(array($file['type']),$file['f']) : ''). |
---|
125 | '</p>'; |
---|
126 | } |
---|
127 | else |
---|
128 | { |
---|
129 | echo '<p>'.__('This file is not writable. Please check your theme files permissions.').'</p>'; |
---|
130 | } |
---|
131 | |
---|
132 | echo |
---|
133 | '</fieldset></form>'; |
---|
134 | |
---|
135 | if ($user_ui_colorsyntax) { |
---|
136 | $editorMode = |
---|
137 | (!empty($_REQUEST['css']) ? "css" : |
---|
138 | (!empty($_REQUEST['js']) ? "javascript" : |
---|
139 | (!empty($_REQUEST['po']) ? "text/plain" : "text/html"))); |
---|
140 | echo |
---|
141 | '<script> |
---|
142 | window.CodeMirror.defineMode("dotclear", function(config) { |
---|
143 | return CodeMirror.multiplexingMode( |
---|
144 | CodeMirror.getMode(config, "'.$editorMode.'"), |
---|
145 | {open: "{{tpl:", close: "}}", |
---|
146 | mode: CodeMirror.getMode(config, "text/plain"), |
---|
147 | delimStyle: "delimit"}, |
---|
148 | {open: "<tpl:", close: ">", |
---|
149 | mode: CodeMirror.getMode(config, "text/plain"), |
---|
150 | delimStyle: "delimit"}, |
---|
151 | {open: "</tpl:", close: ">", |
---|
152 | mode: CodeMirror.getMode(config, "text/plain"), |
---|
153 | delimStyle: "delimit"} |
---|
154 | ); |
---|
155 | }); |
---|
156 | var editor = CodeMirror.fromTextArea(document.getElementById("file_content"), { |
---|
157 | mode: "dotclear", |
---|
158 | tabMode: "indent", |
---|
159 | lineWrapping: "true", |
---|
160 | lineNumbers: "true", |
---|
161 | matchBrackets: "true" |
---|
162 | }); |
---|
163 | </script>'; |
---|
164 | } |
---|
165 | } |
---|
166 | ?> |
---|
167 | </div> |
---|
168 | </div> |
---|
169 | |
---|
170 | <div id="file-chooser"> |
---|
171 | <h3><?php echo __('Templates files'); ?></h3> |
---|
172 | <?php echo $o->filesList('tpl','<a href="'.$p_url.'&tpl=%2$s" class="tpl-link">%1$s</a>'); ?> |
---|
173 | |
---|
174 | <h3><?php echo __('CSS files'); ?></h3> |
---|
175 | <?php echo $o->filesList('css','<a href="'.$p_url.'&css=%2$s" class="css-link">%1$s</a>'); ?> |
---|
176 | |
---|
177 | <h3><?php echo __('JavaScript files'); ?></h3> |
---|
178 | <?php echo $o->filesList('js','<a href="'.$p_url.'&js=%2$s" class="js-link">%1$s</a>'); ?> |
---|
179 | |
---|
180 | <h3><?php echo __('Locales files'); ?></h3> |
---|
181 | <?php echo $o->filesList('po','<a href="'.$p_url.'&po=%2$s" class="po-link">%1$s</a>'); ?> |
---|
182 | </div> |
---|
183 | |
---|
184 | <?php dcPage::helpBlock('themeEditor'); ?> |
---|
185 | </body> |
---|
186 | </html> |
---|