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.10,1.1


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: etemplate/inc class.boetemplate.inc.php,1.10,1.11 class.html.inc.php,1.2,1.3 class.tab_widget.inc.php,1.3,1.4 class.uietemplate.inc.php,1.12,1.13
Date: Sat, 15 Jun 2002 15:58:38 -0400

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

Modified Files:
        class.boetemplate.inc.php class.html.inc.php 
        class.tab_widget.inc.php class.uietemplate.inc.php 
Log Message:
button can be just a link now, if you set onChange for the button and 
javascript is enabled.
Added a test for javascript and removed all javascript from the output if 
javascript is not enabled.

Index: class.boetemplate.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.boetemplate.inc.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** class.boetemplate.inc.php   15 Jun 2002 12:52:33 -0000      1.10
--- class.boetemplate.inc.php   15 Jun 2002 19:58:35 -0000      1.11
***************
*** 385,390 ****
                function complete_array_merge($old,$new)
                {
!                       reset($new);
!                       while (list($k,$v) = each($new))
                        {
                                if (!is_array($v) || !isset($old[$k]) || $k[0] 
== '_')
--- 385,390 ----
                function complete_array_merge($old,$new)
                {
!                       @reset($new);
!                       while (list($k,$v) = @each($new))
                        {
                                if (!is_array($v) || !isset($old[$k]) || $k[0] 
== '_')

Index: class.html.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.html.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.html.inc.php  14 Feb 2002 14:06:30 -0000      1.2
--- class.html.inc.php  15 Jun 2002 19:58:35 -0000      1.3
***************
*** 24,28 ****
        }
  
!       function input_hidden($vars,$value='')
        {
                if (!is_array($vars))
--- 24,28 ----
        }
  
!       function input_hidden($vars,$value='',$ignore_empty=True)
        {
                if (!is_array($vars))
***************
*** 34,38 ****
                        if (is_array($value)) $value = serialize($value);
                        $del = strchr($value,'"') ? "'" : '"';
!                       if ($value && !($name == 'filter' && $value == 'none')) 
// dont need to send all the empty vars
                        {
                                $html .= "<INPUT TYPE=HIDDEN NAME=\"$name\" 
VALUE=$del$value$del>\n";
--- 34,38 ----
                        if (is_array($value)) $value = serialize($value);
                        $del = strchr($value,'"') ? "'" : '"';
!                       if (!$ignore_empty || $value && !($name == 'filter' && 
$value == 'none'))       // dont need to send all the empty vars
                        {
                                $html .= "<INPUT TYPE=HIDDEN NAME=\"$name\" 
VALUE=$del$value$del>\n";
***************
*** 96,102 ****
        }
  
!       function form($content,$hidden_vars,$url,$url_vars='',$method='POST')
        {
!               $html = "<form method=\"$method\" 
action=\"".$this->link($url,$url_vars)."\">\n";
                $html .= $this->input_hidden($hidden_vars);
  
--- 96,102 ----
        }
  
!       function 
form($content,$hidden_vars,$url,$url_vars='',$name='',$method='POST')
        {
!               $html = "<form method=\"$method\" ".($name != '' ? 
"name=\"$name\" " : '')."action=\"".$this->link($url,$url_vars)."\">\n";
                $html .= $this->input_hidden($hidden_vars);
  
***************
*** 109,116 ****
  
        function form_1button($name,$lang,$hidden_vars,$url,$url_vars='',
!                                                                $method='POST')
        {
                return $this->form($this->submit_button($name,$lang),
!                                                                
$hidden_vars,$url,$url_vars,$method);
        }
  
--- 109,116 ----
  
        function form_1button($name,$lang,$hidden_vars,$url,$url_vars='',
!                                                                
$form_name='',$method='POST')
        {
                return $this->form($this->submit_button($name,$lang),
!                                                                
$hidden_vars,$url,$url_vars,$form_name,$method);
        }
  

Index: class.tab_widget.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.tab_widget.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.tab_widget.inc.php    15 Jun 2002 12:54:18 -0000      1.3
--- class.tab_widget.inc.php    15 Jun 2002 19:58:35 -0000      1.4
***************
*** 47,51 ****
                        {
                                $tcell = $tabs->empty_cell();
!                               if (is_array($value['_tab_widget']) && 
isset($value['_tab_widget'][$name]))
                                {
                                        // save selected tab in persistent 
extension_data to use it in post_process
--- 47,51 ----
                        {
                                $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
***************
*** 96,104 ****
                        $old_value = array(
                                '_tab_widget' => array(
!                                       
$GLOBALS['phpgw_info']['etemplate']['extension_data']['tab_widget'][$cell['name']]
 => True
                        ));
                        $this->pre_process($cell,$old_value,$templ);
  
!                       $templ->loop = is_array($value['_tab_widget']);
  
                        return True;
--- 96,114 ----
                        $old_value = array(
                                '_tab_widget' => array(
!                                       
$GLOBALS['phpgw_info']['etemplate']['extension_data']['tab_widget'][$cell['name']]
 => array(True)
                        ));
                        $this->pre_process($cell,$old_value,$templ);
  
!                       if (is_array($value['_tab_widget']))
!                       {
!                               while (list($key,$val) = 
each($value['_tab_widget']))
!                               {
!                                       if (is_array($val) && $val[0])
!                                       {
!                                               $templ->loop = True;
!                                       }
!                               }
!                       }
!                       //$templ->loop = is_array($value['_tab_widget']);
  
                        return True;

Index: class.uietemplate.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.uietemplate.inc.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** class.uietemplate.inc.php   15 Jun 2002 09:21:55 -0000      1.12
--- class.uietemplate.inc.php   15 Jun 2002 19:58:35 -0000      1.13
***************
*** 30,34 ****
        class etemplate extends boetemplate
        {
!               var $debug;//'test.tabs2';//='etemplate.editor.edit'; // 
1=calls to show and process_show, 2=content after process_show,
                                                // 3=calls to show_cell and 
process_show_cell, or template-name or cell-type
                var $html,$sbox;        // instance of html / sbox2-class
--- 30,34 ----
        class etemplate extends boetemplate
        {
!               var $debug; // 1=calls to show and process_show, 2=content 
after process_show,
                                                // 3=calls to show_cell and 
process_show_cell, or template-name or cell-type
                var $html,$sbox;        // instance of html / sbox2-class
***************
*** 81,84 ****
--- 81,85 ----
                function 
exec($method,$content,$sel_options='',$readonlys='',$preserv='',$changes='')
                {
+                       //echo "<br>globals[java_script] = 
'".$GLOBALS['phpgw_info']['etemplate']['java_script']."', this->java_script() = 
'".$this->java_script()."'\n";
                        if (!$sel_options)
                        {
***************
*** 100,106 ****
  
                        $id = $this->appsession_id();
!                       $html = 
$this->html->nextMatchStyles($this->style)."\n\n". // so they get included once
!                               
$this->html->form($this->show($this->complete_array_merge($content,$changes),$sel_options,$readonlys,'exec'),
!                                       array('etemplate_exec_id' => 
$id),'/index.php?menuaction=etemplate.etemplate.process_exec');
  
                        $id = $this->save_appsession($this->as_array(1) + array(
--- 101,109 ----
  
                        $id = $this->appsession_id();
! 
!                       $html .= 
$this->html->nextMatchStyles($this->style)."\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),'/index.php?menuaction=etemplate.etemplate.process_exec','','eTemplate');
  
                        $id = $this->save_appsession($this->as_array(1) + array(
***************
*** 111,114 ****
--- 114,118 ----
                                'preserv' => $preserv,
                                'extension_data' => 
$GLOBALS['phpgw_info']['etemplate']['extension_data'],
+                               'java_script' => 
$GLOBALS['phpgw_info']['etemplate']['java_script'],
                                'method' => $method
                        ),$id);
***************
*** 137,142 ****
                function process_exec()
                {
                        $session_data = 
$this->get_appsession($GLOBALS['HTTP_POST_VARS']['etemplate_exec_id']);
!                       //echo "<p>process_exec($this->name) session_data ="; 
_debug_array($session_data);
  
                        $content = $GLOBALS['HTTP_POST_VARS']['exec'];
--- 141,147 ----
                function process_exec()
                {
+                       //echo "process_exec: HTTP_POST_VARS ="; 
_debug_array($GLOBALS['HTTP_POST_VARS']);
                        $session_data = 
$this->get_appsession($GLOBALS['HTTP_POST_VARS']['etemplate_exec_id']);
!                       //echo "<p>process_exec: session_data ="; 
_debug_array($session_data);
  
                        $content = $GLOBALS['HTTP_POST_VARS']['exec'];
***************
*** 147,151 ****
                        $this->init($session_data);
                        $GLOBALS['phpgw_info']['etemplate']['extension_data'] = 
$session_data['extension_data'];
! 
                        //echo "process_exec($this->name) content ="; 
_debug_array($content);
                        
$this->process_show($content,$session_data['readonlys']);
--- 152,157 ----
                        $this->init($session_data);
                        $GLOBALS['phpgw_info']['etemplate']['extension_data'] = 
$session_data['extension_data'];
!                       $GLOBALS['phpgw_info']['etemplate']['java_script'] = 
$session_data['java_script'] || $GLOBALS['HTTP_POST_VARS']['java_script'];
!                       //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']);
***************
*** 379,395 ****
                                $help = 
$this->get_array($content,substr($help,1));
                        }
!                       if ($help)
                        {
!                               $options .= " 
onFocus=\"self.status='".addslashes(lang($help))."'; return true;\"";
!                               $options .= " onBlur=\"self.status=''; return 
true;\"";
!                               if ($cell['type'] == 'button')  // for button 
additionally when mouse over button
                                {
!                                       $options .= " 
onMouseOver=\"self.status='".addslashes(lang($help))."'; return true;\"";
!                                       $options .= " 
onMouseOut=\"self.status=''; return true;\"";
                                }
-                       }
-                       if ($cell['onchange'])  // values != '1' can only set 
by a program (not in the editor so far)
-                       {
-                               $options .= ' 
onChange="'.($cell['onchange']=='1'?'this.form.submit();':$cell['onchange']).'"';
                        }
                        switch ($cell['type'])
--- 385,404 ----
                                $help = 
$this->get_array($content,substr($help,1));
                        }
!                       if ($this->java_script())
                        {
!                               if ($help)
                                {
!                                       $options .= " 
onFocus=\"self.status='".addslashes(lang($help))."'; return true;\"";
!                                       $options .= " onBlur=\"self.status=''; 
return true;\"";
!                                       if ($cell['type'] == 'button')  // for 
button additionally when mouse over button
!                                       {
!                                               $options .= " 
onMouseOver=\"self.status='".addslashes(lang($help))."'; return true;\"";
!                                               $options .= " 
onMouseOut=\"self.status=''; return true;\"";
!                                       }
!                               }
!                               if ($cell['onchange'] && $cell['type'] != 
'button')     // values != '1' can only set by a program (not in the editor so 
far)
!                               {
!                                       $options .= ' 
onChange="'.($cell['onchange']=='1'?'this.form.submit();':$cell['onchange']).'"';
                                }
                        }
                        switch ($cell['type'])
***************
*** 442,447 ****
                                        break;
                                case 'button':
!                                       $html .= 
$this->html->submit_button($form_name,$label,'',
!                                               strlen($label) <= 1 || 
$cell['no_lang'],$options);
                                        $extra_label = False;
                                        break;
--- 451,465 ----
                                        break;
                                case 'button':
!                                       if ($this->java_script() && 
$cell['onchange'])
!                                       {
!                                               $html .= 
$this->html->input_hidden($form_name,'',False) . "\n";
!                                               $html .= '<a href="" 
onClick="set_element(document.eTemplate,\''.$form_name.'\',\'pressed\'); 
document.eTemplate.submit(); return false;">' .
!                                                       (strlen($label) <= 1 || 
$cell['no_lang'] ? $label : lang($label)) . '</a>';
!                                       }
!                                       else
!                                       {
!                                               $html .= 
$this->html->submit_button($form_name,$label,'',
!                                                       strlen($label) <= 1 || 
$cell['no_lang'],$options);
!                                       }
                                        $extra_label = False;
                                        break;
***************
*** 791,794 ****
--- 809,861 ----
                        }
                        return isset($value);
+               }
+ 
+               /*!
+               @function java_script($consider_not_tested_as_enabled = True)
+               @abstract is javascript enabled?
+               @discussion this should be tested by the api at login
+               @returns true if javascript is enabled or not yet tested
+               */
+               function java_script($consider_not_tested_as_enabled = True)
+               {
+                       return 
!!$GLOBALS['phpgw_info']['etemplate']['java_script'] ||
+                               $consider_not_tested_as_enabled &&
+                               
(!isset($GLOBALS['phpgw_info']['etemplate']['java_script']) ||
+                               
$GLOBALS['phpgw_info']['etemplate']['java_script'].'' == '');
+               }
+ 
+               /*!
+               @function include_java_script()
+               @abstract returns the javascript to be included by exec
+               */
+               function include_java_script()
+               {
+                       // this is to test if javascript is enabled
+                       if 
(!isset($GLOBALS['phpgw_info']['etemplate']['java_script']))
+                       {
+                               $js = '<script language="javascript">
+ 
document.write(\''.str_replace("\n",'',$this->html->input_hidden('java_script','1')).'\');
+ </script>
+ ';
+                       }
+ 
+                       // here are going all the necesarry functions if 
javascript is definitve enabled
+                       if ($this->java_script(False))
+                       {
+                               $js .= '<script language="JavaScript">
+ function set_element(form,name,value)
+ {
+       for (i = 0; i < form.length; i++)
+       {
+               if (form.elements[i].name == name)
+               {
+                       form.elements[i].value = value;
+               }
+       }
+ }
+ </script>
+ ';
+                       }
+                       return $js;
                }
        };




reply via email to

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