[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 ----------------------------------------- |
---|
[3709] | 12 | if (!defined('DC_CONTEXT_ADMIN')) {return;} |
---|
[0] | 13 | |
---|
[589] | 14 | # Local navigation |
---|
| 15 | if (!empty($_POST['gs_nav'])) { |
---|
[3709] | 16 | http::redirect($p_url . $_POST['gs_nav']); |
---|
| 17 | exit; |
---|
[589] | 18 | } |
---|
| 19 | if (!empty($_POST['ls_nav'])) { |
---|
[3709] | 20 | http::redirect($p_url . $_POST['ls_nav']); |
---|
| 21 | exit; |
---|
[589] | 22 | } |
---|
| 23 | |
---|
[0] | 24 | # Local settings update |
---|
[3709] | 25 | if (!empty($_POST['s']) && is_array($_POST['s'])) { |
---|
| 26 | try |
---|
| 27 | { |
---|
| 28 | foreach ($_POST['s'] as $ns => $s) { |
---|
| 29 | $core->blog->settings->addNamespace($ns); |
---|
| 30 | foreach ($s as $k => $v) { |
---|
| 31 | if ($_POST['s_type'][$ns][$k] == 'array') { |
---|
| 32 | $v = json_decode($v, true); |
---|
| 33 | } |
---|
| 34 | $core->blog->settings->$ns->put($k, $v); |
---|
| 35 | } |
---|
| 36 | $core->blog->triggerBlog(); |
---|
| 37 | } |
---|
[2256] | 38 | |
---|
[3709] | 39 | dcPage::addSuccessNotice(__('Configuration successfully updated')); |
---|
| 40 | http::redirect($p_url); |
---|
| 41 | } catch (Exception $e) { |
---|
| 42 | $core->error->add($e->getMessage()); |
---|
| 43 | } |
---|
[0] | 44 | } |
---|
| 45 | |
---|
| 46 | # Global settings update |
---|
[3709] | 47 | if (!empty($_POST['gs']) && is_array($_POST['gs'])) { |
---|
| 48 | try |
---|
| 49 | { |
---|
| 50 | foreach ($_POST['gs'] as $ns => $s) { |
---|
| 51 | $core->blog->settings->addNamespace($ns); |
---|
| 52 | foreach ($s as $k => $v) { |
---|
| 53 | if ($_POST['gs_type'][$ns][$k] == 'array') { |
---|
| 54 | $v = json_decode($v, true); |
---|
| 55 | } |
---|
| 56 | $core->blog->settings->$ns->put($k, $v, null, null, true, true); |
---|
| 57 | } |
---|
| 58 | $core->blog->triggerBlog(); |
---|
| 59 | } |
---|
[2566] | 60 | |
---|
[3709] | 61 | dcPage::addSuccessNotice(__('Configuration successfully updated')); |
---|
| 62 | http::redirect($p_url . '&part=global'); |
---|
| 63 | } catch (Exception $e) { |
---|
| 64 | $core->error->add($e->getMessage()); |
---|
| 65 | } |
---|
[0] | 66 | } |
---|
| 67 | |
---|
| 68 | $part = !empty($_GET['part']) && $_GET['part'] == 'global' ? 'global' : 'local'; |
---|
| 69 | |
---|
[3709] | 70 | function settingLine($id, $s, $ns, $field_name, $strong_label) |
---|
[0] | 71 | { |
---|
[3709] | 72 | if ($s['type'] == 'boolean') { |
---|
| 73 | $field = form::combo(array($field_name . '[' . $ns . '][' . $id . ']', $field_name . '_' . $ns . '_' . $id), |
---|
| 74 | array(__('yes') => 1, __('no') => 0), $s['value'] ? 1 : 0); |
---|
| 75 | } else { |
---|
| 76 | if ($s['type'] == 'array') { |
---|
| 77 | $field = form::field(array($field_name . '[' . $ns . '][' . $id . ']', $field_name . '_' . $ns . '_' . $id), 40, null, |
---|
| 78 | html::escapeHTML(json_encode($s['value']))); |
---|
| 79 | } else { |
---|
| 80 | $field = form::field(array($field_name . '[' . $ns . '][' . $id . ']', $field_name . '_' . $ns . '_' . $id), 40, null, |
---|
| 81 | html::escapeHTML($s['value'])); |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | $type = form::hidden(array($field_name . '_type' . '[' . $ns . '][' . $id . ']', $field_name . '_' . $ns . '_' . $id . '_type'), |
---|
| 85 | html::escapeHTML($s['type'])); |
---|
[2566] | 86 | |
---|
[3709] | 87 | $slabel = $strong_label ? '<strong>%s</strong>' : '%s'; |
---|
[2566] | 88 | |
---|
[3709] | 89 | return |
---|
| 90 | '<tr class="line">' . |
---|
| 91 | '<td scope="row"><label for="' . $field_name . '_' . $ns . '_' . $id . '">' . sprintf($slabel, html::escapeHTML($id)) . '</label></td>' . |
---|
| 92 | '<td>' . $field . '</td>' . |
---|
| 93 | '<td>' . $s['type'] . $type . '</td>' . |
---|
| 94 | '<td>' . html::escapeHTML($s['label']) . '</td>' . |
---|
| 95 | '</tr>'; |
---|
[0] | 96 | } |
---|
| 97 | ?> |
---|
| 98 | <html> |
---|
| 99 | <head> |
---|
| 100 | <title>about:config</title> |
---|
[3709] | 101 | <?php echo dcPage::jsPageTabs($part) . dcPage::jsLoad(dcPage::getPF('aboutConfig/js/index.js')); ?> |
---|
[0] | 102 | </head> |
---|
| 103 | |
---|
| 104 | <body> |
---|
| 105 | <?php |
---|
[1358] | 106 | echo dcPage::breadcrumb( |
---|
[3709] | 107 | array( |
---|
| 108 | __('System') => '', |
---|
| 109 | html::escapeHTML($core->blog->name) => '', |
---|
| 110 | __('about:config') => '' |
---|
| 111 | )) . |
---|
| 112 | dcPage::notices(); |
---|
[0] | 113 | ?> |
---|
| 114 | |
---|
[3709] | 115 | <div id="local" class="multi-part" title="<?php echo sprintf(__('Settings for %s'), html::escapeHTML($core->blog->name)); ?>"> |
---|
| 116 | <h3 class="out-of-screen-if-js"><?php echo sprintf(__('Settings for %s'), html::escapeHTML($core->blog->name)); ?></h3> |
---|
[1294] | 117 | |
---|
| 118 | <?php |
---|
[3709] | 119 | $table_header = '<div class="table-outer"><table class="settings" id="%s"><caption class="as_h3">%s</caption>' . |
---|
| 120 | '<thead>' . |
---|
| 121 | '<tr>' . "\n" . |
---|
| 122 | ' <th class="nowrap">' . __('Setting ID') . '</th>' . "\n" . |
---|
| 123 | ' <th>' . __('Value') . '</th>' . "\n" . |
---|
| 124 | ' <th>' . __('Type') . '</th>' . "\n" . |
---|
| 125 | ' <th class="maximalx">' . __('Description') . '</th>' . "\n" . |
---|
| 126 | '</tr>' . "\n" . |
---|
| 127 | '</thead>' . "\n" . |
---|
| 128 | '<tbody>'; |
---|
[2002] | 129 | $table_footer = '</tbody></table></div>'; |
---|
[581] | 130 | |
---|
[0] | 131 | $settings = array(); |
---|
| 132 | foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { |
---|
[3709] | 133 | foreach ($namespace->dumpSettings() as $k => $v) { |
---|
| 134 | $settings[$ns][$k] = $v; |
---|
| 135 | } |
---|
[0] | 136 | } |
---|
[589] | 137 | ksort($settings); |
---|
| 138 | if (count($settings) > 0) { |
---|
[3709] | 139 | $ns_combo = array(); |
---|
| 140 | foreach ($settings as $ns => $s) { |
---|
| 141 | $ns_combo[$ns] = '#l_' . $ns; |
---|
| 142 | } |
---|
| 143 | echo |
---|
| 144 | '<form action="' . $core->adminurl->get('admin.plugin') . '" method="post">' . |
---|
| 145 | '<p class="anchor-nav">' . |
---|
| 146 | '<label for="ls_nav" class="classic">' . __('Goto:') . '</label> ' . form::combo('ls_nav', $ns_combo) . |
---|
| 147 | ' <input type="submit" value="' . __('Ok') . '" id="ls_submit" />' . |
---|
| 148 | '<input type="hidden" name="p" value="aboutConfig" />' . |
---|
| 149 | $core->formNonce() . '</p></form>'; |
---|
[589] | 150 | } |
---|
| 151 | ?> |
---|
[0] | 152 | |
---|
[2824] | 153 | <form action="<?php echo $core->adminurl->get('admin.plugin'); ?>" method="post"> |
---|
[0] | 154 | |
---|
[589] | 155 | <?php |
---|
[3709] | 156 | foreach ($settings as $ns => $s) { |
---|
| 157 | ksort($s); |
---|
| 158 | echo sprintf($table_header, 'l_' . $ns, $ns); |
---|
| 159 | foreach ($s as $k => $v) { |
---|
| 160 | echo settingLine($k, $v, $ns, 's', !$v['global']); |
---|
| 161 | } |
---|
| 162 | echo $table_footer; |
---|
[0] | 163 | } |
---|
| 164 | ?> |
---|
[581] | 165 | |
---|
[220] | 166 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> |
---|
[0] | 167 | <input type="hidden" name="p" value="aboutConfig" /> |
---|
| 168 | <?php echo $core->formNonce(); ?></p> |
---|
| 169 | </form> |
---|
| 170 | </div> |
---|
| 171 | |
---|
[1526] | 172 | <div id="global" class="multi-part" title="<?php echo __('Global settings'); ?>"> |
---|
[2003] | 173 | <h3 class="out-of-screen-if-js"><?php echo __('Global settings'); ?></h3> |
---|
[589] | 174 | |
---|
[0] | 175 | <?php |
---|
| 176 | $settings = array(); |
---|
| 177 | |
---|
| 178 | foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { |
---|
[3709] | 179 | foreach ($namespace->dumpGlobalSettings() as $k => $v) { |
---|
| 180 | $settings[$ns][$k] = $v; |
---|
| 181 | } |
---|
[0] | 182 | } |
---|
| 183 | |
---|
| 184 | ksort($settings); |
---|
| 185 | |
---|
[582] | 186 | if (count($settings) > 0) { |
---|
[3709] | 187 | $ns_combo = array(); |
---|
| 188 | foreach ($settings as $ns => $s) { |
---|
| 189 | $ns_combo[$ns] = '#g_' . $ns; |
---|
| 190 | } |
---|
| 191 | echo |
---|
| 192 | '<form action="' . $core->adminurl->get('admin.plugin') . '" method="post">' . |
---|
| 193 | '<p class="anchor-nav">' . |
---|
| 194 | '<label for="gs_nav" class="classic">' . __('Goto:') . '</label> ' . form::combo('gs_nav', $ns_combo) . ' ' . |
---|
| 195 | '<input type="submit" value="' . __('Ok') . '" id="gs_submit" />' . |
---|
| 196 | '<input type="hidden" name="p" value="aboutConfig" />' . |
---|
| 197 | $core->formNonce() . '</p></form>'; |
---|
[582] | 198 | } |
---|
[589] | 199 | ?> |
---|
[582] | 200 | |
---|
[2824] | 201 | <form action="<?php echo $core->adminurl->get('admin.plugin'); ?>" method="post"> |
---|
[589] | 202 | |
---|
| 203 | <?php |
---|
[3709] | 204 | foreach ($settings as $ns => $s) { |
---|
| 205 | ksort($s); |
---|
| 206 | echo sprintf($table_header, 'g_' . $ns, $ns); |
---|
| 207 | foreach ($s as $k => $v) { |
---|
| 208 | echo settingLine($k, $v, $ns, 'gs', false); |
---|
| 209 | } |
---|
| 210 | echo $table_footer; |
---|
[0] | 211 | } |
---|
| 212 | ?> |
---|
[581] | 213 | |
---|
[220] | 214 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> |
---|
[0] | 215 | <input type="hidden" name="p" value="aboutConfig" /> |
---|
| 216 | <?php echo $core->formNonce(); ?></p> |
---|
| 217 | </form> |
---|
| 218 | </div> |
---|
| 219 | |
---|
[3709] | 220 | <?php dcPage::helpBlock('aboutConfig');?> |
---|
[2322] | 221 | |
---|
[0] | 222 | </body> |
---|
[1339] | 223 | </html> |
---|