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