mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-07 11:54:26 +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
|
04/26/2009
|
||||||
- added trusted stream checking to security
|
- added trusted stream checking to security
|
||||||
- internal changes at file dependency check for caching
|
- 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);
|
$_attr = $this->_get_attributes($args);
|
||||||
|
|
||||||
$this->_open_tag('if');
|
$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
|
// create template object
|
||||||
$_output = "<?php \$_template = new Smarty_Template ('string:', \$_smarty_tpl);\n";
|
$_output = "<?php \$_template = new Smarty_Template ('string:', \$_smarty_tpl);\n";
|
||||||
// assign default paramter
|
// assign default paramter
|
||||||
if (isset($compiler->template->properties['function'][$_name]['parameter'])) {
|
$_ptr = $compiler->template;
|
||||||
foreach ($compiler->template->properties['function'][$_name]['parameter'] as $_key => $_value) {
|
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])) {
|
if (!isset($_attr[$_key])) {
|
||||||
$_output .= "\$_template->assign('$_key',$_value);\n";
|
$_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";
|
$_output .= "\$_template->assign('$_key',$_value);\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($compiler->template->properties['function'][$_name]['compiled'])) {
|
if (isset($_ptr->properties['function'][$_name]['compiled'])) {
|
||||||
$_compiled = str_replace(array('_%n', "'"), array("\n", "\'"), $compiler->template->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";
|
$_output .= "\$_template->compiled_template = '$_compiled';\n \$_template->mustCompile = false;\n";
|
||||||
} else {
|
} else {
|
||||||
// for recursion
|
// for recursion
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Smarty Class
|
* 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
|
* 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 (isset($_attr['nocache'])) {
|
||||||
if ($_attr['nocache'] == 'true') {
|
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');
|
$this->required_attributes = array('if condition');
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->_get_attributes($args);
|
$_attr = $this->_get_attributes($args);
|
||||||
|
|
||||||
$this->_open_tag('while');
|
$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
|
* Compile Tag
|
||||||
*
|
*
|
||||||
* This is a call back from the lexer/parser
|
* This is a call back from the lexer/parser
|
||||||
* It executes the required compile plugin for the Smarty tag
|
* It executes the required compile plugin for the Smarty tag
|
||||||
*
|
*
|
||||||
* @param string $tag tag name
|
* @param string $tag tag name
|
||||||
* @param array $args array with tag attributes
|
* @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_code = true;
|
||||||
$this->has_output = false;
|
$this->has_output = false;
|
||||||
// compile the smarty tag (required compile classes to compile the tag are autoloaded)
|
// compile the smarty tag (required compile classes to compile the tag are autoloaded)
|
||||||
if (isset($this->template->properties['function'][$tag])) {
|
if (($_output = $this->$tag($args, $this)) === false) {
|
||||||
// template defined by {template} tag
|
$_ptr = $this->template;
|
||||||
$args['name'] = $tag;
|
while ($_ptr != null && !isset($_ptr->properties['function'][$tag])) {
|
||||||
$tag = 'internal_function_call';
|
$_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) {
|
if ($_output !== true) {
|
||||||
// did we get compiled code
|
// did we get compiled code
|
||||||
if ($this->has_code) {
|
if ($this->has_code) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user