From d63e2607f8b89056c3c621a369b93b8c6052ab54 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 17 Oct 2002 23:34:28 +0000 Subject: [PATCH] some fixed to enable infolog with etemplates to run in 0.9.14 --- etemplate/inc/class.etemplate.inc.php | 4 + etemplate/inc/class.uietemplate.inc.php | 13 +- etemplate/inc/get_var.php | 141 ++++++++++++++++++++++ infolog/inc/class.bolink.inc.php | 2 + infolog/inc/class.solink.inc.php | 1 + infolog/inc/hook_addressbook_view.inc.php | 8 +- 6 files changed, 164 insertions(+), 5 deletions(-) create mode 100644 etemplate/inc/get_var.php diff --git a/etemplate/inc/class.etemplate.inc.php b/etemplate/inc/class.etemplate.inc.php index 262b1eace9..3da9b45c33 100644 --- a/etemplate/inc/class.etemplate.inc.php +++ b/etemplate/inc/class.etemplate.inc.php @@ -12,6 +12,10 @@ /* $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['_'])) { diff --git a/etemplate/inc/class.uietemplate.inc.php b/etemplate/inc/class.uietemplate.inc.php index f0a0542236..bf3b1816d8 100644 --- a/etemplate/inc/class.uietemplate.inc.php +++ b/etemplate/inc/class.uietemplate.inc.php @@ -111,8 +111,11 @@ $changes = array(); } $hooked = $GLOBALS['phpgw']->template->get_var('phpgw_body'); - - $GLOBALS['phpgw']->common->phpgw_header(); + + if (!@$GLOBALS['phpgw_info']['etemplate']['hooked']) + { + $GLOBALS['phpgw']->common->phpgw_header(); + } if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'etemplate') { $GLOBALS['phpgw']->translation->add_app('etemplate'); // some extensions have own texts @@ -148,7 +151,11 @@ if ($this->stable) { - echo parse_navbar() . $html; + if (!@$GLOBALS['phpgw_info']['etemplate']['hooked']) + { + echo parse_navbar(); + } + echo $html; } else { diff --git a/etemplate/inc/get_var.php b/etemplate/inc/get_var.php new file mode 100644 index 0000000000..7b79300144 --- /dev/null +++ b/etemplate/inc/get_var.php @@ -0,0 +1,141 @@ += '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); + } diff --git a/infolog/inc/class.bolink.inc.php b/infolog/inc/class.bolink.inc.php index 7f59f1d330..c58bb508c5 100644 --- a/infolog/inc/class.bolink.inc.php +++ b/infolog/inc/class.bolink.inc.php @@ -13,6 +13,8 @@ /* $Id$ */ include_once(PHPGW_INCLUDE_ROOT . '/infolog/inc/class.solink.inc.php'); + + $GLOBALS['phpgw_info']['flags']['included_classes']['bolink'] = True; /*! @class bolink diff --git a/infolog/inc/class.solink.inc.php b/infolog/inc/class.solink.inc.php index 29a9170aee..700edbacfa 100644 --- a/infolog/inc/class.solink.inc.php +++ b/infolog/inc/class.solink.inc.php @@ -12,6 +12,7 @@ /* $Id$ */ + $GLOBALS['phpgw_info']['flags']['included_classes']['solink'] = True; /*! @class solink @author ralfbecker diff --git a/infolog/inc/hook_addressbook_view.inc.php b/infolog/inc/hook_addressbook_view.inc.php index fa195a21c0..75db5c46d8 100644 --- a/infolog/inc/hook_addressbook_view.inc.php +++ b/infolog/inc/hook_addressbook_view.inc.php @@ -12,7 +12,7 @@ /* $Id$ */ $save_app = $GLOBALS['phpgw_info']['flags']['currentapp']; - $GLOBALS['phpgw_info']['flags']['currentapp'] = 'infolog'; + $GLOBALS['phpgw_info']['flags']['currentapp'] = 'infolog'; $GLOBALS['phpgw']->translation->add_app('infolog'); @@ -25,9 +25,13 @@ $out = $html->form($out,'','/index.php',array('menuaction'=>'addressbook.uiaddressbook.view','ab_id'=>$GLOBALS['ab_id'])); $GLOBALS['phpgw']->template->set_var('phpgw_body',$out,True); */ + $GLOBALS['phpgw_info']['etemplate']['hooked'] = True; + $infolog = CreateObject('infolog.uiinfolog'); $infolog->index(0,'addressbook',$GLOBALS['ab_id'],array( 'menuaction' => 'addressbook.uiaddressbook.view', 'ab_id' => $GLOBALS['ab_id'] )); - $GLOBALS['phpgw_info']['flags']['currentapp'] = $save_app; + $GLOBALS['phpgw_info']['flags']['currentapp'] = $save_app; + unset($GLOBALS['phpgw_info']['etemplate']['hooked']); +