| [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; | 
|---|
| [3251] | 21 | $user_ui_colorsyntax_theme = $core->auth->user_prefs->interface->colorsyntax_theme; | 
|---|
| [948] | 22 |  | 
|---|
| [0] | 23 | # Loading themes | 
|---|
 | 24 | $core->themes = new dcThemes($core); | 
|---|
 | 25 | $core->themes->loadModules($core->blog->themes_path,null); | 
|---|
 | 26 | $T = $core->themes->getModules($core->blog->settings->system->theme); | 
|---|
 | 27 | $o = new dcThemeEditor($core); | 
|---|
 | 28 |  | 
|---|
 | 29 | try | 
|---|
 | 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']); | 
|---|
| [1036] | 39 |           } elseif (!empty($_REQUEST['po'])) { | 
|---|
 | 40 |                $file = $o->getFileContent('po',$_REQUEST['po']); | 
|---|
| [0] | 41 |           } | 
|---|
 | 42 |      } | 
|---|
 | 43 |      catch (Exception $e) | 
|---|
 | 44 |      { | 
|---|
 | 45 |           $file = $file_default; | 
|---|
 | 46 |           throw $e; | 
|---|
 | 47 |      } | 
|---|
| [2566] | 48 |  | 
|---|
| [0] | 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 |      } | 
|---|
| [2663] | 55 |  | 
|---|
 | 56 |      # Delete file | 
|---|
 | 57 |      if (!empty($_POST['delete'])) | 
|---|
 | 58 |      { | 
|---|
 | 59 |           $o->deleteFile($file['type'],$file['f']); | 
|---|
| [2744] | 60 |           dcPage::addSuccessNotice(__('The file has been reset.')); | 
|---|
| [2663] | 61 |           http::redirect($p_url.'&'.$file['type'].'='.$file['f']); | 
|---|
 | 62 |      } | 
|---|
| [0] | 63 | } | 
|---|
 | 64 | catch (Exception $e) | 
|---|
 | 65 | { | 
|---|
 | 66 |      $core->error->add($e->getMessage()); | 
|---|
 | 67 | } | 
|---|
 | 68 | ?> | 
|---|
 | 69 |  | 
|---|
 | 70 | <html> | 
|---|
 | 71 | <head> | 
|---|
| [3253] | 72 |      <title><?php echo __('Edit theme files'); ?></title> | 
|---|
 | 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 |      <?php echo dcPage::jsConfirmClose('file-form'); ?> | 
|---|
 | 83 |      <script type="text/javascript" src="<?php echo dcPage::getPF('themeEditor/script.js'); ?>"></script> | 
|---|
 | 84 |      <?php if ($user_ui_colorsyntax) { ?> | 
|---|
| [3256] | 85 |      <?php echo dcPage::jsLoadCodeMirror($user_ui_colorsyntax_theme); ?> | 
|---|
| [3253] | 86 |      <?php } ?> | 
|---|
 | 87 |      <?php echo dcPage::cssLoad(dcPage::getPF('themeEditor/style.css'));?> | 
|---|
| [0] | 88 | </head> | 
|---|
 | 89 |  | 
|---|
 | 90 | <body> | 
|---|
| [1339] | 91 | <?php | 
|---|
| [1358] | 92 | echo dcPage::breadcrumb( | 
|---|
| [1339] | 93 |      array( | 
|---|
 | 94 |           html::escapeHTML($core->blog->name) => '', | 
|---|
| [2815] | 95 |           __('Blog appearance') => $core->adminurl->get('admin.blog.theme'), | 
|---|
| [2166] | 96 |           __('Edit theme files') => '' | 
|---|
| [2256] | 97 |      )). | 
|---|
 | 98 |      dcPage::notices(); | 
|---|
| [1339] | 99 | ?> | 
|---|
| [0] | 100 |  | 
|---|
 | 101 | <p><strong><?php echo sprintf(__('Your current theme on this blog is "%s".'),html::escapeHTML($T['name'])); ?></strong></p> | 
|---|
 | 102 |  | 
|---|
 | 103 | <?php if ($core->blog->settings->system->theme == 'default') { ?> | 
|---|
 | 104 |      <div class="error"><p><?php echo __("You can't edit default theme."); ?></p></div> | 
|---|
 | 105 |      </body></html> | 
|---|
 | 106 | <?php } ?> | 
|---|
 | 107 |  | 
|---|
 | 108 | <div id="file-box"> | 
|---|
 | 109 | <div id="file-editor"> | 
|---|
 | 110 | <?php | 
|---|
 | 111 | if ($file['c'] === null) | 
|---|
 | 112 | { | 
|---|
 | 113 |      echo '<p>'.__('Please select a file to edit.').'</p>'; | 
|---|
 | 114 | } | 
|---|
 | 115 | else | 
|---|
 | 116 | { | 
|---|
 | 117 |      echo | 
|---|
 | 118 |      '<form id="file-form" action="'.$p_url.'" method="post">'. | 
|---|
| [3363] | 119 |      '<div class="fieldset"><h3>'.__('File editor').'</h3>'. | 
|---|
| [100] | 120 |      '<p><label for="file_content">'.sprintf(__('Editing file %s'),'<strong>'.$file['f']).'</strong></label></p>'. | 
|---|
| [0] | 121 |      '<p>'.form::textarea('file_content',72,25,html::escapeHTML($file['c']),'maximal','',!$file['w']).'</p>'; | 
|---|
| [2566] | 122 |  | 
|---|
| [0] | 123 |      if ($file['w']) | 
|---|
 | 124 |      { | 
|---|
 | 125 |           echo | 
|---|
| [219] | 126 |           '<p><input type="submit" name="write" value="'.__('Save').' (s)" accesskey="s" /> '. | 
|---|
| [2663] | 127 |           ($o->deletableFile($file['type'],$file['f']) ? '<input type="submit" name="delete" class="delete" value="'.__('Reset').'" />' : ''). | 
|---|
| [0] | 128 |           $core->formNonce(). | 
|---|
 | 129 |           ($file['type'] ? form::hidden(array($file['type']),$file['f']) : ''). | 
|---|
 | 130 |           '</p>'; | 
|---|
 | 131 |      } | 
|---|
 | 132 |      else | 
|---|
 | 133 |      { | 
|---|
 | 134 |           echo '<p>'.__('This file is not writable. Please check your theme files permissions.').'</p>'; | 
|---|
 | 135 |      } | 
|---|
| [2566] | 136 |  | 
|---|
| [0] | 137 |      echo | 
|---|
| [2955] | 138 |      '</div></form>'; | 
|---|
| [948] | 139 |  | 
|---|
 | 140 |      if ($user_ui_colorsyntax) { | 
|---|
| [2566] | 141 |           $editorMode = | 
|---|
| [1036] | 142 |                (!empty($_REQUEST['css']) ? "css" : | 
|---|
 | 143 |                (!empty($_REQUEST['js']) ? "javascript" : | 
|---|
 | 144 |                (!empty($_REQUEST['po']) ? "text/plain" : "text/html"))); | 
|---|
| [2566] | 145 |           echo | 
|---|
| [3256] | 146 |           '<script type="text/javascript"> | 
|---|
 | 147 |           //<![CDATA[ | 
|---|
| [997] | 148 |                window.CodeMirror.defineMode("dotclear", function(config) { | 
|---|
 | 149 |                     return CodeMirror.multiplexingMode( | 
|---|
 | 150 |                          CodeMirror.getMode(config, "'.$editorMode.'"), | 
|---|
 | 151 |                          {open: "{{tpl:", close: "}}", | 
|---|
 | 152 |                           mode: CodeMirror.getMode(config, "text/plain"), | 
|---|
 | 153 |                           delimStyle: "delimit"}, | 
|---|
 | 154 |                          {open: "<tpl:", close: ">", | 
|---|
 | 155 |                           mode: CodeMirror.getMode(config, "text/plain"), | 
|---|
 | 156 |                           delimStyle: "delimit"}, | 
|---|
 | 157 |                          {open: "</tpl:", close: ">", | 
|---|
 | 158 |                           mode: CodeMirror.getMode(config, "text/plain"), | 
|---|
 | 159 |                           delimStyle: "delimit"} | 
|---|
 | 160 |                          ); | 
|---|
 | 161 |                }); | 
|---|
| [3256] | 162 |           //]]> | 
|---|
| [948] | 163 |          </script>'; | 
|---|
| [3256] | 164 |          echo dcPage::jsRunCodeMirror('editor','file_content','dotclear',$user_ui_colorsyntax_theme); | 
|---|
| [948] | 165 |      } | 
|---|
| [0] | 166 | } | 
|---|
 | 167 | ?> | 
|---|
 | 168 | </div> | 
|---|
 | 169 | </div> | 
|---|
 | 170 |  | 
|---|
 | 171 | <div id="file-chooser"> | 
|---|
 | 172 | <h3><?php echo __('Templates files'); ?></h3> | 
|---|
 | 173 | <?php echo $o->filesList('tpl','<a href="'.$p_url.'&tpl=%2$s" class="tpl-link">%1$s</a>'); ?> | 
|---|
 | 174 |  | 
|---|
 | 175 | <h3><?php echo __('CSS files'); ?></h3> | 
|---|
 | 176 | <?php echo $o->filesList('css','<a href="'.$p_url.'&css=%2$s" class="css-link">%1$s</a>'); ?> | 
|---|
 | 177 |  | 
|---|
 | 178 | <h3><?php echo __('JavaScript files'); ?></h3> | 
|---|
 | 179 | <?php echo $o->filesList('js','<a href="'.$p_url.'&js=%2$s" class="js-link">%1$s</a>'); ?> | 
|---|
| [1036] | 180 |  | 
|---|
 | 181 | <h3><?php echo __('Locales files'); ?></h3> | 
|---|
 | 182 | <?php echo $o->filesList('po','<a href="'.$p_url.'&po=%2$s" class="po-link">%1$s</a>'); ?> | 
|---|
| [0] | 183 | </div> | 
|---|
 | 184 |  | 
|---|
 | 185 | <?php dcPage::helpBlock('themeEditor'); ?> | 
|---|
 | 186 | </body> | 
|---|
| [2566] | 187 | </html> | 
|---|