Skip to content

Commit

Permalink
parse AT parameter: first strtotime then timestamp
Browse files Browse the repository at this point in the history
remove config option
  • Loading branch information
lisps committed Sep 29, 2014
1 parent 1d053a5 commit 80d9f3d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
1 change: 0 additions & 1 deletion conf/dokuwiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@
$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
Expand Down
35 changes: 19 additions & 16 deletions doku.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,33 @@


//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;
}
}
}

//check for existing $REV related to $DATE_AT
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;
}
Expand Down
4 changes: 2 additions & 2 deletions inc/lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,6 @@
$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 <a href="%s">%s</a>.';
$lang['unable_to_parse_date'] = 'Unable to parse at parameter "%s".';
//Setup VIM: ex: et ts=2 :
1 change: 0 additions & 1 deletion lib/plugins/config/lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@
$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 <a href="http://www.php.net/manual/datetime.formats.php">datetime.formats</a> 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';
Expand Down
1 change: 0 additions & 1 deletion lib/plugins/config/settings/config.metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@
$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');
Expand Down

0 comments on commit 80d9f3d

Please sign in to comment.