summaryrefslogtreecommitdiff
path: root/inc/parser
diff options
context:
space:
mode:
authorAnika Henke <anika@selfthinker.org>2013-08-04 10:35:00 +0100
committerAnika Henke <anika@selfthinker.org>2013-08-04 10:35:00 +0100
commitf50634f0c2d6669655b684449d5a6ef44e5ca3f1 (patch)
tree8cef6d79015dc903c50a4efde63f2dbc8833434c /inc/parser
parent6d4af72aa6e7a34b426f494eedb8a93cf2ce097a (diff)
downloadrpg-f50634f0c2d6669655b684449d5a6ef44e5ca3f1.tar.gz
rpg-f50634f0c2d6669655b684449d5a6ef44e5ca3f1.tar.bz2
refactored audio/video code, removed wrong link around audio
Diffstat (limited to 'inc/parser')
-rw-r--r--inc/parser/xhtml.php45
1 files changed, 28 insertions, 17 deletions
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 <video> tag
+ * @return string
*/
function _video($src,$width,$height,$atts=null){
@@ -1296,23 +1302,25 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$posterUrl = ml(reset($poster),array('cache'=>$cache),true,'&');
}
+ $out = '';
// open video tag
- $this->doc .= '<video '.buildAttributes($atts).' controls="controls"';
- if ($posterUrl) $this->doc .= ' poster="'.$posterUrl.'"';
- $this->doc .= '>'.NL;
+ $out .= '<video '.buildAttributes($atts).' controls="controls"';
+ if ($posterUrl) $out .= ' poster="'.$posterUrl.'"';
+ $out .= '>'.NL;
// 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)));
- $this->doc .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL;
+ $out .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL;
// alternative content (just a link to the file)
- $this->internalmedia($file, $title, NULL, NULL, NULL, $cache=NULL, $linking='linkonly');
+ $out .= $this->internalmedia($file, $title, NULL, NULL, NULL, $cache=NULL, $linking='linkonly', $return=true);
}
// finish
- $this->doc .= '</video>'.NL;
+ $out .= '</video>'.NL;
+ return $out;
}
/**
@@ -1322,6 +1330,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @param string $src - ID of audio to embed
* @param array $atts - additional attributes for the <audio> tag
+ * @return string
*/
function _audio($src,$atts=null){
@@ -1329,21 +1338,23 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$extensions = array('ogg', 'mp3', 'wav');
$alternatives = media_alternativefiles($src, $extensions);
+ $out = '';
// open audio tag
- $this->doc .= '<audio '.buildAttributes($atts).' controls="controls">'.NL;
+ $out .= '<audio '.buildAttributes($atts).' controls="controls">'.NL;
// 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)));
- $this->doc .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL;
+ $out .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL;
// alternative content (just a link to the file)
- $this->internalmedia($file, $title, NULL, NULL, NULL, $cache=NULL, $linking='linkonly');
+ $out .= $this->internalmedia($file, $title, NULL, NULL, NULL, $cache=NULL, $linking='linkonly', $return=true);
}
// finish
- $this->doc .= '</audio>'.NL;
+ $out .= '</audio>'.NL;
+ return $out;
}
}