Dotclear

source: plugins/aboutConfig/index.php @ 3421:34cfd92ec45a

Revision 3421:34cfd92ec45a, 6.5 KB checked in by franck <carnet.franck.paul@…>, 9 years ago (diff)

No more <![CDATA[ … ]]> but in rss2.xsl (only useful for XML document, as XHTML)

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

Sites map