1<?php 2if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 3 4require_once DOKU_INC . 'inc/parser/xhtml.php'; 5 6/** 7* The summary XHTML form selects either up to the first two paragraphs 8* it find in a page or the first section (whichever comes first) 9* It strips out the table of contents if one exists 10* Section divs are not used - everything should be nested in a single 11* div with CSS class "page" 12* Headings have their a name link removed and section editing links 13* removed 14* It also attempts to capture the first heading in a page for 15* use as the title of the page. 16*/ 17class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml { 18 19 // Namespace these variables to 20 // avoid clashes with parent classes 21 var $sum_paragraphs = 0; 22 var $sum_capture = TRUE; 23 var $sum_inSection = FALSE; 24 var $sum_summary = ''; 25 var $sum_pageTitle = FALSE; 26 27 function document_start() { 28 $this->doc .= DOKU_LF.'<div>'.DOKU_LF; 29 } 30 31 function document_end() { 32 $this->doc = $this->sum_summary; 33 $this->doc .= DOKU_LF.'</div>'.DOKU_LF; 34 } 35 36 function toc_open() { 37 $this->sum_summary .= $this->doc; 38 } 39 40 function toc_close() { 41 $this->doc = ''; 42 } 43 44 function header($text, $level, $pos) { 45 if ( !$this->sum_pageTitle ) { 46 $this->info['sum_pagetitle'] = $text; 47 $this->sum_pageTitle = TRUE; 48 } 49 $this->doc .= DOKU_LF.'<h'.$level.'>'; 50 $this->doc .= $this->_xmlEntities($text); 51 $this->doc .= "</h$level>".DOKU_LF; 52 } 53 54 function section_open($level) { 55 if ( $this->sum_capture ) { 56 $this->sum_inSection = TRUE; 57 } 58 } 59 60 function section_close() { 61 if ( $this->sum_capture && $this->sum_inSection ) { 62 $this->sum_summary .= $this->doc; 63 $this->sum_capture = FALSE; 64 } 65 } 66 67 function p_open() { 68 if ( $this->sum_capture && $this->sum_paragraphs < 2 ) { 69 $this->sum_paragraphs++; 70 } 71 parent :: p_open(); 72 } 73 74 function p_close() { 75 parent :: p_close(); 76 if ( $this->sum_capture && $this->sum_paragraphs >= 2 ) { 77 $this->sum_summary .= $this->doc; 78 $this->sum_capture = FALSE; 79 } 80 } 81 82} 83 84 85//Setup VIM: ex: et ts=2 enc=utf-8 : 86