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