diff --git a/inc/actions.php b/inc/actions.php index 4083b0454d26f180ca57a77709d81656f0e9e9eb..e0ad908b74c39472ca274f3ec8f23f317fcae760 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 bc49e76b26ec0723665808908e7cc7e491bce53d..c740102234c32366a46ba05d92ace095d98b8a22 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 5c1c75cf652b3cf3a79588d286b0cde02708d0c1..4449132331d4b74c713bac35b0d743aa3da4d3d7 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 4af35cc2bff233238124af4c9a329a18cf01b30c..aa0fd5c0032633ffefb3df9125fcd11f5265c379 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?