Dotclear

source: plugins/userPref/index.php @ 2168:ac4827f94a9f

Revision 2168:ac4827f94a9f, 5.6 KB checked in by franck <carnet.franck.paul@…>, 12 years ago (diff)

Typo

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['gp_nav'])) {
16     http::redirect($p_url.$_POST['gp_nav']);
17     exit;
18}
19if (!empty($_POST['lp_nav'])) {
20     http::redirect($p_url.$_POST['lp_nav']);
21     exit;
22}
23
24# Local prefs update
25if (!empty($_POST['s']) && is_array($_POST['s']))
26{
27     try
28     {
29          foreach ($_POST['s'] as $ws => $s)
30          {
31               $core->auth->user_prefs->addWorkspace($ws);
32               
33               foreach ($s as $k => $v)      {
34                    $core->auth->user_prefs->$ws->put($k,$v);
35               }
36          }
37         
38          http::redirect($p_url.'&upd=1');
39     }
40     catch (Exception $e)
41     {
42          $core->error->add($e->getMessage());
43     }
44}
45
46# Global prefs update
47if (!empty($_POST['gs']) && is_array($_POST['gs']))
48{
49     try
50     {
51          foreach ($_POST['gs'] as $ws => $s)
52          {
53               $core->auth->user_prefs->addWorkspace($ws);
54               
55               foreach ($s as $k => $v)      {
56                    $core->auth->user_prefs->$ws->put($k,$v,null,null,true,true);
57               }
58          }
59         
60          http::redirect($p_url.'&upd=1&part=global');
61     }
62     catch (Exception $e)
63     {
64          $core->error->add($e->getMessage());
65     }
66}
67
68$part = !empty($_GET['part']) && $_GET['part'] == 'global' ? 'global' : 'local';
69
70function prefLine($id,$s,$ws,$field_name,$strong_label)
71{
72     if ($s['type'] == 'boolean') {
73          $field = form::combo(array($field_name.'['.$ws.']['.$id.']',$field_name.'_'.$id),
74          array(__('yes') => 1, __('no') => 0),$s['value'] ? 1 : 0);
75     } else {
76          $field = form::field(array($field_name.'['.$ws.']['.$id.']',$field_name.'_'.$id),40,null,
77          html::escapeHTML($s['value']));
78     }
79     
80     $slabel = $strong_label ? '<strong>%s</strong>' : '%s';
81     
82     return
83     '<tr class="line">'.
84     '<td scope="row"><label for="s_'.$id.'">'.sprintf($slabel,html::escapeHTML($id)).'</label></td>'.
85     '<td>'.$field.'</td>'.
86     '<td>'.$s['type'].'</td>'.
87     '<td>'.html::escapeHTML($s['label']).'</td>'.
88     '</tr>';
89}
90?>
91<html>
92<head>
93  <title>user:preferences</title>
94  <?php echo dcPage::jsPageTabs($part); ?>
95     <script type="text/javascript">
96     //<![CDATA[
97     $(function() {
98          $("#gp_submit").hide();
99          $("#lp_submit").hide();
100          $("#gp_nav").change(function() {
101               window.location = $("#gp_nav option:selected").val();
102          })
103          $("#lp_nav").change(function() {
104               window.location = $("#lp_nav option:selected").val();
105          })
106     });
107     //]]>
108     </script>
109</head>
110
111<body>
112<?php
113echo dcPage::breadcrumb(
114     array(
115          __('System') => '',
116          html::escapeHTML($core->auth->userID()) => '',
117          __('user:preferences') => ''
118     ));
119
120if (!empty($_GET['upd'])) {
121     dcPage::success(__('Preferences successfully updated'));
122}
123
124if (!empty($_GET['upda'])) {
125     dcPage::success(__('Preferences definition successfully updated'));
126}
127?>
128
129<div id="local" class="multi-part" title="<?php echo __('User preferences'); ?>">
130<h3 class="out-of-screen-if-js"><?php echo __('User preferences'); ?></h3>
131
132<?php 
133$table_header = '<div class="table-outer"><table class="prefs" id="%s"><caption class="as_h3">%s</caption>'.
134'<thead>'.
135'<tr>'."\n".
136'  <th class="nowrap">Setting ID</th>'."\n".
137'  <th>'.__('Value').'</th>'."\n".
138'  <th>'.__('Type').'</th>'."\n".
139'  <th class="maximalx">'.__('Description').'</th>'."\n".
140'</tr>'."\n".
141'</thead>'."\n".
142'<tbody>';
143$table_footer = '</tbody></table></div>';
144
145$prefs = array();
146foreach ($core->auth->user_prefs->dumpWorkspaces() as $ws => $workspace) {
147     foreach ($workspace->dumpPrefs() as $k => $v) {
148          $prefs[$ws][$k] = $v;
149     }
150}
151ksort($prefs);
152if (count($prefs) > 0) {
153     $ws_combo = array();
154     foreach ($prefs as $ws => $s) {
155          $ws_combo[$ws] = '#l_'.$ws;
156     }
157     echo 
158          '<form action="plugin.php" method="post">'.
159          '<p class="anchor-nav">'.
160          '<label for="lp_nav" class="classic">'.__('Goto:').'</label> '.form::combo('lp_nav',$ws_combo).
161          ' <input type="submit" value="'.__('Ok').'" id="lp_submit" />'.
162          '<input type="hidden" name="p" value="userPref" />'.
163          $core->formNonce().'</p></form>';
164}
165?>
166
167<form action="plugin.php" method="post">
168
169<?php
170foreach ($prefs as $ws => $s)
171{
172     ksort($s);
173     echo sprintf($table_header,'l_'.$ws,$ws);
174     foreach ($s as $k => $v)
175     {
176          echo prefLine($k,$v,$ws,'s',!$v['global']);
177     }
178     echo $table_footer;
179}
180?>
181
182<p><input type="submit" value="<?php echo __('Save'); ?>" />
183<input type="hidden" name="p" value="userPref" />
184<?php echo $core->formNonce(); ?></p>
185</form>
186</div>
187
188<div id="global" class="multi-part" title="<?php echo __('Global preferences'); ?>">
189<h3 class="out-of-screen-if-js"><?php echo __('Global preferences'); ?></h3>
190
191<?php
192$prefs = array();
193
194foreach ($core->auth->user_prefs->dumpWorkspaces() as $ws => $workspace) {
195     foreach ($workspace->dumpGlobalPrefs() as $k => $v) {
196          $prefs[$ws][$k] = $v;
197     }
198}
199
200ksort($prefs);
201
202if (count($prefs) > 0) {
203     $ws_combo = array();
204     foreach ($prefs as $ws => $s) {
205          $ws_combo[$ws] = '#g_'.$ws;
206     }
207     echo 
208          '<form action="plugin.php" method="post">'.
209          '<p class="anchor-nav">'.
210          '<label for="gp_nav" class="classic">'.__('Goto:').'</label> '.form::combo('gp_nav',$ws_combo).
211          ' <input type="submit" value="'.__('Ok').'" id="gp_submit" />'.
212          '<input type="hidden" name="p" value="userPref" />'.
213          $core->formNonce().'</p></form>';
214}
215?>
216
217<form action="plugin.php" method="post">
218
219<?php
220foreach ($prefs as $ws => $s)
221{
222     ksort($s);
223     echo sprintf($table_header,'g_'.$ws,$ws);
224     foreach ($s as $k => $v)
225     {
226          echo prefLine($k,$v,$ws,'gs',false);
227     }
228     echo $table_footer;
229}
230?>
231
232<p><input type="submit" value="<?php echo __('Save'); ?>" />
233<input type="hidden" name="p" value="userPref" />
234<?php echo $core->formNonce(); ?></p>
235</form>
236</div>
237
238</body>
239</html>
Note: See TracBrowser for help on using the repository browser.

Sites map