aboutsummaryrefslogtreecommitdiff
path: root/scripts/prefs.php
blob: 375d841e649a3ee348e9d6eee342266815977657 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php if (!defined('PmWiki')) exit();
/*  Copyright 2005-2019 Patrick R. Michaud (pmichaud@pobox.com)
    This file is part of PmWiki; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
    by the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.  See pmwiki.php for full details.

    This script handles per-browser preferences.  Preference settings
    are stored in wiki pages as XLPage translations, and a cookie on
    the browser tells PmWiki where to find the browser's preferred
    settings.

    This script looks for a ?setprefs= request parameter (e.g., in
    a url); when it finds one it sets a 'setprefs' cookie on the browser 
    identifying the page to be used to load browser preferences,
    and loads the associated preferences.

    If there is no ?setprefs= request, then the script uses the
    'setprefs' cookie from the browser to load the preference settings.
    
    Script maintained by Petko YOTOV www.pmwiki.org/petko
*/

SDV($PrefsCookie, $CookiePrefix.'setprefs');
SDV($PrefsCookieExpires, $Now + 60 * 60 * 24 * 365);
$LogoutCookies[] = $PrefsCookie;

$sp = '';
if (@$_COOKIE[$PrefsCookie]) $sp = $_COOKIE[$PrefsCookie];
if (isset($_GET['setprefs'])) {
  $sp = MakePageName($pagename, $_GET['setprefs']);
  pmsetcookie($PrefsCookie, $sp, $PrefsCookieExpires, '/');
}
if ($sp && PageExists($sp)) XLPage('prefs', $sp, true);

if(@is_array($XL['prefs'])) {
  foreach($XL['prefs'] as $k=>$v) {
    if(! preg_match('/^(e_rows|e_cols|TimeFmt|Locale|Site\\.EditForm)$|^ak_/', $k))
      unset($XL['prefs'][$k]);
  }
}

XLSDV('en', array(
  'ak_view' => '',
  'ak_edit' => 'e',
  'ak_history' => 'h',
  'ak_attach'  => '',
  'ak_backlinks' => '',
  'ak_logout' => '',
  'ak_print' => '',
  'ak_recentchanges' => 'c',
  'ak_save' => 's',
  'ak_saveedit' => 'u',
  'ak_savedraft' => 'd',
  'ak_preview' => 'p',
  'ak_em' => '',
  'ak_strong' => '',
  ));