Changeset 3709:c88e69474c34 for plugins/themeEditor/index.php
- Timestamp:
- 02/18/18 18:16:29 (8 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/themeEditor/index.php
r3421 r3709 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 13 14 require dirname(__FILE__) .'/class.themeEditor.php';14 require dirname(__FILE__) . '/class.themeEditor.php'; 15 15 16 $file_default = $file = array('c' =>null, 'w'=>false, 'type'=>null, 'f'=>null, 'default_file'=>false);16 $file_default = $file = array('c' => null, 'w' => false, 'type' => null, 'f' => null, 'default_file' => false); 17 17 18 18 # Get interface setting 19 19 $core->auth->user_prefs->addWorkspace('interface'); 20 $user_ui_colorsyntax = $core->auth->user_prefs->interface->colorsyntax;20 $user_ui_colorsyntax = $core->auth->user_prefs->interface->colorsyntax; 21 21 $user_ui_colorsyntax_theme = $core->auth->user_prefs->interface->colorsyntax_theme; 22 22 23 23 # Loading themes 24 24 $core->themes = new dcThemes($core); 25 $core->themes->loadModules($core->blog->themes_path, null);25 $core->themes->loadModules($core->blog->themes_path, null); 26 26 $T = $core->themes->getModules($core->blog->settings->system->theme); 27 27 $o = new dcThemeEditor($core); … … 29 29 try 30 30 { 31 try 32 { 33 if (!empty($_REQUEST['tpl'])) { 34 $file = $o->getFileContent('tpl',$_REQUEST['tpl']); 35 } elseif (!empty($_REQUEST['css'])) { 36 $file = $o->getFileContent('css',$_REQUEST['css']); 37 } elseif (!empty($_REQUEST['js'])) { 38 $file = $o->getFileContent('js',$_REQUEST['js']); 39 } elseif (!empty($_REQUEST['po'])) { 40 $file = $o->getFileContent('po',$_REQUEST['po']); 41 } 42 } 43 catch (Exception $e) 44 { 45 $file = $file_default; 46 throw $e; 47 } 31 try 32 { 33 if (!empty($_REQUEST['tpl'])) { 34 $file = $o->getFileContent('tpl', $_REQUEST['tpl']); 35 } elseif (!empty($_REQUEST['css'])) { 36 $file = $o->getFileContent('css', $_REQUEST['css']); 37 } elseif (!empty($_REQUEST['js'])) { 38 $file = $o->getFileContent('js', $_REQUEST['js']); 39 } elseif (!empty($_REQUEST['po'])) { 40 $file = $o->getFileContent('po', $_REQUEST['po']); 41 } 42 } catch (Exception $e) { 43 $file = $file_default; 44 throw $e; 45 } 48 46 49 # Write file 50 if (!empty($_POST['write'])) 51 { 52 $file['c'] = $_POST['file_content']; 53 $o->writeFile($file['type'],$file['f'],$file['c']); 54 } 47 # Write file 48 if (!empty($_POST['write'])) { 49 $file['c'] = $_POST['file_content']; 50 $o->writeFile($file['type'], $file['f'], $file['c']); 51 } 55 52 56 # Delete file 57 if (!empty($_POST['delete'])) 58 { 59 $o->deleteFile($file['type'],$file['f']); 60 dcPage::addSuccessNotice(__('The file has been reset.')); 61 http::redirect($p_url.'&'.$file['type'].'='.$file['f']); 62 } 63 } 64 catch (Exception $e) 65 { 66 $core->error->add($e->getMessage()); 53 # Delete file 54 if (!empty($_POST['delete'])) { 55 $o->deleteFile($file['type'], $file['f']); 56 dcPage::addSuccessNotice(__('The file has been reset.')); 57 http::redirect($p_url . '&' . $file['type'] . '=' . $file['f']); 58 } 59 } catch (Exception $e) { 60 $core->error->add($e->getMessage()); 67 61 } 68 62 ?> … … 70 64 <html> 71 65 <head> 72 <title><?php echo __('Edit theme files'); ?></title> 73 <script type="text/javascript"> 74 <?php echo dcPage::jsVar('dotclear.msg.saving_document',__("Saving document...")); ?> 75 <?php echo dcPage::jsVar('dotclear.msg.document_saved',__("Document saved")); ?> 76 <?php echo dcPage::jsVar('dotclear.msg.error_occurred',__("An error occurred:")); ?> 77 <?php echo dcPage::jsVar('dotclear.msg.confirm_reset_file',__("Are you sure you want to reset this file?")); ?> 78 <?php echo dcPage::jsVar('dotclear.colorsyntax',$user_ui_colorsyntax); ?> 79 </script> 80 <?php echo dcPage::jsConfirmClose('file-form'); ?> 81 <script type="text/javascript" src="<?php echo dcPage::getPF('themeEditor/script.js'); ?>"></script> 82 <?php if ($user_ui_colorsyntax) { ?> 83 <?php echo dcPage::jsLoadCodeMirror($user_ui_colorsyntax_theme); ?> 84 <?php } ?> 85 <?php echo dcPage::cssLoad(dcPage::getPF('themeEditor/style.css'));?> 66 <title><?php echo __('Edit theme files'); ?></title> 67 <?php 68 echo dcPage::jsVars(array( 69 'dotclear.msg.saving_document' => __("Saving document..."), 70 'dotclear.msg.document_saved' => __("Document saved"), 71 'dotclear.msg.error_occurred' => __("An error occurred:"), 72 'dotclear.msg.confirm_reset_file' => __("Are you sure you want to reset this file?"), 73 'dotclear.colorsyntax' => $user_ui_colorsyntax 74 )) . 75 dcPage::jsConfirmClose('file-form') . 76 dcPage::jsLoad(dcPage::getPF('themeEditor/js/script.js')); 77 if ($user_ui_colorsyntax) { 78 echo dcPage::jsLoadCodeMirror($user_ui_colorsyntax_theme); 79 } 80 echo dcPage::cssLoad(dcPage::getPF('themeEditor/style.css')); 81 ?> 86 82 </head> 87 83 … … 89 85 <?php 90 86 echo dcPage::breadcrumb( 91 92 93 __('Blog appearance')=> $core->adminurl->get('admin.blog.theme'),94 __('Edit theme files')=> ''95 )).96 87 array( 88 html::escapeHTML($core->blog->name) => '', 89 __('Blog appearance') => $core->adminurl->get('admin.blog.theme'), 90 __('Edit theme files') => '' 91 )) . 92 dcPage::notices(); 97 93 ?> 98 94 99 <p><strong><?php echo sprintf(__('Your current theme on this blog is "%s".'), html::escapeHTML($T['name'])); ?></strong></p>95 <p><strong><?php echo sprintf(__('Your current theme on this blog is "%s".'), html::escapeHTML($T['name'])); ?></strong></p> 100 96 101 <?php if ($core->blog->settings->system->theme == 'default') { 102 103 104 <?php } 97 <?php if ($core->blog->settings->system->theme == 'default') {?> 98 <div class="error"><p><?php echo __("You can't edit default theme."); ?></p></div> 99 </body></html> 100 <?php }?> 105 101 106 102 <div id="file-box"> 107 103 <div id="file-editor"> 108 104 <?php 109 if ($file['c'] === null) 110 { 111 echo '<p>'.__('Please select a file to edit.').'</p>'; 112 } 113 else 114 { 115 echo 116 '<form id="file-form" action="'.$p_url.'" method="post">'. 117 '<div class="fieldset"><h3>'.__('File editor').'</h3>'. 118 '<p><label for="file_content">'.sprintf(__('Editing file %s'),'<strong>'.$file['f']).'</strong></label></p>'. 119 '<p>'.form::textarea('file_content',72,25,html::escapeHTML($file['c']),'maximal','',!$file['w']).'</p>'; 105 if ($file['c'] === null) { 106 echo '<p>' . __('Please select a file to edit.') . '</p>'; 107 } else { 108 echo 109 '<form id="file-form" action="' . $p_url . '" method="post">' . 110 '<div class="fieldset"><h3>' . __('File editor') . '</h3>' . 111 '<p><label for="file_content">' . sprintf(__('Editing file %s'), '<strong>' . $file['f']) . '</strong></label></p>' . 112 '<p>' . form::textarea('file_content', 72, 25, html::escapeHTML($file['c']), 'maximal', '', !$file['w']) . '</p>'; 120 113 121 if ($file['w']) 122 { 123 echo 124 '<p><input type="submit" name="write" value="'.__('Save').' (s)" accesskey="s" /> '. 125 ($o->deletableFile($file['type'],$file['f']) ? '<input type="submit" name="delete" class="delete" value="'.__('Reset').'" />' : ''). 126 $core->formNonce(). 127 ($file['type'] ? form::hidden(array($file['type']),$file['f']) : ''). 128 '</p>'; 129 } 130 else 131 { 132 echo '<p>'.__('This file is not writable. Please check your theme files permissions.').'</p>'; 133 } 114 if ($file['w']) { 115 echo 116 '<p><input type="submit" name="write" value="' . __('Save') . ' (s)" accesskey="s" /> ' . 117 ($o->deletableFile($file['type'], $file['f']) ? '<input type="submit" name="delete" class="delete" value="' . __('Reset') . '" />' : '') . 118 $core->formNonce() . 119 ($file['type'] ? form::hidden(array($file['type']), $file['f']) : '') . 120 '</p>'; 121 } else { 122 echo '<p>' . __('This file is not writable. Please check your theme files permissions.') . '</p>'; 123 } 134 124 135 136 125 echo 126 '</div></form>'; 137 127 138 139 140 141 142 143 144 145 146 147 CodeMirror.getMode(config, "'.$editorMode.'"),148 149 150 151 152 153 154 155 156 157 158 159 160 echo dcPage::jsRunCodeMirror('editor','file_content','dotclear',$user_ui_colorsyntax_theme);161 128 if ($user_ui_colorsyntax) { 129 $editorMode = 130 (!empty($_REQUEST['css']) ? "css" : 131 (!empty($_REQUEST['js']) ? "javascript" : 132 (!empty($_REQUEST['po']) ? "text/plain" : "text/html"))); 133 echo 134 '<script type="text/javascript"> 135 window.CodeMirror.defineMode("dotclear", function(config) { 136 return CodeMirror.multiplexingMode( 137 CodeMirror.getMode(config, "' . $editorMode . '"), 138 {open: "{{tpl:", close: "}}", 139 mode: CodeMirror.getMode(config, "text/plain"), 140 delimStyle: "delimit"}, 141 {open: "<tpl:", close: ">", 142 mode: CodeMirror.getMode(config, "text/plain"), 143 delimStyle: "delimit"}, 144 {open: "</tpl:", close: ">", 145 mode: CodeMirror.getMode(config, "text/plain"), 146 delimStyle: "delimit"} 147 ); 148 }); 149 </script>'; 150 echo dcPage::jsRunCodeMirror('editor', 'file_content', 'dotclear', $user_ui_colorsyntax_theme); 151 } 162 152 } 163 153 ?> … … 167 157 <div id="file-chooser"> 168 158 <h3><?php echo __('Templates files'); ?></h3> 169 <?php echo $o->filesList('tpl', '<a href="'.$p_url.'&tpl=%2$s" class="tpl-link">%1$s</a>'); ?>159 <?php echo $o->filesList('tpl', '<a href="' . $p_url . '&tpl=%2$s" class="tpl-link">%1$s</a>'); ?> 170 160 171 161 <h3><?php echo __('CSS files'); ?></h3> 172 <?php echo $o->filesList('css', '<a href="'.$p_url.'&css=%2$s" class="css-link">%1$s</a>'); ?>162 <?php echo $o->filesList('css', '<a href="' . $p_url . '&css=%2$s" class="css-link">%1$s</a>'); ?> 173 163 174 164 <h3><?php echo __('JavaScript files'); ?></h3> 175 <?php echo $o->filesList('js', '<a href="'.$p_url.'&js=%2$s" class="js-link">%1$s</a>'); ?>165 <?php echo $o->filesList('js', '<a href="' . $p_url . '&js=%2$s" class="js-link">%1$s</a>'); ?> 176 166 177 167 <h3><?php echo __('Locales files'); ?></h3> 178 <?php echo $o->filesList('po', '<a href="'.$p_url.'&po=%2$s" class="po-link">%1$s</a>'); ?>168 <?php echo $o->filesList('po', '<a href="' . $p_url . '&po=%2$s" class="po-link">%1$s</a>'); ?> 179 169 </div> 180 170 181 <?php dcPage::helpBlock('themeEditor'); 171 <?php dcPage::helpBlock('themeEditor');?> 182 172 </body> 183 173 </html>
Note: See TracChangeset
for help on using the changeset viewer.