From 3dadb5abe39c6df7dc603c4d6a64bc7bfdda181d Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 24 May 2009 18:02:54 +0000 Subject: [PATCH] - allow to specify on sub-type level, if post_process method should be used for extensions - if extension is called with empty name, it can set a name in cell[name], which then get's used for the content (extensions can use eg. an option to select the name) --- etemplate/inc/class.boetemplate.inc.php | 10 ++++++++-- etemplate/inc/class.etemplate.inc.php | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/etemplate/inc/class.boetemplate.inc.php b/etemplate/inc/class.boetemplate.inc.php index 418a5b8ca7..f935f3f2b8 100644 --- a/etemplate/inc/class.boetemplate.inc.php +++ b/etemplate/inc/class.boetemplate.inc.php @@ -426,8 +426,14 @@ class boetemplate extends soetemplate */ protected function haveExtension($type,$function='') { - return (self::$extensions[$type] || $this->loadExtension($type,$ui)) && - ($function == '' || self::$extensions[$type]->public_functions[$function]); + if (self::$extensions[$type] || $this->loadExtension($type,$ui)) + { + if (empty($function)) return true; + + return isset(self::$extensions[$type]->public_functions[$function]) ? + self::$extensions[$type]->public_functions[$function] : false; + } + return false; } /** diff --git a/etemplate/inc/class.etemplate.inc.php b/etemplate/inc/class.etemplate.inc.php index 03b839e7f9..7a321e7cb1 100644 --- a/etemplate/inc/class.etemplate.inc.php +++ b/etemplate/inc/class.etemplate.inc.php @@ -989,6 +989,7 @@ class etemplate extends boetemplate $readonly = $cell['readonly'] !== false && ($readonly || $cell['readonly']); // might be set or unset (===false) by extension + if (is_null($name)) $name = $cell['name']; self::set_array($content,$name,$value); if ($cell['type'] == $type.'-'.$sub_type) break; // stop if no further type-change @@ -1661,7 +1662,8 @@ class etemplate extends boetemplate break; } // extension-processing need to be after all other and only with diff. name - if ($ext_type && !$readonly && $this->haveExtension($ext_type,'post_process')) + if ($ext_type && !$readonly && ($have = $this->haveExtension($ext_type,'post_process')) && + ($have === true || isset($have[$cell['type']]))) // check if post-process should be used for all sub-types { // unset it first, if it is already set, to be after the other widgets of the ext. $to_process = self::$request->get_to_process($form_name); self::$request->unset_to_process($form_name);