Blame


1 5127fd58 2021-12-17 jrmu <?php if (!defined('PmWiki')) exit();
2 5127fd58 2021-12-17 jrmu /* Copyright 2005-2019 Patrick R. Michaud (pmichaud@pobox.com)
3 5127fd58 2021-12-17 jrmu This file is part of PmWiki; you can redistribute it and/or modify
4 5127fd58 2021-12-17 jrmu it under the terms of the GNU General Public License as published
5 5127fd58 2021-12-17 jrmu by the Free Software Foundation; either version 2 of the License, or
6 5127fd58 2021-12-17 jrmu (at your option) any later version. See pmwiki.php for full details.
7 5127fd58 2021-12-17 jrmu
8 5127fd58 2021-12-17 jrmu This script handles per-browser preferences. Preference settings
9 5127fd58 2021-12-17 jrmu are stored in wiki pages as XLPage translations, and a cookie on
10 5127fd58 2021-12-17 jrmu the browser tells PmWiki where to find the browser's preferred
11 5127fd58 2021-12-17 jrmu settings.
12 5127fd58 2021-12-17 jrmu
13 5127fd58 2021-12-17 jrmu This script looks for a ?setprefs= request parameter (e.g., in
14 5127fd58 2021-12-17 jrmu a url); when it finds one it sets a 'setprefs' cookie on the browser
15 5127fd58 2021-12-17 jrmu identifying the page to be used to load browser preferences,
16 5127fd58 2021-12-17 jrmu and loads the associated preferences.
17 5127fd58 2021-12-17 jrmu
18 5127fd58 2021-12-17 jrmu If there is no ?setprefs= request, then the script uses the
19 5127fd58 2021-12-17 jrmu 'setprefs' cookie from the browser to load the preference settings.
20 5127fd58 2021-12-17 jrmu
21 5127fd58 2021-12-17 jrmu Script maintained by Petko YOTOV www.pmwiki.org/petko
22 5127fd58 2021-12-17 jrmu */
23 5127fd58 2021-12-17 jrmu
24 5127fd58 2021-12-17 jrmu SDV($PrefsCookie, $CookiePrefix.'setprefs');
25 5127fd58 2021-12-17 jrmu SDV($PrefsCookieExpires, $Now + 60 * 60 * 24 * 365);
26 5127fd58 2021-12-17 jrmu $LogoutCookies[] = $PrefsCookie;
27 5127fd58 2021-12-17 jrmu
28 5127fd58 2021-12-17 jrmu $sp = '';
29 5127fd58 2021-12-17 jrmu if (@$_COOKIE[$PrefsCookie]) $sp = $_COOKIE[$PrefsCookie];
30 5127fd58 2021-12-17 jrmu if (isset($_GET['setprefs'])) {
31 5127fd58 2021-12-17 jrmu $sp = MakePageName($pagename, $_GET['setprefs']);
32 5127fd58 2021-12-17 jrmu pmsetcookie($PrefsCookie, $sp, $PrefsCookieExpires, '/');
33 5127fd58 2021-12-17 jrmu }
34 5127fd58 2021-12-17 jrmu if ($sp && PageExists($sp)) XLPage('prefs', $sp, true);
35 5127fd58 2021-12-17 jrmu
36 5127fd58 2021-12-17 jrmu if(@is_array($XL['prefs'])) {
37 5127fd58 2021-12-17 jrmu foreach($XL['prefs'] as $k=>$v) {
38 5127fd58 2021-12-17 jrmu if(! preg_match('/^(e_rows|e_cols|TimeFmt|Locale|Site\\.EditForm)$|^ak_/', $k))
39 5127fd58 2021-12-17 jrmu unset($XL['prefs'][$k]);
40 5127fd58 2021-12-17 jrmu }
41 5127fd58 2021-12-17 jrmu }
42 5127fd58 2021-12-17 jrmu
43 5127fd58 2021-12-17 jrmu XLSDV('en', array(
44 5127fd58 2021-12-17 jrmu 'ak_view' => '',
45 5127fd58 2021-12-17 jrmu 'ak_edit' => 'e',
46 5127fd58 2021-12-17 jrmu 'ak_history' => 'h',
47 5127fd58 2021-12-17 jrmu 'ak_attach' => '',
48 5127fd58 2021-12-17 jrmu 'ak_backlinks' => '',
49 5127fd58 2021-12-17 jrmu 'ak_logout' => '',
50 5127fd58 2021-12-17 jrmu 'ak_print' => '',
51 5127fd58 2021-12-17 jrmu 'ak_recentchanges' => 'c',
52 5127fd58 2021-12-17 jrmu 'ak_save' => 's',
53 5127fd58 2021-12-17 jrmu 'ak_saveedit' => 'u',
54 5127fd58 2021-12-17 jrmu 'ak_savedraft' => 'd',
55 5127fd58 2021-12-17 jrmu 'ak_preview' => 'p',
56 5127fd58 2021-12-17 jrmu 'ak_em' => '',
57 5127fd58 2021-12-17 jrmu 'ak_strong' => '',
58 5127fd58 2021-12-17 jrmu ));
59 5127fd58 2021-12-17 jrmu