mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
Fix passing variables to included files.
This commit is contained in:
@@ -696,10 +696,10 @@ class Smarty
|
|||||||
Function: _smarty_include()
|
Function: _smarty_include()
|
||||||
Purpose: called for included templates
|
Purpose: called for included templates
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _smarty_include($_smarty_include_tpl_file ,$_smarty_def_vars,
|
function _smarty_include($_smarty_include_tpl_file, $_smarty_include_vars,
|
||||||
$_smarty_include_vars, &$_smarty_config_parent)
|
&$_smarty_config_parent)
|
||||||
{
|
{
|
||||||
extract($_smarty_def_vars);
|
$this->_tpl_vars = array_merge($this->_tpl_vars, $_smarty_include_vars);
|
||||||
extract($_smarty_include_vars);
|
extract($_smarty_include_vars);
|
||||||
|
|
||||||
$this->_process_template($_smarty_include_tpl_file, $compile_path);
|
$this->_process_template($_smarty_include_tpl_file, $compile_path);
|
||||||
|
@@ -363,7 +363,9 @@ class Smarty_Compiler extends Smarty {
|
|||||||
|
|
||||||
foreach ($attrs as $arg_name => $arg_value) {
|
foreach ($attrs as $arg_name => $arg_value) {
|
||||||
if ($arg_name == 'file') {
|
if ($arg_name == 'file') {
|
||||||
$_smarty_include_tpl_file = $arg_value;
|
$_smarty_include_tpl_file = $this->_dequote($arg_value);
|
||||||
|
if ($_smarty_include_tpl_file{0} != '$')
|
||||||
|
$_smarty_include_tpl_file = '"' . $_smarty_include_tpl_file . '"';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (is_bool($arg_value))
|
if (is_bool($arg_value))
|
||||||
@@ -372,11 +374,12 @@ class Smarty_Compiler extends Smarty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "<?php " .
|
return "<?php " .
|
||||||
"\$_smarty_defined_vars = get_defined_vars();\n" .
|
"\$_smarty_tpl_vars = \$this->_tpl_vars;\n" .
|
||||||
"unset(\$_smarty_defined_vars['_smarty_include_tpl_file']);\n" .
|
"unset(\$_smarty_defined_vars['_smarty_include_tpl_file']);\n" .
|
||||||
"unset(\$_smarty_defined_vars['_smarty_def_vars']);\n" .
|
|
||||||
"unset(\$_smarty_defined_vars['_smarty_include_vars']);\n" .
|
"unset(\$_smarty_defined_vars['_smarty_include_vars']);\n" .
|
||||||
"\$this->_smarty_include(".$_smarty_include_tpl_file.", \$_smarty_defined_vars, array(".implode(',', (array)$arg_list)."), \$_smarty_config);\n?>";
|
"\$this->_smarty_include(".$_smarty_include_tpl_file.", array(".implode(',', (array)$arg_list)."), \$_smarty_config);\n" .
|
||||||
|
"\$this->_tpl_vars = \$_smarty_defined_vars;\n" .
|
||||||
|
"unset(\$_smarty_tpl_vars); ?>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
|
@@ -696,10 +696,10 @@ class Smarty
|
|||||||
Function: _smarty_include()
|
Function: _smarty_include()
|
||||||
Purpose: called for included templates
|
Purpose: called for included templates
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _smarty_include($_smarty_include_tpl_file ,$_smarty_def_vars,
|
function _smarty_include($_smarty_include_tpl_file, $_smarty_include_vars,
|
||||||
$_smarty_include_vars, &$_smarty_config_parent)
|
&$_smarty_config_parent)
|
||||||
{
|
{
|
||||||
extract($_smarty_def_vars);
|
$this->_tpl_vars = array_merge($this->_tpl_vars, $_smarty_include_vars);
|
||||||
extract($_smarty_include_vars);
|
extract($_smarty_include_vars);
|
||||||
|
|
||||||
$this->_process_template($_smarty_include_tpl_file, $compile_path);
|
$this->_process_template($_smarty_include_tpl_file, $compile_path);
|
||||||
|
@@ -363,7 +363,9 @@ class Smarty_Compiler extends Smarty {
|
|||||||
|
|
||||||
foreach ($attrs as $arg_name => $arg_value) {
|
foreach ($attrs as $arg_name => $arg_value) {
|
||||||
if ($arg_name == 'file') {
|
if ($arg_name == 'file') {
|
||||||
$_smarty_include_tpl_file = $arg_value;
|
$_smarty_include_tpl_file = $this->_dequote($arg_value);
|
||||||
|
if ($_smarty_include_tpl_file{0} != '$')
|
||||||
|
$_smarty_include_tpl_file = '"' . $_smarty_include_tpl_file . '"';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (is_bool($arg_value))
|
if (is_bool($arg_value))
|
||||||
@@ -372,11 +374,12 @@ class Smarty_Compiler extends Smarty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "<?php " .
|
return "<?php " .
|
||||||
"\$_smarty_defined_vars = get_defined_vars();\n" .
|
"\$_smarty_tpl_vars = \$this->_tpl_vars;\n" .
|
||||||
"unset(\$_smarty_defined_vars['_smarty_include_tpl_file']);\n" .
|
"unset(\$_smarty_defined_vars['_smarty_include_tpl_file']);\n" .
|
||||||
"unset(\$_smarty_defined_vars['_smarty_def_vars']);\n" .
|
|
||||||
"unset(\$_smarty_defined_vars['_smarty_include_vars']);\n" .
|
"unset(\$_smarty_defined_vars['_smarty_include_vars']);\n" .
|
||||||
"\$this->_smarty_include(".$_smarty_include_tpl_file.", \$_smarty_defined_vars, array(".implode(',', (array)$arg_list)."), \$_smarty_config);\n?>";
|
"\$this->_smarty_include(".$_smarty_include_tpl_file.", array(".implode(',', (array)$arg_list)."), \$_smarty_config);\n" .
|
||||||
|
"\$this->_tpl_vars = \$_smarty_defined_vars;\n" .
|
||||||
|
"unset(\$_smarty_tpl_vars); ?>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
|
Reference in New Issue
Block a user