Implemented access to request vars via $smarty var.

This commit is contained in:
andrey
2001-07-03 21:24:27 +00:00
parent eb35a91397
commit 15139eefce
3 changed files with 130 additions and 20 deletions

2
NEWS
View File

@@ -1,3 +1,5 @@
- implemented access to request variables via auto-assigned $smarty
template variable. (Andrei)
- fixed a bug with parsing function arguments inside {if} tags if a comma
was present. (Andrei)
- updated debug console with config file vars. (Monte)

View File

@@ -172,6 +172,10 @@ class Smarty
var $prefilter_funcs = array(); // what functions templates are prefiltered through
// before being compiled
var $request_vars_order = "EGPCS"; // the order in which request variables are
// registered, similar to variables_order
// in php.ini
/**************************************************************************/
/* END SMARTY CONFIGURATION SECTION */
/* There should be no need to touch anything below this line. */
@@ -538,6 +542,8 @@ class Smarty
}
}
$this->_assign_smarty_interface();
if ($this->_conf_obj === null) {
/* Prepare the configuration object. */
if (!class_exists('Config_File'))
@@ -598,6 +604,54 @@ class Smarty
}
}
/*======================================================================*\
Function: _assign_smarty_interface
Purpose: assign $smarty interface variable
\*======================================================================*/
function _assign_smarty_interface()
{
$smarty = array('get' => $GLOBALS['HTTP_GET_VARS'],
'post' => $GLOBALS['HTTP_POST_VARS'],
'cookies' => $GLOBALS['HTTP_COOKIE_VARS'],
'session' => $GLOBALS['HTTP_SESSION_VARS'],
'server' => $GLOBALS['HTTP_SERVER_VARS'],
'env' => $GLOBALS['HTTP_ENV_VARS']);
$smarty['request'] = array();
foreach (preg_split('!!', $this->request_vars_order) as $c) {
switch (strtolower($c)) {
case 'p':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_POST_VARS']);
break;
case 'c':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_COOKIE_VARS']);
break;
case 'g':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_GET_VARS']);
break;
case 'e':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_ENV_VARS']);
break;
case 's':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_SERVER_VARS']);
break;
}
}
$this->assign('smarty', $smarty);
}
/*======================================================================*\
Function: _generate_debug_output()
Purpose: generate debug output

View File

@@ -172,6 +172,10 @@ class Smarty
var $prefilter_funcs = array(); // what functions templates are prefiltered through
// before being compiled
var $request_vars_order = "EGPCS"; // the order in which request variables are
// registered, similar to variables_order
// in php.ini
/**************************************************************************/
/* END SMARTY CONFIGURATION SECTION */
/* There should be no need to touch anything below this line. */
@@ -538,6 +542,8 @@ class Smarty
}
}
$this->_assign_smarty_interface();
if ($this->_conf_obj === null) {
/* Prepare the configuration object. */
if (!class_exists('Config_File'))
@@ -598,6 +604,54 @@ class Smarty
}
}
/*======================================================================*\
Function: _assign_smarty_interface
Purpose: assign $smarty interface variable
\*======================================================================*/
function _assign_smarty_interface()
{
$smarty = array('get' => $GLOBALS['HTTP_GET_VARS'],
'post' => $GLOBALS['HTTP_POST_VARS'],
'cookies' => $GLOBALS['HTTP_COOKIE_VARS'],
'session' => $GLOBALS['HTTP_SESSION_VARS'],
'server' => $GLOBALS['HTTP_SERVER_VARS'],
'env' => $GLOBALS['HTTP_ENV_VARS']);
$smarty['request'] = array();
foreach (preg_split('!!', $this->request_vars_order) as $c) {
switch (strtolower($c)) {
case 'p':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_POST_VARS']);
break;
case 'c':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_COOKIE_VARS']);
break;
case 'g':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_GET_VARS']);
break;
case 'e':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_ENV_VARS']);
break;
case 's':
$smarty['request'] = array_merge($smarty['request'],
$GLOBALS['HTTP_SERVER_VARS']);
break;
}
}
$this->assign('smarty', $smarty);
}
/*======================================================================*\
Function: _generate_debug_output()
Purpose: generate debug output