phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: etemplate/inc get_var.php,NONE,1.1 class.etempla


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: etemplate/inc get_var.php,NONE,1.1 class.etemplate.inc.php,1.4,1.5 class.uietemplate.inc.php,1.46,1.47
Date: Thu, 17 Oct 2002 19:34:56 -0400

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

Modified Files:
        class.etemplate.inc.php class.uietemplate.inc.php 
Added Files:
        get_var.php 
Log Message:
some fixed to enable infolog with etemplates to run in 0.9.14


--- NEW FILE ---
<?php
        function reg_var($varname, $method = 'any', $valuetype = 
'alphanumeric',$default_value='',$register=True)
        {
                if($method == 'any')
                {
                        $method = 
Array('POST','GET','COOKIE','SERVER','GLOBAL','DEFAULT');
                }
                elseif(!is_array($method))
                {
                        $method = Array($method);
                }
                $cnt = count($method);
                for($i=0;$i<$cnt;$i++)
                {
                        switch(strtoupper($method[$i]))
                        {
                                case 'DEFAULT':
                                        if($default_value)
                                        {
                                                $value = $default_value;
                                                $i = $cnt+1; /* Found what we 
were looking for, now we end the loop */
                                        }
                                        break;
                                case 'GLOBAL':
                                        if(@isset($GLOBALS[$varname]))
                                        {
                                                $value = $GLOBALS[$varname];
                                                $i = $cnt+1;
                                        }
                                        break;
                                case 'POST':
                                case 'GET':
                                case 'COOKIE':
                                case 'SERVER':
                                        if(phpversion() >= '4.2.0')
                                        {
                                                $meth = 
'_'.strtoupper($method[$i]);
                                        }
                                        else
                                        {
                                                $meth = 
'HTTP_'.strtoupper($method[$i]).'_VARS';
                                        }
                                        if(@isset($GLOBALS[$meth][$varname]))
                                        {
                                                $value = 
$GLOBALS[$meth][$varname];
                                                $i = $cnt+1;
                                        }
                                        break;
                                default:
                                        
if(@isset($GLOBALS[strtoupper($method[$i])][$varname]))
                                        {
                                                $value = 
$GLOBALS[strtoupper($method[$i])][$varname];
                                                $i = $cnt+1;
                                        }
                                        break;
                        }
                }

                if (@!isset($value))
                {
                        $value = $default_value;
                }

                if (@!is_array($value))
                {
                        if ($value == '')
                        {
                                $result = $value;
                        }
                        else
                        {
                                if (sanitize($value,$valuetype) == 1)
                                {
                                        $result = $value;
                                }
                                else
                                {
                                        $result = $default_value;
                                }
                        }
                }
                else
                {
                        reset($value);
                        while(list($k, $v) = each($value))
                        {
                                if ($v == '')
                                {
                                        $result[$k] = $v;
                                }
                                else
                                {
                                        if (is_array($valuetype))
                                        {
                                                $vt = $valuetype[$k];
                                        }
                                        else
                                        {
                                                $vt = $valuetype;
                                        }

                                        if (sanitize($v,$vt) == 1)
                                        {
                                                $result[$k] = $v;
                                        }
                                        else
                                        {
                                                if (is_array($default_value))
                                                {
                                                        $result[$k] = 
$default_value[$k];
                                                }
                                                else
                                                {
                                                        $result[$k] = 
$default_value;
                                                }
                                        }
                                }
                        }
                }
                if($register)
                {
                        
$GLOBALS['phpgw_info'][$GLOBALS['phpgw_info']['flags']['currentapp']][$varname] 
= $result;
                }
                return $result;
        }

        /*!
         @function get_var
         @abstract retrieve a value from either a POST, GET, COOKIE, SERVER or 
from a class variable.
         @author skeeter
         @discussion This function is used to retrieve a value from a user 
defined order of methods.
         @syntax 
get_var('id',array('HTTP_POST_VARS'||'POST','HTTP_GET_VARS'||'GET','HTTP_COOKIE_VARS'||'COOKIE','GLOBAL','DEFAULT'));
         @example $this->id = 
get_var('id',array('HTTP_POST_VARS'||'POST','HTTP_GET_VARS'||'GET','HTTP_COOKIE_VARS'||'COOKIE','GLOBAL','DEFAULT'));
         @param $variable name
         @param $method ordered array of methods to search for supplied variable
         @param $default_value (optional)
        */
        function get_var($variable,$method='any',$default_value='')
        {
                return reg_var($variable,$method,'any',$default_value,False);
        }

Index: class.etemplate.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.etemplate.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.etemplate.inc.php     29 Sep 2002 08:50:18 -0000      1.4
--- class.etemplate.inc.php     17 Oct 2002 23:34:28 -0000      1.5
***************
*** 13,16 ****
--- 13,20 ----
        /* $Id$ */
  
+       if (!function_exists('get_var'))
+       {
+               include_once('get_var.php');
+       }
        $ui = ''; // html UI, which UI to use, should come from api and be in 
$GLOBALS['phpgw']???
        if ($_ENV['DISPLAY'] && isset($_SERVER['_']))

Index: class.uietemplate.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.uietemplate.inc.php,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** class.uietemplate.inc.php   17 Oct 2002 22:08:24 -0000      1.46
--- class.uietemplate.inc.php   17 Oct 2002 23:34:28 -0000      1.47
***************
*** 112,117 ****
                        }
                        $hooked = 
$GLOBALS['phpgw']->template->get_var('phpgw_body');
! 
!                       $GLOBALS['phpgw']->common->phpgw_header();
                        if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 
'etemplate')
                        {
--- 112,120 ----
                        }
                        $hooked = 
$GLOBALS['phpgw']->template->get_var('phpgw_body');
!                       
!                       if (address@hidden'phpgw_info']['etemplate']['hooked'])
!                       {
!                               $GLOBALS['phpgw']->common->phpgw_header();
!                       }
                        if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 
'etemplate')
                        {
***************
*** 149,153 ****
                        if ($this->stable)
                        {
!                               echo parse_navbar() . $html;
                        }
                        else
--- 152,160 ----
                        if ($this->stable)
                        {
!                               if 
(address@hidden'phpgw_info']['etemplate']['hooked'])
!                               {
!                                       echo parse_navbar();
!                               }
!                               echo $html;
                        }
                        else





reply via email to

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