1<?php 2/** 3 * Renderer for XHTML output 4 * 5 * @author Harry Fuecks <hfuecks@gmail.com> 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8// must be run within Dokuwiki 9if(!defined('DOKU_INC')) die(); 10 11// we inherit from the XHTML renderer instead directly of the base renderer 12require_once DOKU_INC.'inc/parser/xhtml.php'; 13 14/** 15 * The Renderer 16 */ 17class renderer_plugin_s5 extends Doku_Renderer_xhtml { 18 var $slideopen = false; 19 var $base=''; 20 var $tpl=''; 21 22 /** 23 * the format we produce 24 */ 25 function getFormat(){ 26 // this should be 's5' usally, but we inherit from the xhtml renderer 27 // and produce XHTML as well, so we can gain magically compatibility 28 // by saying we're the 'xhtml' renderer here. 29 return 'xhtml'; 30 } 31 32 33 /** 34 * Initialize the rendering 35 */ 36 function document_start() { 37 global $ID; 38 39 // call the parent 40 parent::document_start(); 41 42 // store the content type headers in metadata 43 $headers = array( 44 'Content-Type' => 'text/html; charset=utf-8' 45 ); 46 p_set_metadata($ID,array('format' => array('s5' => $headers) )); 47 $this->base = DOKU_BASE.'lib/plugins/s5/ui/'; 48 $this->tpl = isset($_GET['s5theme'])?$_GET['s5theme']:$this->getConf('template'); 49 $this->tpl = preg_replace('/[^a-z0-9_-]+/', '', $this->tpl); // clean user provided path 50 } 51 52 /** 53 * Print the header of the page 54 * 55 * Gets called when the very first H1 header is discovered. It includes 56 * all the S5 CSS and JavaScript magic 57 */ 58 function s5_init($title){ 59 global $conf; 60 global $lang; 61 global $INFO; 62 global $ID; 63 64 //throw away any previous content 65 $this->doc = ' 66<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 67 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 68<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$conf['lang'].'" 69 lang="'.$conf['lang'].'" dir="'.$lang['direction'].'"> 70 71<head> 72<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 73<title>'.hsc($title).'</title> 74<!-- metadata --> 75<meta name="generator" content="S5" /> 76<meta name="version" content="S5 1.1" /> 77<!-- configuration parameters --> 78<meta name="defaultView" content="slideshow" /> 79<meta name="controlVis" content="hidden" /> 80<!-- style sheet links --> 81<link rel="stylesheet" href="'.DOKU_BASE.'lib/styles/all.css" type="text/css" media="screen" /> 82<link rel="stylesheet" href="'.DOKU_BASE.'lib/styles/screen.css" type="text/css" media="screen" /> 83<link rel="stylesheet" href="'.$this->base.$this->tpl.'/slides.css" type="text/css" media="projection" id="slideProj" /> 84<link rel="stylesheet" href="'.$this->base.'default/outline.css" type="text/css" media="screen" id="outlineStyle" /> 85<link rel="stylesheet" href="'.$this->base.'default/print.css" type="text/css" media="print" id="slidePrint" /> 86<link rel="stylesheet" href="'.$this->base.'default/opera.css" type="text/css" media="projection" id="operaFix" /> 87<!-- S5 JS --> 88<script src="'.$this->base.'default/slides.js" type="text/javascript"></script> 89</head> 90<body> 91<div class="layout"> 92<div id="controls"><!-- DO NOT EDIT --></div> 93<div id="currentSlide"><!-- DO NOT EDIT --></div> 94<div id="header"></div> 95<div id="footer"> 96<h1>'.tpl_pagetitle($ID, true).'</h1> 97<h2>'.hsc($conf['title']).' • '.strftime($conf['dformat'],$INFO['lastmod']).'</h2> 98</div> 99 100</div> 101<div class="presentation"> 102'; 103 } 104 105 /** 106 * Closes the document 107 */ 108 function document_end(){ 109 // we don't care for footnotes and toc 110 // but cleanup is nice 111 $this->doc = preg_replace('#<p>\s*</p>#','',$this->doc); 112 113 if($this->slideopen){ 114 $this->doc .= '</div>'.DOKU_LF; //close previous slide 115 } 116 $this->doc .= '</div> 117 </body> 118 </html>'; 119 } 120 121 /** 122 * This is what creates new slides 123 * 124 * A new slide is started for each H2 header 125 */ 126 127 public function header($text, $level, $pos, $returnonly = false) { 128 if($level == 1){ 129 if(!$this->slideopen){ 130 $this->s5_init($text); // this is the first slide 131 $level = 2; 132 }else{ 133 return; 134 } 135 } 136 137 if($level == 2){ 138 if($this->slideopen){ 139 $this->doc .= '</div>'.DOKU_LF; //close previous slide 140 } 141 $this->doc .= '<div class="slide">'.DOKU_LF; 142 $this->slideopen = true; 143 } 144 $this->doc .= '<h'.($level-1).'>'; 145 $this->doc .= $this->_xmlEntities($text); 146 $this->doc .= '</h'.($level-1).'>'.DOKU_LF; 147 } 148 149 /** 150 * Top-Level Sections are slides 151 */ 152 function section_open($level) { 153 if($level < 3){ 154 $this->doc .= '<div class="slidecontent">'.DOKU_LF; 155 }else{ 156 $this->doc .= '<div>'.DOKU_LF; 157 } 158 // we don't use it 159 } 160 161 /** 162 * Throw away footnote 163 */ 164 function footnote_close() { 165 // recover footnote into the stack and restore old content 166 $footnote = $this->doc; 167 $this->doc = $this->store; 168 $this->store = ''; 169 } 170 171 /** 172 * No acronyms in a presentation 173 */ 174 function acronym($acronym){ 175 $this->doc .= $this->_xmlEntities($acronym); 176 } 177 178 /** 179 * A line stops the slide and start the handout section 180 */ 181 function hr() { 182 $this->doc .= '</div>'.DOKU_LF; 183 $this->doc .= '<div class="handout">'.DOKU_LF; 184 } 185} 186 187//Setup VIM: ex: et ts=4 enc=utf-8 : 188