From 80d9f3ddb3a602960d23f1849c1ad6287c4f9d92 Mon Sep 17 00:00:00 2001 From: lisps Date: Mon, 29 Sep 2014 10:13:57 +0200 Subject: parse AT parameter: first strtotime then timestamp remove config option --- conf/dokuwiki.php | 1 - doku.php | 35 ++++++++++++++----------- inc/lang/en/lang.php | 4 +-- lib/plugins/config/lang/en/lang.php | 1 - lib/plugins/config/settings/config.metadata.php | 1 - 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php index f92e81e8c..bdc9739d1 100644 --- a/conf/dokuwiki.php +++ b/conf/dokuwiki.php @@ -155,7 +155,6 @@ $conf['broken_iua'] = 0; //Platform with broken ignore_user_abor $conf['xsendfile'] = 0; //Use X-Sendfile (1 = lighttpd, 2 = standard) $conf['renderer_xhtml'] = 'xhtml'; //renderer to use for main page generation $conf['readdircache'] = 0; //time cache in second for the readdir operation, 0 to deactivate. -$conf['date_at_format'] = 'Y-m-d-H:i:s'; /* Network Settings */ $conf['dnslookups'] = 1; //disable to disallow IP to hostname lookups diff --git a/doku.php b/doku.php index 6673d2d66..f4309d122 100644 --- a/doku.php +++ b/doku.php @@ -50,13 +50,16 @@ $SUM = $INPUT->post->str('summary'); //parse DATE_AT -if($DATE_AT && $conf['date_at_format']) { - $date_o = DateTime::createFromFormat($conf['date_at_format'],$DATE_AT); - if(!$date_o) { - msg(sprintf($lang['unable_to_parse_date'], $DATE_AT,$conf['date_at_format'])); - $DATE_AT = null; - } else { - $DATE_AT = $date_o->getTimestamp(); +if($DATE_AT) { + $date_parse = strtotime($DATE_AT); + if($date_parse) { + $DATE_AT = $date_parse; + } else { // check for UNIX Timestamp + $date_parse = @date('Ymd',$DATE_AT); + if(!$date_parse || $date_parse === '19700101') { + msg(sprintf($lang['unable_to_parse_date'], $DATE_AT)); + $DATE_AT = null; + } } } @@ -64,16 +67,16 @@ if($DATE_AT && $conf['date_at_format']) { if($DATE_AT) { $pagelog = new PageChangeLog($ID); $rev_t = $pagelog->getLastRevisionAt($DATE_AT); - if($rev_t === '') { - $REV = ''; - } else if ($rev_t === false) { + if($rev_t === '') { //current revision + $REV = null; + $DATE_AT = null; + } else if ($rev_t === false) { //page did not exist $rev_n = $pagelog->getRelativeRevision($DATE_AT,+1); - if($conf['date_at_format']) { - msg(sprintf($lang['page_nonexist_rev'], date($conf['date_at_format'],$DATE_AT),date($conf['date_at_format'],$rev_n))); - } else { - msg(sprintf($lang['page_nonexist_rev'], $DATE_AT,$rev_n)); - } - $REV = $DATE_AT; + msg(sprintf($lang['page_nonexist_rev'], + strftime($conf['dformat'],$DATE_AT), + wl($ID, array('rev' => $rev_n)), + strftime($conf['dformat'],$rev_n))); + $REV = $DATE_AT; //will result in a page not exists message } else { $REV = $rev_t; } diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 9215a3f1d..b8d5b2280 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -367,6 +367,6 @@ $lang['currentns'] = 'Current namespace'; $lang['searchresult'] = 'Search Result'; $lang['plainhtml'] = 'Plain HTML'; $lang['wikimarkup'] = 'Wiki Markup'; -$lang['page_nonexist_rev'] = 'Page did not exist at %s. It was subsequently created at %s.'; -$lang['unable_to_parse_date'] = 'Unable to parse at parameter "%s" with format "%s".'; +$lang['page_nonexist_rev'] = 'Page did not exist at %s. It was subsequently created at %s.'; +$lang['unable_to_parse_date'] = 'Unable to parse at parameter "%s".'; //Setup VIM: ex: et ts=2 : diff --git a/lib/plugins/config/lang/en/lang.php b/lib/plugins/config/lang/en/lang.php index 3fc9c2920..5e5218aff 100644 --- a/lib/plugins/config/lang/en/lang.php +++ b/lib/plugins/config/lang/en/lang.php @@ -172,7 +172,6 @@ $lang['xsendfile'] = 'Use the X-Sendfile header to let the webserver deliver s $lang['renderer_xhtml'] = 'Renderer to use for main (xhtml) wiki output'; $lang['renderer__core'] = '%s (dokuwiki core)'; $lang['renderer__plugin'] = '%s (plugin)'; -$lang['date_at_format'] = 'Date at format (see PHP\'s datetime.formats information). If empty UNIX timestamp format will be used.'; /* Network Options */ $lang['dnslookups'] = 'DokuWiki will lookup hostnames for remote IP addresses of users editing pages. If you have a slow or non working DNS server or don\'t want this feature, disable this option'; diff --git a/lib/plugins/config/settings/config.metadata.php b/lib/plugins/config/settings/config.metadata.php index 5cd09a8cb..aaa32cd70 100644 --- a/lib/plugins/config/settings/config.metadata.php +++ b/lib/plugins/config/settings/config.metadata.php @@ -209,7 +209,6 @@ $meta['broken_iua'] = array('onoff'); $meta['xsendfile'] = array('multichoice','_choices' => array(0,1,2,3),'_caution' => 'warning'); $meta['renderer_xhtml'] = array('renderer','_format' => 'xhtml','_choices' => array('xhtml'),'_caution' => 'warning'); $meta['readdircache'] = array('numeric'); -$meta['date_at_format'] = array('string'); $meta['_network'] = array('fieldset'); $meta['dnslookups'] = array('onoff'); -- cgit v1.2.3