phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: etemplate/inc class.uietemplate_gtk.inc.php,1.1,


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: etemplate/inc class.uietemplate_gtk.inc.php,1.1,1.2
Date: Wed, 20 Feb 2002 05:04:24 -0500

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

Modified Files:
        class.uietemplate_gtk.inc.php 
Log Message:
Got a nice persistent main-window with automatic scrollbars now.
Deleted a lot of stuff not needed for GTK.

Index: class.uietemplate_gtk.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.uietemplate_gtk.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.uietemplate_gtk.inc.php       20 Feb 2002 01:26:03 -0000      1.1
--- class.uietemplate_gtk.inc.php       20 Feb 2002 10:04:22 -0000      1.2
***************
*** 26,30 ****
        @param $debug enables debug messages: 0=no, 1=calls to show and 
process_show, 2=content of process_show
        @param                                3=calls to show_cell OR template- 
or cell-type name
-       @param $html,$sbox instances of html and sbox2 class used to generate 
the html
        */
        class etemplate extends boetemplate
--- 26,29 ----
***************
*** 33,36 ****
--- 32,43 ----
                                                // 3=calls to show_cell and 
process_show_cell, or template-name or cell-type
  
+               var $no_result = array( // field-types which generate no direct 
result
+                       'label' => True,
+                       'hrule' => True,
+                       'image' => True,
+                       'raw' => True,
+                       'template' => True
+               );
+ 
                /*!
                @function etemplate
***************
*** 42,48 ****
                        $this->public_functions += array(
                                'exec'                  => True,
-                               'process_exec'  => True,
-                               'show'                  => True,
-                               'process_show'  => True,
                        );
                        $this->boetemplate();
--- 49,52 ----
***************
*** 102,119 ****
                        /*
                        * Create a new top-level window and connect the signals 
to the appropriate
!                       * functions. Note that all constructors must be 
assigned by reference.
                        */
!                       $this->window = &new GtkWindow();
!                       
$this->window->connect('destroy',array('etemplate','destroy'));
!                       
$this->window->connect('delete-event',array('etemplate','delete_event'));
!                       $this->window->set_title('phpGroupware & GTK');
!                       $this->window->set_border_width(10);
  
                        $result = array();
!                       
$this->window->add($this->show($result,$content,$sel_options,$readonlys));
!                       /*
!                       * Show the window and all its child widgets.
!                       */
!                       $this->window->show_all();
  
                        /* Run the main loop. */
--- 106,137 ----
                        /*
                        * Create a new top-level window and connect the signals 
to the appropriate
!                       * functions if the window not already exists.
                        */
!                       if (!$GLOBALS['phpgw_info']['etemplate']['window'])
!                       {
!                               $window = &new GtkWindow();
!                               
$window->connect('destroy',array('etemplate','destroy'));
!                               
$window->connect('delete-event',array('etemplate','delete_event'));
!                               $window->set_title('phpGroupwareGTK');
!                               $window->set_default_size(800,600);
  
+                               $GLOBALS['phpgw_info']['etemplate']['window'] = 
&$window;
+                       }
+                       else
+                       {
+                               $window = 
&$GLOBALS['phpgw_info']['etemplate']['window'];
+                       }
                        $result = array();
!                       $table = 
&$this->show($result,$content,$sel_options,$readonlys);
!                       $table->set_border_width(10);
!                       $table->show();
! 
!                       $swindow = &new GtkScrolledWindow(null,null);
!                       
$swindow->set_policy(GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
!                       $swindow->add_with_viewport($table);
!                       $swindow->show();
! 
!                       $window->add($swindow);
!                       $window->show_all();
  
                        /* Run the main loop. */
***************
*** 122,127 ****
                        $this->collect_results();
  
!                       $this->window->hide();
!                       unset($this->window);
                        unset($this->widgets);
  
--- 140,146 ----
                        $this->collect_results();
  
!                       $swindow->hide();
!                       $window->remove($swindow);
!                       unset($swindow);
                        unset($this->widgets);
  
***************
*** 168,171 ****
--- 187,192 ----
                                switch ($set['type'])
                                {
+                                       case 'button':  // is already done in 
the signal-handler
+                                               break;
                                        case 'int':
                                        case 'float':
***************
*** 198,202 ****
                                        case 'textarea':
                                        case 'date':
-                                       case 'button':
                                }
                                echo " = '$set[var]'\n";
--- 219,222 ----
***************
*** 623,632 ****
                                        break;
  */                            default:
!                                       $html .= '<i>unknown type</i>';
                                        $widget = &new GtkLabel('unknown type: 
'.$cell['type']);
                                        break;
                        }
!                       $no_result = array('label' => True,'hrule' => 
True,'image' => True,'raw' => True,'template' => True);
!                       if ($widget && !$readonly && !$no_result[$cell['type']])
                        {
                                $this->widgets[] = array(
--- 643,651 ----
                                        break;
  */                            default:
!                                       //$html .= '<i>unknown type</i>';
                                        $widget = &new GtkLabel('unknown type: 
'.$cell['type']);
                                        break;
                        }
!                       if ($widget && !$readonly && 
!$this->no_result[$cell['type']])
                        {
                                $this->widgets[] = array(
***************
*** 675,918 ****
                        }
                        return $hbox ? $hbox : $widget;
-               }
- 
-               /*!
-               @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)
-               @returns the adjusted content (in the simplest case that would 
be $vars[$cname])
-               */
-               function process_show(&$content,$readonlys='')
-               {
-                       if (!$readonlys)
-                       {
-                               $readonlys = array();
-                       }
-                       if (!isset($content) || !is_array($content))
-                       {
-                               return;
-                       }
-                       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)
-                       {
-                               $old_cols = $cols;
-                               if (!(list($nul,$cols) = each($this->data)))    
// no further row
-                               {
-                                       $cols = $old_cols;
-                                       list($nul,$cell) = each($cols); 
reset($cols);
-                                       if 
((!$this->autorepeat_idx($cols['A'],0,$r,$idx,$idx_cname) ||
-                                               $idx_cname == '' || 
!$this->isset_array($idx,$content)) &&
-                                               
(!$this->autorepeat_idx($cols['B'],1,$r,$idx,$idx_cname) ||
-                                               $idx_cname == '' || 
!$this->isset_array($idx,$content)))
-                                       {
-                                               break;  // no auto-row-repeat
-                                       }
-                               }
-                               $row = 1+$r;
-                               for ($c = 0; True /*list($col,$cell) = 
each($cols)*/; ++$c)
-                               {
-                                       $old_cell = $cell;
-                                       if (!(list($nul,$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($idx,$content))
-                                               {
-                                                       break;  // no 
auto-col-repeat
-                                               }
-                                       }
-                                       else
-                                       {
-                                               
$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')    // only templates
-                                       {
-                                               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($cell,$name,$c,$r,$readonlys,&$value)
-               @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
-               @returns 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'])
-                       {
-                               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";
-                               }
-                       }
-                       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 'date':
-                                       if ($value['d'])
-                                       {
-                                               if (!$value['m'])
-                                               {
-                                                       $value['m'] = date('m');
-                                               }
-                                               if (!$value['Y'])
-                                               {
-                                                       $value['Y'] = date('Y');
-                                               }
-                                               if ($cell['size'] == '')
-                                               {
-                                                       $value = 
mktime(0,0,0,$value['m'],$value['d'],$value['Y']);
-                                               }
-                                               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]);
-                                                               }
-                                                               else
-                                                               {
-                                                                       $str .= 
$c;
-                                                               }
-                                                       }
-                                                       $value = $str;
-                                               }
-                                       }
-                                       else
-                                       {
-                                               $value = '';
-                                       }
-                                       break;
-                               case 'checkbox':
-                                       if (!isset($value))     // checkbox was 
not checked
-                                       {
-                                               $value = 0;                     
// need to be reported too
-                                       }
-                                       break;
-                               case 'template':
-                                       $templ = new etemplate($name);
-                                       $templ->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);
                }
        };
--- 694,697 ----




reply via email to

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