diff options
author | Anika Henke <anika@selfthinker.org> | 2013-01-26 16:53:23 +0000 |
---|---|---|
committer | Anika Henke <anika@selfthinker.org> | 2013-01-26 16:53:23 +0000 |
commit | 3c94d07beba64154ecd707805fa87f2eaf5e4d02 (patch) | |
tree | 9be7178deadbba10404f3757f776e9eedcf9fe5b | |
parent | b5460ee2c820d95f75fd47d2f8bcbe5dddc21e7e (diff) | |
download | rpg-3c94d07beba64154ecd707805fa87f2eaf5e4d02.tar.gz rpg-3c94d07beba64154ecd707805fa87f2eaf5e4d02.tar.bz2 |
store choices for recent changes and diff views in cookie (FS#2438 and
FS#2700)
Note: These changes don't work yet. The cookie is not set and deletes the old
one.
-rw-r--r-- | inc/actions.php | 16 | ||||
-rw-r--r-- | inc/common.php | 26 | ||||
-rw-r--r-- | inc/html.php | 11 | ||||
-rw-r--r-- | inc/template.php | 6 |
4 files changed, 57 insertions, 2 deletions
diff --git a/inc/actions.php b/inc/actions.php index 4083b0454..e0ad908b7 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -67,6 +67,22 @@ function act_dispatch(){ act_sitemap($ACT); } + //recent changes + if ($ACT == 'recent'){ + $show_changes = $INPUT->str('show_changes'); + if (!empty($show_changes)) { + set_doku_pref('show_changes', $show_changes); + } + } + + //diff + if ($ACT == 'diff'){ + $difftype = $INPUT->str('difftype'); + if (!empty($difftype)) { + set_doku_pref('difftype', $difftype); + } + } + //register if($ACT == 'register' && $INPUT->post->bool('save') && register()){ $ACT = 'login'; diff --git a/inc/common.php b/inc/common.php index bc49e76b2..c74010223 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1560,4 +1560,30 @@ function get_doku_pref($pref, $default) { return $default; } +/** + * Add a preference to the DokuWiki cookie + */ +function set_doku_pref($pref, $val) { + global $conf; + $orig = get_doku_pref($pref, false); + $cookieVal = ''; + + if($orig && ($orig != $val)) { + $parts = explode('#', $_COOKIE['DOKU_PREFS']); + $cnt = count($parts); + for($i = 0; $i < $cnt; $i += 2) { + if($parts[$i] == $pref) { + $parts[$i + 1] = urlencode($val); + } + } + $cookieVal = implode('#', $parts); + } else if (!$orig) { + $cookieVal = $_COOKIE['DOKU_PREFS'].'#'.urlencode($pref).'#'.urlencode($val); + } + + if (!empty($cookieVal)) { + setcookie('DOKU_PREFS', $cookieVal, mktime('+1 year'), DOKU_BASE, '', ($conf['securecookie'] && is_ssl())); + } +} + //Setup VIM: ex: et ts=2 : diff --git a/inc/html.php b/inc/html.php index 5c1c75cf6..444913233 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1088,8 +1088,17 @@ function html_diff($text='',$intro=true,$type=null){ global $REV; global $lang; global $INPUT; + global $INFO; - if(!$type) $type = $INPUT->str('difftype'); + if(!$type) { + $type = $INPUT->str('difftype'); + if (empty($type)) { + $type = get_doku_pref('difftype', $type); + if (empty($type) && $INFO['ismobile']) { + $type = 'inline'; + } + } + } if($type != 'inline') $type = 'sidebyside'; // we're trying to be clever here, revisions to compare can be either diff --git a/inc/template.php b/inc/template.php index 4af35cc2b..aa0fd5c00 100644 --- a/inc/template.php +++ b/inc/template.php @@ -124,7 +124,11 @@ function tpl_content_core() { html_diff(); break; case 'recent': - html_recent($INPUT->extract('first')->int('first'), $INPUT->str('show_changes')); + $show_changes = $INPUT->str('show_changes'); + if (empty($show_changes)) { + $show_changes = get_doku_pref('show_changes', $show_changes); + } + html_recent($INPUT->extract('first')->int('first'), $show_changes); break; case 'index': html_index($IDX); #FIXME can this be pulled from globals? is it sanitized correctly? |