[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
| 6 | # Copyright (c) 2003-2010 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 | # Loading themes |
---|
| 19 | $core->themes = new dcThemes($core); |
---|
| 20 | $core->themes->loadModules($core->blog->themes_path,null); |
---|
| 21 | $T = $core->themes->getModules($core->blog->settings->system->theme); |
---|
| 22 | $o = new dcThemeEditor($core); |
---|
| 23 | |
---|
| 24 | try |
---|
| 25 | { |
---|
| 26 | try |
---|
| 27 | { |
---|
| 28 | if (!empty($_REQUEST['tpl'])) { |
---|
| 29 | $file = $o->getFileContent('tpl',$_REQUEST['tpl']); |
---|
| 30 | } elseif (!empty($_REQUEST['css'])) { |
---|
| 31 | $file = $o->getFileContent('css',$_REQUEST['css']); |
---|
| 32 | } elseif (!empty($_REQUEST['js'])) { |
---|
| 33 | $file = $o->getFileContent('js',$_REQUEST['js']); |
---|
| 34 | } |
---|
| 35 | } |
---|
| 36 | catch (Exception $e) |
---|
| 37 | { |
---|
| 38 | $file = $file_default; |
---|
| 39 | throw $e; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | # Write file |
---|
| 43 | if (!empty($_POST['write'])) |
---|
| 44 | { |
---|
| 45 | $file['c'] = $_POST['file_content']; |
---|
| 46 | $o->writeFile($file['type'],$file['f'],$file['c']); |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | catch (Exception $e) |
---|
| 50 | { |
---|
| 51 | $core->error->add($e->getMessage()); |
---|
| 52 | } |
---|
| 53 | ?> |
---|
| 54 | |
---|
| 55 | <html> |
---|
| 56 | <head> |
---|
| 57 | <title><?php echo __('Theme Editor'); ?></title> |
---|
| 58 | <link rel="stylesheet" type="text/css" href="index.php?pf=themeEditor/style.css" /> |
---|
| 59 | <script type="text/javascript"> |
---|
| 60 | //<![CDATA[ |
---|
| 61 | <?php echo dcPage::jsVar('dotclear.msg.saving_document',__("Saving document...")); ?> |
---|
| 62 | <?php echo dcPage::jsVar('dotclear.msg.document_saved',__("Document saved")); ?> |
---|
| 63 | <?php echo dcPage::jsVar('dotclear.msg.error_occurred',__("An error occurred:")); ?> |
---|
| 64 | //]]> |
---|
| 65 | </script> |
---|
| 66 | <script type="text/javascript" src="index.php?pf=themeEditor/script.js"></script> |
---|
| 67 | </head> |
---|
| 68 | |
---|
| 69 | <body> |
---|
| 70 | <?php echo '<h2>'.html::escapeHTML($core->blog->name). |
---|
| 71 | ' › <a href="blog_theme.php">'.__('Blog appearance').'</a> › '.__('Theme Editor').'</h2>'; ?> |
---|
| 72 | |
---|
| 73 | <p><strong><?php echo sprintf(__('Your current theme on this blog is "%s".'),html::escapeHTML($T['name'])); ?></strong></p> |
---|
| 74 | |
---|
| 75 | <?php if ($core->blog->settings->system->theme == 'default') { ?> |
---|
| 76 | <div class="error"><p><?php echo __("You can't edit default theme."); ?></p></div> |
---|
| 77 | </body></html> |
---|
| 78 | <?php } ?> |
---|
| 79 | |
---|
| 80 | <div id="file-box"> |
---|
| 81 | <div id="file-editor"> |
---|
| 82 | <?php |
---|
| 83 | if ($file['c'] === null) |
---|
| 84 | { |
---|
| 85 | echo '<p>'.__('Please select a file to edit.').'</p>'; |
---|
| 86 | } |
---|
| 87 | else |
---|
| 88 | { |
---|
| 89 | echo |
---|
| 90 | '<form id="file-form" action="'.$p_url.'" method="post">'. |
---|
| 91 | '<fieldset><legend>'.__('File editor').'</legend>'. |
---|
[100] | 92 | '<p><label for="file_content">'.sprintf(__('Editing file %s'),'<strong>'.$file['f']).'</strong></label></p>'. |
---|
[0] | 93 | '<p>'.form::textarea('file_content',72,25,html::escapeHTML($file['c']),'maximal','',!$file['w']).'</p>'; |
---|
| 94 | |
---|
| 95 | if ($file['w']) |
---|
| 96 | { |
---|
| 97 | echo |
---|
[219] | 98 | '<p><input type="submit" name="write" value="'.__('Save').' (s)" accesskey="s" /> '. |
---|
[0] | 99 | $core->formNonce(). |
---|
| 100 | ($file['type'] ? form::hidden(array($file['type']),$file['f']) : ''). |
---|
| 101 | '</p>'; |
---|
| 102 | } |
---|
| 103 | else |
---|
| 104 | { |
---|
| 105 | echo '<p>'.__('This file is not writable. Please check your theme files permissions.').'</p>'; |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | echo |
---|
| 109 | '</fieldset></form>'; |
---|
| 110 | } |
---|
| 111 | ?> |
---|
| 112 | </div> |
---|
| 113 | </div> |
---|
| 114 | |
---|
| 115 | <div id="file-chooser"> |
---|
| 116 | <h3><?php echo __('Templates files'); ?></h3> |
---|
| 117 | <?php echo $o->filesList('tpl','<a href="'.$p_url.'&tpl=%2$s" class="tpl-link">%1$s</a>'); ?> |
---|
| 118 | |
---|
| 119 | <h3><?php echo __('CSS files'); ?></h3> |
---|
| 120 | <?php echo $o->filesList('css','<a href="'.$p_url.'&css=%2$s" class="css-link">%1$s</a>'); ?> |
---|
| 121 | |
---|
| 122 | <h3><?php echo __('JavaScript files'); ?></h3> |
---|
| 123 | <?php echo $o->filesList('js','<a href="'.$p_url.'&js=%2$s" class="js-link">%1$s</a>'); ?> |
---|
| 124 | </div> |
---|
| 125 | |
---|
| 126 | <?php dcPage::helpBlock('themeEditor'); ?> |
---|
| 127 | </body> |
---|
| 128 | </html> |
---|