[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>'. |
---|
[581] | 78 | '<td scope="raw"><label for="s_'.$id.'">'.sprintf($slabel,html::escapeHTML($id)).'</label></td>'. |
---|
[0] | 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"> |
---|
[581] | 90 | table.settings { border: 1px solid #999; margin-bottom: 2em; } |
---|
| 91 | table.settings th { background: #f5f5f5; color: #444; padding-top: 0.3em; padding-bottom: 0.3em; } |
---|
[0] | 92 | </style> |
---|
| 93 | </head> |
---|
| 94 | |
---|
| 95 | <body> |
---|
| 96 | <?php |
---|
| 97 | if (!empty($_GET['upd'])) { |
---|
| 98 | echo '<p class="message">'.__('Configuration successfully updated').'</p>'; |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | if (!empty($_GET['upda'])) { |
---|
| 102 | echo '<p class="message">'.__('Settings definition successfully updated').'</p>'; |
---|
| 103 | } |
---|
| 104 | ?> |
---|
[500] | 105 | <h2><?php echo html::escapeHTML($core->blog->name); ?> › <span class="page-title">about:config</span></h2> |
---|
[0] | 106 | |
---|
| 107 | <div id="local" class="multi-part" title="<?php echo __('blog settings'); ?>"> |
---|
| 108 | <form action="plugin.php" method="post"> |
---|
[581] | 109 | |
---|
| 110 | <?php |
---|
| 111 | |
---|
| 112 | $table_header = '<table class="settings"><caption>%s</caption>'. |
---|
| 113 | '<thead>'. |
---|
| 114 | '<tr>'."\n". |
---|
| 115 | ' <th class="nowrap">Setting ID</th>'."\n". |
---|
| 116 | ' <th>'.__('Value').'</th>'."\n". |
---|
| 117 | ' <th>'.__('Type').'</th>'."\n". |
---|
| 118 | ' <th class="maximalx">'.__('Description').'</th>'."\n". |
---|
| 119 | '</tr>'."\n". |
---|
| 120 | '</thead>'."\n". |
---|
| 121 | '<tbody>'; |
---|
| 122 | $table_footer = '</tbody></table>'; |
---|
| 123 | |
---|
[0] | 124 | $settings = array(); |
---|
| 125 | |
---|
| 126 | foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { |
---|
| 127 | foreach ($namespace->dumpSettings() as $k => $v) { |
---|
| 128 | $settings[$ns][$k] = $v; |
---|
| 129 | } |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | ksort($settings); |
---|
| 133 | |
---|
| 134 | foreach ($settings as $ns => $s) |
---|
| 135 | { |
---|
| 136 | ksort($s); |
---|
[581] | 137 | echo sprintf($table_header,$ns); |
---|
[0] | 138 | foreach ($s as $k => $v) |
---|
| 139 | { |
---|
| 140 | echo settingLine($k,$v,$ns,'s',!$v['global']); |
---|
| 141 | } |
---|
[581] | 142 | echo $table_footer; |
---|
[0] | 143 | } |
---|
| 144 | ?> |
---|
[581] | 145 | |
---|
[220] | 146 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> |
---|
[0] | 147 | <input type="hidden" name="p" value="aboutConfig" /> |
---|
| 148 | <?php echo $core->formNonce(); ?></p> |
---|
| 149 | </form> |
---|
| 150 | </div> |
---|
| 151 | |
---|
| 152 | <div id="global" class="multi-part" title="<?php echo __('global settings'); ?>"> |
---|
| 153 | <form action="plugin.php" method="post"> |
---|
| 154 | <?php |
---|
| 155 | $settings = array(); |
---|
| 156 | |
---|
| 157 | foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { |
---|
| 158 | foreach ($namespace->dumpGlobalSettings() as $k => $v) { |
---|
| 159 | $settings[$ns][$k] = $v; |
---|
| 160 | } |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | ksort($settings); |
---|
| 164 | |
---|
| 165 | foreach ($settings as $ns => $s) |
---|
| 166 | { |
---|
| 167 | ksort($s); |
---|
[581] | 168 | echo sprintf($table_header,$ns); |
---|
[0] | 169 | foreach ($s as $k => $v) |
---|
| 170 | { |
---|
| 171 | echo settingLine($k,$v,$ns,'gs',false); |
---|
| 172 | } |
---|
[581] | 173 | echo $table_footer; |
---|
[0] | 174 | } |
---|
| 175 | ?> |
---|
[581] | 176 | |
---|
[220] | 177 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> |
---|
[0] | 178 | <input type="hidden" name="p" value="aboutConfig" /> |
---|
| 179 | <?php echo $core->formNonce(); ?></p> |
---|
| 180 | </form> |
---|
| 181 | </div> |
---|
| 182 | |
---|
| 183 | </body> |
---|
| 184 | </html> |
---|