* @author Andreas Gohr */ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); // we inherit from the XHTML renderer instead directly of the base renderer require_once DOKU_INC.'inc/parser/xhtml.php'; /** * The Renderer */ class renderer_plugin_s5reloaded extends Doku_Renderer_xhtml { var $slideopen = false; var $notesopen = false; var $base=''; var $tpl=''; /** * the format we produce */ function getFormat(){ // this should be 's5' usally, but we inherit from the xhtml renderer // and produce XHTML as well, so we can gain magically compatibility // by saying we're the 'xhtml' renderer here. return 'xhtml'; } /** * Initialize the rendering */ function document_start() { global $ID; // call the parent parent::document_start(); // store the content type headers in metadata $headers = array( 'Content-Type' => 'text/html; charset=utf-8' ); p_set_metadata($ID,array('format' => array('s5reloaded' => $headers) )); $this->base = DOKU_MEDIA.'lib/plugins/s5reloaded/ui/'; /* $this->tpl = $this->getConf('template'); */ $this->tpl = isset($_GET['s5theme'])?$_GET['s5theme']:$this->getConf('template'); } /** * Print the header of the page * * Gets called when the very first H1 header is discovered. It includes * all the S5 CSS and JavaScript magic */ function s5reloaded_init($title){ global $conf; global $lang; global $INFO; global $ID; //throw away any previous content $this->doc = ' '.hsc($title).'
'; } /** * Closes the document */ function document_end(){ // we don't care for footnotes and toc // but cleanup is nice $this->doc = preg_replace('#

\s*

#','',$this->doc); if($this->slideopen){ $this->doc .= '
'.DOKU_LF; //close previous slide } if($this->notesopen){ $this->doc .= ''.DOKU_LF; //close notes $this->notesopen = false; } $this->doc .= ' '; } /** * This is what creates new slides * * A new slide is started for each H2 header */ function header($text, $level, $pos) { if($level == 1){ if(!$this->slideopen){ $this->s5reloaded_init($text); // this is the first slide $level = 2; }else{ return; } } if($level == 2){ $this->last_h1 = $text; } if($level > 1){ //if($level == 2){ if($this->notesopen){ $this->doc .= ''.DOKU_LF; //close notes $this->notesopen = false; } $this->doc .= '
'.DOKU_LF; $this->slideopen = true; } $this->doc .= '

'; if ($this->last_h1 && $level > 2) { $this->doc .= $this->_xmlEntities($this->last_h1.": ".$text); $this->doc .= '

'.DOKU_LF; /* $this->doc .= ' '; $this->doc .= ''.DOKU_LF; $this->doc .= ''; $this->doc .= $text; $this->doc .= ''.DOKU_LF;*/ } else { $this->doc .= $this->_xmlEntities($text); $this->doc .= ''.DOKU_LF; } } /** * Top-Level Sections are slides */ function section_open($level) { // if($level < 3){ // $this->doc .= '
'.DOKU_LF; // }else{ // $this->doc .= '
'.DOKU_LF; // } // we don't use it } /** * Throw away footnote */ function footnote_close() { // recover footnote into the stack and restore old content $footnote = $this->doc; $this->doc = $this->store; $this->store = ''; } /** * No acronyms in a presentation */ function acronym($acronym){ $this->doc .= $this->_xmlEntities($acronym); } /** * A line stops the slide and start the handout section */ function hr() { $this->doc .= '
'.DOKU_LF; $this->notesopen = true; } /** * Renders internal and external media */ function _media ($src, $title=NULL, $align=NULL, $width=NULL, $height=NULL, $cache=NULL, $render = true) { $ret = ''; list($ext,$mime,$dl) = mimetype($src); if(substr($mime,0,5) == 'image'){ // first get the $title if (!is_null($title)) { $title = $this->_xmlEntities($title); }elseif($ext == 'jpg' || $ext == 'jpeg'){ //try to use the caption from IPTC/EXIF require_once(DOKU_INC.'inc/JpegMeta.php'); $jpeg =& new JpegMeta(mediaFN($src)); if($jpeg !== false) $cap = $jpeg->getTitle(); if($cap){ $title = $this->_xmlEntities($cap); } } if (!$render) { // if the picture is not supposed to be rendered // return the title of the picture if (!$title) { // just show the sourcename $title = $this->_xmlEntities(basename(noNS($src))); } return $title; } //add image tag $ret .= '_xmlEntities($width).'"'; if ( !is_null($height) ) $ret .= ' height="'.$this->_xmlEntities($height).'"'; $ret .= ' />'; }elseif($mime == 'application/x-shockwave-flash'){ if (!$render) { // if the flash is not supposed to be rendered // return the title of the flash if (!$title) { // just show the sourcename $title = basename(noNS($src)); } return $this->_xmlEntities($title); } $att = array(); $att['class'] = "media$align"; if($align == 'right') $att['align'] = 'right'; if($align == 'left') $att['align'] = 'left'; $ret .= html_flashobject(ml($src,array('cache'=>$cache)),$width,$height, array('quality' => 'high'), null, $att, $this->_xmlEntities($title)); }elseif($title){ // well at least we have a title to display $ret .= $this->_xmlEntities($title); }else{ // just show the sourcename $ret .= $this->_xmlEntities(basename(noNS($src))); } return $ret; } } //Setup VIM: ex: et ts=4 enc=utf-8 :