1<?php 2 3class renderer_plugin_bez_xhtmlmail extends Doku_Renderer_xhtml { 4 5 /** @var array Settings, control the behavior of the renderer */ 6 public $info = array( 7 'cache' => true, // may the rendered result cached? 8 'toc' => true, // render the TOC? 9 'img' => array(), //images to attach in mail 10 ); 11 12 /** 13 * Our own format 14 * 15 * @return string 16 */ 17 function getFormat() { 18 return 'bez_xhtmlmail'; 19 } 20 21 /** 22 * Renders internal and external media 23 * 24 * @author Andreas Gohr <andi@splitbrain.org> 25 * @param string $src media ID 26 * @param string $title descriptive text 27 * @param string $align left|center|right 28 * @param int $width width of media in pixel 29 * @param int $height height of media in pixel 30 * @param string $cache cache|recache|nocache 31 * @param bool $render should the media be embedded inline or just linked 32 * @return string 33 */ 34 public function _media($src, $title = null, $align = null, $width = null, 35 $height = null, $cache = null, $render = true) { 36 37 $ret = ''; 38 39 list($ext, $mime) = mimetype($src); 40 if(substr($mime, 0, 5) == 'image') { 41 // first get the $title 42 if(!is_null($title)) { 43 $title = $this->_xmlEntities($title); 44 } elseif($ext == 'jpg' || $ext == 'jpeg') { 45 //try to use the caption from IPTC/EXIF 46 require_once(DOKU_INC.'inc/JpegMeta.php'); 47 $jpeg = new JpegMeta(mediaFN($src)); 48 if($jpeg !== false) $cap = $jpeg->getTitle(); 49 if(!empty($cap)) { 50 $title = $this->_xmlEntities($cap); 51 } 52 } 53 if(!$render) { 54 // if the picture is not supposed to be rendered 55 // return the title of the picture 56 if($title === null || $title === "") { 57 // just show the sourcename 58 $title = $this->_xmlEntities(\dokuwiki\Utf8\PhpString::basename(noNS($src))); 59 } 60 return $title; 61 } 62 //add image tag 63 $ret .= '<img src="@MEDIA(' . $src . ')@"'; 64 $ret .= ' class="media'.$align.'"'; 65 66 if($title) { 67 $ret .= ' title="'.$title.'"'; 68 $ret .= ' alt="'.$title.'"'; 69 } else { 70 $ret .= ' alt=""'; 71 } 72 73 if(!is_null($width)) 74 $ret .= ' width="'.$this->_xmlEntities($width).'"'; 75 76 if(!is_null($height)) 77 $ret .= ' height="'.$this->_xmlEntities($height).'"'; 78 79 $ret .= ' />'; 80 81 } elseif(media_supportedav($mime, 'video') || media_supportedav($mime, 'audio')) { 82 // first get the $title 83 $title = !is_null($title) ? $title : false; 84 if(!$render) { 85 // if the file is not supposed to be rendered 86 // return the title of the file (just the sourcename if there is no title) 87 return $this->_xmlEntities($title ? $title : \dokuwiki\Utf8\PhpString::basename(noNS($src))); 88 } 89 90 $att = array(); 91 $att['class'] = "media$align"; 92 if($title) { 93 $att['title'] = $title; 94 } 95 96 if(media_supportedav($mime, 'video')) { 97 //add video 98 $ret .= $this->_video($src, $width, $height, $att); 99 } 100 if(media_supportedav($mime, 'audio')) { 101 //add audio 102 $ret .= $this->_audio($src, $att); 103 } 104 105 } elseif($mime == 'application/x-shockwave-flash') { 106 if(!$render) { 107 // if the flash is not supposed to be rendered 108 // return the title of the flash 109 if(!$title) { 110 // just show the sourcename 111 $title = \dokuwiki\Utf8\PhpString::basename(noNS($src)); 112 } 113 return $this->_xmlEntities($title); 114 } 115 116 $att = array(); 117 $att['class'] = "media$align"; 118 if($align == 'right') $att['align'] = 'right'; 119 if($align == 'left') $att['align'] = 'left'; 120 $ret .= html_flashobject( 121 ml($src, array('cache' => $cache), true, '&'), $width, $height, 122 array('quality' => 'high'), 123 null, 124 $att, 125 $this->_xmlEntities($title) 126 ); 127 } elseif($title) { 128 // well at least we have a title to display 129 $ret .= $this->_xmlEntities($title); 130 } else { 131 // just show the sourcename 132 $ret .= $this->_xmlEntities(\dokuwiki\Utf8\PhpString::basename(noNS($src))); 133 } 134 135 return $ret; 136 } 137}