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_twcheckliste 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 'twcheckliste' 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('twcheckliste' => $headers) )); 47 $this->base = DOKU_BASE.'lib/plugins/twcheckliste/'; 48 $this->tpl = $this->getConf('template'); 49 } 50 51 /** 52 * Print the header of the page 53 * 54 * Gets called when the very first H1 header is discovered. It includes 55 * all the S5 CSS and JavaScript magic 56 */ 57 function twcheckliste_init($title){ 58 global $conf; 59 global $lang; 60 global $INFO; 61 global $ID; 62 63 //throw away any previous content 64 $this->doc = ' 65<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 66 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 67<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$conf['lang'].'" 68 lang="'.$conf['lang'].'" dir="'.$lang['direction'].'"> 69 70<head> 71<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 72<title>'.hsc($title).'</title> 73<link rel="stylesheet" href="'.DOKU_BASE.'lib/styles/style.css" type="text/css" media="screen" /> 74<script src="'.$this->base.'default/slides.js" type="text/javascript"></script> 75</head> 76<body> 77<div class="tw_checkliste_druck"> 78'; 79 } 80 81 /** 82 * Closes the document 83 */ 84 function document_end(){ 85 // we don't care for footnotes and toc 86 // but cleanup is nice 87 $this->doc = preg_replace('#<p>\s*</p>#','',$this->doc); 88 89 if($this->slideopen){ 90 $this->doc .= '</div>'.DOKU_LF; //close previous slide 91 } 92 $this->doc .= '</div> 93 </body> 94 </html>'; 95 } 96 97 /** 98 * This is what creates new slides 99 * 100 * A new slide is started for each H2 header 101 */ 102 function header($text, $level, $pos) { 103 104 if($level == 1){ 105 if(!$this->slideopen){ 106 $this->twcheckliste_init($text); // this is the first slide 107 $level = 2; 108 }else{ 109 return; 110 } 111 } 112 113 if($level == 2){ 114 if($this->slideopen){ 115 $this->doc .= '</div>'.DOKU_LF; //close previous slide 116 } 117 $this->doc .= '<div class="slide">'.DOKU_LF; 118 $this->slideopen = true; 119 } 120 $this->doc .= '<h'.($level-1).'>'; 121 $this->doc .= $this->_xmlEntities($text); 122 $this->doc .= '</h'.($level-1).'>'.DOKU_LF; 123 } 124 125 /** 126 * Top-Level Sections are slides 127 */ 128 function section_open($level) { 129 if($level < 3){ 130 $this->doc .= '<div class="slidecontent">'.DOKU_LF; 131 }else{ 132 $this->doc .= '<div>'.DOKU_LF; 133 } 134 // we don't use it 135 } 136 137 /** 138 * Throw away footnote 139 */ 140 function footnote_close() { 141 // recover footnote into the stack and restore old content 142 $footnote = $this->doc; 143 $this->doc = $this->store; 144 $this->store = ''; 145 } 146 147 /** 148 * No acronyms in a presentation 149 */ 150 function acronym($acronym){ 151 $this->doc .= $this->_xmlEntities($acronym); 152 } 153 154 /** 155 * A line stops the slide and start the handout section 156 */ 157 function hr() { 158 $this->doc .= '</div>'.DOKU_LF; 159 $this->doc .= '<div class="handout">'.DOKU_LF; 160 } 161} 162 163//Setup VIM: ex: et ts=4 enc=utf-8 : 164