1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
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 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 | |
---|
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 | } |
---|
39 | |
---|
40 | http::redirect($p_url.'&upd=1'); |
---|
41 | } |
---|
42 | catch (Exception $e) |
---|
43 | { |
---|
44 | $core->error->add($e->getMessage()); |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | # Global settings update |
---|
49 | if (!empty($_POST['gs']) && is_array($_POST['gs'])) |
---|
50 | { |
---|
51 | try |
---|
52 | { |
---|
53 | foreach ($_POST['gs'] as $ns => $s) |
---|
54 | { |
---|
55 | $core->blog->settings->addNamespace($ns); |
---|
56 | |
---|
57 | foreach ($s as $k => $v) { |
---|
58 | $core->blog->settings->$ns->put($k,$v,null,null,true,true); |
---|
59 | } |
---|
60 | |
---|
61 | $core->blog->triggerBlog(); |
---|
62 | } |
---|
63 | |
---|
64 | http::redirect($p_url.'&upd=1&part=global'); |
---|
65 | } |
---|
66 | catch (Exception $e) |
---|
67 | { |
---|
68 | $core->error->add($e->getMessage()); |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | $part = !empty($_GET['part']) && $_GET['part'] == 'global' ? 'global' : 'local'; |
---|
73 | |
---|
74 | function settingLine($id,$s,$ns,$field_name,$strong_label) |
---|
75 | { |
---|
76 | if ($s['type'] == 'boolean') { |
---|
77 | $field = form::combo(array($field_name.'['.$ns.']['.$id.']',$field_name.'_'.$id), |
---|
78 | array(__('yes') => 1, __('no') => 0),$s['value'] ? 1 : 0); |
---|
79 | } else { |
---|
80 | $field = form::field(array($field_name.'['.$ns.']['.$id.']',$field_name.'_'.$id),40,null, |
---|
81 | html::escapeHTML($s['value'])); |
---|
82 | } |
---|
83 | |
---|
84 | $slabel = $strong_label ? '<strong>%s</strong>' : '%s'; |
---|
85 | |
---|
86 | return |
---|
87 | '<tr>'. |
---|
88 | '<td scope="raw"><label for="s_'.$id.'">'.sprintf($slabel,html::escapeHTML($id)).'</label></td>'. |
---|
89 | '<td>'.$field.'</td>'. |
---|
90 | '<td>'.$s['type'].'</td>'. |
---|
91 | '<td>'.html::escapeHTML($s['label']).'</td>'. |
---|
92 | '</tr>'; |
---|
93 | } |
---|
94 | ?> |
---|
95 | <html> |
---|
96 | <head> |
---|
97 | <title>about:config</title> |
---|
98 | <?php echo dcPage::jsPageTabs($part); ?> |
---|
99 | <style type="text/css"> |
---|
100 | table.settings { border: 1px solid #999; margin-bottom: 2em; } |
---|
101 | table.settings th { background: #f5f5f5; color: #444; padding-top: 0.3em; padding-bottom: 0.3em; } |
---|
102 | </style> |
---|
103 | <script type="text/javascript"> |
---|
104 | //<![CDATA[ |
---|
105 | $(function() { |
---|
106 | $("#gs_submit").hide(); |
---|
107 | $("#ls_submit").hide(); |
---|
108 | $("#gs_nav").change(function() { |
---|
109 | window.location = $("#gs_nav option:selected").val(); |
---|
110 | }) |
---|
111 | $("#ls_nav").change(function() { |
---|
112 | window.location = $("#ls_nav option:selected").val(); |
---|
113 | }) |
---|
114 | }); |
---|
115 | //]]> |
---|
116 | </script> |
---|
117 | </head> |
---|
118 | |
---|
119 | <body> |
---|
120 | <?php |
---|
121 | if (!empty($_GET['upd'])) { |
---|
122 | dcPage::message(__('Configuration successfully updated')); |
---|
123 | } |
---|
124 | |
---|
125 | if (!empty($_GET['upda'])) { |
---|
126 | dcPage::message(__('Settings definition successfully updated')); |
---|
127 | } |
---|
128 | ?> |
---|
129 | <h2><?php echo __('System'); ?> › <span class="page-title">about:config</span></h2> |
---|
130 | |
---|
131 | <div id="local" class="multi-part" title="<?php echo sprintf(__('Settings for %s'),html::escapeHTML($core->blog->name)); ?>"> |
---|
132 | |
---|
133 | |
---|
134 | <?php |
---|
135 | $table_header = '<table class="settings" id="%s"><caption>%s</caption>'. |
---|
136 | '<thead>'. |
---|
137 | '<tr>'."\n". |
---|
138 | ' <th class="nowrap">Setting ID</th>'."\n". |
---|
139 | ' <th>'.__('Value').'</th>'."\n". |
---|
140 | ' <th>'.__('Type').'</th>'."\n". |
---|
141 | ' <th class="maximalx">'.__('Description').'</th>'."\n". |
---|
142 | '</tr>'."\n". |
---|
143 | '</thead>'."\n". |
---|
144 | '<tbody>'; |
---|
145 | $table_footer = '</tbody></table>'; |
---|
146 | |
---|
147 | $settings = array(); |
---|
148 | foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { |
---|
149 | foreach ($namespace->dumpSettings() as $k => $v) { |
---|
150 | $settings[$ns][$k] = $v; |
---|
151 | } |
---|
152 | } |
---|
153 | ksort($settings); |
---|
154 | if (count($settings) > 0) { |
---|
155 | $ns_combo = array(); |
---|
156 | foreach ($settings as $ns => $s) { |
---|
157 | $ns_combo[$ns] = '#l_'.$ns; |
---|
158 | } |
---|
159 | echo |
---|
160 | '<form action="plugin.php" method="post">'. |
---|
161 | '<p class="anchor-nav">'. |
---|
162 | '<label for="ls_nav" class="classic">'.__('Goto:').'</label> '.form::combo('ls_nav',$ns_combo). |
---|
163 | ' <input type="submit" value="'.__('Ok').'" id="ls_submit" />'. |
---|
164 | '<input type="hidden" name="p" value="aboutConfig" />'. |
---|
165 | $core->formNonce().'</p></form>'; |
---|
166 | } |
---|
167 | ?> |
---|
168 | |
---|
169 | <form action="plugin.php" method="post"> |
---|
170 | |
---|
171 | <?php |
---|
172 | foreach ($settings as $ns => $s) |
---|
173 | { |
---|
174 | ksort($s); |
---|
175 | echo sprintf($table_header,'l_'.$ns,$ns); |
---|
176 | foreach ($s as $k => $v) |
---|
177 | { |
---|
178 | echo settingLine($k,$v,$ns,'s',!$v['global']); |
---|
179 | } |
---|
180 | echo $table_footer; |
---|
181 | } |
---|
182 | ?> |
---|
183 | |
---|
184 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> |
---|
185 | <input type="hidden" name="p" value="aboutConfig" /> |
---|
186 | <?php echo $core->formNonce(); ?></p> |
---|
187 | </form> |
---|
188 | </div> |
---|
189 | |
---|
190 | <div id="global" class="multi-part" title="<?php echo __('global settings'); ?>"> |
---|
191 | |
---|
192 | <?php |
---|
193 | $settings = array(); |
---|
194 | |
---|
195 | foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { |
---|
196 | foreach ($namespace->dumpGlobalSettings() as $k => $v) { |
---|
197 | $settings[$ns][$k] = $v; |
---|
198 | } |
---|
199 | } |
---|
200 | |
---|
201 | ksort($settings); |
---|
202 | |
---|
203 | if (count($settings) > 0) { |
---|
204 | $ns_combo = array(); |
---|
205 | foreach ($settings as $ns => $s) { |
---|
206 | $ns_combo[$ns] = '#g_'.$ns; |
---|
207 | } |
---|
208 | echo |
---|
209 | '<form action="plugin.php" method="post">'. |
---|
210 | '<p class="anchor-nav">'. |
---|
211 | '<label for="gs_nav" class="classic">'.__('Goto:').'</label> '.form::combo('gs_nav',$ns_combo). |
---|
212 | ' <input type="submit" value="'.__('Ok').'" id="gs_submit" />'. |
---|
213 | '<input type="hidden" name="p" value="aboutConfig" />'. |
---|
214 | $core->formNonce().'</p></form>'; |
---|
215 | } |
---|
216 | ?> |
---|
217 | |
---|
218 | <form action="plugin.php" method="post"> |
---|
219 | |
---|
220 | <?php |
---|
221 | foreach ($settings as $ns => $s) |
---|
222 | { |
---|
223 | ksort($s); |
---|
224 | echo sprintf($table_header,'g_'.$ns,$ns); |
---|
225 | foreach ($s as $k => $v) |
---|
226 | { |
---|
227 | echo settingLine($k,$v,$ns,'gs',false); |
---|
228 | } |
---|
229 | echo $table_footer; |
---|
230 | } |
---|
231 | ?> |
---|
232 | |
---|
233 | <p><input type="submit" value="<?php echo __('Save'); ?>" /> |
---|
234 | <input type="hidden" name="p" value="aboutConfig" /> |
---|
235 | <?php echo $core->formNonce(); ?></p> |
---|
236 | </form> |
---|
237 | </div> |
---|
238 | |
---|
239 | </body> |
---|
240 | </html> |
---|