Dotclear

source: admin/preferences.php @ 3800:2781551f254a

Revision 3800:2781551f254a, 32.1 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Keep default fontsize if it is not yet set for the current user

Line 
1<?php
2/**
3 * @package Dotclear
4 * @subpackage Backend
5 *
6 * @copyright Olivier Meunier & Association Dotclear
7 * @copyright GPL-2.0-only
8 */
9
10require dirname(__FILE__) . '/../inc/admin/prepend.php';
11
12dcPage::check('usage,contentadmin');
13
14$page_title = __('My preferences');
15
16$user_name        = $core->auth->getInfo('user_name');
17$user_firstname   = $core->auth->getInfo('user_firstname');
18$user_displayname = $core->auth->getInfo('user_displayname');
19$user_email       = $core->auth->getInfo('user_email');
20$user_url         = $core->auth->getInfo('user_url');
21$user_lang        = $core->auth->getInfo('user_lang');
22$user_tz          = $core->auth->getInfo('user_tz');
23$user_post_status = $core->auth->getInfo('user_post_status');
24
25$user_options = $core->auth->getOptions();
26if (empty($user_options['editor']) || !is_array($user_options['editor'])) {
27    $user_options['editor'] = array();
28}
29
30$core->auth->user_prefs->addWorkspace('dashboard');
31$user_dm_doclinks   = $core->auth->user_prefs->dashboard->doclinks;
32$user_dm_dcnews     = $core->auth->user_prefs->dashboard->dcnews;
33$user_dm_quickentry = $core->auth->user_prefs->dashboard->quickentry;
34$user_dm_nofavicons = $core->auth->user_prefs->dashboard->nofavicons;
35if ($core->auth->isSuperAdmin()) {
36    $user_dm_nodcupdate = $core->auth->user_prefs->dashboard->nodcupdate;
37}
38
39$core->auth->user_prefs->addWorkspace('accessibility');
40$user_acc_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop;
41
42$core->auth->user_prefs->addWorkspace('interface');
43$user_ui_darkmode         = $core->auth->user_prefs->interface->darkmode;
44$user_ui_enhanceduploader = $core->auth->user_prefs->interface->enhanceduploader;
45$user_ui_hidemoreinfo     = $core->auth->user_prefs->interface->hidemoreinfo;
46$user_ui_hidehelpbutton   = $core->auth->user_prefs->interface->hidehelpbutton;
47$user_ui_showajaxloader   = $core->auth->user_prefs->interface->showajaxloader;
48$user_ui_htmlfontsize     = $core->auth->user_prefs->interface->htmlfontsize;
49$user_ui_dynfontsize      = $core->auth->user_prefs->interface->dynfontsize;
50if ($core->auth->isSuperAdmin()) {
51    $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon;
52}
53$user_ui_iconset            = @$core->auth->user_prefs->interface->iconset;
54$user_ui_nofavmenu          = $core->auth->user_prefs->interface->nofavmenu;
55$user_ui_media_by_page      = ($core->auth->user_prefs->interface->media_by_page ?: 30);
56$user_ui_media_nb_last_dirs = $core->auth->user_prefs->interface->media_nb_last_dirs;
57
58$default_tab = !empty($_GET['tab']) ? html::escapeHTML($_GET['tab']) : 'user-profile';
59
60if (!empty($_GET['append']) || !empty($_GET['removed']) || !empty($_GET['neworder']) ||
61    !empty($_GET['replaced']) || !empty($_POST['appendaction']) || !empty($_POST['removeaction']) ||
62    !empty($_GET['db-updated'])) {
63    $default_tab = 'user-favorites';
64} elseif (!empty($_GET['updated'])) {
65    $default_tab = 'user-options';
66}
67if (($default_tab != 'user-profile') && ($default_tab != 'user-options') && ($default_tab != 'user-favorites')) {
68    $default_tab = 'user-profile';
69}
70
71# Editors combo
72$editors_combo = dcAdminCombos::getEditorsCombo();
73$editors       = array_keys($editors_combo);
74
75# Format by editors
76$formaters         = $core->getFormaters();
77$format_by_editors = array();
78foreach ($formaters as $editor => $formats) {
79    foreach ($formats as $format) {
80        $format_by_editors[$format][$editor] = $editor;
81    }
82}
83$available_formats = array('' => '');
84foreach (array_keys($format_by_editors) as $format) {
85    $available_formats[$format] = $format;
86    if (!isset($user_options['editor'][$format])) {
87        $user_options['editor'][$format] = '';
88    }
89}
90$status_combo = dcAdminCombos::getPostStatusescombo();
91
92$iconsets_combo = array(__('Default') => '');
93$iconsets_root  = dirname(__FILE__) . '/images/iconset/';
94if (is_dir($iconsets_root) && is_readable($iconsets_root)) {
95    if (($d = @dir($iconsets_root)) !== false) {
96        while (($entry = $d->read()) !== false) {
97            if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_dir($iconsets_root . '/' . $entry)) {
98                $iconsets_combo[$entry] = $entry;
99            }
100        }
101    }
102}
103
104# Body base font size (37.5% = 6px, 50% = 8px, 62.5% = 10px, 75% = 12px, 87.5% = 14px)
105$htmlfontsize_combo = array(
106    __('Smallest') => '37.5%',
107    __('Smaller')  => '50%',
108    __('Default')  => '62.5%',
109    __('Larger')   => '75%',
110    __('Largest')  => '87,5%'
111);
112# Ensure Font size is set to default is empty
113if ($user_ui_htmlfontsize == '') {
114    $user_ui_htmlfontsize = '62.5%';
115}
116
117# Language codes
118$lang_combo = dcAdminCombos::getAdminLangsCombo();
119
120# Get 3rd parts xhtml editor flags
121$rte = array(
122    'blog_descr' => array(true, __('Blog description (in blog parameters)')),
123    'cat_descr'  => array(true, __('Category description'))
124);
125$rte = new ArrayObject($rte);
126$core->callBehavior('adminRteFlags', $core, $rte);
127# Load user settings
128$rte_flags = @$core->auth->user_prefs->interface->rte_flags;
129if (is_array($rte_flags)) {
130    foreach ($rte_flags as $fk => $fv) {
131        if (isset($rte[$fk])) {
132            $rte[$fk][0] = $fv;
133        }
134    }
135}
136
137# Get default colums (admin lists)
138$cols = array(
139    'posts' => array(__('Posts'), array(
140        'date'       => array(true, __('Date')),
141        'category'   => array(true, __('Category')),
142        'author'     => array(true, __('Author')),
143        'comments'   => array(true, __('Comments')),
144        'trackbacks' => array(true, __('Trackbacks'))
145    ))
146);
147$cols = new arrayObject($cols);
148$core->callBehavior('adminColumnsLists', $core, $cols);
149# Load user settings
150$cols_user = @$core->auth->user_prefs->interface->cols;
151if (is_array($cols_user)) {
152    foreach ($cols_user as $ct => $cv) {
153        foreach ($cv as $cn => $cd) {
154            if (isset($cols[$ct][1][$cn])) {
155                $cols[$ct][1][$cn][0] = $cd;
156            }
157        }
158    }
159}
160
161# Add or update user
162if (isset($_POST['user_name'])) {
163    try
164    {
165        $pwd_check = !empty($_POST['cur_pwd']) && $core->auth->checkPassword($_POST['cur_pwd']);
166
167        if ($core->auth->allowPassChange() && !$pwd_check && $user_email != $_POST['user_email']) {
168            throw new Exception(__('If you want to change your email or password you must provide your current password.'));
169        }
170
171        $cur = $core->con->openCursor($core->prefix . 'user');
172
173        $cur->user_name        = $user_name        = $_POST['user_name'];
174        $cur->user_firstname   = $user_firstname   = $_POST['user_firstname'];
175        $cur->user_displayname = $user_displayname = $_POST['user_displayname'];
176        $cur->user_email       = $user_email       = $_POST['user_email'];
177        $cur->user_url         = $user_url         = $_POST['user_url'];
178        $cur->user_lang        = $user_lang        = $_POST['user_lang'];
179        $cur->user_tz          = $user_tz          = $_POST['user_tz'];
180
181        $cur->user_options = new ArrayObject($user_options);
182
183        if ($core->auth->allowPassChange() && !empty($_POST['new_pwd'])) {
184            if (!$pwd_check) {
185                throw new Exception(__('If you want to change your email or password you must provide your current password.'));
186            }
187
188            if ($_POST['new_pwd'] != $_POST['new_pwd_c']) {
189                throw new Exception(__("Passwords don't match"));
190            }
191
192            $cur->user_pwd = $_POST['new_pwd'];
193        }
194
195        # --BEHAVIOR-- adminBeforeUserUpdate
196        $core->callBehavior('adminBeforeUserProfileUpdate', $cur, $core->auth->userID());
197
198        # Udate user
199        $core->updUser($core->auth->userID(), $cur);
200
201        # --BEHAVIOR-- adminAfterUserUpdate
202        $core->callBehavior('adminAfterUserProfileUpdate', $cur, $core->auth->userID());
203
204        dcPage::addSuccessNotice(__('Personal information has been successfully updated.'));
205
206        $core->adminurl->redirect("admin.user.preferences");
207    } catch (Exception $e) {
208        $core->error->add($e->getMessage());
209    }
210}
211
212# Update user options
213if (isset($_POST['user_editor'])) {
214    try
215    {
216        $cur = $core->con->openCursor($core->prefix . 'user');
217
218        $cur->user_name        = $user_name;
219        $cur->user_firstname   = $user_firstname;
220        $cur->user_displayname = $user_displayname;
221        $cur->user_email       = $user_email;
222        $cur->user_url         = $user_url;
223        $cur->user_lang        = $user_lang;
224        $cur->user_tz          = $user_tz;
225
226        $cur->user_post_status = $user_post_status = $_POST['user_post_status'];
227
228        $user_options['edit_size'] = (integer) $_POST['user_edit_size'];
229        if ($user_options['edit_size'] < 1) {
230            $user_options['edit_size'] = 10;
231        }
232        $user_options['post_format']    = $_POST['user_post_format'];
233        $user_options['editor']         = $_POST['user_editor'];
234        $user_options['enable_wysiwyg'] = !empty($_POST['user_wysiwyg']);
235        $user_options['toolbar_bottom'] = !empty($_POST['user_toolbar_bottom']);
236
237        $cur->user_options = new ArrayObject($user_options);
238
239        # --BEHAVIOR-- adminBeforeUserOptionsUpdate
240        $core->callBehavior('adminBeforeUserOptionsUpdate', $cur, $core->auth->userID());
241
242        # Update user prefs
243        $core->auth->user_prefs->accessibility->put('nodragdrop', !empty($_POST['user_acc_nodragdrop']), 'boolean');
244        $core->auth->user_prefs->interface->put('darkmode', !empty($_POST['user_ui_darkmode']), 'boolean');
245        $core->auth->user_prefs->interface->put('enhanceduploader', !empty($_POST['user_ui_enhanceduploader']), 'boolean');
246        $core->auth->user_prefs->interface->put('hidemoreinfo', !empty($_POST['user_ui_hidemoreinfo']), 'boolean');
247        $core->auth->user_prefs->interface->put('hidehelpbutton', !empty($_POST['user_ui_hidehelpbutton']), 'boolean');
248        $core->auth->user_prefs->interface->put('showajaxloader', !empty($_POST['user_ui_showajaxloader']), 'boolean');
249        $core->auth->user_prefs->interface->put('htmlfontsize', $_POST['user_ui_htmlfontsize'], 'string');
250        $core->auth->user_prefs->interface->put('dynfontsize', !empty($_POST['user_ui_dynfontsize']), 'boolean');
251        if ($core->auth->isSuperAdmin()) {
252            # Applied to all users
253            $core->auth->user_prefs->interface->put('hide_std_favicon', !empty($_POST['user_ui_hide_std_favicon']), 'boolean', null, true, true);
254        }
255        $core->auth->user_prefs->interface->put('media_by_page', (integer) $_POST['user_ui_media_by_page'], 'integer');
256        $core->auth->user_prefs->interface->put('media_nb_last_dirs', (integer) $_POST['user_ui_media_nb_last_dirs'], 'integer');
257        $core->auth->user_prefs->interface->put('media_last_dirs', array(), 'array', null, false);
258        $core->auth->user_prefs->interface->put('media_fav_dirs', array(), 'array', null, false);
259
260        # Update user columns (lists)
261        $cu = array();
262        foreach ($cols as $col_type => $cols_list) {
263            $ct = array();
264            foreach ($cols_list[1] as $col_name => $col_data) {
265                $ct[$col_name] = isset($_POST['cols_' . $col_type]) && in_array($col_name, $_POST['cols_' . $col_type], true) ? true : false;
266            }
267            if (count($ct)) {
268                $cu[$col_type] = $ct;
269            }
270        }
271        $core->auth->user_prefs->interface->put('cols', $cu, 'array');
272
273        # Update user xhtml editor flags
274        $rf = array();
275        foreach ($rte as $rk => $rv) {
276            $rf[$rk] = isset($_POST['rte_flags']) && in_array($rk, $_POST['rte_flags'], true) ? true : false;
277        }
278        $core->auth->user_prefs->interface->put('rte_flags', $rf, 'array');
279
280        # Update user
281        $core->updUser($core->auth->userID(), $cur);
282
283        # --BEHAVIOR-- adminAfterUserOptionsUpdate
284        $core->callBehavior('adminAfterUserOptionsUpdate', $cur, $core->auth->userID());
285
286        dcPage::addSuccessNotice(__('Personal options has been successfully updated.'));
287        $core->adminurl->redirect("admin.user.preferences", array(), '#user-options');
288    } catch (Exception $e) {
289        $core->error->add($e->getMessage());
290    }
291}
292
293# Dashboard options
294if (isset($_POST['db-options'])) {
295    try
296    {
297        # --BEHAVIOR-- adminBeforeUserOptionsUpdate
298        $core->callBehavior('adminBeforeDashboardOptionsUpdate', $core->auth->userID());
299
300        # Update user prefs
301        $core->auth->user_prefs->dashboard->put('doclinks', !empty($_POST['user_dm_doclinks']), 'boolean');
302        $core->auth->user_prefs->dashboard->put('dcnews', !empty($_POST['user_dm_dcnews']), 'boolean');
303        $core->auth->user_prefs->dashboard->put('quickentry', !empty($_POST['user_dm_quickentry']), 'boolean');
304        $core->auth->user_prefs->dashboard->put('nofavicons', empty($_POST['user_dm_nofavicons']), 'boolean');
305        if ($core->auth->isSuperAdmin()) {
306            $core->auth->user_prefs->dashboard->put('nodcupdate', !empty($_POST['user_dm_nodcupdate']), 'boolean');
307        }
308        $core->auth->user_prefs->interface->put('iconset', (!empty($_POST['user_ui_iconset']) ? $_POST['user_ui_iconset'] : ''));
309        $core->auth->user_prefs->interface->put('nofavmenu', empty($_POST['user_ui_nofavmenu']), 'boolean');
310
311        # --BEHAVIOR-- adminAfterUserOptionsUpdate
312        $core->callBehavior('adminAfterDashboardOptionsUpdate', $core->auth->userID());
313
314        dcPage::addSuccessNotice(__('Dashboard options has been successfully updated.'));
315        $core->adminurl->redirect("admin.user.preferences", array(), '#user-favorites');
316    } catch (Exception $e) {
317        $core->error->add($e->getMessage());
318    }
319}
320
321# Add selected favorites
322if (!empty($_POST['appendaction'])) {
323    try {
324        if (empty($_POST['append'])) {
325            throw new Exception(__('No favorite selected'));
326        }
327        $user_favs = $core->favs->getFavoriteIDs(false);
328        foreach ($_POST['append'] as $k => $v) {
329            if ($core->favs->exists($v)) {
330                $user_favs[] = $v;
331            }
332        }
333        $core->favs->setFavoriteIDs($user_favs, false);
334
335        if (!$core->error->flag()) {
336            dcPage::addSuccessNotice(__('Favorites have been successfully added.'));
337            $core->adminurl->redirect("admin.user.preferences", array(), '#user-favorites');
338        }
339    } catch (Exception $e) {
340        $core->error->add($e->getMessage());
341    }
342}
343
344# Delete selected favorites
345if (!empty($_POST['removeaction'])) {
346    try {
347        if (empty($_POST['remove'])) {
348            throw new Exception(__('No favorite selected'));
349        }
350        $user_fav_ids = array();
351        foreach ($core->favs->getFavoriteIDs(false) as $v) {
352            $user_fav_ids[$v] = true;
353        }
354        foreach ($_POST['remove'] as $v) {
355            if (isset($user_fav_ids[$v])) {
356                unset($user_fav_ids[$v]);
357            }
358        }
359        $core->favs->setFavoriteIDs(array_keys($user_fav_ids), false);
360        if (!$core->error->flag()) {
361            dcPage::addSuccessNotice(__('Favorites have been successfully removed.'));
362            $core->adminurl->redirect("admin.user.preferences", array(), '#user-favorites');
363        }
364    } catch (Exception $e) {
365        $core->error->add($e->getMessage());
366    }
367}
368
369# Order favs
370$order = array();
371if (empty($_POST['favs_order']) && !empty($_POST['order'])) {
372    $order = $_POST['order'];
373    asort($order);
374    $order = array_keys($order);
375} elseif (!empty($_POST['favs_order'])) {
376    $order = explode(',', $_POST['favs_order']);
377}
378
379if (!empty($_POST['saveorder']) && !empty($order)) {
380    foreach ($order as $k => $v) {
381        if (!$core->favs->exists($v)) {
382            unset($order[$k]);
383        }
384    }
385    $core->favs->setFavoriteIDs($order, false);
386    if (!$core->error->flag()) {
387        dcPage::addSuccessNotice(__('Favorites have been successfully updated.'));
388        $core->adminurl->redirect("admin.user.preferences", array(), '#user-favorites');
389    }
390}
391
392# Replace default favorites by current set (super admin only)
393if (!empty($_POST['replace']) && $core->auth->isSuperAdmin()) {
394    $user_favs = $core->favs->getFavoriteIDs(false);
395    $core->favs->setFavoriteIDs($user_favs, true);
396
397    if (!$core->error->flag()) {
398        dcPage::addSuccessNotice(__('Default favorites have been successfully updated.'));
399        $core->adminurl->redirect("admin.user.preferences", array(), '#user-favorites');
400    }
401}
402
403/* DISPLAY
404-------------------------------------------------------- */
405dcPage::open($page_title,
406    dcPage::jsLoad('js/_preferences.js') .
407    ($user_acc_nodragdrop ? '' : dcPage::jsLoad('js/_preferences-dragdrop.js')) .
408    dcPage::jsLoad('js/jquery/jquery-ui.custom.js') .
409    dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') .
410    dcPage::jsLoad('js/jquery/jquery.pwstrength.js') .
411    '<script type="text/javascript">' . "\n" .
412    "\$(function() {\n" .
413    "   \$('#new_pwd').pwstrength({texts: ['" .
414    sprintf(__('Password strength: %s'), __('very weak')) . "', '" .
415    sprintf(__('Password strength: %s'), __('weak')) . "', '" .
416    sprintf(__('Password strength: %s'), __('mediocre')) . "', '" .
417    sprintf(__('Password strength: %s'), __('strong')) . "', '" .
418    sprintf(__('Password strength: %s'), __('very strong')) . "']});\n" .
419    "});\n" .
420    "</script>\n" .
421    dcPage::jsPageTabs($default_tab) .
422    dcPage::jsConfirmClose('user-form', 'opts-forms', 'favs-form') .
423
424    # --BEHAVIOR-- adminPreferencesHeaders
425    $core->callBehavior('adminPreferencesHeaders'),
426
427    dcPage::breadcrumb(
428        array(
429            html::escapeHTML($core->auth->userID()) => '',
430            $page_title                             => ''
431        ))
432);
433
434# User profile
435echo '<div class="multi-part" id="user-profile" title="' . __('My profile') . '">';
436
437echo
438'<h3>' . __('My profile') . '</h3>' .
439'<form action="' . $core->adminurl->get("admin.user.preferences") . '" method="post" id="user-form">' .
440
441'<p><label for="user_name">' . __('Last Name:') . '</label>' .
442form::field('user_name', 20, 255, array(
443    'default'      => html::escapeHTML($user_name),
444    'autocomplete' => 'family-name'
445)) .
446'</p>' .
447
448'<p><label for="user_firstname">' . __('First Name:') . '</label>' .
449form::field('user_firstname', 20, 255, array(
450    'default'      => html::escapeHTML($user_firstname),
451    'autocomplete' => 'given-name'
452)) .
453'</p>' .
454
455'<p><label for="user_displayname">' . __('Display name:') . '</label>' .
456form::field('user_displayname', 20, 255, array(
457    'default'      => html::escapeHTML($user_displayname),
458    'autocomplete' => 'nickname'
459)) .
460'</p>' .
461
462'<p><label for="user_email">' . __('Email:') . '</label>' .
463form::email('user_email', array(
464    'default'      => html::escapeHTML($user_email),
465    'autocomplete' => 'email'
466)) .
467'</p>' .
468
469'<p><label for="user_url">' . __('URL:') . '</label>' .
470form::url('user_url', array(
471    'size'         => 30,
472    'default'      => html::escapeHTML($user_url),
473    'autocomplete' => 'url'
474)) .
475'</p>' .
476
477'<p><label for="user_lang">' . __('Language for my interface:') . '</label>' .
478form::combo('user_lang', $lang_combo, $user_lang, 'l10n') . '</p>' .
479
480'<p><label for="user_tz">' . __('My timezone:') . '</label>' .
481form::combo('user_tz', dt::getZones(true, true), $user_tz) . '</p>';
482
483if ($core->auth->allowPassChange()) {
484    echo
485    '<h4 class="vertical-separator pretty-title">' . __('Change my password') . '</h4>' .
486
487    '<div class="pw-table">' .
488    '<p class="pw-cell"><label for="new_pwd">' . __('New password:') . '</label>' .
489    form::password('new_pwd', 20, 255,
490        array(
491            'extra_html'   => 'data-indicator="pwindicator"',
492            'autocomplete' => 'new-password')
493    ) . '</p>' .
494    '<div id="pwindicator">' .
495    '    <div class="bar"></div>' .
496    '    <p class="label no-margin"></p>' .
497    '</div>' .
498    '</div>' .
499
500    '<p><label for="new_pwd_c">' . __('Confirm new password:') . '</label>' .
501    form::password('new_pwd_c', 20, 255,
502        array(
503            'autocomplete' => 'new-password')
504    ) . '</p>' .
505
506    '<p><label for="cur_pwd">' . __('Your current password:') . '</label>' .
507    form::password('cur_pwd', 20, 255,
508        array(
509            'autocomplete' => 'current-password')
510    ) . '</p>' .
511    '<p class="form-note warn">' .
512    __('If you have changed your email or password you must provide your current password to save these modifications.') .
513        '</p>';
514}
515
516echo
517'<p class="clear vertical-separator">' .
518$core->formNonce() .
519'<input type="submit" accesskey="s" value="' . __('Update my profile') . '" /></p>' .
520    '</form>' .
521
522    '</div>';
523
524# User options : some from actual user profile, dashboard modules, ...
525echo '<div class="multi-part" id="user-options" title="' . __('My options') . '">';
526
527echo
528'<form action="' . $core->adminurl->get("admin.user.preferences") . '#user-options" method="post" id="opts-forms">' .
529'<h3>' . __('My options') . '</h3>';
530
531echo
532'<div class="fieldset">' .
533'<h4 id="user_options_interface">' . __('Interface') . '</h4>' .
534
535'<p><label for="user_ui_darkmode" class="classic">' .
536form::checkbox('user_ui_darkmode', 1, $user_ui_darkmode) . ' ' .
537__('Activate dark mode') . '</label></p>' .
538
539'<p><label for="user_ui_enhanceduploader" class="classic">' .
540form::checkbox('user_ui_enhanceduploader', 1, $user_ui_enhanceduploader) . ' ' .
541__('Activate enhanced uploader in media manager') . '</label></p>' .
542
543'<p><label for="user_acc_nodragdrop" class="classic">' .
544form::checkbox('user_acc_nodragdrop', 1, $user_acc_nodragdrop) . ' ' .
545__('Disable javascript powered drag and drop for ordering items') . '</label></p>' .
546'<p class="clear form-note">' . __('If checked, numeric fields will allow to type the elements\' ordering number.') . '</p>' .
547
548'<p><label for="user_ui_hidemoreinfo" class="classic">' .
549form::checkbox('user_ui_hidemoreinfo', 1, $user_ui_hidemoreinfo) . ' ' .
550__('Hide all secondary information and notes') . '</label></p>' .
551
552'<p><label for="user_ui_hidehelpbutton" class="classic">' .
553form::checkbox('user_ui_hidehelpbutton', 1, $user_ui_hidehelpbutton) . ' ' .
554__('Hide help button') . '</label></p>' .
555
556'<p><label for="user_ui_showajaxloader" class="classic">' .
557form::checkbox('user_ui_showajaxloader', 1, $user_ui_showajaxloader) . ' ' .
558__('Show asynchronous requests indicator') . '</label></p>' .
559
560'<p><label for="user_ui_htmlfontsize" class="classic">' . __('Font size:') . '</label>' . ' ' .
561form::combo('user_ui_htmlfontsize', $htmlfontsize_combo, $user_ui_htmlfontsize) . '</p>' .
562
563'<p><label for="user_ui_dynfontsize" class="classic">' .
564form::checkbox('user_ui_dynfontsize', 1, $user_ui_dynfontsize) . ' ' .
565__('Activate adpative font size') . '</label></p>' .
566'<p class="clear form-note">' . __('If checked, font size will vary depending on viewport size (from 12px to 16px with default font size selected).') . '</p>';
567
568echo
569'<p><label for="user_ui_media_by_page" class="classic">' . __('Number of elements displayed per page in media manager:') . '</label> ' .
570form::number('user_ui_media_by_page', 0, 999, (integer) $user_ui_media_by_page) . '</p>';
571
572echo
573'<p><label for="user_ui_media_nb_last_dirs" class="classic">' . __('Number of recent folders proposed in media manager:') . '</label> ' .
574form::number('user_ui_media_nb_last_dirs', 0, 999, (integer) $user_ui_media_nb_last_dirs) . '</p>' .
575'<p class="clear form-note">' . __('Leave empty to ignore, displayed only if Javascript is enabled in your browser.') . '</p>';
576
577if ($core->auth->isSuperAdmin()) {
578    echo
579    '<p><label for="user_ui_hide_std_favicon" class="classic">' .
580    form::checkbox('user_ui_hide_std_favicon', 1, $user_ui_hide_std_favicon) . ' ' .
581    __('Do not use standard favicon') . '</label> ' .
582    '<span class="clear form-note warn">' . __('This will be applied for all users') . '.</span>' .
583        '</p>'; //Opera sucks;
584}
585
586echo
587    '</div>';
588
589echo
590'<div class="fieldset">' .
591'<h4 id="user_options_columns">' . __('Optional columns displayed in lists') . '</h4>';
592$odd = true;
593foreach ($cols as $col_type => $col_list) {
594    echo '<div class="two-boxes ' . ($odd ? 'odd' : 'even') . '">';
595    echo '<h5>' . $col_list[0] . '</h5>';
596    foreach ($col_list[1] as $col_name => $col_data) {
597        echo
598        '<p><label for="cols_' . $col_type . '-' . $col_name . '" class="classic">' .
599        form::checkbox(array('cols_' . $col_type . '[]', 'cols_' . $col_type . '-' . $col_name), $col_name, $col_data[0]) . $col_data[1] . '</label>';
600    }
601    echo '</div>';
602    $odd = !$odd;
603}
604echo '</div>';
605
606echo
607'<div class="fieldset">' .
608'<h4 id="user_options_edition">' . __('Edition') . '</h4>';
609
610echo '<div class="two-boxes odd">';
611foreach ($format_by_editors as $format => $editors) {
612    echo
613    '<p class="field"><label for="user_editor_' . $format . '">' . sprintf(__('Preferred editor for %s:'), $format) . '</label>' .
614    form::combo(
615        array('user_editor[' . $format . ']', 'user_editor_' . $format),
616        array_merge(array(__('Choose an editor') => ''), $editors),
617        $user_options['editor'][$format]
618    ) . '</p>';
619}
620echo
621'<p class="field"><label for="user_post_format">' . __('Preferred format:') . '</label>' .
622form::combo('user_post_format', $available_formats, $user_options['post_format']) . '</p>';
623
624echo
625'<p class="field"><label for="user_post_status">' . __('Default entry status:') . '</label>' .
626form::combo('user_post_status', $status_combo, $user_post_status) . '</p>' .
627
628'<p class="field"><label for="user_edit_size">' . __('Entry edit field height:') . '</label>' .
629form::number('user_edit_size', 10, 999, (integer) $user_options['edit_size']) . '</p>' .
630
631'<p><label for="user_wysiwyg" class="classic">' .
632form::checkbox('user_wysiwyg', 1, $user_options['enable_wysiwyg']) . ' ' .
633__('Enable WYSIWYG mode') . '</label></p>' .
634
635'<p><label for="user_toolbar_bottom" class="classic">' .
636form::checkbox('user_toolbar_bottom', 1, $user_options['toolbar_bottom']) . ' ' .
637__('Display editor\'s toolbar at bottom of textarea (if possible)') . '</label></p>' .
638
639    '</div>';
640
641echo '<div class="two-boxes even">';
642echo '<h5>' . __('Use xhtml editor for:') . '</h5>';
643foreach ($rte as $rk => $rv) {
644    echo
645    '<p><label for="rte_' . $rk . '" class="classic">' .
646    form::checkbox(array('rte_flags[]', 'rte_' . $rk), $rk, $rv[0]) . $rv[1] . '</label>';
647}
648echo '</div>';
649
650echo '</div>'; // fieldset
651
652echo
653'<h4 class="pretty-title">' . __('Other options') . '</h4>';
654
655# --BEHAVIOR-- adminPreferencesForm
656$core->callBehavior('adminPreferencesForm', $core);
657
658echo
659'<p class="clear vertical-separator">' .
660$core->formNonce() .
661'<input type="submit" accesskey="s" value="' . __('Save my options') . '" /></p>' .
662    '</form>';
663
664echo '</div>';
665
666# My dashboard
667echo '<div class="multi-part" id="user-favorites" title="' . __('My dashboard') . '">';
668$ws = $core->auth->user_prefs->addWorkspace('favorites');
669echo '<h3>' . __('My dashboard') . '</h3>';
670
671echo '<form action="' . $core->adminurl->get("admin.user.preferences") . '" method="post" id="favs-form" class="two-boxes odd">';
672
673echo '<div id="my-favs" class="fieldset"><h4>' . __('My favorites') . '</h4>';
674
675$count    = 0;
676$user_fav = $core->favs->getFavoriteIDs(false);
677foreach ($user_fav as $id) {
678    $fav = $core->favs->getFavorite($id);
679    if ($fav != false) {
680        // User favorites only
681        if ($count == 0) {
682            echo '<ul class="fav-list">';
683        }
684
685        $count++;
686        echo '<li id="fu-' . $id . '">' . '<label for="fuk-' . $id . '">' .
687        '<img src="' . dc_admin_icon_url($fav['small-icon']) . '" alt="" /> ' . '<span class="zoom"><img src="' . dc_admin_icon_url($fav['large-icon']) . '" alt="" /></span>' .
688        form::field(array('order[' . $id . ']'), 2, 3, array(
689            'default'    => $count,
690            'class'      => 'position',
691            'extra_html' => 'title="' . sprintf(__('position of %s'), $fav['title']) . '"'
692        )) .
693        form::hidden(array('dynorder[]', 'dynorder-' . $id . ''), $id) .
694        form::checkbox(array('remove[]', 'fuk-' . $id), $id) . __($fav['title']) . '</label>' .
695            '</li>';
696    }
697}
698if ($count > 0) {
699    echo '</ul>';
700}
701
702if ($count > 0) {
703    echo
704    '<div class="clear">' .
705    '<p>' . form::hidden('favs_order', '') .
706    $core->formNonce() .
707    '<input type="submit" name="saveorder" value="' . __('Save order') . '" /> ' .
708
709    '<input type="submit" class="delete" name="removeaction" ' .
710    'value="' . __('Delete selected favorites') . '" ' .
711    'onclick="return window.confirm(\'' . html::escapeJS(
712        __('Are you sure you want to remove selected favorites?')) . '\');" /></p>' .
713
714        ($core->auth->isSuperAdmin() ?
715        '<div class="info">' .
716        '<p>' . __('If you are a super administrator, you may define this set of favorites to be used by default on all blogs of this installation.') . '</p>' .
717        '<p><input class="reset" type="submit" name="replace" value="' . __('Define as default favorites') . '" />' . '</p>' .
718        '</div>'
719        :
720        '') .
721
722        '</div>';
723} else {
724    echo
725    '<p>' . __('Currently no personal favorites.') . '</p>';
726}
727
728$avail_fav       = $core->favs->getFavorites($core->favs->getAvailableFavoritesIDs());
729$default_fav_ids = array();
730foreach ($core->favs->getFavoriteIDs(true) as $v) {
731    $default_fav_ids[$v] = true;
732}
733echo '</div>'; # /box my-fav
734
735echo '<div class="fieldset" id="available-favs">';
736# Available favorites
737echo '<h5 class="pretty-title">' . __('Other available favorites') . '</h5>';
738$count = 0;
739uasort($avail_fav, function ($a, $b) {
740    return strcoll(
741        strtolower(dcUtils::removeDiacritics($a['title'])),
742        strtolower(dcUtils::removeDiacritics($b['title'])));
743});
744
745foreach ($avail_fav as $k => $v) {
746    if (in_array($k, $user_fav)) {
747        unset($avail_fav[$k]);
748    }
749}
750foreach ($avail_fav as $k => $fav) {
751    if ($count == 0) {
752        echo '<ul class="fav-list">';
753    }
754
755    $count++;
756    echo '<li id="fa-' . $k . '">' . '<label for="fak-' . $k . '">' .
757    '<img src="' . dc_admin_icon_url($fav['small-icon']) . '" alt="" /> ' .
758    '<span class="zoom"><img src="' . dc_admin_icon_url($fav['large-icon']) . '" alt="" /></span>' .
759    form::checkbox(array('append[]', 'fak-' . $k), $k) .
760        $fav['title'] . '</label>' .
761        (isset($default_fav_ids[$k]) ? ' <span class="default-fav"><img src="images/selected.png" alt="' . __('(default favorite)') . '" /></span>' : '') .
762        '</li>';
763}
764if ($count > 0) {
765    echo '</ul>';
766}
767
768echo
769'<p>' .
770$core->formNonce() .
771'<input type="submit" name="appendaction" value="' . __('Add to my favorites') . '" /></p>';
772echo '</div>'; # /available favorites
773
774echo '</form>';
775
776echo
777'<form action="' . $core->adminurl->get("admin.user.preferences") . '" method="post" id="db-forms" class="two-boxes even">' .
778
779'<div class="fieldset">' .
780'<h4>' . __('Menu') . '</h4>' .
781'<p><label for="user_ui_nofavmenu" class="classic">' .
782form::checkbox('user_ui_nofavmenu', 1, !$user_ui_nofavmenu) . ' ' .
783__('Display favorites at the top of the menu') . '</label></p></div>';
784
785echo
786'<div class="fieldset">' .
787'<h4>' . __('Dashboard icons') . '</h4>' .
788'<p><label for="user_dm_nofavicons" class="classic">' .
789form::checkbox('user_dm_nofavicons', 1, !$user_dm_nofavicons) . ' ' .
790__('Display dashboard icons') . '</label></p>';
791
792if (count($iconsets_combo) > 1) {
793    echo
794    '<p><label for="user_ui_iconset" class="classic">' . __('Iconset:') . '</label> ' .
795    form::combo('user_ui_iconset', $iconsets_combo, $user_ui_iconset) . '</p>';
796} else {
797    echo '<p class="hidden">' . form::hidden('user_ui_iconset', '') . '</p>';
798}
799echo
800    '</div>';
801
802echo
803'<div class="fieldset">' .
804'<h4>' . __('Dashboard modules') . '</h4>' .
805
806'<p><label for="user_dm_doclinks" class="classic">' .
807form::checkbox('user_dm_doclinks', 1, $user_dm_doclinks) . ' ' .
808__('Display documentation links') . '</label></p>' .
809
810'<p><label for="user_dm_dcnews" class="classic">' .
811form::checkbox('user_dm_dcnews', 1, $user_dm_dcnews) . ' ' .
812__('Display Dotclear news') . '</label></p>' .
813
814'<p><label for="user_dm_quickentry" class="classic">' .
815form::checkbox('user_dm_quickentry', 1, $user_dm_quickentry) . ' ' .
816__('Display quick entry form') . '</label></p>';
817
818if ($core->auth->isSuperAdmin()) {
819    echo
820    '<p><label for="user_dm_nodcupdate" class="classic">' .
821    form::checkbox('user_dm_nodcupdate', 1, $user_dm_nodcupdate) . ' ' .
822    __('Do not display Dotclear updates') . '</label></p>';
823}
824
825echo '</div>';
826
827# --BEHAVIOR-- adminDashboardOptionsForm
828$core->callBehavior('adminDashboardOptionsForm', $core);
829
830echo
831'<p>' .
832form::hidden('db-options', '-') .
833$core->formNonce() .
834'<input type="submit" accesskey="s" value="' . __('Save my dashboard options') . '" /></p>' .
835    '</form>';
836
837echo '</div>'; # /multipart-user-favorites
838
839dcPage::helpBlock('core_user_pref');
840dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map