Skip to content

Commit

Permalink
add config date_at_format
Browse files Browse the repository at this point in the history
change translation message
  • Loading branch information
lisps committed Mar 19, 2014
1 parent e310313 commit 7b62b42
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions conf/dokuwiki.php
Expand Up @@ -155,6 +155,7 @@
$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
21 changes: 19 additions & 2 deletions doku.php
Expand Up @@ -34,7 +34,7 @@
$ID = getID();

$REV = $INPUT->int('rev');
$DATE_AT = $INPUT->int('at');
$DATE_AT = $INPUT->str('at');
$IDX = $INPUT->str('idx');
$DATE = $INPUT->int('date');
$RANGE = $INPUT->str('range');
Expand All @@ -48,14 +48,31 @@
$SUF = cleanText($INPUT->post->str('suffix'));
$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();
}
}

//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) {
$rev_n = $pagelog->getRelativeRevision($DATE_AT,+1);
msg(sprintf($lang['page_nonexist_rev'], $DATE_AT,$rev_n));
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;
} else {
$REV = $rev_t;
Expand Down
1 change: 1 addition & 0 deletions inc/common.php
Expand Up @@ -395,6 +395,7 @@ function wl($id = '', $urlParameters = '', $absolute = false, $separator = '&amp
global $conf;
if(is_array($urlParameters)) {
if(isset($urlParameters['rev']) && !$urlParameters['rev']) unset($urlParameters['rev']);
if(isset($urlParameters['at']) && $conf['date_at_format']) $urlParameters['at'] = date($conf['date_at_format'],$urlParameters['at']);
$urlParameters = buildURLparams($urlParameters, $separator);
} else {
$urlParameters = str_replace(',', $separator, $urlParameters);
Expand Down
3 changes: 2 additions & 1 deletion inc/lang/en/lang.php
Expand Up @@ -366,5 +366,6 @@
$lang['searchresult'] = 'Search Result';
$lang['plainhtml'] = 'Plain HTML';
$lang['wikimarkup'] = 'Wiki Markup';
$lang['page_nonexist_rev'] = "Page has not existed with revision %d, try %d";
$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".';
//Setup VIM: ex: et ts=2 :

0 comments on commit 7b62b42

Please sign in to comment.