From f50634f0c2d6669655b684449d5a6ef44e5ca3f1 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 4 Aug 2013 10:35:00 +0100 Subject: refactored audio/video code, removed wrong link around audio --- inc/parser/xhtml.php | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'inc/parser/xhtml.php') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 05472db1d..32aa99a1b 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -783,7 +783,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } function internalmedia ($src, $title=NULL, $align=NULL, $width=NULL, - $height=NULL, $cache=NULL, $linking=NULL) { + $height=NULL, $cache=NULL, $linking=NULL, $return=NULL) { global $ID; list($src,$hash) = explode('#',$src,2); resolve_mediaid(getNS($ID),$src, $exists); @@ -795,7 +795,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')); - }elseif(($mime == 'application/x-shockwave-flash' || substr($mime,0,5) == 'video') && $render){ + }elseif(($mime == 'application/x-shockwave-flash' || media_supportedav($mime)) && $render){ // don't link movies $noLink = true; }else{ @@ -814,8 +814,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } //output formatted - if ($linking == 'nolink' || $noLink) $this->doc .= $link['name']; - else $this->doc .= $this->_formatLink($link); + if ($return) { + if ($linking == 'nolink' || $noLink) return $link['name']; + else return $this->_formatLink($link); + } else { + if ($linking == 'nolink' || $noLink) $this->doc .= $link['name']; + else $this->doc .= $this->_formatLink($link); + } } function externalmedia ($src, $title=NULL, $align=NULL, $width=NULL, @@ -831,7 +836,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { if(substr($mime,0,5) == 'image' && $render){ // link only jpeg images // if ($ext != 'jpg' && $ext != 'jpeg') $noLink = true; - }elseif(($mime == 'application/x-shockwave-flash' || substr($mime,0,5) == 'video') && $render){ + }elseif(($mime == 'application/x-shockwave-flash' || media_supportedav($mime)) && $render){ // don't link movies $noLink = true; }else{ @@ -1093,7 +1098,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $ret .= ' />'; - }elseif($mime == 'video/webm' || $mime == 'video/ogg' || $mime == 'video/mp4' ){ + }elseif(media_supportedav($mime, 'video')){ // first get the $title if (!is_null($title)) { $title = $this->_xmlEntities($title); @@ -1114,7 +1119,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { //add video(s) $ret .= $this->_video($src, $width, $height, $att); - }elseif($mime == 'audio/ogg' || $mime == 'audio/mpeg' || $mime == 'audio/wav' ){ + }elseif(media_supportedav($mime, 'audio')){ // first get the $title if (!is_null($title)) { $title = $this->_xmlEntities($title); @@ -1277,6 +1282,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * @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