[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 | { |
---|
| 29 | foreach ($_POST['s'] as $ns => $s) |
---|
| 30 | { |
---|
| 31 | $core->blog->settings->addNamespace($ns); |
---|
| 32 | |
---|
| 33 | foreach ($s as $k => $v) { |
---|
| 34 | $core->blog->settings->$ns->put($k,$v); |
---|
| 35 | } |
---|
| 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 | { |
---|
| 54 | foreach ($_POST['gs'] as $ns => $s) |
---|
| 55 | { |
---|
| 56 | $core->blog->settings->addNamespace($ns); |
---|
| 57 | |
---|
| 58 | foreach ($s as $k => $v) { |
---|
| 59 | $core->blog->settings->$ns->put($k,$v,null,null,true,true); |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | $core->blog->triggerBlog(); |
---|
| 63 | } |
---|
| 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 { |
---|
[2253] | 82 | $field = form::field(array($field_name.'['.$ns.']['.$id.']',$field_name.'_'.$ns.'_'.$id),40,null, |
---|
[0] | 83 | html::escapeHTML($s['value'])); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | $slabel = $strong_label ? '<strong>%s</strong>' : '%s'; |
---|
| 87 | |
---|
| 88 | return |
---|
[1348] | 89 | '<tr class="line">'. |
---|
[2253] | 90 | '<td scope="row"><label for="'.$field_name.'_'.$ns.'_'.$id.'">'.sprintf($slabel,html::escapeHTML($id)).'</label></td>'. |
---|
[0] | 91 | '<td>'.$field.'</td>'. |
---|
| 92 | '<td>'.$s['type'].'</td>'. |
---|
| 93 | '<td>'.html::escapeHTML($s['label']).'</td>'. |
---|
| 94 | '</tr>'; |
---|
| 95 | } |
---|
| 96 | ?> |
---|
| 97 | <html> |
---|
| 98 | <head> |
---|
| 99 | <title>about:config</title> |
---|
| 100 | <?php echo dcPage::jsPageTabs($part); ?> |
---|
[1338] | 101 | <script type="text/javascript"> |
---|
[589] | 102 | //<![CDATA[ |
---|
| 103 | $(function() { |
---|
| 104 | $("#gs_submit").hide(); |
---|
| 105 | $("#ls_submit").hide(); |
---|
| 106 | $("#gs_nav").change(function() { |
---|
| 107 | window.location = $("#gs_nav option:selected").val(); |
---|
| 108 | }) |
---|
| 109 | $("#ls_nav").change(function() { |
---|
| 110 | window.location = $("#ls_nav option:selected").val(); |
---|
| 111 | }) |
---|
| 112 | }); |
---|
| 113 | //]]> |
---|
| 114 | </script> |
---|
[0] | 115 | </head> |
---|
| 116 | |
---|
| 117 | <body> |
---|
| 118 | <?php |
---|
[1358] | 119 | echo dcPage::breadcrumb( |
---|
| 120 | array( |
---|
| 121 | __('System') => '', |
---|
| 122 | html::escapeHTML($core->blog->name) => '', |
---|
[2166] | 123 | __('about:config') => '' |
---|
[2256] | 124 | )). |
---|
| 125 | dcPage::notices(); |
---|
[0] | 126 | ?> |
---|
| 127 | |
---|
[1294] | 128 | <div id="local" class="multi-part" title="<?php echo sprintf(__('Settings for %s'),html::escapeHTML($core->blog->name)); ?>"> |
---|
[2003] | 129 | <h3 class="out-of-screen-if-js"><?php echo sprintf(__('Settings for %s'),html::escapeHTML($core->blog->name)); ?></h3> |
---|
[1294] | 130 | |
---|
| 131 | <?php |
---|
[2002] | 132 | $table_header = '<div class="table-outer"><table class="settings" id="%s"><caption class="as_h3">%s</caption>'. |
---|
[581] | 133 | '<thead>'. |
---|
| 134 | '<tr>'."\n". |
---|
| 135 | ' <th class="nowrap">Setting ID</th>'."\n". |
---|
| 136 | ' <th>'.__('Value').'</th>'."\n". |
---|
| 137 | ' <th>'.__('Type').'</th>'."\n". |
---|
| 138 | ' <th class="maximalx">'.__('Description').'</th>'."\n". |
---|
| 139 | '</tr>'."\n". |
---|
| 140 | '</thead>'."\n". |
---|
| 141 | '<tbody>'; |
---|
[2002] | 142 | $table_footer = '</tbody></table></div>'; |
---|
[581] | 143 | |
---|
[0] | 144 | $settings = array(); |
---|
| 145 | foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { |
---|
| 146 | foreach ($namespace->dumpSettings() as $k => $v) { |
---|
| 147 | $settings[$ns][$k] = $v; |
---|
| 148 | } |
---|
| 149 | } |
---|
[589] | 150 | ksort($settings); |
---|
| 151 | if (count($settings) > 0) { |
---|
| 152 | $ns_combo = array(); |
---|
| 153 | foreach ($settings as $ns => $s) { |
---|
| 154 | $ns_combo[$ns] = '#l_'.$ns; |
---|
| 155 | } |
---|
| 156 | echo |
---|
| 157 | '<form action="plugin.php" method="post">'. |
---|
| 158 | '<p class="anchor-nav">'. |
---|
| 159 | '<label for="ls_nav" class="classic">'.__('Goto:').'</label> '.form::combo('ls_nav',$ns_combo). |
---|
| 160 | ' <input type="submit" value="'.__('Ok').'" id="ls_submit" />'. |
---|
| 161 | '<input type="hidden" name="p" value="aboutConfig" />'. |
---|
| 162 | $core->formNonce().'</p></form>'; |
---|
| 163 | } |
---|
| 164 | ?> |
---|
[0] | 165 | |
---|
[589] | 166 | <form action="plugin.php" method="post"> |
---|
[0] | 167 | |
---|
[589] | 168 | <?php |
---|
[0] | 169 | foreach ($settings as $ns => $s) |
---|
| 170 | { |
---|
| 171 | ksort($s); |
---|
[582] | 172 | echo sprintf($table_header,'l_'.$ns,$ns); |
---|
[0] | 173 | foreach ($s as $k => $v) |
---|
| 174 | { |
---|
| 175 | echo settingLine($k,$v,$ns,'s',!$v['global']); |
---|
| 176 | } |
---|
[581] | 177 | echo $table_footer; |
---|
[0] | 178 | } |
---|
| 179 | ?> |
---|
[581] | 180 | |
---|
[220] | 181 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> |
---|
[0] | 182 | <input type="hidden" name="p" value="aboutConfig" /> |
---|
| 183 | <?php echo $core->formNonce(); ?></p> |
---|
| 184 | </form> |
---|
| 185 | </div> |
---|
| 186 | |
---|
[1526] | 187 | <div id="global" class="multi-part" title="<?php echo __('Global settings'); ?>"> |
---|
[2003] | 188 | <h3 class="out-of-screen-if-js"><?php echo __('Global settings'); ?></h3> |
---|
[589] | 189 | |
---|
[0] | 190 | <?php |
---|
| 191 | $settings = array(); |
---|
| 192 | |
---|
| 193 | foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { |
---|
| 194 | foreach ($namespace->dumpGlobalSettings() as $k => $v) { |
---|
| 195 | $settings[$ns][$k] = $v; |
---|
| 196 | } |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | ksort($settings); |
---|
| 200 | |
---|
[582] | 201 | if (count($settings) > 0) { |
---|
[589] | 202 | $ns_combo = array(); |
---|
[582] | 203 | foreach ($settings as $ns => $s) { |
---|
[589] | 204 | $ns_combo[$ns] = '#g_'.$ns; |
---|
[582] | 205 | } |
---|
[589] | 206 | echo |
---|
| 207 | '<form action="plugin.php" method="post">'. |
---|
| 208 | '<p class="anchor-nav">'. |
---|
[1526] | 209 | '<label for="gs_nav" class="classic">'.__('Goto:').'</label> '.form::combo('gs_nav',$ns_combo).' '. |
---|
| 210 | '<input type="submit" value="'.__('Ok').'" id="gs_submit" />'. |
---|
[589] | 211 | '<input type="hidden" name="p" value="aboutConfig" />'. |
---|
| 212 | $core->formNonce().'</p></form>'; |
---|
[582] | 213 | } |
---|
[589] | 214 | ?> |
---|
[582] | 215 | |
---|
[589] | 216 | <form action="plugin.php" method="post"> |
---|
| 217 | |
---|
| 218 | <?php |
---|
[0] | 219 | foreach ($settings as $ns => $s) |
---|
| 220 | { |
---|
| 221 | ksort($s); |
---|
[582] | 222 | echo sprintf($table_header,'g_'.$ns,$ns); |
---|
[0] | 223 | foreach ($s as $k => $v) |
---|
| 224 | { |
---|
| 225 | echo settingLine($k,$v,$ns,'gs',false); |
---|
| 226 | } |
---|
[581] | 227 | echo $table_footer; |
---|
[0] | 228 | } |
---|
| 229 | ?> |
---|
[581] | 230 | |
---|
[220] | 231 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> |
---|
[0] | 232 | <input type="hidden" name="p" value="aboutConfig" /> |
---|
| 233 | <?php echo $core->formNonce(); ?></p> |
---|
| 234 | </form> |
---|
| 235 | </div> |
---|
| 236 | |
---|
[2322] | 237 | <?php dcPage::helpBlock('aboutConfig'); ?> |
---|
| 238 | |
---|
[0] | 239 | </body> |
---|
[1339] | 240 | </html> |
---|