mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 02:14: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
|
- fixed a bug with parsing function arguments inside {if} tags if a comma
|
||||||
was present. (Andrei)
|
was present. (Andrei)
|
||||||
- updated debug console with config file vars. (Monte)
|
- updated debug console with config file vars. (Monte)
|
||||||
|
@@ -172,22 +172,26 @@ class Smarty
|
|||||||
var $prefilter_funcs = array(); // what functions templates are prefiltered through
|
var $prefilter_funcs = array(); // what functions templates are prefiltered through
|
||||||
// before being compiled
|
// 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 */
|
/* END SMARTY CONFIGURATION SECTION */
|
||||||
/* There should be no need to touch anything below this line. */
|
/* There should be no need to touch anything below this line. */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
// internal vars
|
// internal vars
|
||||||
var $_error_msg = false; // error messages. true/false
|
var $_error_msg = false; // error messages. true/false
|
||||||
var $_tpl_vars = array(); // where assigned template vars are kept
|
var $_tpl_vars = array(); // where assigned template vars are kept
|
||||||
var $_sections = array(); // keeps track of sections
|
var $_sections = array(); // keeps track of sections
|
||||||
var $_conf_obj = null; // configuration object
|
var $_conf_obj = null; // configuration object
|
||||||
var $_config = array(); // loaded configuration settings
|
var $_config = array(); // loaded configuration settings
|
||||||
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
||||||
var $_version = '1.4.3'; // Smarty version number
|
var $_version = '1.4.3'; // Smarty version number
|
||||||
var $_extract = false; // flag for custom functions
|
var $_extract = false; // flag for custom functions
|
||||||
var $_included_tpls = array(); // list of run-time included templates
|
var $_included_tpls = array(); // list of run-time included templates
|
||||||
var $_inclusion_depth = 0; // current template inclusion depth
|
var $_inclusion_depth = 0; // current template inclusion depth
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
@@ -538,6 +542,8 @@ class Smarty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_assign_smarty_interface();
|
||||||
|
|
||||||
if ($this->_conf_obj === null) {
|
if ($this->_conf_obj === null) {
|
||||||
/* Prepare the configuration object. */
|
/* Prepare the configuration object. */
|
||||||
if (!class_exists('Config_File'))
|
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()
|
Function: _generate_debug_output()
|
||||||
Purpose: generate debug output
|
Purpose: generate debug output
|
||||||
|
@@ -172,22 +172,26 @@ class Smarty
|
|||||||
var $prefilter_funcs = array(); // what functions templates are prefiltered through
|
var $prefilter_funcs = array(); // what functions templates are prefiltered through
|
||||||
// before being compiled
|
// 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 */
|
/* END SMARTY CONFIGURATION SECTION */
|
||||||
/* There should be no need to touch anything below this line. */
|
/* There should be no need to touch anything below this line. */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
// internal vars
|
// internal vars
|
||||||
var $_error_msg = false; // error messages. true/false
|
var $_error_msg = false; // error messages. true/false
|
||||||
var $_tpl_vars = array(); // where assigned template vars are kept
|
var $_tpl_vars = array(); // where assigned template vars are kept
|
||||||
var $_sections = array(); // keeps track of sections
|
var $_sections = array(); // keeps track of sections
|
||||||
var $_conf_obj = null; // configuration object
|
var $_conf_obj = null; // configuration object
|
||||||
var $_config = array(); // loaded configuration settings
|
var $_config = array(); // loaded configuration settings
|
||||||
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
||||||
var $_version = '1.4.3'; // Smarty version number
|
var $_version = '1.4.3'; // Smarty version number
|
||||||
var $_extract = false; // flag for custom functions
|
var $_extract = false; // flag for custom functions
|
||||||
var $_included_tpls = array(); // list of run-time included templates
|
var $_included_tpls = array(); // list of run-time included templates
|
||||||
var $_inclusion_depth = 0; // current template inclusion depth
|
var $_inclusion_depth = 0; // current template inclusion depth
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
@@ -538,6 +542,8 @@ class Smarty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_assign_smarty_interface();
|
||||||
|
|
||||||
if ($this->_conf_obj === null) {
|
if ($this->_conf_obj === null) {
|
||||||
/* Prepare the configuration object. */
|
/* Prepare the configuration object. */
|
||||||
if (!class_exists('Config_File'))
|
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()
|
Function: _generate_debug_output()
|
||||||
Purpose: generate debug output
|
Purpose: generate debug output
|
||||||
|
Reference in New Issue
Block a user