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/html.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index d31c97724..09e871b67 100644 --- a/inc/html.php +++ b/inc/html.php @@ -130,23 +130,21 @@ function html_editbutton(){ /** * prints a section editing button + * used as a callback in html_secedit * * @author Andreas Gohr */ -function html_secedit_button($section,$p){ +function html_secedit_button($matches){ global $ID; global $lang; - global $INFO; $secedit = ''; -# if($p) $secedit .= "

\n"; $secedit .= '
'; $secedit .= html_btn('secedit',$ID,'', array('do' => 'edit', 'lines' => "$section", 'rev' => $INFO['lastmod']), - 'post'); + 'post', $name); $secedit .= '
'; -# if($p) $secedit .= "\n

"; return $secedit; } @@ -157,16 +155,14 @@ function html_secedit_button($section,$p){ */ function html_secedit($text,$show=true){ global $INFO; + if($INFO['writable'] && $show && !$INFO['rev']){ - $text = preg_replace('##e', - "html_secedit_button('\\1',true)", - $text); - $text = preg_replace('##e', - "html_secedit_button('\\1',false)", - $text); + $text = preg_replace_callback('##', + 'html_secedit_button', $text); }else{ - $text = preg_replace('##e','',$text); + $text = preg_replace('##','',$text); } + return $text; } @@ -214,16 +210,18 @@ function html_backtomedia_button($params,$akey=''){ /** * Displays a button (using its own form) + * If tooltip exists, the access key tooltip is replaced. * * @author Andreas Gohr */ -function html_btn($name,$id,$akey,$params,$method='get'){ +function html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){ global $conf; global $lang; $label = $lang['btn_'.$name]; $ret = ''; + $tip = ''; //filter id (without urlencoding) $id = idfilter($id,false); @@ -250,9 +248,13 @@ function html_btn($name,$id,$akey,$params,$method='get'){ $ret .= '