コード例 #1
0
ファイル: xhtml.php プロジェクト: sawachan/dokuwiki
 /**
  * Embed audio in HTML
  *
  * @author Anika Henke <*****@*****.**>
  *
  * @param string $src       - ID of audio to embed
  * @param array  $atts      - additional attributes for the <audio> tag
  * @return string
  */
 function _audio($src, $atts = array())
 {
     $files = array();
     $isExternal = media_isexternal($src);
     if ($isExternal) {
         // take direct source for external files
         list(, $srcMime) = mimetype($src);
         $files[$srcMime] = $src;
     } else {
         // prepare alternative formats
         $extensions = array('ogg', 'mp3', 'wav');
         $files = media_alternativefiles($src, $extensions);
     }
     $out = '';
     // open audio tag
     $out .= '<audio ' . buildAttributes($atts) . ' controls="controls">' . NL;
     $fallback = '';
     // output source for each alternative audio format
     foreach ($files as $mime => $file) {
         if ($isExternal) {
             $url = $file;
             $linkType = 'externalmedia';
         } else {
             $url = ml($file, '', true, '&');
             $linkType = 'internalmedia';
         }
         $title = $atts['title'] ? $atts['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->{$linkType}($file, $title, null, null, null, $cache = null, $linking = 'linkonly', $return = true);
     }
     // finish
     $out .= $fallback;
     $out .= '</audio>' . NL;
     return $out;
 }
コード例 #2
0
 /**
  * Embed audio in HTML
  *
  * @author Anika Henke <*****@*****.**>
  *
  * @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 = $atts['title'] ? $atts['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;
 }