fixed fatal error when calling soetemplate::add_cell with the template itself

This commit is contained in:
Ralf Becker 2005-10-31 09:06:24 +00:00
parent 33cb3881af
commit 968c1d41a5

View File

@ -132,14 +132,20 @@
* @static * @static
* @param string $type type of the widget * @param string $type type of the widget
* @param string $name name of widget * @param string $name name of widget
* @param array $attributes=null array with further attributes
* @return array the cell * @return array the cell
*/ */
function empty_cell($type='label',$name='') function empty_cell($type='label',$name='',$attributes=null)
{ {
return array( $cell = array(
'type' => $type, 'type' => $type,
'name' => $name, 'name' => $name,
); );
if ($attributes && is_array($attributes))
{
return array_merge($attributes,$cell);
}
return $cell;
} }
/** /**
@ -197,7 +203,12 @@
*/ */
function add_child(&$parent,&$cell) 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 'vbox':
case 'hbox': case 'hbox':
@ -232,10 +243,6 @@
if ($col > $cols) $cols = $col; if ($col > $cols) $cols = $col;
} }
break; break;
default: // parent is the template itself
$parent[] = &$cell;
break;
} }
} }