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