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