mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
fixed problem with vars as attributes in {include_php}
This commit is contained in:
@@ -2034,8 +2034,11 @@ class Smarty
|
|||||||
* wrapper for include() retaining $this
|
* wrapper for include() retaining $this
|
||||||
* @return mixed
|
* @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) {
|
if ($once) {
|
||||||
return include_once($filename);
|
return include_once($filename);
|
||||||
} else {
|
} else {
|
||||||
@@ -2048,8 +2051,11 @@ class Smarty
|
|||||||
* wrapper for eval() retaining $this
|
* wrapper for eval() retaining $this
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function _eval($code)
|
function _eval($code, $vars=null)
|
||||||
{
|
{
|
||||||
|
if (is_array($vars))
|
||||||
|
extract($vars, EXTR_PREFIX_SAME, 'include_php_');
|
||||||
|
|
||||||
return eval($code);
|
return eval($code);
|
||||||
}
|
}
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
@@ -26,22 +26,20 @@ function smarty_core_smarty_include_php($params, &$smarty)
|
|||||||
$_smarty_resource_type = $_params['resource_type'];
|
$_smarty_resource_type = $_params['resource_type'];
|
||||||
$_smarty_php_resource = $_params['php_resource'];
|
$_smarty_php_resource = $_params['php_resource'];
|
||||||
|
|
||||||
extract($params['smarty_include_vars'], EXTR_PREFIX_SAME, 'include_php_');
|
|
||||||
|
|
||||||
if (!empty($params['smarty_assign'])) {
|
if (!empty($params['smarty_assign'])) {
|
||||||
ob_start();
|
ob_start();
|
||||||
if ($_smarty_resource_type == 'file') {
|
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 {
|
} else {
|
||||||
$smarty->_eval($_smarty_php_resource);
|
$smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
|
||||||
}
|
}
|
||||||
$smarty->assign($params['smarty_assign'], ob_get_contents());
|
$smarty->assign($params['smarty_assign'], ob_get_contents());
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
} else {
|
} else {
|
||||||
if ($_smarty_resource_type == 'file') {
|
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 {
|
} else {
|
||||||
$smarty->_eval($_smarty_php_resource);
|
$smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user