From 35dae8b08b9fb243b06bc972c20a0b00a8d97f0b Mon Sep 17 00:00:00 2001 From: Ben Coburn Date: Mon, 22 May 2006 08:00:04 +0200 Subject: 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 --- inc/parser/handler.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'inc/parser/handler.php') 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); -- cgit v1.2.3