fixed problem with vars as attributes in {include_php}

This commit is contained in:
messju
2003-08-13 16:37:12 +00:00
parent 4b034eaa81
commit 2319787c5f
2 changed files with 12 additions and 8 deletions

View File

@@ -2034,8 +2034,11 @@ class Smarty
* wrapper for include() retaining $this
* @return mixed
*/
function _include($filename, $once=false)
function _include($filename, $once=false, $vars=null)
{
if (is_array($vars))
extract($vars, EXTR_PREFIX_SAME, 'include_php_');
if ($once) {
return include_once($filename);
} else {
@@ -2048,8 +2051,11 @@ class Smarty
* wrapper for eval() retaining $this
* @return mixed
*/
function _eval($code)
function _eval($code, $vars=null)
{
if (is_array($vars))
extract($vars, EXTR_PREFIX_SAME, 'include_php_');
return eval($code);
}
/**#@-*/

View File

@@ -26,22 +26,20 @@ function smarty_core_smarty_include_php($params, &$smarty)
$_smarty_resource_type = $_params['resource_type'];
$_smarty_php_resource = $_params['php_resource'];
extract($params['smarty_include_vars'], EXTR_PREFIX_SAME, 'include_php_');
if (!empty($params['smarty_assign'])) {
ob_start();
if ($_smarty_resource_type == 'file') {
$smarty->_include($_smarty_php_resource, $params['smarty_once']);
$smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
} else {
$smarty->_eval($_smarty_php_resource);
$smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
}
$smarty->assign($params['smarty_assign'], ob_get_contents());
ob_end_clean();
} else {
if ($_smarty_resource_type == 'file') {
$smarty->_include($_smarty_php_resource, $params['smarty_once']);
$smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
} else {
$smarty->_eval($_smarty_php_resource);
$smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
}
}
}