mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- Added $smarty.template variable.
- Fixed {include_php} tag when dynamic values were used for 'file' attribute.
This commit is contained in:
5
NEWS
5
NEWS
@@ -1,3 +1,6 @@
|
|||||||
|
- fixed a problem with using dynamic values for 'file'
|
||||||
|
attribute of {include_php} tag. (Andrei)
|
||||||
|
- added $smarty.template variable. (Andrei)
|
||||||
- fixed several plugins that would not work if the plugin
|
- fixed several plugins that would not work if the plugin
|
||||||
directory was not the default one. (Andrei)
|
directory was not the default one. (Andrei)
|
||||||
- implemented support for block functions. (Andrei)
|
- implemented support for block functions. (Andrei)
|
||||||
@@ -339,4 +342,4 @@ Version 1.0
|
|||||||
------------
|
------------
|
||||||
- initial release
|
- initial release
|
||||||
|
|
||||||
/* vim: set et tw=64: */
|
/* vim: set et tw=64 ft=changelog: */
|
||||||
|
@@ -1008,6 +1008,33 @@ function _generate_debug_output() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*======================================================================*\
|
||||||
|
Function: _smarty_include_php()
|
||||||
|
Purpose: called for included templates
|
||||||
|
\*======================================================================*/
|
||||||
|
function _smarty_include_php($_smarty_include_php_file, $_smarty_assign)
|
||||||
|
{
|
||||||
|
$this->_get_php_resource($_smarty_include_php_file, $_smarty_resource_type,
|
||||||
|
$_smarty_php_resource);
|
||||||
|
|
||||||
|
if (!empty($_smarty_assign)) {
|
||||||
|
ob_start();
|
||||||
|
if ($_smarty_resource_type == 'file') {
|
||||||
|
include_once($_smarty_php_resource);
|
||||||
|
} else {
|
||||||
|
eval($_smarty_php_resource);
|
||||||
|
}
|
||||||
|
$this->assign($_smarty_assign, ob_get_contents());
|
||||||
|
ob_end_clean();
|
||||||
|
} else {
|
||||||
|
if ($_smarty_resource_type == 'file') {
|
||||||
|
include_once($_smarty_php_resource);
|
||||||
|
} else {
|
||||||
|
eval($_smarty_php_resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _config_load
|
Function: _config_load
|
||||||
Purpose: load configuration values
|
Purpose: load configuration values
|
||||||
|
@@ -633,26 +633,9 @@ class Smarty_Compiler extends Smarty {
|
|||||||
$this->_syntax_error("missing 'file' attribute in include_php tag");
|
$this->_syntax_error("missing 'file' attribute in include_php tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_get_php_resource($this->_dequote($attrs['file']),
|
$assign_var = $this->_dequote($attrs['assign']);
|
||||||
$resource_type, $php_resource);
|
|
||||||
|
|
||||||
if (!empty($attrs['assign'])) {
|
return "<?php \$this->_smarty_include_php($attrs[file], '$assign_var'); ?>";
|
||||||
$output = "<?php ob_start();\n";
|
|
||||||
if ($resource_type == 'file') {
|
|
||||||
$output .= 'include("' . $php_resource . '");'."\n";
|
|
||||||
} else {
|
|
||||||
$output .= $php_resource;
|
|
||||||
}
|
|
||||||
$output .= "\$this->assign(" . $attrs['assign'] . ", ob_get_contents()); ob_end_clean();\n?>";
|
|
||||||
} else {
|
|
||||||
if ($resource_type == 'file') {
|
|
||||||
$output = '<?php include("' . $php_resource . '"); ?>';
|
|
||||||
} else {
|
|
||||||
$output = '<?php ' . $php_resource . ' ?>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1350,6 +1333,13 @@ class Smarty_Compiler extends Smarty {
|
|||||||
case 'capture':
|
case 'capture':
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
case 'template':
|
||||||
|
$compiled_ref = "'$this->_current_file'";
|
||||||
|
if (count($indexes) > 1) {
|
||||||
|
$this->_syntax_error('$smarty' . implode('', $indexes) .' is an invalid reference');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$this->_syntax_error('$smarty.' . $ref . ' is an unknown reference');
|
$this->_syntax_error('$smarty.' . $ref . ' is an unknown reference');
|
||||||
break;
|
break;
|
||||||
|
@@ -1008,6 +1008,33 @@ function _generate_debug_output() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*======================================================================*\
|
||||||
|
Function: _smarty_include_php()
|
||||||
|
Purpose: called for included templates
|
||||||
|
\*======================================================================*/
|
||||||
|
function _smarty_include_php($_smarty_include_php_file, $_smarty_assign)
|
||||||
|
{
|
||||||
|
$this->_get_php_resource($_smarty_include_php_file, $_smarty_resource_type,
|
||||||
|
$_smarty_php_resource);
|
||||||
|
|
||||||
|
if (!empty($_smarty_assign)) {
|
||||||
|
ob_start();
|
||||||
|
if ($_smarty_resource_type == 'file') {
|
||||||
|
include_once($_smarty_php_resource);
|
||||||
|
} else {
|
||||||
|
eval($_smarty_php_resource);
|
||||||
|
}
|
||||||
|
$this->assign($_smarty_assign, ob_get_contents());
|
||||||
|
ob_end_clean();
|
||||||
|
} else {
|
||||||
|
if ($_smarty_resource_type == 'file') {
|
||||||
|
include_once($_smarty_php_resource);
|
||||||
|
} else {
|
||||||
|
eval($_smarty_php_resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _config_load
|
Function: _config_load
|
||||||
Purpose: load configuration values
|
Purpose: load configuration values
|
||||||
|
@@ -633,26 +633,9 @@ class Smarty_Compiler extends Smarty {
|
|||||||
$this->_syntax_error("missing 'file' attribute in include_php tag");
|
$this->_syntax_error("missing 'file' attribute in include_php tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_get_php_resource($this->_dequote($attrs['file']),
|
$assign_var = $this->_dequote($attrs['assign']);
|
||||||
$resource_type, $php_resource);
|
|
||||||
|
|
||||||
if (!empty($attrs['assign'])) {
|
return "<?php \$this->_smarty_include_php($attrs[file], '$assign_var'); ?>";
|
||||||
$output = "<?php ob_start();\n";
|
|
||||||
if ($resource_type == 'file') {
|
|
||||||
$output .= 'include("' . $php_resource . '");'."\n";
|
|
||||||
} else {
|
|
||||||
$output .= $php_resource;
|
|
||||||
}
|
|
||||||
$output .= "\$this->assign(" . $attrs['assign'] . ", ob_get_contents()); ob_end_clean();\n?>";
|
|
||||||
} else {
|
|
||||||
if ($resource_type == 'file') {
|
|
||||||
$output = '<?php include("' . $php_resource . '"); ?>';
|
|
||||||
} else {
|
|
||||||
$output = '<?php ' . $php_resource . ' ?>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1350,6 +1333,13 @@ class Smarty_Compiler extends Smarty {
|
|||||||
case 'capture':
|
case 'capture':
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
case 'template':
|
||||||
|
$compiled_ref = "'$this->_current_file'";
|
||||||
|
if (count($indexes) > 1) {
|
||||||
|
$this->_syntax_error('$smarty' . implode('', $indexes) .' is an invalid reference');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$this->_syntax_error('$smarty.' . $ref . ' is an unknown reference');
|
$this->_syntax_error('$smarty.' . $ref . ' is an unknown reference');
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user