From 2e77c2a4c68a24531912cc5089706a3492758565 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 11 Jun 2008 04:20:39 +0000 Subject: [PATCH] "a little bit nicer implementation" --- etemplate/inc/class.nextmatch_widget.inc.php | 26 +++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/etemplate/inc/class.nextmatch_widget.inc.php b/etemplate/inc/class.nextmatch_widget.inc.php index 472f18f52d..a9e3d8e785 100644 --- a/etemplate/inc/class.nextmatch_widget.inc.php +++ b/etemplate/inc/class.nextmatch_widget.inc.php @@ -142,6 +142,24 @@ return array_slice($parts,$offset,$length); } + /** + * Return global storages shared within the parts of a nextmatch widget (including all nextmatch-* subwidgets) + * + * @param string $name + * @param string $type + * @return mixed reference to storage: use =& to assign! + */ + static private function &get_nm_global($name,$type) + { + static $nm_globals = array(); + + // extract the original nextmatch name from $name, taken into account the type of nextmatch-* subwidgets + $nm_global = implode('/',self::get_parts($name,1,$type == 'nextmatch' ? null : -2)); + //echo '

'.__METHOD__."($name,$type) = $nm_global

\n"; + + return $nm_globals[$nm_global]; + } + /** * pre-processing of the extension * @@ -157,9 +175,7 @@ */ function pre_process($name,&$value,array &$cell,&$readonlys,&$extension_data,etemplate &$tmpl) { - // extract the original nextmatch name from $name, taken into account the nextmatch-* subwidgets - $nm_global = implode('/',self::get_parts($name,1,$cell['type']=='nextmatch' ? null : -2)); - $nm_global = &$GLOBALS['egw_info']['etemplate']['nextmatch'][$nm_global]; + $nm_global =& self::get_nm_global($name,$cell['type']); //echo "

nextmatch_widget.pre_process(name='$name',type='$cell[type]'): value = "; _debug_array($value); //echo "

nextmatch_widget.pre_process(name='$name',type='$cell[type]'): nm_global = "; _debug_array($nm_global); @@ -663,9 +679,7 @@ */ function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in) { - // extract the original nextmatch name from $name, taken into account the nextmatch-* subwidgets - $nm_global = implode('/',$cell['type']=='nextmatch' || !($parts = self::get_parts($name,1,-2)) ? self::get_parts($name,1) : $parts); - $nm_global = &$GLOBALS['egw_info']['etemplate']['nextmatch'][$nm_global]; + $nm_global =& self::get_nm_global($name,$extension_data['type']); if ($this->debug) { echo "

nextmatch_widget.post_process(type='$extension_data[type]', name='$name',value_in=".print_r($value_in,true).",order='$nm_global[order]'): value = "; _debug_array($value); }