mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 19:34:27 +02:00
- the {function} tag can no longer overwrite standard smarty tags
- inherit functions defined by the {fuction} tag into subtemplates - added {while <statement>} sytax to while tag
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
04/28/2009
|
||||
- the {function} tag can no longer overwrite standard smarty tags
|
||||
- inherit functions defined by the {fuction} tag into subtemplates
|
||||
- added {while <statement>} sytax to while tag
|
||||
|
||||
04/26/2009
|
||||
- added trusted stream checking to security
|
||||
- internal changes at file dependency check for caching
|
||||
|
@@ -27,7 +27,13 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$this->_open_tag('if');
|
||||
return '<?php if (' . $args['if condition'] . '): ?>';
|
||||
if (is_array($args['if condition'])) {
|
||||
$_output = " <?php if (!isset(\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$args['if condition']['var']."] = new Smarty_Variable;\n";
|
||||
$_output .= " if (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value']."): ?>";
|
||||
return $_output;
|
||||
} else {
|
||||
return '<?php if (' . $args['if condition'] . '): ?>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -36,8 +36,12 @@ class Smarty_Internal_Compile_Internal_Function_Call extends Smarty_Internal_Com
|
||||
// create template object
|
||||
$_output = "<?php \$_template = new Smarty_Template ('string:', \$_smarty_tpl);\n";
|
||||
// assign default paramter
|
||||
if (isset($compiler->template->properties['function'][$_name]['parameter'])) {
|
||||
foreach ($compiler->template->properties['function'][$_name]['parameter'] as $_key => $_value) {
|
||||
$_ptr = $compiler->template;
|
||||
while ($_ptr != null && !isset($_ptr->properties['function'][$_name])) {
|
||||
$_ptr = $_ptr->parent;
|
||||
}
|
||||
if ($_ptr != null && isset($_ptr->properties['function'][$_name]['parameter'])) {
|
||||
foreach ($_ptr->properties['function'][$_name]['parameter'] as $_key => $_value) {
|
||||
if (!isset($_attr[$_key])) {
|
||||
$_output .= "\$_template->assign('$_key',$_value);\n";
|
||||
}
|
||||
@@ -52,8 +56,8 @@ class Smarty_Internal_Compile_Internal_Function_Call extends Smarty_Internal_Com
|
||||
$_output .= "\$_template->assign('$_key',$_value);\n";
|
||||
}
|
||||
}
|
||||
if (isset($compiler->template->properties['function'][$_name]['compiled'])) {
|
||||
$_compiled = str_replace(array('_%n', "'"), array("\n", "\'"), $compiler->template->properties['function'][$_name]['compiled']);
|
||||
if (isset($_ptr->properties['function'][$_name]['compiled'])) {
|
||||
$_compiled = str_replace(array('_%n', "'"), array("\n", "\'"), $_ptr->properties['function'][$_name]['compiled']);
|
||||
$_output .= "\$_template->compiled_template = '$_compiled';\n \$_template->mustCompile = false;\n";
|
||||
} else {
|
||||
// for recursion
|
||||
|
@@ -11,7 +11,7 @@
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Smarty Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Smarty extends Smarty_Internal_CompileBase {
|
||||
class Smarty_Internal_Compile_Internal_Smarty_Var extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the speical $smarty variables
|
||||
*
|
@@ -29,7 +29,7 @@ class Smarty_Internal_Compile_Print_Expression extends Smarty_Internal_CompileBa
|
||||
|
||||
if (isset($_attr['nocache'])) {
|
||||
if ($_attr['nocache'] == 'true') {
|
||||
$this->compiler->_compiler_status->tag_nocache = true;
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,9 +25,14 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase {
|
||||
$this->required_attributes = array('if condition');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$this->_open_tag('while');
|
||||
return '<?php while (' . $args['if condition'] . ') { ?>';
|
||||
if (is_array($args['if condition'])) {
|
||||
$_output = " <?php if (!isset(\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$args['if condition']['var']."] = new Smarty_Variable;\n";
|
||||
$_output .= " while (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value'].") {\n ?>";
|
||||
return $_output;
|
||||
} else {
|
||||
return '<?php while (' . $args['if condition'] . ') { ?>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -98,8 +98,8 @@ class Smarty_Internal_TemplateCompilerBase extends Smarty_Internal_Base {
|
||||
/**
|
||||
* Compile Tag
|
||||
*
|
||||
* This is a call back from the lexer/parser
|
||||
* It executes the required compile plugin for the Smarty tag
|
||||
* This is a call back from the lexer/parser
|
||||
* It executes the required compile plugin for the Smarty tag
|
||||
*
|
||||
* @param string $tag tag name
|
||||
* @param array $args array with tag attributes
|
||||
@@ -112,12 +112,19 @@ class Smarty_Internal_TemplateCompilerBase extends Smarty_Internal_Base {
|
||||
$this->has_code = true;
|
||||
$this->has_output = false;
|
||||
// compile the smarty tag (required compile classes to compile the tag are autoloaded)
|
||||
if (isset($this->template->properties['function'][$tag])) {
|
||||
// template defined by {template} tag
|
||||
$args['name'] = $tag;
|
||||
$tag = 'internal_function_call';
|
||||
if (($_output = $this->$tag($args, $this)) === false) {
|
||||
$_ptr = $this->template;
|
||||
while ($_ptr != null && !isset($_ptr->properties['function'][$tag])) {
|
||||
$_ptr = $_ptr->parent;
|
||||
}
|
||||
if ($_ptr != null) {
|
||||
// template defined by {template} tag
|
||||
$args['name'] = $tag;
|
||||
$tag = 'internal_function_call';
|
||||
$_output = $this->$tag($args, $this);
|
||||
}
|
||||
}
|
||||
if (!($_output = $this->$tag($args, $this)) === false) {
|
||||
if ($_output !== false) {
|
||||
if ($_output !== true) {
|
||||
// did we get compiled code
|
||||
if ($this->has_code) {
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user