[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[270] | 6 | # Copyright (c) 2003-2011 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 | # Local settings update |
---|
| 15 | if (!empty($_POST['s']) && is_array($_POST['s'])) |
---|
| 16 | { |
---|
| 17 | try |
---|
| 18 | { |
---|
| 19 | foreach ($_POST['s'] as $ns => $s) |
---|
| 20 | { |
---|
| 21 | $core->blog->settings->addNamespace($ns); |
---|
| 22 | |
---|
| 23 | foreach ($s as $k => $v) { |
---|
| 24 | $core->blog->settings->$ns->put($k,$v); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | $core->blog->triggerBlog(); |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | http::redirect($p_url.'&upd=1'); |
---|
| 31 | } |
---|
| 32 | catch (Exception $e) |
---|
| 33 | { |
---|
| 34 | $core->error->add($e->getMessage()); |
---|
| 35 | } |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | # Global settings update |
---|
| 39 | if (!empty($_POST['gs']) && is_array($_POST['gs'])) |
---|
| 40 | { |
---|
| 41 | try |
---|
| 42 | { |
---|
| 43 | foreach ($_POST['gs'] as $ns => $s) |
---|
| 44 | { |
---|
| 45 | $core->blog->settings->addNamespace($ns); |
---|
| 46 | |
---|
| 47 | foreach ($s as $k => $v) { |
---|
| 48 | $core->blog->settings->$ns->put($k,$v,null,null,true,true); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | $core->blog->triggerBlog(); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | http::redirect($p_url.'&upd=1&part=global'); |
---|
| 55 | } |
---|
| 56 | catch (Exception $e) |
---|
| 57 | { |
---|
| 58 | $core->error->add($e->getMessage()); |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | $part = !empty($_GET['part']) && $_GET['part'] == 'global' ? 'global' : 'local'; |
---|
| 63 | |
---|
| 64 | function settingLine($id,$s,$ns,$field_name,$strong_label) |
---|
| 65 | { |
---|
| 66 | if ($s['type'] == 'boolean') { |
---|
| 67 | $field = form::combo(array($field_name.'['.$ns.']['.$id.']',$field_name.'_'.$id), |
---|
| 68 | array(__('yes') => 1, __('no') => 0),$s['value']); |
---|
| 69 | } else { |
---|
| 70 | $field = form::field(array($field_name.'['.$ns.']['.$id.']',$field_name.'_'.$id),40,null, |
---|
| 71 | html::escapeHTML($s['value'])); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | $slabel = $strong_label ? '<strong>%s</strong>' : '%s'; |
---|
| 75 | |
---|
| 76 | return |
---|
| 77 | '<tr>'. |
---|
| 78 | '<td><label for="s_'.$id.'">'.sprintf($slabel,html::escapeHTML($id)).'</label></td>'. |
---|
| 79 | '<td>'.$field.'</td>'. |
---|
| 80 | '<td>'.$s['type'].'</td>'. |
---|
| 81 | '<td>'.html::escapeHTML($s['label']).'</td>'. |
---|
| 82 | '</tr>'; |
---|
| 83 | } |
---|
| 84 | ?> |
---|
| 85 | <html> |
---|
| 86 | <head> |
---|
| 87 | <title>about:config</title> |
---|
| 88 | <?php echo dcPage::jsPageTabs($part); ?> |
---|
| 89 | <style type="text/css"> |
---|
[74] | 90 | .ns-name { background: #dfdfdf; color: #333; padding-top: 0.3em; padding-bottom: 0.3em; font-size: 1.1em; } |
---|
[0] | 91 | </style> |
---|
| 92 | </head> |
---|
| 93 | |
---|
| 94 | <body> |
---|
| 95 | <?php |
---|
| 96 | if (!empty($_GET['upd'])) { |
---|
| 97 | echo '<p class="message">'.__('Configuration successfully updated').'</p>'; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | if (!empty($_GET['upda'])) { |
---|
| 101 | echo '<p class="message">'.__('Settings definition successfully updated').'</p>'; |
---|
| 102 | } |
---|
| 103 | ?> |
---|
[500] | 104 | <h2><?php echo html::escapeHTML($core->blog->name); ?> › <span class="page-title">about:config</span></h2> |
---|
[0] | 105 | |
---|
| 106 | <div id="local" class="multi-part" title="<?php echo __('blog settings'); ?>"> |
---|
| 107 | <form action="plugin.php" method="post"> |
---|
| 108 | <table> |
---|
| 109 | <tr> |
---|
| 110 | <th class="nowrap">Setting ID</th> |
---|
| 111 | <th><?php echo __('Value'); ?></th> |
---|
| 112 | <th><?php echo __('Type'); ?></th> |
---|
| 113 | <th class="maximal"><?php echo __('Description'); ?></th> |
---|
| 114 | </tr> |
---|
| 115 | <?php |
---|
| 116 | $settings = array(); |
---|
| 117 | |
---|
| 118 | foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { |
---|
| 119 | foreach ($namespace->dumpSettings() as $k => $v) { |
---|
| 120 | $settings[$ns][$k] = $v; |
---|
| 121 | } |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | ksort($settings); |
---|
| 125 | |
---|
| 126 | foreach ($settings as $ns => $s) |
---|
| 127 | { |
---|
| 128 | ksort($s); |
---|
| 129 | echo '<tr><td colspan="4" class="ns-name">namespace: <strong>'.$ns.'</strong></td></tr>'; |
---|
| 130 | |
---|
| 131 | foreach ($s as $k => $v) |
---|
| 132 | { |
---|
| 133 | echo settingLine($k,$v,$ns,'s',!$v['global']); |
---|
| 134 | } |
---|
| 135 | } |
---|
| 136 | ?> |
---|
| 137 | </table> |
---|
[220] | 138 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> |
---|
[0] | 139 | <input type="hidden" name="p" value="aboutConfig" /> |
---|
| 140 | <?php echo $core->formNonce(); ?></p> |
---|
| 141 | </form> |
---|
| 142 | </div> |
---|
| 143 | |
---|
| 144 | <div id="global" class="multi-part" title="<?php echo __('global settings'); ?>"> |
---|
| 145 | <form action="plugin.php" method="post"> |
---|
| 146 | <table> |
---|
| 147 | <tr> |
---|
| 148 | <th class="nowrap">Setting ID</th> |
---|
| 149 | <th><?php echo __('Value'); ?></th> |
---|
| 150 | <th><?php echo __('Type'); ?></th> |
---|
| 151 | <th class="maximal"><?php echo __('Description'); ?></th> |
---|
| 152 | </tr> |
---|
| 153 | <?php |
---|
| 154 | $settings = array(); |
---|
| 155 | |
---|
| 156 | foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { |
---|
| 157 | foreach ($namespace->dumpGlobalSettings() as $k => $v) { |
---|
| 158 | $settings[$ns][$k] = $v; |
---|
| 159 | } |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | ksort($settings); |
---|
| 163 | |
---|
| 164 | foreach ($settings as $ns => $s) |
---|
| 165 | { |
---|
| 166 | ksort($s); |
---|
| 167 | echo '<tr><td colspan="4" class="ns-name">namespace: <strong>'.$ns.'</strong></td></tr>'; |
---|
| 168 | |
---|
| 169 | foreach ($s as $k => $v) |
---|
| 170 | { |
---|
| 171 | echo settingLine($k,$v,$ns,'gs',false); |
---|
| 172 | } |
---|
| 173 | } |
---|
| 174 | ?> |
---|
| 175 | </table> |
---|
[220] | 176 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> |
---|
[0] | 177 | <input type="hidden" name="p" value="aboutConfig" /> |
---|
| 178 | <?php echo $core->formNonce(); ?></p> |
---|
| 179 | </form> |
---|
| 180 | </div> |
---|
| 181 | |
---|
| 182 | </body> |
---|
| 183 | </html> |
---|