diff options
author | Ben Coburn <btcoburn@silicodon.net> | 2006-05-22 08:00:04 +0200 |
---|---|---|
committer | Ben Coburn <btcoburn@silicodon.net> | 2006-05-22 08:00:04 +0200 |
commit | 35dae8b08b9fb243b06bc972c20a0b00a8d97f0b (patch) | |
tree | ef27f982d48a7f1c950d67feeeda06888b93e59b /inc/parser/xhtml.php | |
parent | 6c48a22e4902b77e1397e8e9132632b2cf0c7400 (diff) | |
download | rpg-35dae8b08b9fb243b06bc972c20a0b00a8d97f0b.tar.gz rpg-35dae8b08b9fb243b06bc972c20a0b00a8d97f0b.tar.bz2 |
decouple section edit from header in renderer
This patch achieves a partial decoupling of the section edit buttons
from the header syntax. A new 'section_edit' instruction is added to the
instruction list. The default set of these instructions is generated from
the header handler and the _finalize function. A generic 'section_edit'
renderer is now part of the renderer.
To rewrite the section semantics, add, or remove section edit buttons the
header handler and renderer no longer need to be modified. Changes can be
dynamically made to the section edit buttons through the 'PARSER_HANDLER_DONE'
action event. An action plugin that registers this event can then modify
the calls list of the handler object before it is rendered.
In short, this patch makes it possible to change the behavior of the section
edit buttons without having to change unrelated code. This patch should be
entirely transparent to DokuWiki users and cleanly written plugins.
darcs-hash:20060522060004-05dcb-8e6b5215e1b610877f126ca0b9e1e5bc21cc6469.gz
Diffstat (limited to 'inc/parser/xhtml.php')
-rw-r--r-- | inc/parser/xhtml.php | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index dc28423f9..ad981df35 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -52,9 +52,6 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } function document_end() { - // add button for last section if any and more than one - if($this->lastsec > 1) $this->_secedit($this->lastsec,''); - if ( count ($this->footnotes) > 0 ) { $this->doc .= '<div class="footnotes">'.DOKU_LF; @@ -126,13 +123,6 @@ class Doku_Renderer_xhtml extends Doku_Renderer { function header($text, $level, $pos) { global $conf; - //handle section editing - if($level <= $conf['maxseclevel']){ - // add button for last section if any - if($this->lastsec) $this->_secedit($this->lastsec,$pos-1); - // remember current position - $this->lastsec = $pos; - } // create a unique header id $hid = $this->_headerToLink($text,'true'); @@ -152,6 +142,22 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= "</a></h$level>".DOKU_LF; } + /** + * Section edit marker is replaced by an edit button when + * the page is editable. Replacement done in 'inc/html.php#html_secedit' + * + * @author Andreas Gohr <andi@splitbrain.org> + * @author Ben Coburn <btcoburn@silicodon.net> + */ + function section_edit($start, $end, $level, $name) { + global $conf; + + if ($start!=-1 && $level<=$conf['maxseclevel']) { + $name = str_replace('"', '', $name); + $this->doc .= '<!-- SECTION "'.$name.'" ['.$start.'-'.(($end===0)?'':$end).'] -->'; + } + } + function section_open($level) { $this->doc .= "<div class=\"level$level\">".DOKU_LF; } @@ -1040,18 +1046,6 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } /** - * Adds code for section editing button - * - * This is just aplaceholder and gets replace by the button if - * section editing is allowed - * - * @author Andreas Gohr <andi@splitbrain.org> - */ - function _secedit($f, $t){ - $this->doc .= '<!-- SECTION ['.$f.'-'.$t.'] -->'; - } - - /** * Construct a title and handle images in titles * * @author Harry Fuecks <hfuecks@gmail.com> |