10f57655dSAndreas Gohr<?php 20f57655dSAndreas Gohr 30f57655dSAndreas Gohr/** 40f57655dSAndreas Gohr * The Renderer 50f57655dSAndreas Gohr */ 6*f30cb4bfSAndreas Gohrclass renderer_plugin_s5 extends Doku_Renderer_xhtml 7*f30cb4bfSAndreas Gohr{ 8*f30cb4bfSAndreas Gohr protected $slideopen = false; 9*f30cb4bfSAndreas Gohr protected $base = ''; 10*f30cb4bfSAndreas Gohr protected $tpl = ''; 110f57655dSAndreas Gohr 120f57655dSAndreas Gohr /** 13a71242cdSAndreas Gohr * the format we produce 14a71242cdSAndreas Gohr */ 15*f30cb4bfSAndreas Gohr public function getFormat() 16*f30cb4bfSAndreas Gohr { 17a71242cdSAndreas Gohr // this should be 's5' usally, but we inherit from the xhtml renderer 18a71242cdSAndreas Gohr // and produce XHTML as well, so we can gain magically compatibility 19a71242cdSAndreas Gohr // by saying we're the 'xhtml' renderer here. 20a71242cdSAndreas Gohr return 'xhtml'; 21a71242cdSAndreas Gohr } 22a71242cdSAndreas Gohr 23a71242cdSAndreas Gohr 24a71242cdSAndreas Gohr /** 250f57655dSAndreas Gohr * Initialize the rendering 260f57655dSAndreas Gohr */ 27*f30cb4bfSAndreas Gohr public function document_start() 28*f30cb4bfSAndreas Gohr { 29893eb574SAndreas Gohr global $ID; 30893eb574SAndreas Gohr 310f57655dSAndreas Gohr // call the parent 320f57655dSAndreas Gohr parent::document_start(); 330f57655dSAndreas Gohr 34893eb574SAndreas Gohr // store the content type headers in metadata 35*f30cb4bfSAndreas Gohr $headers = [ 36893eb574SAndreas Gohr 'Content-Type' => 'text/html; charset=utf-8' 37*f30cb4bfSAndreas Gohr ]; 38*f30cb4bfSAndreas Gohr p_set_metadata($ID, ['format' => ['s5' => $headers] ]); 390f57655dSAndreas Gohr $this->base = DOKU_BASE . 'lib/plugins/s5/ui/'; 40*f30cb4bfSAndreas Gohr $this->tpl = $_GET['s5theme'] ?? $this->getConf('template'); 4125ce19eaSAndreas Gohr $this->tpl = preg_replace('/[^a-z0-9_-]+/', '', $this->tpl); // clean user provided path 420f57655dSAndreas Gohr } 430f57655dSAndreas Gohr 440f57655dSAndreas Gohr /** 450f57655dSAndreas Gohr * Print the header of the page 460f57655dSAndreas Gohr * 470f57655dSAndreas Gohr * Gets called when the very first H1 header is discovered. It includes 480f57655dSAndreas Gohr * all the S5 CSS and JavaScript magic 490f57655dSAndreas Gohr */ 50*f30cb4bfSAndreas Gohr protected function s5_init($title) 51*f30cb4bfSAndreas Gohr { 520f57655dSAndreas Gohr global $conf; 530f57655dSAndreas Gohr global $lang; 540f57655dSAndreas Gohr global $INFO; 550f57655dSAndreas Gohr global $ID; 560f57655dSAndreas Gohr 570f57655dSAndreas Gohr //throw away any previous content 580f57655dSAndreas Gohr $this->doc = ' 590f57655dSAndreas Gohr<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 600f57655dSAndreas Gohr "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 610f57655dSAndreas Gohr<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $conf['lang'] . '" 620f57655dSAndreas Gohr lang="' . $conf['lang'] . '" dir="' . $lang['direction'] . '"> 630f57655dSAndreas Gohr 640f57655dSAndreas Gohr<head> 650f57655dSAndreas Gohr<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 660f57655dSAndreas Gohr<title>' . hsc($title) . '</title> 670f57655dSAndreas Gohr<!-- metadata --> 680f57655dSAndreas Gohr<meta name="generator" content="S5" /> 690f57655dSAndreas Gohr<meta name="version" content="S5 1.1" /> 700f57655dSAndreas Gohr<!-- configuration parameters --> 710f57655dSAndreas Gohr<meta name="defaultView" content="slideshow" /> 720f57655dSAndreas Gohr<meta name="controlVis" content="hidden" /> 730f57655dSAndreas Gohr<!-- style sheet links --> 74703886d1SAnika Henke<link rel="stylesheet" href="' . DOKU_BASE . 'lib/styles/all.css" type="text/css" media="screen" /> 758fbf9965Saliva<link rel="stylesheet" href="' . DOKU_BASE . 'lib/styles/screen.css" type="text/css" media="screen" /> 760f57655dSAndreas Gohr<link rel="stylesheet" href="' . $this->base . $this->tpl . '/slides.css" type="text/css" media="projection" id="slideProj" /> 770f57655dSAndreas Gohr<link rel="stylesheet" href="' . $this->base . 'default/outline.css" type="text/css" media="screen" id="outlineStyle" /> 780f57655dSAndreas Gohr<link rel="stylesheet" href="' . $this->base . 'default/print.css" type="text/css" media="print" id="slidePrint" /> 790f57655dSAndreas Gohr<link rel="stylesheet" href="' . $this->base . 'default/opera.css" type="text/css" media="projection" id="operaFix" /> 800f57655dSAndreas Gohr<!-- S5 JS --> 810f57655dSAndreas Gohr<script src="' . $this->base . 'default/slides.js" type="text/javascript"></script> 820f57655dSAndreas Gohr</head> 830f57655dSAndreas Gohr<body> 840f57655dSAndreas Gohr<div class="layout"> 850f57655dSAndreas Gohr<div id="controls"><!-- DO NOT EDIT --></div> 860f57655dSAndreas Gohr<div id="currentSlide"><!-- DO NOT EDIT --></div> 870f57655dSAndreas Gohr<div id="header"></div> 880f57655dSAndreas Gohr<div id="footer"> 89fdedbf48SAndreas Gohr<h1>' . tpl_pagetitle($ID, true) . '</h1> 90a71242cdSAndreas Gohr<h2>' . hsc($conf['title']) . ' • ' . strftime($conf['dformat'], $INFO['lastmod']) . '</h2> 910f57655dSAndreas Gohr</div> 920f57655dSAndreas Gohr 930f57655dSAndreas Gohr</div> 940f57655dSAndreas Gohr<div class="presentation"> 950f57655dSAndreas Gohr'; 960f57655dSAndreas Gohr } 970f57655dSAndreas Gohr 980f57655dSAndreas Gohr /** 990f57655dSAndreas Gohr * Closes the document 1000f57655dSAndreas Gohr */ 101*f30cb4bfSAndreas Gohr public function document_end() 102*f30cb4bfSAndreas Gohr { 1030f57655dSAndreas Gohr // we don't care for footnotes and toc 1040f57655dSAndreas Gohr // but cleanup is nice 1050f57655dSAndreas Gohr $this->doc = preg_replace('#<p>\s*</p>#', '', $this->doc); 1060f57655dSAndreas Gohr 1070f57655dSAndreas Gohr if ($this->slideopen) { 1080f57655dSAndreas Gohr $this->doc .= '</div>' . DOKU_LF; //close previous slide 1090f57655dSAndreas Gohr } 1100f57655dSAndreas Gohr $this->doc .= '</div> 1110f57655dSAndreas Gohr </body> 1120f57655dSAndreas Gohr </html>'; 1130f57655dSAndreas Gohr } 1140f57655dSAndreas Gohr 1150f57655dSAndreas Gohr /** 1160f57655dSAndreas Gohr * This is what creates new slides 1170f57655dSAndreas Gohr * 1180f57655dSAndreas Gohr * A new slide is started for each H2 header 1190f57655dSAndreas Gohr */ 120*f30cb4bfSAndreas Gohr public function header($text, $level, $pos, $returnonly = false) 121*f30cb4bfSAndreas Gohr { 1220f57655dSAndreas Gohr if ($level == 1) { 1230f57655dSAndreas Gohr if (!$this->slideopen) { 1240f57655dSAndreas Gohr $this->s5_init($text); // this is the first slide 1250f57655dSAndreas Gohr $level = 2; 1260f57655dSAndreas Gohr } else { 1270f57655dSAndreas Gohr return; 1280f57655dSAndreas Gohr } 1290f57655dSAndreas Gohr } 1300f57655dSAndreas Gohr 1310f57655dSAndreas Gohr if ($level == 2) { 1320f57655dSAndreas Gohr if ($this->slideopen) { 1330f57655dSAndreas Gohr $this->doc .= '</div>' . DOKU_LF; //close previous slide 1340f57655dSAndreas Gohr } 1350f57655dSAndreas Gohr $this->doc .= '<div class="slide">' . DOKU_LF; 1360f57655dSAndreas Gohr $this->slideopen = true; 1370f57655dSAndreas Gohr } 1380f57655dSAndreas Gohr $this->doc .= '<h' . ($level - 1) . '>'; 1390f57655dSAndreas Gohr $this->doc .= $this->_xmlEntities($text); 1400f57655dSAndreas Gohr $this->doc .= '</h' . ($level - 1) . '>' . DOKU_LF; 1410f57655dSAndreas Gohr } 1420f57655dSAndreas Gohr 1430f57655dSAndreas Gohr /** 1440f57655dSAndreas Gohr * Top-Level Sections are slides 1450f57655dSAndreas Gohr */ 146*f30cb4bfSAndreas Gohr public function section_open($level) 147*f30cb4bfSAndreas Gohr { 1480f57655dSAndreas Gohr if ($level < 3) { 1490f57655dSAndreas Gohr $this->doc .= '<div class="slidecontent">' . DOKU_LF; 1500f57655dSAndreas Gohr } else { 1510f57655dSAndreas Gohr $this->doc .= '<div>' . DOKU_LF; 1520f57655dSAndreas Gohr } 1530f57655dSAndreas Gohr // we don't use it 1540f57655dSAndreas Gohr } 1550f57655dSAndreas Gohr 1560f57655dSAndreas Gohr /** 1570f57655dSAndreas Gohr * Throw away footnote 1580f57655dSAndreas Gohr */ 159*f30cb4bfSAndreas Gohr public function footnote_close() 160*f30cb4bfSAndreas Gohr { 1610f57655dSAndreas Gohr $this->doc = $this->store; 1620f57655dSAndreas Gohr $this->store = ''; 1630f57655dSAndreas Gohr } 1640f57655dSAndreas Gohr 1650f57655dSAndreas Gohr /** 1660f57655dSAndreas Gohr * No acronyms in a presentation 1670f57655dSAndreas Gohr */ 168*f30cb4bfSAndreas Gohr public function acronym($acronym) 169*f30cb4bfSAndreas Gohr { 1700f57655dSAndreas Gohr $this->doc .= $this->_xmlEntities($acronym); 1710f57655dSAndreas Gohr } 1720f57655dSAndreas Gohr 1730f57655dSAndreas Gohr /** 1740f57655dSAndreas Gohr * A line stops the slide and start the handout section 1750f57655dSAndreas Gohr */ 176*f30cb4bfSAndreas Gohr public function hr() 177*f30cb4bfSAndreas Gohr { 1780f57655dSAndreas Gohr $this->doc .= '</div>' . DOKU_LF; 1790f57655dSAndreas Gohr $this->doc .= '<div class="handout">' . DOKU_LF; 1800f57655dSAndreas Gohr } 1810f57655dSAndreas Gohr} 182