diff options
Diffstat (limited to 'inc/parser')
-rw-r--r-- | inc/parser/handler.php | 10 | ||||
-rw-r--r-- | inc/parser/renderer.php | 2 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 38 |
3 files changed, 28 insertions, 22 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php index fde538515..58eed0c34 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -11,6 +11,9 @@ class Doku_Handler { var $status = array( 'section' => FALSE, + 'section_edit_start' => -1, + 'section_edit_level' => 1, + 'section_edit_title' => '' ); var $rewriteBlocks = TRUE; @@ -29,6 +32,8 @@ class Doku_Handler { if ( $this->status['section'] ) { $last_call = end($this->calls); array_push($this->calls,array('section_close',array(), $last_call[2])); + array_push($this->calls,array('section_edit',array($this->status['section_edit_start'], 0, + $this->status['section_edit_level'], $this->status['section_edit_title']), $last_call[2])); } if ( $this->rewriteBlocks ) { @@ -90,6 +95,11 @@ class Doku_Handler { if ($this->status['section']) $this->_addCall('section_close',array(),$pos); + $this->_addCall('section_edit',array($this->status['section_edit_start'], $pos-1, $this->status['section_edit_level'], $this->status['section_edit_title']), $pos); + $this->status['section_edit_start'] = $pos; + $this->status['section_edit_level'] = $level; + $this->status['section_edit_title'] = $title; + $this->_addCall('header',array($title,$level,$pos), $pos); $this->_addCall('section_open',array($level),$pos); diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 238abdeff..931be6ceb 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -43,6 +43,8 @@ class Doku_Renderer { function header($text, $level, $pos) {} + function section_edit($start, $end, $level, $name) {} + function section_open($level) {} function section_close() {} 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> |