Dotclear

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

Revision 3421:34cfd92ec45a, 6.4 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)

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

Sites map