summaryrefslogtreecommitdiff
path: root/doku.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2014-09-29 18:29:20 +0200
committerAndreas Gohr <andi@splitbrain.org>2014-09-29 18:29:20 +0200
commit17553fca1944b80c25826f2f71620bbf64e1a49b (patch)
tree45716d17564d0ea39cda4b0f6961b757e382c068 /doku.php
parent2f981761b3f5b7c8dcc53b8026d9fd3c499a7e1e (diff)
parent80d9f3ddb3a602960d23f1849c1ad6287c4f9d92 (diff)
downloadrpg-17553fca1944b80c25826f2f71620bbf64e1a49b.tar.gz
rpg-17553fca1944b80c25826f2f71620bbf64e1a49b.tar.bz2
Merge pull request #624 from lisps/revisions
date_at support
Diffstat (limited to 'doku.php')
-rw-r--r--doku.php37
1 files changed, 36 insertions, 1 deletions
diff --git a/doku.php b/doku.php
index da3643544..f4309d122 100644
--- a/doku.php
+++ b/doku.php
@@ -34,6 +34,7 @@ $QUERY = trim($INPUT->str('id'));
$ID = getID();
$REV = $INPUT->int('rev');
+$DATE_AT = $INPUT->str('at');
$IDX = $INPUT->str('idx');
$DATE = $INPUT->int('date');
$RANGE = $INPUT->str('range');
@@ -47,7 +48,41 @@ $PRE = cleanText(substr($INPUT->post->str('prefix'), 0, -1));
$SUF = cleanText($INPUT->post->str('suffix'));
$SUM = $INPUT->post->str('summary');
-//make info about the selected page available
+
+//parse DATE_AT
+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 === '') { //current revision
+ $REV = null;
+ $DATE_AT = null;
+ } else if ($rev_t === false) { //page did not exist
+ $rev_n = $pagelog->getRelativeRevision($DATE_AT,+1);
+ 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;
+ }
+}
+
+//make infos about the selected page available
$INFO = pageinfo();
//export minimal info to JS, plugins can add more