phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: etemplate/inc class.boetemplate.inc.php,1.23,1.2


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: etemplate/inc class.boetemplate.inc.php,1.23,1.24 class.date_widget.inc.php,1.5,1.6 class.datefield_widget.inc.php,1.6,1.7 class.nextmatch_widget.inc.php,1.9,1.10 class.tab_widget.inc.php,1.8,1.9 class.uietemplate.inc.php,1.32,1.33 class.xslt_widget.inc.php,1.1,1.2
Date: Tue, 01 Oct 2002 14:26:32 -0400

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

Modified Files:
        class.boetemplate.inc.php class.date_widget.inc.php 
        class.datefield_widget.inc.php class.nextmatch_widget.inc.php 
        class.tab_widget.inc.php class.uietemplate.inc.php 
        class.xslt_widget.inc.php 
Log Message:
completly rewritten uietemplate::process_show to not longer need to work 
recursively and be able to do input-checks later on

Index: class.boetemplate.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.boetemplate.inc.php,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** class.boetemplate.inc.php   29 Sep 2002 22:21:29 -0000      1.23
--- class.boetemplate.inc.php   1 Oct 2002 18:26:30 -0000       1.24
***************
*** 341,348 ****
                }
  
!               function extensionPreProcess(&$cell,&$value,&$readonlys)
                /*
                @function extensionPreProcess
                @syntax extensionPreProcess(&$cell,&$value,&$readonlys)
                @param &$cell table-cell on which the extension operates
                @param &$value value of the extensions content(-array)
--- 341,350 ----
                }
  
!               function 
extensionPreProcess($type,$name,&$value,&$cell,&$readonlys)
                /*
                @function extensionPreProcess
                @syntax extensionPreProcess(&$cell,&$value,&$readonlys)
+               @param $type of the extension
+               @param $name form-name of this widget/field (used as a unique 
index into extension_data)
                @param &$cell table-cell on which the extension operates
                @param &$value value of the extensions content(-array)
***************
*** 351,379 ****
                */
                {
!                       if (!$this->haveExtension($type = $cell['type']))
                        {
                                return False;
                        }
!                       return 
$GLOBALS['phpgw_info']['etemplate']['extension'][$type]->pre_process($cell,$value,
!                               
$GLOBALS['phpgw_info']['etemplate']['extension_data'][$type][$cell['name']],$readonlys,$this);
                }
  
!               function extensionPostProcess(&$cell,&$value)
                /*
                @function extensionPostProcess
                @syntax extensionPostProcess(&$cell,&$value)
                @abstract executes the post_process-function of the extension 
$cell[type]
                */
                {
!                       if (!$this->haveExtension($type = 
$cell['type'],'post_process'))
                        {
                                return False;
                        }
!                       return 
$GLOBALS['phpgw_info']['etemplate']['extension'][$type]->post_process($cell,$value,
!                               
$GLOBALS['phpgw_info']['etemplate']['extension_data'][$type][$cell['name']],
!                               
$GLOBALS['phpgw_info']['etemplate']['loop'],$this);
                }
  
!               function extensionRender(&$cell,$form_name,&$value,$readonly)
                /*
                @function extensionRender
--- 353,384 ----
                */
                {
!                       if (!$this->haveExtension($type))
                        {
                                return False;
                        }
!                       return 
$GLOBALS['phpgw_info']['etemplate']['extension'][$type]->pre_process($name,$value,$cell,$readonlys,
!                               
$GLOBALS['phpgw_info']['etemplate']['extension_data'][$name],$this);
                }
  
!               function extensionPostProcess($type,$name,&$value,$value_in)
                /*
                @function extensionPostProcess
                @syntax extensionPostProcess(&$cell,&$value)
+               @param $type of the extension
+               @param $name form-name of this widget/field (used as a unique 
index into extension_data)
+               @param &$value value of the extensions content(-array)
                @abstract executes the post_process-function of the extension 
$cell[type]
                */
                {
!                       if (!$this->haveExtension($type,'post_process'))
                        {
                                return False;
                        }
!                       return 
$GLOBALS['phpgw_info']['etemplate']['extension'][$type]->post_process($name,$value,
!                               
$GLOBALS['phpgw_info']['etemplate']['extension_data'][$name],
!                               
$GLOBALS['phpgw_info']['etemplate']['loop'],$this,$value_in);
                }
  
!               function extensionRender($type,$name,&$value,&$cell,$readonly)
                /*
                @function extensionRender
***************
*** 382,391 ****
                */
                {
!                       if (!$this->haveExtension($type = 
$cell['type'],'render'))
                        {
                                return False;
                        }
!                       return 
$GLOBALS['phpgw_info']['etemplate']['extension'][$type]->render($cell,$form_name,$value,$readonly,
!                               
$GLOBALS['phpgw_info']['etemplate']['extension_data'][$type][$cell['name']],$this);
                }
  
--- 387,396 ----
                */
                {
!                       if (!$this->haveExtension($type,'render'))
                        {
                                return False;
                        }
!                       return 
$GLOBALS['phpgw_info']['etemplate']['extension'][$type]->render($cell,$name,$value,$readonly,
!                               
$GLOBALS['phpgw_info']['etemplate']['extension_data'][$name],$this);
                }
  
***************
*** 425,429 ****
                        eval($code = 
str_replace(']',"']",str_replace('[',"['",$code)));
  
!                       //echo "set_array: $code = '$val'\n";
                }
  
--- 430,439 ----
                        eval($code = 
str_replace(']',"']",str_replace('[',"['",$code)));
  
!                       //echo "set_array: $code = '$val'<br>\n";
!               }
! 
!               function unset_array(&$arr,$idx)
!               {
!                       $this->set_array($arr,$idx,0,False);
                }
  
***************
*** 433,437 ****
                        {
                                eval($code = 
str_replace(']',"']",str_replace('[',"['",'$val = 
&$arr['.$regs[1].']'.$regs[2].';')));
!                               //echo "get_array: $code = '$val'\n";
                        }
                        else
--- 443,447 ----
                        {
                                eval($code = 
str_replace(']',"']",str_replace('[',"['",'$val = 
&$arr['.$regs[1].']'.$regs[2].';')));
!                               //echo "get_array: $code = '$val'<br>\n";
                        }
                        else
***************
*** 447,452 ****
                @author ralfbecker
                @abstract merges $old and $new, content of $new has precedence 
over $old
!               @discussion THIS IS NOT THE SAME AS PHP4: array_merge (as it 
calls itself recursive for values which are arrays,
!               @discussion if there key does NOT start with a '_' (array_merge 
just overwrites the old (sub)array)
                */
                function complete_array_merge($old,$new)
--- 457,461 ----
                @author ralfbecker
                @abstract merges $old and $new, content of $new has precedence 
over $old
!               @discussion THIS IS NOT THE SAME AS PHP4: array_merge (as it 
calls itself recursive for values which are arrays.
                */
                function complete_array_merge($old,$new)
***************
*** 455,459 ****
                        while (list($k,$v) = @each($new))
                        {
!                               if (!is_array($v) || !isset($old[$k]) || $k[0] 
== '_')
                                {
                                        $old[$k] = $v;
--- 464,468 ----
                        while (list($k,$v) = @each($new))
                        {
!                               if (!is_array($v) || !isset($old[$k]))
                                {
                                        $old[$k] = $v;

Index: class.date_widget.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.date_widget.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** class.date_widget.inc.php   27 Sep 2002 16:17:39 -0000      1.5
--- class.date_widget.inc.php   1 Oct 2002 18:26:30 -0000       1.6
***************
*** 45,50 ****
                }
  
!               function 
pre_process(&$cell,&$value,&$extension_data,&$readonlys,&$tmpl)
                {
                        if ($cell['size'] != '')
                        {
--- 45,51 ----
                }
  
!               function 
pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
                {
+                       $extension_data = $cell['size'];
                        if ($cell['size'] != '')
                        {
***************
*** 78,82 ****
                }
  
!               function 
post_process(&$cell,&$value,&$extension_data,&$loop,&$tmpl)
                {
                        if (!isset($value))
--- 79,83 ----
                }
  
!               function 
post_process($name,&$value,&$extension_data,&$loop,&$tmpl)
                {
                        if (!isset($value))
***************
*** 94,98 ****
                                        $value['Y'] = date('Y');
                                }
!                               if ($cell['size'] == '')
                                {
                                        $value = 
mktime(0,0,0,$value['m'],$value['d'],$value['Y']);
--- 95,99 ----
                                        $value['Y'] = date('Y');
                                }
!                               if ($extension_data)
                                {
                                        $value = 
mktime(0,0,0,$value['m'],$value['d'],$value['Y']);
***************
*** 100,106 ****
                                else
                                {
!                                       for ($n = 0,$str = ''; $n < 
strlen($cell['size']); ++$n)
                                        {
!                                               if (strstr('Ymd',$c = 
$cell['size'][$n]))
                                                {
                                                        $str .= 
sprintf($c=='Y'?'%04d':'%02d',$value[$c]);
--- 101,107 ----
                                else
                                {
!                                       for ($n = 0,$str = ''; $n < 
strlen($extension_data); ++$n)
                                        {
!                                               if (strstr('Ymd',$c = 
$extension_data[$n]))
                                                {
                                                        $str .= 
sprintf($c=='Y'?'%04d':'%02d',$value[$c]);

Index: class.datefield_widget.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.datefield_widget.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** class.datefield_widget.inc.php      27 Sep 2002 16:17:39 -0000      1.6
--- class.datefield_widget.inc.php      1 Oct 2002 18:26:30 -0000       1.7
***************
*** 31,36 ****
                }
  
!               function 
pre_process(&$cell,&$value,&$extension_data,&$readonlys,&$tmpl)
                {
                        if ($cell['size'] != '')
                        {
--- 31,38 ----
                }
  
!               function 
pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
                {
+                       $extension_data = $cell['size'];
+ 
                        if ($cell['size'] != '')
                        {
***************
*** 70,74 ****
                }
  
!               function 
post_process(&$cell,&$value,&$extension_data,&$loop,&$tmpl)
                {
                        if (!isset($value))
--- 72,76 ----
                }
  
!               function 
post_process($name,&$value,&$extension_data,&$loop,&$tmpl)
                {
                        if (!isset($value))
***************
*** 97,101 ****
                                        $value['Y'] += $value['Y'] < 30 ? 2000 
: 1900;
                                }
!                               if ($cell['size'] == '')
                                {
                                        $value = 
mktime(0,0,0,$value['m'],$value['d'],$value['Y']);
--- 99,103 ----
                                        $value['Y'] += $value['Y'] < 30 ? 2000 
: 1900;
                                }
!                               if (empty($extension_data))
                                {
                                        $value = 
mktime(0,0,0,$value['m'],$value['d'],$value['Y']);
***************
*** 103,109 ****
                                else
                                {
!                                       for ($n = 0,$str = ''; $n < 
strlen($cell['size']); ++$n)
                                        {
!                                               if (strstr('Ymd',$c = 
$cell['size'][$n]))
                                                {
                                                        $str .= 
sprintf($c=='Y'?'%04d':'%02d',$value[$c]);
--- 105,111 ----
                                else
                                {
!                                       for ($n = 0,$str = ''; $n < 
strlen($extension_data); ++$n)
                                        {
!                                               if (strstr('Ymd',$c = 
$extension_data[$n]))
                                                {
                                                        $str .= 
sprintf($c=='Y'?'%04d':'%02d',$value[$c]);

Index: class.nextmatch_widget.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.nextmatch_widget.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** class.nextmatch_widget.inc.php      27 Sep 2002 16:17:39 -0000      1.9
--- class.nextmatch_widget.inc.php      1 Oct 2002 18:26:30 -0000       1.10
***************
*** 32,57 ****
                }
  
!               function 
pre_process(&$cell,&$value,&$extension_data,&$readonlys,&$tmpl)
                {
                        //echo "<p>nextmatch_widget.pre_process: value = "; 
_debug_array($value);
                        // save values in persistent extension_data to be able 
use it in post_process
!                       $extension_data = $value;
  
                        list($app,$class,$method) = 
explode('.',$value['get_rows']);
                        $obj = CreateObject($app.'.'.$class);
                        $total = $value['total'] = 
$obj->$method($value,$value['rows'],$readonlys['rows']);
                        if ($value['start'] > $total)
                        {
!                               $extension_data['start'] = $value['start'] = 0;
                                $total = 
$obj->$method($value,$value['rows'],$readonlys['rows']);
                        }
!                       $extension_data['total'] = $total;
! 
!                       if ($cell['size'])
                        {
                                $value['template'] = $cell['size'];
                        }
!                       $value['template'] = new 
etemplate($value['template'],$tmpl->as_array());
! 
                        $nextmatch = new 
etemplate('etemplate.nextmatch_widget');
  
--- 32,62 ----
                }
  
!               function 
pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
                {
                        //echo "<p>nextmatch_widget.pre_process: value = "; 
_debug_array($value);
                        // save values in persistent extension_data to be able 
use it in post_process
!                       //$extension_data = $value;
  
                        list($app,$class,$method) = 
explode('.',$value['get_rows']);
                        $obj = CreateObject($app.'.'.$class);
+                       if (!is_object($obj))
+                       {
+                               echo "<p>nextmatch_widget::pre_process($name): 
'$value[get_rows]' is no valid method !!!</p>\n";
+                               return;
+                       }
                        $total = $value['total'] = 
$obj->$method($value,$value['rows'],$readonlys['rows']);
                        if ($value['start'] > $total)
                        {
!                               $value['start'] = 0;
                                $total = 
$obj->$method($value,$value['rows'],$readonlys['rows']);
                        }
!                       if ($cell['size'])      // template name can be 
supplied either in $value['template'] or the options-field
                        {
                                $value['template'] = $cell['size'];
                        }
!                       if (!is_object($value['template']))
!                       {
!                               $value['template'] = new 
etemplate($value['template'],$tmpl->as_array());
!                       }
                        $nextmatch = new 
etemplate('etemplate.nextmatch_widget');
  
***************
*** 83,98 ****
                        $cell['label'] = $cell['help'] = '';
  
                        return False;   // NO extra Label
                }
  
!               function 
post_process(&$cell,&$value,&$extension_data,&$loop,&$tmpl)
                {
                        //echo "<p>nextmatch_widget.post_process: value = "; 
_debug_array($value);
- 
                        $old_value = $extension_data;
  
-                       list($value['cat_id']) = $value['cat_id'];
-                       list($value['filter']) = $value['filter'];
-                       list($value['filter2'])= $value['filter2'];
                        $value['start'] = $old_value['start'];  // need to be 
set, to be reported back
                        $max   = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
--- 88,101 ----
                        $cell['label'] = $cell['help'] = '';
  
+                       $extension_data = $value;
+ 
                        return False;   // NO extra Label
                }
  
!               function 
post_process($name,&$value,&$extension_data,&$loop,&$tmpl)
                {
                        //echo "<p>nextmatch_widget.post_process: value = "; 
_debug_array($value);
                        $old_value = $extension_data;
  
                        $value['start'] = $old_value['start'];  // need to be 
set, to be reported back
                        $max   = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];

Index: class.tab_widget.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.tab_widget.inc.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** class.tab_widget.inc.php    27 Sep 2002 16:17:39 -0000      1.8
--- class.tab_widget.inc.php    1 Oct 2002 18:26:30 -0000       1.9
***************
*** 32,36 ****
                }
  
!               function 
pre_process(&$cell,&$value,&$extension_data,&$readonlys,&$tmpl)
                {
                        $labels = explode('|',$cell['label']);
--- 32,36 ----
                }
  
!               function 
pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
                {
                        $labels = explode('|',$cell['label']);
***************
*** 48,55 ****
                        {
                                $tcell = $tabs->empty_cell();
!                               if (is_array($value['_tab_widget']) && 
$value['_tab_widget'][$name][0])
                                {
                                        // save selected tab in persistent 
extension_data to use it in post_process
!                                       $extension_data = $selected_tab = $name;
                                        $tcell['obj'] = &$tab_active;
                                        $tcell['name'] = $tab_active->name;
--- 48,55 ----
                        {
                                $tcell = $tabs->empty_cell();
!                               if ($extension_data == $name)
                                {
                                        // save selected tab in persistent 
extension_data to use it in post_process
!                                       $selected_tab = $name;
                                        $tcell['obj'] = &$tab_active;
                                        $tcell['name'] = $tab_active->name;
***************
*** 61,66 ****
                                }
                                $tcell['type'] = 'template';
!                               $tcell['size'] = "_tab_widget[$name]";
!                               $value['_tab_widget'][$name] = array(
                                        'name'  => $name,
                                        'label' => $labels[$k],
--- 61,66 ----
                                }
                                $tcell['type'] = 'template';
!                               $tcell['size'] = 
$cell['name']/*form_name*/.'['.$name.']';
!                               $value[$name] = array(
                                        'name'  => $name,
                                        'label' => $labels[$k],
***************
*** 99,118 ****
                }
  
!               function 
post_process(&$cell,&$value,&$extension_data,&$loop,&$tmpl)
                {
!                       $old_value = array(
!                               '_tab_widget' => array(
!                                       $extension_data => array(True)
!                       ));
!                       
$this->pre_process($cell,$old_value,$extension_data,$dummy,$tmpl);
! 
!                       if (is_array($value['_tab_widget']))
                        {
!                               while (list($key,$val) = 
each($value['_tab_widget']))
                                {
!                                       if (is_array($val) && $val[0])
!                                       {
!                                               $loop = True;
!                                       }
                                }
                        }
--- 99,114 ----
                }
  
!               function 
post_process($name,&$value,&$extension_data,&$loop,&$tmpl)
                {
!                       //echo "<p>tab_widget::post_process($name): value = "; 
_debug_array($value);
!                       if (is_array($value))
                        {
!                               reset($value);
!                               list($tab,$button) = each($value);
!                               list(,$button) = each($button);
!                               if ($button)
                                {
!                                       $extension_data = $tab;
!                                       $loop = True;
                                }
                        }

Index: class.uietemplate.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.uietemplate.inc.php,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -r1.32 -r1.33
*** class.uietemplate.inc.php   29 Sep 2002 22:24:33 -0000      1.32
--- class.uietemplate.inc.php   1 Oct 2002 18:26:30 -0000       1.33
***************
*** 104,113 ****
                        $GLOBALS['phpgw_info']['etemplate']['loop'] = False;
                        $GLOBALS['phpgw_info']['etemplate']['form_options'] = 
'';       // might be set in show
                        $html .= ($this->stable ? 
$this->html->nextMatchStyles()."\n\n" : ''). // so they get included once
                                $this->html->form($this->include_java_script() .
!                                       
$this->show($this->complete_array_merge($content,$changes),$sel_options,$readonlys,'exec'),
!                                       array('etemplate_exec_id' => $id,'app' 
=> $GLOBALS['phpgw_info']['flags']['currentapp']),
!                                       
'/etemplate/process_exec.php','','eTemplate',$GLOBALS['phpgw_info']['etemplate']['form_options']);
! 
                        list($width,$height,,,,,$overflow) = 
explode(',',$this->size);
                        if ($overflow)
--- 104,115 ----
                        $GLOBALS['phpgw_info']['etemplate']['loop'] = False;
                        $GLOBALS['phpgw_info']['etemplate']['form_options'] = 
'';       // might be set in show
+                       $GLOBALS['phpgw_info']['etemplate']['to_process'] = 
array();
                        $html .= ($this->stable ? 
$this->html->nextMatchStyles()."\n\n" : ''). // so they get included once
                                $this->html->form($this->include_java_script() .
!                                       
$this->show($this->complete_array_merge($content,$changes),$sel_options,$readonlys,'exec'),array(
!                                               'etemplate_exec_id' => $id,
!                                               'etemplate_exec_app' => 
$GLOBALS['phpgw_info']['flags']['currentapp']
!                                       
),'/etemplate/process_exec.php','','eTemplate',$GLOBALS['phpgw_info']['etemplate']['form_options']);
!                       
//_debug_array($GLOBALS['phpgw_info']['etemplate']['to_process']);
                        list($width,$height,,,,,$overflow) = 
explode(',',$this->size);
                        if ($overflow)
***************
*** 122,125 ****
--- 124,128 ----
                                'preserv' => $preserv,
                                'extension_data' => 
$GLOBALS['phpgw_info']['etemplate']['extension_data'],
+                               'to_process' => 
$GLOBALS['phpgw_info']['etemplate']['to_process'],
                                'java_script' => 
$GLOBALS['phpgw_info']['etemplate']['java_script'],
                                'method' => $method
***************
*** 162,166 ****
                        //echo "globals[java_script] = 
'".$GLOBALS['phpgw_info']['etemplate']['java_script']."', 
session_data[java_script] = '".$session_data['java_script']."', 
HTTP_POST_VARS[java_script] = 
'".$GLOBALS['HTTP_POST_VARS']['java_script']."'\n";
                        //echo "process_exec($this->name) content ="; 
_debug_array($content);
!                       
$this->process_show($content,$session_data['readonlys']);
  
                        //echo "process_exec($this->name) process_show(content) 
="; _debug_array($content);
--- 165,169 ----
                        //echo "globals[java_script] = 
'".$GLOBALS['phpgw_info']['etemplate']['java_script']."', 
session_data[java_script] = '".$session_data['java_script']."', 
HTTP_POST_VARS[java_script] = 
'".$GLOBALS['HTTP_POST_VARS']['java_script']."'\n";
                        //echo "process_exec($this->name) content ="; 
_debug_array($content);
!                       
$this->process_show($content,$session_data['to_process'],'exec');
  
                        //echo "process_exec($this->name) process_show(content) 
="; _debug_array($content);
***************
*** 198,202 ****
                @result the generated HTML
                */
!               function 
show($content,$sel_options='',$readonlys='',$cname='cont',$show_c=0,$show_row=0)
                {
                        if (!$sel_options)
--- 201,205 ----
                @result the generated HTML
                */
!               function 
show($content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0)
                {
                        if (!$sel_options)
***************
*** 340,348 ****
                        $name = 
$this->expand_name($cell['name'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
  
!                       if (strstr($name,'|'))  // extension which uses whole 
content array
                        {
                                $value = $content;
                        }
!                       elseif (ereg('^([^[]*)(\\[.*\\])$',$name,$regs))        
// name contains array-index
                        {
                                $form_name = $cname == '' ? $name : 
$cname.'['.$regs[1].']'.$regs[2];
--- 343,351 ----
                        $name = 
$this->expand_name($cell['name'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
  
!                       /*if (strstr($name,'|'))        // extension which uses 
whole content array
                        {
                                $value = $content;
                        }
!                       else*/if (ereg('^([^[]*)(\\[.*\\])$',$name,$regs))      
// name contains array-index
                        {
                                $form_name = $cname == '' ? $name : 
$cname.'['.$regs[1].']'.$regs[2];
***************
*** 372,383 ****
                        if (!$this->types[$cell['type']] && 
$this->haveExtension($cell['type'],'pre_process'))
                        {
!                               $type = $cell['type'];
!                               $extra_label = 
$this->extensionPreProcess($cell,$value,$readonlys[$name]);
!                               //echo "<p>$type::pre_process"; 
_debug_array($cell);
!                               if (strstr($name,'|'))
                                {
                                        $content = 
$this->complete_array_merge($content,$value);
                                }
!                               elseif (!$regs)
                                {
                                        $content[$name] = $value;       // set 
result for template
--- 375,386 ----
                        if (!$this->types[$cell['type']] && 
$this->haveExtension($cell['type'],'pre_process'))
                        {
!                               $ext_type = $cell['type'];
!                               $extra_label = 
$this->extensionPreProcess($ext_type,$form_name,$value,$cell,$readonlys[$name]);
! 
!                               /*if (strstr($name,'|'))
                                {
                                        $content = 
$this->complete_array_merge($content,$value);
                                }
!                               else*/if (!$regs)
                                {
                                        $content[$name] = $value;       // set 
result for template
***************
*** 443,446 ****
--- 446,450 ----
                                                $html .= 
$this->html->input($form_name,$value,'',
                                                        
$options.$this->html->formatOptions($cell['size'],'SIZE,MAXLENGTH'));
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        }
                                        break;
***************
*** 448,451 ****
--- 452,457 ----
                                        $html .= 
$this->html->textarea($form_name,$value,
                                                
$options.$this->html->formatOptions($cell['size'],'ROWS,COLS'));
+                                       if (!$readonly)
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'checkbox':
***************
*** 455,458 ****
--- 461,466 ----
                                        }
                                        $html .= 
$this->html->input($form_name,'1','CHECKBOX',$options);
+                                       if (!$readonly)
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'radio':           // size: value if 
checked
***************
*** 462,465 ****
--- 470,475 ----
                                        }
                                        $html .= 
$this->html->input($form_name,$cell['size'],'RADIO',$options);
+                                       if (!$readonly)
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'button':
***************
*** 479,482 ****
--- 489,494 ----
                                        }
                                        $extra_label = False;
+                                       if (!$readonly)
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'hrule':
***************
*** 516,520 ****
                                                if ($span == '' && 
isset($content[$idx]['span']))
                                                {       // this allows a 
colspan in autorepeated cells like the editor
!                                                       $span = 
explode(',',$content[$idx]['span']); $span = $span[0];
                                                        if ($span == 'all')
                                                        {
--- 528,532 ----
                                                if ($span == '' && 
isset($content[$idx]['span']))
                                                {       // this allows a 
colspan in autorepeated cells like the editor
!                                                       list($span) = 
explode(',',$content[$idx]['span']);
                                                        if ($span == 'all')
                                                        {
***************
*** 550,572 ****
--- 562,598 ----
                                        $html .= 
$this->sbox->getArrayItem($form_name.'[]',$value,$sel_options,$cell['no_lang'],
                                                $options,$cell['size']);
+                                       if (!$readonly)
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'select-percent':
                                        $html .= 
$this->sbox->getPercentage($form_name,$value,$options);
+                                       if (!$readonly)
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'select-priority':
                                        $html .= 
$this->sbox->getPriority($form_name,$value,$options);
+                                       if (!$readonly)
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'select-access':
                                        $html .= 
$this->sbox->getAccessList($form_name,$value,$options);
+                                       if (!$readonly)
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'select-country':
                                        $html .= 
$this->sbox->getCountry($form_name,$value,$options);
+                                       if (!$readonly)
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'select-state':
                                        $html .= 
$this->sbox->list_states($form_name,$value);  // no helptext - old Function!!!
+                                       if (!$readonly)
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'select-cat':
                                        $html .= 
$this->sbox->getCategory($form_name.'[]',$value,$cell['size'] >= 0,
                                                False,$cell['size'],$options);
+                                       if (!$readonly)
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'select-account':
***************
*** 577,580 ****
--- 603,608 ----
                                        }
                                        $html .= 
$this->sbox->getAccount($form_name.'[]',$value,2,$type,0+$cell['size'],$options);
+                                       if (!$readonly)
+                                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'image':
***************
*** 589,597 ****
                                        
$GLOBALS['phpgw_info']['etemplate']['form_options'] =
                                                
"enctype=\"multipart/form-data\" 
onSubmit=\"set_element2(this,'$path','$form_name')\"";
                                        break;
                                default:
!                                       if 
($this->haveExtension($cell['type'],'render'))
                                        {
!                                               $html .= 
$this->extensionRender($cell,$form_name,$value,$readonly);
                                        }
                                        else
--- 617,627 ----
                                        
$GLOBALS['phpgw_info']['etemplate']['form_options'] =
                                                
"enctype=\"multipart/form-data\" 
onSubmit=\"set_element2(this,'$path','$form_name')\"";
+                                       
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
+                                       
$GLOBALS['phpgw_info']['etemplate']['to_process'][$path] = 'file-path';
                                        break;
                                default:
!                                       if ($ext_type && 
$this->haveExtension($ext_type,'render'))
                                        {
!                                               $html .= 
$this->extensionRender($ext_type,$form_name,$value,$cell,$readonly);
                                        }
                                        else
***************
*** 601,604 ****
--- 631,638 ----
                                        break;
                        }
+                       if ($ext_type && !$readonly)    // extension-processing 
need to be after all other
+                       {
+                               
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = 
'ext-'.$ext_type;
+                       }
                        if ($extra_label && ($label != '' || $html == ''))
                        {
***************
*** 625,644 ****
                }
  
                /*!
                @function process_show
                @abstract makes necessary adjustments on HTTP_POST_VARS after a 
eTemplate / form gots submitted
                @discussion This is only an internal function, dont call it 
direct use only exec
!               @discussion process_show recursivly calls itself for the 
included eTemplates.
!               @param $vars HTTP_POST_VARS on first call, later (deeper 
recursions) subscripts of it
!               @param $readonly array with cell- / var-names which should NOT 
return content (this is to workaround browsers who not understand READONLY 
correct)
                @param $cname basename of our returnt content (same as in call 
to show)
                @result the adjusted content (by using the var-param &$content)
                */
!               function process_show(&$content,$readonlys='')
                {
-                       if (!$readonlys)
-                       {
-                               $readonlys = array();
-                       }
                        if (!isset($content) || !is_array($content))
                        {
--- 659,675 ----
                }
  
+ 
                /*!
                @function process_show
                @abstract makes necessary adjustments on HTTP_POST_VARS after a 
eTemplate / form gots submitted
                @discussion This is only an internal function, dont call it 
direct use only exec
!               @discussion Process_show uses a list of input-fields/widgets 
generated by show.
!               @param $content HTTP_POST_VARS[$cname]
!               @param $to_process list of widgets/form-fields to process
                @param $cname basename of our returnt content (same as in call 
to show)
                @result the adjusted content (by using the var-param &$content)
                */
!               function process_show(&$content,$to_process,$cname='')
                {
                        if (!isset($content) || !is_array($content))
                        {
***************
*** 647,865 ****
                        if ($this->debug >= 1 || $this->debug == $this->name && 
$this->name)
                        {
!                               echo "<p>process_show($this->name) start: 
content ="; _debug_array($content);
                        }
!                       reset($this->data);
!                       if (isset($this->data[0]))
!                       {
!                               each($this->data);      // skip width
!                       }
!                       for ($r = 0; True /*list($row,$cols) = 
each($this->data)*/; ++$r)
!                       {
!                               if (!(list($r_key) = each($this->data)))        
// no further row
!                               {
!                                       //list($nul,$cell) = each($cols); 
reset($cols);
!                                       if 
((!$this->autorepeat_idx($cols['A'],0,$r,$idx,$idx_cname) ||
!                                               $idx_cname == '' || 
!$this->isset_array($content,$idx)) &&
!                                               
(!$this->autorepeat_idx($cols['B'],1,$r,$idx,$idx_cname) ||
!                                               $idx_cname == '' || 
!$this->isset_array($content,$idx)))
!                                       {
!                                               break;  // no auto-row-repeat
!                                       }
!                               }
!                               else
!                               {
!                                       $cols = &$this->data[$r_key];
!                               }
!                               $row = 1+$r;
!                               reset($cols);
!                               for ($c = 0; True /*list($col,$cell) = 
each($cols)*/; ++$c)
!                               {
!                                       //$old_cell = $cell;
!                                       if (!(list($c_key/*,$cell*/) = 
each($cols)))    // no further cols
!                                       {
!                                               //$cell = $old_cell;
!                                               if 
(!$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True) ||
!                                                       $idx_cname == '' || 
!$this->isset_array($content,$idx))
!                                               {
!                                                       break;  // no 
auto-col-repeat
!                                               }
!                                       }
!                                       else
!                                       {
!                                               $cell = &$cols[$c_key];
!                                               
$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True); // get idx_cname
!                                       }
!                                       $col = $this->num2chrs($c);
! 
!                                       $name = 
$this->expand_name($cell['name'],$c,$r);
!                                       $readonly = $cell['readonly'] || 
$readonlys[$name] || $readonlys['__ALL__'] ||
!                                               $cell['type'] == 'label' || 
$cell['type'] == 'image' || $cell['type'] == 'raw' ||
!                                               $cell['type'] == 'hrule';
! 
!                                       if ($idx_cname == '' && $cell['type'] 
== 'template' || strstr($name,'|'))       // only templates or extensions
!                                       {
!                                               if ($readonly && 
!isset($readonlys['__ALL__']))         // can't unset whole content!!!
!                                               {
!                                                       $readonlys['__ALL__'] = 
True;
!                                                       
$this->process_show_cell($cell,$name,$c,$r,$readonlys,$content);
!                                                       
unset($readonlys['__ALL__']);           // unset it after or everything gets 
set readonly
!                                               }
!                                               else
                                                {
!                                                       
$this->process_show_cell($cell,$name,$c,$r,$readonlys,$content);
                                                }
!                                       }
!                                       elseif 
(ereg('^([^[]*)\\[(.*)\\]$',$idx_cname,$regs))   // name contains array-index
!                                       {
!                                               /*  Attention: the unsets here 
and in the next else are vor two reasons:
!                                               *  1) some browsers does NOT 
understand the READONLY-tag and sent content back
!                                               *     this has to be unset, as 
we only report no-readonly fields
!                                               *  2) php has a fault / feature 
:-) that it set unset array-elements passed as
!                                               *     variable / changeable 
(&$var) to a function, this messes up a lot, as we
!                                               *     depend on the fact 
variables are set or not for the autorepeat. To work
!                                               *     around that, 
process_show_cell reports back if a variable is set or not
!                                               *     via the returnvalue and 
we unset it or even the parent if is was not set.
!                                               */
!                                               $parent_isset = 
isset($content[$regs[1]]);
! 
!                                               if ($readonly || 
!$this->process_show_cell($cell,$name,$c,$r,
!                                                               
$readonlys[$regs[1]][$regs[2]],$content[$regs[1]][$regs[2]]))
                                                {
!                                                       if (!$parent_isset)
!                                                       {
!                                                               
unset($content[$regs[1]]);
!                                                       }
!                                                       else
!                                                       {
!                                                               
unset($content[$regs[1]][$regs[2]]);
!                                                       }
                                                }
!                                       }
!                                       else
!                                       {
!                                               if ($readonly || 
!$this->process_show_cell($cell,$name,$c,$r,
!                                                               
$readonlys[$idx_cname],$content[$idx_cname]))
                                                {
!                                                       
unset($content[$idx_cname]);
                                                }
!                                       }
                                }
                        }
!                       if ($this->debug >= 2 || $this->debug == $this->name && 
$this->name)
                        {
!                               echo "<p>process_show($this->name) end: content 
="; _debug_array($content);
                        }
!               }
! 
!               /*!
!               @function process_show_cell
!               @syntax process_show_cell( $cell,$name,$c,$r,$readonlys,&$value 
)
!               @author ralfbecker
!               @abstract makes necessary adjustments on $value eTemplate / 
form gots submitted
!               @discussion This is only an internal function, dont call it 
direct use only exec
!               @discussion process_show recursivly calls itself for the 
included eTemplates.
!               @param $cell processed cell
!               @param $name expanded name of cell
!               @param $c,$r col,row index
!               @param $readonlys readonlys-array to pass on for templates
!               @param &$value value to change
!               @result if $value is set
!               */
!               function process_show_cell($cell,$name,$c,$r,$readonlys,&$value)
!               {
!                       if (is_array($cell['type']))
!                       {
!                               $cell['type'] = $cell['type'][0];
!                       }
!                       if ($this->debug >= 3 || $this->debug == $this->name || 
$this->debug == $cell['type'])
!                       {
!                               if (is_object($name))
!                               {
!                                       $name = $name->name;
!                               }
!                               echo "<p>process_show_cell(c=$c, r=$r, 
name='$name',type='${cell['type']}') start: isset(value)=".(0+isset($value)).", 
value=";
!                               if (is_array($value))
!                               {
!                                       _debug_array($value);
!                               }
!                               else
!                               {
!                                       echo "'$value'</p>\n";
!                               }
!                       }
!                       if ($this->haveExtension($cell['type'],'post_process'))
!                       {
!                               if ($this->debug > 1 || $this->debug && 
$this->debug == $this->name)
!                               {
!                                       echo "<p>value for 
$cell[type]::post_process: "; _debug_array($value);
!                               }
!                               $this->extensionPostProcess($cell,$value);
! 
!                               if ($this->debug > 1 || $this->debug && 
$this->debug == $this->name)
!                               {
!                                       echo "<p>value after 
$cell[type]::post_process: ";
!                                       if (is_array($value))
!                                       {
!                                               _debug_array($value);
!                                       }
!                                       else
!                                       {
!                                               echo "'$value'</p>";
!                                       }
!                               }
!                       }
!                       switch ($cell['type'])
!                       {
!                               case 'int':
!                               case 'float':
!                                       list($min,$max) = 
explode(',',$cell['size']);
!                                       /*
!                                       * TO DO: number- and range-check, if 
not enshured by java-script
!                                       */
!                                       break;
!                               case 'text':
!                               case 'textarea':
!                                       if (isset($value))
!                                       {
!                                               $value = stripslashes($value);
!                                       }
!                                       break;
!                               case 'checkbox':
!                                       if (!isset($value))     // checkbox was 
not checked
!                                       {
!                                               $value = 0;                     
// need to be reported too
!                                       }
!                                       break;
!                               case 'template':
!                                       if (!is_object($cell['obj']))
!                                       {
!                                               $cell['obj'] = new 
etemplate($cell['name'],$this->as_array());
!                                       }
!                                       //$templ = is_object($cell['name']) ? 
$cell['name'] : new etemplate($cell['name'],$this->as_array());
!                                       
$cell['obj']->process_show($value,$readonlys);
!                                       break;
!                               case 'select':
!                               case 'select-cat':
!                               case 'select-account':
!                                       if (is_array($value))
!                                       {
!                                               $value = count($value) <= 1 ? 
$value[0] : implode(',',$value);
!                                       }
!                                       break;
!                               default: // do nothing, $value is correct as is
!                       }
!                       if ($this->debug >= 3 || $this->debug == $this->name || 
$this->debug == $cell['type'])
                        {
!                               echo 
"<p>process_show_cell(name='$name',type='${cell['type']}) end: 
isset(value)=".(0+isset($value)).", value=";
!                               if (is_array($value))
!                               {
!                                       _debug_array($value);
!                               }
!                               else
!                               {
!                                       echo "'$value'</p>\n";
!                               }
                        }
-                       return isset($value);
                }
  
--- 678,732 ----
                        if ($this->debug >= 1 || $this->debug == $this->name && 
$this->name)
                        {
!                               echo "<p>process_show($this->name) start: 
content ="; _debug_array($GLOBALS['HTTP_POST_VARS']/*$content*/);
                        }
!                       $content_in = $cname ? array($cname => $content) : 
$content;
!                       $content = array();
!                       reset($to_process);
!                       while (list($form_name,$type) = each($to_process))
!                       {
!                               $value = 
$this->get_array($content_in,$form_name);
!                               list($type,$sub) = explode('-',$type);
!                               switch ($type)
!                               {
!                                       case 'ext':
!                                               
$this->extensionPostProcess($sub,$form_name,$this->get_array($content,$form_name),$value);
!                                               break;
!                                       case 'text':
!                                       case 'textarea':
!                                               if (isset($value))
                                                {
!                                                       $value = 
stripslashes($value);
                                                }
!                                               
$this->set_array($content,$form_name,$value);
!                                               break;
!                                       case 'button':
!                                               if ($value)
                                                {
!                                                       
$this->set_array($content,$form_name,$value);
                                                }
!                                               break;
!                                       case 'select':
!                                               
$this->set_array($content,$form_name,is_array($value) ? implode(',',$value) : 
$value);
!                                               break;
!                                       case 'checkbox':
!                                               if (!isset($value))     // 
checkbox was not checked
                                                {
!                                                       $value = 0;             
        // need to be reported too
                                                }
!                                               
$this->set_array($content,$form_name,$value);
!                                               break;
!                                       default:
!                                               
$this->set_array($content,$form_name,$value);
!                                               break;
                                }
                        }
!                       if ($cname)
                        {
!                               $content = $content[$cname];
                        }
!                       if ($this->debug >= 2 || $this->debug == $this->name && 
$this->name)
                        {
!                               echo "<p>process_show($this->name) end: content 
="; _debug_array($content);
                        }
                }
  

Index: class.xslt_widget.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.xslt_widget.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.xslt_widget.inc.php   29 Sep 2002 22:26:41 -0000      1.1
--- class.xslt_widget.inc.php   1 Oct 2002 18:26:30 -0000       1.2
***************
*** 25,29 ****
                var $public_functions = array(
                        'pre_process' => True,
!                       'render' => True
                );
                var $human_name = 'XSLT Template';      // this is the name for 
the editor
--- 25,30 ----
                var $public_functions = array(
                        'pre_process' => True,
!                       'render' => True,
!                       'post_process' => True
                );
                var $human_name = 'XSLT Template';      // this is the name for 
the editor
***************
*** 45,49 ****
                }
  
!               function 
pre_process(&$cell,&$value,&$extension_data,&$readonlys,&$tmpl)
                {
                        return False;   // no extra label
--- 46,50 ----
                }
  
!               function 
pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
                {
                        return False;   // no extra label
***************
*** 94,97 ****
--- 95,105 ----
                        ));
                        return $this->xslttemplates->parse();
+               }
+ 
+               function 
post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
+               {
+                       //echo "<p>xslt_widget.post_process: $name = "; 
_debug_array($value_in);
+ 
+                       $value = $value_in;
                }
        }





reply via email to

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