Dotclear

source: admin/preferences.php @ 3770:75566f4ffead

Revision 3770:75566f4ffead, 31.9 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Add a dark mode (user preferences), some refinements to come

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

Sites map