From 968c1d41a5eb2b6eb942d74c3d3aead6bddb305b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 31 Oct 2005 09:06:24 +0000 Subject: [PATCH] fixed fatal error when calling soetemplate::add_cell with the template itself --- etemplate/inc/class.soetemplate.inc.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/etemplate/inc/class.soetemplate.inc.php b/etemplate/inc/class.soetemplate.inc.php index 9e7651c709..8b8bb18c81 100644 --- a/etemplate/inc/class.soetemplate.inc.php +++ b/etemplate/inc/class.soetemplate.inc.php @@ -132,14 +132,20 @@ * @static * @param string $type type of the widget * @param string $name name of widget + * @param array $attributes=null array with further attributes * @return array the cell */ - function empty_cell($type='label',$name='') + function empty_cell($type='label',$name='',$attributes=null) { - return array( + $cell = array( 'type' => $type, 'name' => $name, ); + if ($attributes && is_array($attributes)) + { + return array_merge($attributes,$cell); + } + return $cell; } /** @@ -197,7 +203,12 @@ */ function add_child(&$parent,&$cell) { - switch($parent['type']) + if (is_object($parent)) // parent is the template itself + { + $parent->children[] = &$cell; + return; + } + switch(get_type($parent) == 'Array' ? $parent['type'] : 'etemplate') { case 'vbox': case 'hbox': @@ -232,10 +243,6 @@ if ($col > $cols) $cols = $col; } break; - - default: // parent is the template itself - $parent[] = &$cell; - break; } }