summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorlisps <stummp@loewen.de>2013-11-21 15:50:52 +0100
committerlisps <stummp@loewen.de>2013-11-21 15:50:52 +0100
commit5c2eed9a193e9341fbfee63d4a973898acdc5ee5 (patch)
treed4c1a321973ed74700c53e32282e459afb2e3986 /inc
parentee33e0c5628d9cab52676a5aa2f55356c563c209 (diff)
downloadrpg-5c2eed9a193e9341fbfee63d4a973898acdc5ee5.tar.gz
rpg-5c2eed9a193e9341fbfee63d4a973898acdc5ee5.tar.bz2
add parameter at($DATE_AT) and mind revisions
Diffstat (limited to 'inc')
-rw-r--r--inc/changelog.php23
-rw-r--r--inc/common.php2
-rw-r--r--inc/html.php5
-rw-r--r--inc/parser/xhtml.php44
-rw-r--r--inc/parserutils.php15
-rw-r--r--inc/template.php5
6 files changed, 81 insertions, 13 deletions
diff --git a/inc/changelog.php b/inc/changelog.php
index de26fdf6a..0a33f6a6e 100644
--- a/inc/changelog.php
+++ b/inc/changelog.php
@@ -814,3 +814,26 @@ function getRevisions($id, $first, $num, $chunk_size=8192, $media=false) {
$log = new PageRevisionLog($id, $chunk_size);
return $log->getRevisions($first, $num, $media);
}
+
+/**
+* Return an existing revision for a specific date which is
+* the current one or less or equal then the date
+*
+* @param string $id
+* @param number $date_at
+* @param boolean $media
+* @return string revision ('' for current)
+*/
+function getProperRevision($id,$date_at,$media = false){
+ $create_time = @filemtime($media?mediaFN($id):wikiFN($id));
+ if(((int)$date_at) >= $create_time) { //requestet REV older then time($id) => load current
+ return '';
+ } else {
+ $log = new PageRevisionLog($id);
+ if($rev = $log->getRelativeRevision($date_at+1, -1,$media)) {
+ return $rev;
+ } else {
+ return false;
+ }
+ }
+} \ No newline at end of file
diff --git a/inc/common.php b/inc/common.php
index dd30b53ab..e5e4f78c8 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -161,7 +161,7 @@ function pageinfo() {
if($REV) {
//check if current revision was meant
if($info['exists'] && (@filemtime($info['filepath']) == $REV)) {
- $REV = '';
+ //$REV = ''; //if we enter a rev we want to see that revision (inc media files)
} elseif($RANGE) {
//section editing does not work with old revisions!
$REV = '';
diff --git a/inc/html.php b/inc/html.php
index b48a17fc5..5b79ab659 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -207,6 +207,7 @@ function html_show($txt=null){
global $REV;
global $HIGH;
global $INFO;
+ global $DATE_AT;
//disable section editing for old revisions or in preview
if($txt || $REV){
$secedit = false;
@@ -226,8 +227,8 @@ function html_show($txt=null){
echo '</div></div>';
}else{
- if ($REV) print p_locale_xhtml('showrev');
- $html = p_wiki_xhtml($ID,$REV,true);
+ if ($REV||$DATE_AT) print p_locale_xhtml('showrev');
+ $html = p_wiki_xhtml($ID,$REV,true,$DATE_AT);
$html = html_secedit($html,$secedit);
if($INFO['prependTOC']) $html = tpl_toc(true).$html;
$html = html_hilight($html,$HIGH);
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index fd02c0ce0..a677db276 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -28,6 +28,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// @access public
var $doc = ''; // will contain the whole document
var $toc = array(); // will contain the Table of Contents
+ var $rev = '';
+ var $date_at = '';
var $sectionedits = array(); // A stack of section edit data
private $lastsecid = 0; // last section edit id, used by startSectionEdit
@@ -618,6 +620,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
$link['more'] = '';
$link['class'] = $class;
+ if($this->date_at) {
+ $params['at'] = $this->date_at;
+ } else if($this->rev) {
+ //$params['at'] = $this->rev;
+ }
$link['url'] = wl($id, $params);
$link['name'] = $name;
$link['title'] = $id;
@@ -792,7 +799,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
list($ext,$mime,$dl) = mimetype($src,false);
if(substr($mime,0,5) == 'image' && $render){
- $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),($linking=='direct'));
+ if(($this->rev||$this->date_at)) {
+ $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache,'rev'=>$this->_getProperMediaRevision($src)),($linking=='direct'));
+ } else {
+ $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),($linking=='direct'));
+ }
}elseif($mime == 'application/x-shockwave-flash' && $render){
// don't link flash movies
$noLink = true;
@@ -800,7 +811,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// add file icons
$class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext);
$link['class'] .= ' mediafile mf_'.$class;
- $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),true);
+ if(($this->rev||$this->date_at)) {
+ $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache,'rev'=>$this->_getProperMediaRevision($src)),true);
+ } else {
+ $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),true);
+ }
if ($exists) $link['title'] .= ' (' . filesize_h(filesize(mediaFN($src))).')';
}
@@ -1048,7 +1063,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$height=null, $cache=null, $render = true) {
$ret = '';
-
+ $intern = !is_externalmedia($src);
list($ext,$mime,$dl) = mimetype($src);
if(substr($mime,0,5) == 'image'){
// first get the $title
@@ -1073,7 +1088,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
return $title;
}
//add image tag
- $ret .= '<img src="'.ml($src,array('w'=>$width,'h'=>$height,'cache'=>$cache)).'"';
+ if($intern && ($this->rev||$this->date_at)) {
+ $ret .= '<img src="'.ml($src,array('w'=>$width,'h'=>$height,'cache'=>$cache,'rev'=>$this->_getProperMediaRevision($src))).'"';
+ } else {
+ $ret .= '<img src="'.ml($src,array('w'=>$width,'h'=>$height,'cache'=>$cache)).'"';
+ }
$ret .= ' class="media'.$align.'"';
if ($title) {
@@ -1221,6 +1240,23 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
return $link;
}
+
+ /**
+ * _getProperMediaRevision is a helperfunction to internalmedia() and _media()
+ * which returns an existing media revision less or equal to rev or date_at
+ *
+ * @author lisps
+ * @param string $media_id
+ * @access protected
+ * @return string revision ('' for current)
+ */
+ function _getProperMediaRevision($media_id){
+ $rev = $this->rev;
+ if($this->date_at){
+ $rev = $this->date_at;
+ }
+ return getProperRevision($media_id,$rev,true);
+ }
}
diff --git a/inc/parserutils.php b/inc/parserutils.php
index b67daaabb..c50bf7332 100644
--- a/inc/parserutils.php
+++ b/inc/parserutils.php
@@ -56,7 +56,7 @@ define('METADATA_RENDER_UNLIMITED', 4);
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function p_wiki_xhtml($id, $rev='', $excuse=true){
+function p_wiki_xhtml($id, $rev='', $excuse=true,$date_at=''){
$file = wikiFN($id,$rev);
$ret = '';
@@ -65,9 +65,9 @@ function p_wiki_xhtml($id, $rev='', $excuse=true){
$keep = $ID;
$ID = $id;
- if($rev){
+ if($rev || $date_at){
if(@file_exists($file)){
- $ret = p_render('xhtml',p_get_instructions(io_readWikiPage($file,$id,$rev)),$info); //no caching on old revisions
+ $ret = p_render('xhtml',p_get_instructions(io_readWikiPage($file,$id,$rev)),$info,$rev,$date_at); //no caching on old revisions
}elseif($excuse){
$ret = p_locale_xhtml('norev');
}
@@ -583,7 +583,7 @@ function p_sort_modes($a, $b){
* @author Harry Fuecks <hfuecks@gmail.com>
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function p_render($mode,$instructions,&$info){
+function p_render($mode,$instructions,&$info,$rev='',$date_at=''){
if(is_null($instructions)) return '';
$Renderer =& p_get_renderer($mode);
@@ -591,6 +591,13 @@ function p_render($mode,$instructions,&$info){
$Renderer->reset();
+ if($rev) {
+ $Renderer->rev = $rev;
+ }
+ if($date_at) {
+ $Renderer->date_at = $date_at;
+ }
+
$Renderer->smileys = getSmileys();
$Renderer->entities = getEntities();
$Renderer->acronyms = getAcronyms();
diff --git a/inc/template.php b/inc/template.php
index 60e178d1a..ac85059a8 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1031,6 +1031,7 @@ function tpl_img_getTag($tags, $alt = '', $src = null) {
function tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null) {
global $IMG;
global $INPUT;
+ global $REV;
$w = tpl_img_getTag('File.Width');
$h = tpl_img_getTag('File.Height');
@@ -1055,8 +1056,8 @@ function tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null) {
}
//prepare URLs
- $url = ml($IMG, array('cache'=> $INPUT->str('cache')), true, '&');
- $src = ml($IMG, array('cache'=> $INPUT->str('cache'), 'w'=> $w, 'h'=> $h), true, '&');
+ $url = ml($IMG, array('cache'=> $INPUT->str('cache'),'rev'=>$REV), true, '&');
+ $src = ml($IMG, array('cache'=> $INPUT->str('cache'),'rev'=>$REV, 'w'=> $w, 'h'=> $h), true, '&');
//prepare attributes
$alt = tpl_img_getTag('Simple.Title');