mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
Implemented access to request vars via $smarty var.
This commit is contained in:
2
NEWS
2
NEWS
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user