1<?php 2/** 3 * Plugin Tab: Inserts a pagebreak into the document for every <pagebreak> it encounters. Based on the tab plugin by Tim Skoch <timskoch@hotmail.com> 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Jonathan McBride and Chris Sturm - The University of Texas at Austin 7 * 8 */ 9 10if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 12require_once(DOKU_PLUGIN.'syntax.php'); 13 14/** 15 * All DokuWiki plugins to extend the parser/rendering mechanism 16 * need to inherit from this class 17 */ 18class syntax_plugin_pagebreak extends DokuWiki_Syntax_Plugin { 19 20 /** 21 * What kind of syntax are we? 22 */ 23 function getType(){ 24 return 'substition'; 25 } 26 27 28 /** 29 * Where to sort in? 30 */ 31 function getSort(){ 32 return 999; 33 } 34 35 36 /** 37 * Connect pattern to lexer 38 */ 39 function connectTo($mode) { 40 $this->Lexer->addSpecialPattern('<pagebreak>',$mode,'plugin_pagebreak'); 41 } 42 43 /** 44 * Handle the match 45 */ 46 function handle($match, $state, $pos, Doku_Handler $handler){ 47 switch ($state) { 48 case DOKU_LEXER_ENTER : 49 break; 50 case DOKU_LEXER_MATCHED : 51 break; 52 case DOKU_LEXER_UNMATCHED : 53 break; 54 case DOKU_LEXER_EXIT : 55 break; 56 case DOKU_LEXER_SPECIAL : 57 break; 58 } 59 return array(); 60 } 61 62 /** 63 * Create output 64 */ 65 function render($mode, Doku_Renderer $renderer, $data) { 66 if($mode == 'xhtml'){ 67 if(is_a($renderer,'renderer_plugin_dw2pdf')){ 68 $renderer->doc .= "<pagebreak />"; 69 } else { 70 $renderer->doc .= "<br style=\"page-break-after:always;\">"; 71 } 72 return true; 73 } else if ($mode == 'odt') { 74 $renderer->pagebreak(); 75 return true; 76 } 77 return false; 78 } 79} 80 81