phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: etemplate/inc class.xul_io.inc.php,1.19,1.20


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: etemplate/inc class.xul_io.inc.php,1.19,1.20
Date: Sat, 12 Oct 2002 12:35:01 -0400

Update of /cvsroot/phpgroupware/etemplate/inc
In directory subversions:/tmp/cvs-serv29558

Modified Files:
        class.xul_io.inc.php 
Log Message:
Many new stuff for the eTemplates:
- added vbox and hbox support: container to put widgets in one row or column
- complete rows and column can now be disabled (even with a simple comparison 
with a variable in content, eg. disabled if the var is empty)
- labels and helptexts from tpls with 'test' in there name, get no longer 
written to the lang-file
- update the documentation 

Index: class.xul_io.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.xul_io.inc.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** class.xul_io.inc.php        10 Oct 2002 11:28:39 -0000      1.19
--- class.xul_io.inc.php        12 Oct 2002 16:34:59 -0000      1.20
***************
*** 80,84 ****
                                'image'   => array(
                                        '.name' => 'image',
!                                       'label' => 'src'
                                ),
                                'tab' => array(
--- 80,84 ----
                                'image'   => array(
                                        '.name' => 'image',
!                                       'name' => 'src'
                                ),
                                'tab' => array(
***************
*** 91,95 ****
                        );
                        $this->xul2widget = array(
!                               'menupopup' => 'select',
                                'listbox' => 'select',
                                'description' => 'label'
--- 91,95 ----
                        );
                        $this->xul2widget = array(
!                               'menulist' => 'select',
                                'listbox' => 'select',
                                'description' => 'label'
***************
*** 122,125 ****
--- 122,244 ----
                }
  
+               function 
cell2widget($cell,&$spanned,$etempl,&$root,$embeded_too=True)
+               {
+                       $type = $cell['type'];
+                       if (is_array($type))
+                       {
+                               list(,$type) = each($type);
+                       }
+                       if ($type == 'template' && $cell['name'][0] != '@' && 
$embeded_too)
+                       {
+                               $embeded = new etemplate();
+                               if 
($embeded->read($embeded->expand_name($cell['name'],0,0),'default','default',0,'',$etempl->as_array()))
+                               {
+                                       
$this->etempl2grid($embeded,&$root,$embeded_too);
+                               }
+                               unset($embeded);
+                       }
+                       if (substr($type,0,6) == 'select')
+                       {
+                               $type = $cell['size'] > 1 ? 'select-multi' : 
'select';
+                       }
+                       $widgetattr2xul = isset($this->widget2xul[$type]) ? 
$this->widget2xul[$type] : array();
+                       $type = isset($widgetattr2xul['.name']) ? 
$widgetattr2xul['.name'] : $type;
+                       list($parent,$child,$child2) = explode(',',$type);
+                       $widget = new xmlnode($parent);
+                       $attr_widget = &$widget;
+                       if ($child)
+                       {
+                               $child = new xmlnode($child);
+                               $attr_widget = &$child;
+                       }
+                       if ($child2)
+                       {
+                               $child2 = new xmlnode($child2);
+                       }
+                       if (isset($widgetattr2xul['.set']))     // set 
default-attr for type
+                       {
+                               $attrs = explode(',',$widgetattr2xul['.set']);
+                               while (list(,$attr) = each($attrs))
+                               {
+                                       list($attr,$val) = explode('=',$attr);
+                                       $widget->set_attribute($attr,$val);
+                               }
+                       }
+                       switch ($parent)
+                       {
+                       case 'nextmatch':
+                               $embeded = new 
etemplate($cell['size'],$etempl->as_array());
+                               
$this->etempl2grid($embeded,&$root,$embeded_too);
+                               unset($embeded);
+                               break;
+                       case '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);
+ 
+                                       $embeded = new 
etemplate($names[$n],$etempl->as_array());
+                                       
$this->etempl2grid($embeded,&$root,$embeded_too);
+                                       $grid = new xmlnode('grid');
+                                       
$grid->set_attribute('id',$embeded->name);
+                                       $child2->add_node($grid);
+                                       unset($embeded);
+                               }
+                               break;
+                       case 'menulist':        // id,options belongs to the 
'menupopup' child
+                               if ($cell['span'])
+                               {
+                                       
$widget->set_attribute('span',$cell['span']);
+                                       unset($cell['span']);
+                               }
+                               // fall-trought
+                       case 'listbox':
+                               if ($cell['type'] != 'select')  // one of the 
sub-types
+                               {
+                                       
$attr_widget->set_attribute('type',$cell['type']);
+                               }
+                               break; 
+                       case 'vbox':
+                       case 'hbox':
+                               for ($n = 1; $n <= $cell['size']; ++$n)
+                               {
+                                       
$widget->add_node($this->cell2widget($cell[$n],$no_span,$etempl,$root,$embeded_too));
+                                       unset($cell[$n]);
+                               }
+                               unset($cell['size']);
+                               break;
+                       }
+                       while (list($attr,$val) = each($cell))
+                       {
+                               if (is_array($val))     // correct old buggy 
etemplates
+                               {
+                                       list(,$val) = each($val);
+                               }
+                               if (isset($widgetattr2xul[$attr]))
+                               {
+                                       $attr = $widgetattr2xul[$attr];
+                               }
+                               elseif (isset($this->attr2xul[$attr]))
+                               {
+                                       $attr = $this->attr2xul[$attr];
+                               }
+                               
$this->set_attributes($attr_widget,$attr,$val,&$spanned);
+                       }
+                       if ($child)
+                       {
+                               $widget->add_node($child);
+                       }
+                       if ($child2)
+                       {
+                               $widget->add_node($child2);
+                       }
+                       return $widget;
+               }
+ 
                function etempl2grid($etempl,&$root,$embeded_too=True)
                {
***************
*** 157,263 ****
                                                continue;       // spanned 
cells are not written
                                        }
!                                       $type = $cell['type'];
!                                       if (is_array($type))
!                                       {
!                                               list(,$type) = each($type);
!                                       }
!                                       if ($type == 'template' && 
$cell['name'][0] != '@' && $embeded_too)
!                                       {
!                                               $embeded = new 
etemplate($cell['name'],$etempl->as_array());
!                                               
$this->etempl2grid($embeded,&$root,$embeded_too);
!                                               unset($embeded);
!                                       }
!                                       if (substr($type,0,6) == 'select')
!                                       {
!                                               $type = $cell['size'] > 1 ? 
'select-multi' : 'select';
!                                       }
!                                       $widgetattr2xul = 
isset($this->widget2xul[$type]) ? $this->widget2xul[$type] : array();
!                                       $type = isset($widgetattr2xul['.name']) 
? $widgetattr2xul['.name'] : $type;
!                                       list($parent,$child,$child2) = 
explode(',',$type);
!                                       $widget = new xmlnode($parent);
!                                       $attr_widget = &$widget;
!                                       if ($child)
!                                       {
!                                               $child = new xmlnode($child);
!                                               $attr_widget = &$child;
!                                       }
!                                       if ($child2)
!                                       {
!                                               $child2 = new xmlnode($child2);
!                                       }
!                                       if (isset($widgetattr2xul['.set']))     
// set default-attr for type
!                                       {
!                                               $attrs = 
explode(',',$widgetattr2xul['.set']);
!                                               while (list(,$attr) = 
each($attrs))
!                                               {
!                                                       list($attr,$val) = 
explode('=',$attr);
!                                                       
$widget->set_attribute($attr,$val);
!                                               }
!                                       }
!                                       switch ($parent)
!                                       {
!                                       case 'nextmatch':
!                                               $embeded = new 
etemplate($cell['size']);
!                                               
$this->etempl2grid($embeded,&$root,$embeded_too);
!                                               unset($embeded);
!                                               break;
!                                       case '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);
! 
!                                                       $embeded = new 
etemplate($names[$n],$etempl->as_array());
!                                                       
$this->etempl2grid($embeded,&$root,$embeded_too);
!                                                       $grid = new 
xmlnode('grid');
!                                                       
$grid->set_attribute('id',$embeded->name);
!                                                       
$child2->add_node($grid);
!                                                       unset($embeded);
!                                               }
!                                               break;
!                                       case 'menulist':        // id,options 
belongs to the 'menupopup' child
!                                               if ($cell['span'])
!                                               {
!                                                       
$widget->set_attribute('span',$cell['span']);
!                                                       unset($cell['span']);
!                                               }
!                                               // fall-trought
!                                       case 'listbox':
!                                               if ($cell['type'] != 'select')  
// one of the sub-types
!                                               {
!                                                       
$attr_widget->set_attribute('type',$cell['type']);
!                                               }
!                                               break;
!                                       }
!                                       while (list($attr,$val) = each($cell))
!                                       {
!                                               if (is_array($val))     // 
correct old buggy etemplates
!                                               {
!                                                       list(,$val) = 
each($val);
!                                               }
!                                               if 
(isset($widgetattr2xul[$attr]))
!                                               {
!                                                       $attr = 
$widgetattr2xul[$attr];
!                                               }
!                                               elseif 
(isset($this->attr2xul[$attr]))
!                                               {
!                                                       $attr = 
$this->attr2xul[$attr];
!                                               }
!                                               
$this->set_attributes($attr_widget,$attr,$val,&$spanned);
!                                       }
!                                       if ($child)
!                                       {
!                                               $widget->add_node($child);
!                                       }
!                                       if ($child2)
!                                       {
!                                               $widget->add_node($child2);
!                                       }
!                                       $xul_row->add_node($widget);
                                }
                                $xul_rows->add_node($xul_row);
--- 276,280 ----
                                                continue;       // spanned 
cells are not written
                                        }
!                                       
$xul_row->add_node($this->cell2widget($cell,$spanned,$etempl,$root,$embeded_too));
                                }
                                $xul_rows->add_node($xul_row);
***************
*** 300,303 ****
--- 317,345 ----
                }
  
+               function add_cell(&$etempl,$cell,&$box,&$col,$node_level)
+               {
+                       if (!isset($box[$node_level-1]))
+                       {
+                               list($spanned) = explode(',',$cell['span']);
+                               $spanned = $spanned == 'all' ? $etempl->cols - 
$col : $spanned;
+ 
+                               
$etempl->data[$etempl->rows][$etempl->num2chrs($col++)] = $cell;
+ 
+                       /*      if ($attr['type'] == 'template' && 
!empty($attr['name']) && $attr['name'][0] != '@')
+                               {
+                                       
$etempl->data[$etempl->rows][$etempl->num2chrs($col++)]['obj'] = new 
etemplate($attr['name']);
+                               } */
+                               while (--$spanned > 0)
+                               {
+                                       
$etempl->data[$etempl->rows][$etempl->num2chrs($col++)] = $etempl->empty_cell();
+                               }
+                       }
+                       else
+                       {
+                               $pcell = &$box[$node_level-1];
+                               $pcell[++$pcell['size']] = $cell;
+                       }
+               }
+ 
                function import(&$etempl,$data)
                {
***************
*** 421,434 ****
                                                        $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;
--- 463,471 ----
                                                        $tab_attr['name'] = 
implode('|',$tab_names);
                                                        $tab_attr['help'] = 
implode('|',$tab_helps);
                                                        $tab_attr['span'] .= 
$tab_attr['class'] ? ','.$tab_attr['class'] : '';
                                                        
unset($tab_attr['class']);
!                                                       
!                                                       
$this->add_cell($etempl,$tab_attr,&$box,&$col,$node['level']);
                                                        unset($tab_attr);
                                                }
                                                break;
***************
*** 443,448 ****
                                                }
                                                break;
                                        case 'menulist':
!                                               $menulist_attr = $attr; // save 
for following menupopup
                                                break;
                                        case 'textbox':
--- 480,512 ----
                                                }
                                                break;
+                                       case 'menupopup':
+                                               if (is_array($menulist_attr))
+                                               {
+                                                       $attr['help'] = 
$attr['statustext']; unset($attr['statustext']);
+                                                       $menulist_attr += $attr;
+                                               }
+                                               break;
                                        case 'menulist':
!                                               if ($type == 'open')
!                                               {
!                                                       $menulist_attr = $attr;
!                                               }
!                                               else
!                                               {
!                                                       
$this->add_cell($etempl,$menulist_attr,&$box,&$col,$node['level']);
!                                                       unset($menulist_attr);
!                                               }
!                                               break; 
!                                       case 'vbox':
!                                       case 'hbox':
!                                               if ($type == 'open')
!                                               {
!                                                       $box[$node['level']] = 
$attr;
!                                               }
!                                               else
!                                               {
!                                                       
$this->add_cell($etempl,$box[$node['level']],&$box,&$col,$node['level']);
!                                                       
unset($box[$node['level']]);
!                                               }
                                                break;
                                        case 'textbox':
***************
*** 480,484 ****
                                                                break;
                                                        case 'image':
!                                                               $attr['label'] 
= $attr['src'];
                                                                
unset($attr['src']);
                                                                break;
--- 544,548 ----
                                                                break;
                                                        case 'image':
!                                                               $attr['name'] = 
$attr['src'];
                                                                
unset($attr['src']);
                                                                break;
***************
*** 487,496 ****
                                                                
unset($attr['rows']);
                                                                break;
-                                                       case 'menupopup':
-                                                               if 
(is_array($menulist_attr))
-                                                               {
-                                                                       $attr 
+= $menulist_attr;
-                                                               }
-                                                               break;
                                                        case 'button':
                                                                if 
($attr['image'] || $attr['ro_image'])
--- 551,554 ----
***************
*** 502,506 ****
                                                }
                                                $attr['help'] = 
$attr['statustext']; unset($attr['statustext']);
-                                               $spanned = $attr['span'] == 
'all' ? $etempl->cols - $col : $attr['span'];
                                                $attr['span'] .= $attr['class'] 
? ','.$attr['class'] : ''; unset($attr['class']);
                                                if ($type == 'close')
--- 560,563 ----
***************
*** 508,521 ****
                                                        break;
                                                }
!                                               
$etempl->data[$etempl->rows][$etempl->num2chrs($col++)] = $attr;
! 
!                                               if ($attr['type'] == 'template' 
&& !empty($attr['name']) && $attr['name'][0] != '@')
!                                               {
!                                                       
$etempl->data[$etempl->rows][$etempl->num2chrs($col++)]['obj'] = new 
etemplate($attr['name']);
!                                               }
!                                               while (--$spanned > 0)
!                                               {
!                                                       
$etempl->data[$etempl->rows][$etempl->num2chrs($col++)] = $etempl->empty_cell();
!                                               }
                                                break;
                                }
--- 565,569 ----
                                                        break;
                                                }
!                                               
$this->add_cell($etempl,$attr,&$box,&$col,$node['level']);
                                                break;
                                }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]