diff options
Diffstat (limited to 'inc/parser/xhtml.php')
-rw-r--r-- | inc/parser/xhtml.php | 105 |
1 files changed, 18 insertions, 87 deletions
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 80701cd2e..1cf1acc32 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -28,6 +28,7 @@ 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 $date_at = ''; // link pages and media against this revision var $sectionedits = array(); // A stack of section edit data private $lastsecid = 0; // last section edit id, used by startSectionEdit @@ -618,6 +619,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } $link['more'] = ''; $link['class'] = $class; + if($this->date_at) { + $params['at'] = $this->date_at; + } $link['url'] = wl($id, $params); $link['name'] = $name; $link['title'] = $id; @@ -792,7 +796,7 @@ 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')); + $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache,'rev'=>$this->_getLastMediaRevisionAt($src)),($linking=='direct')); }elseif(($mime == 'application/x-shockwave-flash' || media_supportedav($mime)) && $render){ // don't link movies $noLink = true; @@ -800,7 +804,7 @@ 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); + $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache,'rev'=>$this->_getLastMediaRevisionAt($src)),true); if ($exists) $link['title'] .= ' (' . filesize_h(filesize(mediaFN($src))).')'; } @@ -1078,7 +1082,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { return $title; } //add image tag - $ret .= '<img src="'.ml($src,array('w'=>$width,'h'=>$height,'cache'=>$cache)).'"'; + $ret .= '<img src="'.ml($src,array('w'=>$width,'h'=>$height,'cache'=>$cache,'rev'=>$this->_getLastMediaRevisionAt($src))).'"'; $ret .= ' class="media'.$align.'"'; if ($title) { @@ -1268,95 +1272,22 @@ class Doku_Renderer_xhtml extends Doku_Renderer { return $link; } - - + /** - * Embed video(s) in HTML + * _getLastMediaRevisionAt is a helperfunction to internalmedia() and _media() + * which returns an existing media revision less or equal to rev or date_at * - * @author Anika Henke <anika@selfthinker.org> - * - * @param string $src - ID of video to embed - * @param int $width - width of the video in pixels - * @param int $height - height of the video in pixels - * @param array $atts - additional attributes for the <video> tag - * @return string + * @author lisps + * @param string $media_id + * @access protected + * @return string revision ('' for current) */ - function _video($src,$width,$height,$atts=null){ - - // prepare width and height - if(is_null($atts)) $atts = array(); - $atts['width'] = (int) $width; - $atts['height'] = (int) $height; - if(!$atts['width']) $atts['width'] = 320; - if(!$atts['height']) $atts['height'] = 240; - - // prepare alternative formats - $extensions = array('webm', 'ogv', 'mp4'); - $alternatives = media_alternativefiles($src, $extensions); - $poster = media_alternativefiles($src, array('jpg', 'png'), true); - $posterUrl = ''; - if (!empty($poster)) { - $posterUrl = ml(reset($poster),array('cache'=>$cache),true,'&'); - } - - $out = ''; - // open video tag - $out .= '<video '.buildAttributes($atts).' controls="controls"'; - if ($posterUrl) $out .= ' poster="'.hsc($posterUrl).'"'; - $out .= '>'.NL; - $fallback = ''; - - // output source for each alternative video format - foreach($alternatives as $mime => $file) { - $url = ml($file,array('cache'=>$cache),true,'&'); - $title = $this->_xmlEntities(utf8_basename(noNS($file))); - - $out .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL; - // alternative content (just a link to the file) - $fallback .= $this->internalmedia($file, $title, NULL, NULL, NULL, $cache=NULL, $linking='linkonly', $return=true); - } - - // finish - $out .= $fallback; - $out .= '</video>'.NL; - return $out; + function _getLastMediaRevisionAt($media_id){ + if(!$this->date_at || media_isexternal($media_id)) return ''; + $pagelog = new MediaChangeLog($media_id); + return $pagelog->getLastRevisionAt($this->date_at); } - /** - * Embed audio in HTML - * - * @author Anika Henke <anika@selfthinker.org> - * - * @param string $src - ID of audio to embed - * @param array $atts - additional attributes for the <audio> tag - * @return string - */ - function _audio($src,$atts=null){ - - // prepare alternative formats - $extensions = array('ogg', 'mp3', 'wav'); - $alternatives = media_alternativefiles($src, $extensions); - - $out = ''; - // open audio tag - $out .= '<audio '.buildAttributes($atts).' controls="controls">'.NL; - $fallback = ''; - - // output source for each alternative audio format - foreach($alternatives as $mime => $file) { - $url = ml($file,array('cache'=>$cache),true,'&'); - $title = $this->_xmlEntities(utf8_basename(noNS($file))); - - $out .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL; - // alternative content (just a link to the file) - $fallback .= $this->internalmedia($file, $title, NULL, NULL, NULL, $cache=NULL, $linking='linkonly', $return=true); - } - - // finish - $out .= $fallback; - $out .= '</audio>'.NL; - return $out; - } } |