1*a876b55bSAndreas Gohr<?php 2*a876b55bSAndreas Gohr/** 3*a876b55bSAndreas Gohr * DokuWiki Plugin dw2pdf (Renderer Component) 4*a876b55bSAndreas Gohr * 5*a876b55bSAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6*a876b55bSAndreas Gohr * @author Andreas Gohr <gohr@cosmocode.de> 7*a876b55bSAndreas Gohr */ 8*a876b55bSAndreas Gohr 9*a876b55bSAndreas Gohr// must be run within Dokuwiki 10*a876b55bSAndreas Gohrif (!defined('DOKU_INC')) die(); 11*a876b55bSAndreas Gohr 12*a876b55bSAndreas Gohrif (!defined('DOKU_LF')) define('DOKU_LF', "\n"); 13*a876b55bSAndreas Gohrif (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); 14*a876b55bSAndreas Gohrrequire_once DOKU_INC.'inc/parser/xhtml.php'; 15*a876b55bSAndreas Gohr 16*a876b55bSAndreas Gohrclass renderer_plugin_dw2pdf extends Doku_Renderer_xhtml { 17*a876b55bSAndreas Gohr 18*a876b55bSAndreas Gohr /** 19*a876b55bSAndreas Gohr * Make available as XHTML replacement renderer 20*a876b55bSAndreas Gohr */ 21*a876b55bSAndreas Gohr public function canRender($format){ 22*a876b55bSAndreas Gohr if($format == 'xhtml') return true; 23*a876b55bSAndreas Gohr return false; 24*a876b55bSAndreas Gohr } 25*a876b55bSAndreas Gohr 26*a876b55bSAndreas Gohr // FIXME override any methods of Doku_Renderer_xhtml here 27*a876b55bSAndreas Gohr 28*a876b55bSAndreas Gohr 29*a876b55bSAndreas Gohr /** 30*a876b55bSAndreas Gohr * Simplified header printing with PDF bookmarks 31*a876b55bSAndreas Gohr */ 32*a876b55bSAndreas Gohr function header($text, $level, $pos) { 33*a876b55bSAndreas Gohr if(!$text) return; //skip empty headlines 34*a876b55bSAndreas Gohr 35*a876b55bSAndreas Gohr // add PDF bookmark 36*a876b55bSAndreas Gohr $bmlevel = $this->getConf('maxbookmarks'); 37*a876b55bSAndreas Gohr if($bmlevel && $bmlevel >= $level){ 38*a876b55bSAndreas Gohr $this->doc .= '<bookmark content="'.$this->_xmlEntities($text).'" level="'.($level-1).'" />'; 39*a876b55bSAndreas Gohr } 40*a876b55bSAndreas Gohr 41*a876b55bSAndreas Gohr // print header 42*a876b55bSAndreas Gohr $this->doc .= DOKU_LF."<h$level>"; 43*a876b55bSAndreas Gohr $this->doc .= $this->_xmlEntities($text); 44*a876b55bSAndreas Gohr $this->doc .= "</h$level>".DOKU_LF; 45*a876b55bSAndreas Gohr } 46*a876b55bSAndreas Gohr 47*a876b55bSAndreas Gohr} 48*a876b55bSAndreas Gohr 49