added tab and image import/export

the label's get now exported as <description ...>
This commit is contained in:
Ralf Becker 2002-09-12 21:43:41 +00:00
parent 21d8665717
commit c4f5c280da

View File

@ -33,7 +33,7 @@
); );
$this->widget2xul = array( // how to translate widget-names and widget-spec. attr. $this->widget2xul = array( // how to translate widget-names and widget-spec. attr.
'label' => array( 'label' => array(
'.name' => 'label', '.name' => 'description',
'label' => 'value' 'label' => 'value'
), ),
'text' => array( 'text' => array(
@ -61,10 +61,18 @@
'template' => array( 'template' => array(
'.name' => 'grid', '.name' => 'grid',
'size' => 'content' 'size' => 'content'
),
'image' => array(
'.name' => 'image',
'label' => 'src'
),
'tab' => array(
'.name' => 'tabbox,tabs,tabpanels'
) )
); );
$this->xul2widget = array( $this->xul2widget = array(
'menupopup' => 'select' 'menupopup' => 'select',
'description' => 'label'
); );
} }
@ -143,9 +151,14 @@
} }
$widgetattr2xul = isset($this->widget2xul[$type]) ? $this->widget2xul[$type] : array(); $widgetattr2xul = isset($this->widget2xul[$type]) ? $this->widget2xul[$type] : array();
$type = isset($widgetattr2xul['.name']) ? $widgetattr2xul['.name'] : $type; $type = isset($widgetattr2xul['.name']) ? $widgetattr2xul['.name'] : $type;
list($parent,$child) = explode(',',$type); list($parent,$child,$child2) = explode(',',$type);
$widget = new xmlnode($child ? $child : $parent); $widget = new xmlnode($child ? $child : $parent);
if ($child2)
{
$child2 = new xmlnode($child2);
$child = $widget;
$widget = new xmlnode($parent);
}
if (isset($widgetattr2xul['.set'])) // set default-attr for type if (isset($widgetattr2xul['.set'])) // set default-attr for type
{ {
$attrs = explode(',',$widgetattr2xul[1]); $attrs = explode(',',$widgetattr2xul[1]);
@ -155,6 +168,23 @@
$widget->set_attribute($attr,$val); $widget->set_attribute($attr,$val);
} }
} }
if ($parent == 'tabbox')
{
$labels = explode('|',$cell['label']); unset($cell['label']);
$helps = explode('|',$cell['help']); unset($cell['help']);
$names = explode('|',$cell['name']); unset($cell['name']);
for ($n = 0; $n < count($labels); ++$n)
{
$tab = new xmlnode('tab');
$tab->set_attribute('label',$labels[$n]);
$tab->set_attribute('statustext',$helps[$n]);
$child->add_node($tab);
$grid = new xmlnode('grid');
$grid->set_attribute('id',$names[$n]);
$child2->add_node($grid);
}
}
while (list($attr,$val) = each($cell)) while (list($attr,$val) = each($cell))
{ {
if (is_array($val)) // correct old buggy etemplates if (is_array($val)) // correct old buggy etemplates
@ -171,7 +201,7 @@
} }
$this->set_attributes($widget,$attr,$val,&$spanned); $this->set_attributes($widget,$attr,$val,&$spanned);
} }
if ($child) if ($child && !$child2)
{ {
$parent = new xmlnode($parent); $parent = new xmlnode($parent);
$parent->add_node($widget); $parent->add_node($widget);
@ -179,6 +209,11 @@
} }
else else
{ {
if ($child2)
{
$widget->add_node($child);
$widget->add_node($child2);
}
$xul_row->add_node($widget); $xul_row->add_node($widget);
} }
} }
@ -236,7 +271,7 @@
{ {
$attr['name'] = $attr['id']; unset($attr['id']); $attr['name'] = $attr['id']; unset($attr['id']);
} }
if ($tag == 'grid' && $type == 'complete') if ($tag == 'grid' && $type == 'complete' && !is_array($tab_attr))
{ {
$tag = 'template'; $tag = 'template';
} }
@ -251,6 +286,11 @@
switch ($tag) switch ($tag)
{ {
case 'grid': case 'grid':
if ($type != 'close' && is_array($tab_attr))
{
$tab_names[] = $attr['name'];
break;
}
if ($node['level'] > 2) // level 1 is the overlay if ($node['level'] > 2) // level 1 is the overlay
{ {
return "Can't import nested $node[tag]'s !!!"; return "Can't import nested $node[tag]'s !!!";
@ -291,7 +331,41 @@
$etempl->data[0]["h$r"] = $attr['height']; $etempl->data[0]["h$r"] = $attr['height'];
break; break;
case 'styles': case 'styles':
$etempl->style = $node['value']; $etempl->style = trim($node['value']);
break;
case 'tabbox':
if ($type == 'open')
{
$tab_labels = $tab_helps = $tab_names = array();
$tab_attr = $attr;
}
else
{
$tab_attr['type'] = 'tab';
$tab_attr['label'] = implode('|',$tab_labels);
$tab_attr['name'] = implode('|',$tab_names);
$tab_attr['help'] = implode('|',$tab_helps);
$spanned = $tab_attr['span'] == 'all' ? $etempl->cols - $col : $tab_attr['span'];
$tab_attr['span'] .= $tab_attr['class'] ? ','.$tab_attr['class'] : '';
unset($tab_attr['class']);
$etempl->data[$etempl->rows][$etempl->num2chrs($col++)] = $tab_attr;
unset($tab_attr);
while (--$spanned > 0)
{
$etempl->data[$etempl->rows][$etempl->num2chrs($col++)] = $etempl->empty_cell();
}
}
break;
case 'tabs':
case 'tabpanels':
break;
case 'tab':
if ($type != 'close')
{
$tab_labels[] = $attr['label'];
$tab_helps[] = $attr['statustext'];
}
break; break;
case 'textbox': case 'textbox':
if ($attr['multiline']) if ($attr['multiline'])
@ -317,7 +391,7 @@
default: default:
switch ($tag) switch ($tag)
{ {
case 'label': case 'description':
$attr['label'] = $attr['value']; $attr['label'] = $attr['value'];
unset($attr['value']); unset($attr['value']);
break; break;
@ -325,6 +399,10 @@
$attr['size'] = $attr['content']; $attr['size'] = $attr['content'];
unset($attr['content']); unset($attr['content']);
break; break;
case 'image':
$attr['label'] = $attr['src'];
unset($attr['src']);
break;
} }
$attr['help'] = $attr['statustext']; unset($attr['statustext']); $attr['help'] = $attr['statustext']; unset($attr['statustext']);
$spanned = $attr['span'] == 'all' ? $etempl->cols - $col : $attr['span']; $spanned = $attr['span'] == 'all' ? $etempl->cols - $col : $attr['span'];