Skip to content

Commit

Permalink
fix last merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lisps committed Feb 17, 2014
1 parent d90a79c commit df0e21b
Showing 1 changed file with 90 additions and 2 deletions.
92 changes: 90 additions & 2 deletions inc/parser/xhtml.php
Expand Up @@ -1272,6 +1272,95 @@ function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $rende

return $link;
}


/**
* Embed video(s) in HTML
*
* @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
*/
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;
}

/**
* 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;
}

/**
* _getLastMediaRevisionAt is a helperfunction to internalmedia() and _media()
Expand All @@ -1280,15 +1369,14 @@ function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $rende
* @author lisps
* @param string $media_id
* @access protected
* @return string revision ('' for current)
* @return string revision ('' for current)
*/
function _getLastMediaRevisionAt($media_id){
if(!$this->date_at || media_isexternal($media_id)) return '';
$pagelog = new MediaChangeLog($media_id);
return $pagelog->getLastRevisionAt($this->date_at);
}


}

//Setup VIM: ex: et ts=4 :

0 comments on commit df0e21b

Please sign in to comment.