@@ -17,52 +17,52 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Smarty_Data extends Smarty_Internal_Data |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Counter |
|
| 22 | - * |
|
| 23 | - * @var int |
|
| 24 | - */ |
|
| 25 | - static $count = 0; |
|
| 20 | + /** |
|
| 21 | + * Counter |
|
| 22 | + * |
|
| 23 | + * @var int |
|
| 24 | + */ |
|
| 25 | + static $count = 0; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Data block name |
|
| 29 | - * |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - public $dataObjectName = ''; |
|
| 27 | + /** |
|
| 28 | + * Data block name |
|
| 29 | + * |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + public $dataObjectName = ''; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Smarty object |
|
| 36 | - * |
|
| 37 | - * @var Smarty |
|
| 38 | - */ |
|
| 39 | - public $smarty = null; |
|
| 34 | + /** |
|
| 35 | + * Smarty object |
|
| 36 | + * |
|
| 37 | + * @var Smarty |
|
| 38 | + */ |
|
| 39 | + public $smarty = null; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * create Smarty data object |
|
| 43 | - * |
|
| 44 | - * @param Smarty|array $_parent parent template |
|
| 45 | - * @param Smarty|Smarty_Internal_Template $smarty global smarty instance |
|
| 46 | - * @param string $name optional data block name |
|
| 47 | - * |
|
| 48 | - * @throws SmartyException |
|
| 49 | - */ |
|
| 50 | - public function __construct($_parent = null, $smarty = null, $name = null) |
|
| 51 | - { |
|
| 52 | - parent::__construct(); |
|
| 53 | - self::$count ++; |
|
| 54 | - $this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count); |
|
| 55 | - $this->smarty = $smarty; |
|
| 56 | - if (is_object($_parent)) { |
|
| 57 | - // when object set up back pointer |
|
| 58 | - $this->parent = $_parent; |
|
| 59 | - } elseif (is_array($_parent)) { |
|
| 60 | - // set up variable values |
|
| 61 | - foreach ($_parent as $_key => $_val) { |
|
| 62 | - $this->tpl_vars[ $_key ] = new Smarty_Variable($_val); |
|
| 63 | - } |
|
| 64 | - } elseif ($_parent != null) { |
|
| 65 | - throw new SmartyException("Wrong type for template variables"); |
|
| 66 | - } |
|
| 67 | - } |
|
| 41 | + /** |
|
| 42 | + * create Smarty data object |
|
| 43 | + * |
|
| 44 | + * @param Smarty|array $_parent parent template |
|
| 45 | + * @param Smarty|Smarty_Internal_Template $smarty global smarty instance |
|
| 46 | + * @param string $name optional data block name |
|
| 47 | + * |
|
| 48 | + * @throws SmartyException |
|
| 49 | + */ |
|
| 50 | + public function __construct($_parent = null, $smarty = null, $name = null) |
|
| 51 | + { |
|
| 52 | + parent::__construct(); |
|
| 53 | + self::$count ++; |
|
| 54 | + $this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count); |
|
| 55 | + $this->smarty = $smarty; |
|
| 56 | + if (is_object($_parent)) { |
|
| 57 | + // when object set up back pointer |
|
| 58 | + $this->parent = $_parent; |
|
| 59 | + } elseif (is_array($_parent)) { |
|
| 60 | + // set up variable values |
|
| 61 | + foreach ($_parent as $_key => $_val) { |
|
| 62 | + $this->tpl_vars[ $_key ] = new Smarty_Variable($_val); |
|
| 63 | + } |
|
| 64 | + } elseif ($_parent != null) { |
|
| 65 | + throw new SmartyException("Wrong type for template variables"); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | public function __construct($_parent = null, $smarty = null, $name = null) |
| 51 | 51 | { |
| 52 | 52 | parent::__construct(); |
| 53 | - self::$count ++; |
|
| 53 | + self::$count++; |
|
| 54 | 54 | $this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count); |
| 55 | 55 | $this->smarty = $smarty; |
| 56 | 56 | if (is_object($_parent)) { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } elseif (is_array($_parent)) { |
| 60 | 60 | // set up variable values |
| 61 | 61 | foreach ($_parent as $_key => $_val) { |
| 62 | - $this->tpl_vars[ $_key ] = new Smarty_Variable($_val); |
|
| 62 | + $this->tpl_vars[$_key] = new Smarty_Variable($_val); |
|
| 63 | 63 | } |
| 64 | 64 | } elseif ($_parent != null) { |
| 65 | 65 | throw new SmartyException("Wrong type for template variables"); |
@@ -12,25 +12,25 @@ |
||
| 12 | 12 | class Smarty_Internal_Method_AssignByRef |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * assigns values to template variables by reference |
|
| 17 | - * |
|
| 18 | - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data |
|
| 19 | - * @param string $tpl_var the template variable name |
|
| 20 | - * @param $value |
|
| 21 | - * @param boolean $nocache if true any output of this variable will be not cached |
|
| 22 | - * |
|
| 23 | - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty |
|
| 24 | - */ |
|
| 25 | - public function assignByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $nocache) |
|
| 26 | - { |
|
| 27 | - if ($tpl_var != '') { |
|
| 28 | - $data->tpl_vars[ $tpl_var ] = new Smarty_Variable(null, $nocache); |
|
| 29 | - $data->tpl_vars[ $tpl_var ]->value = &$value; |
|
| 30 | - if ($data->_objType == 2 && $data->scope) { |
|
| 31 | - $data->ext->_updateScope->_updateScope($data, $tpl_var); |
|
| 32 | - } |
|
| 33 | - } |
|
| 34 | - return $data; |
|
| 35 | - } |
|
| 15 | + /** |
|
| 16 | + * assigns values to template variables by reference |
|
| 17 | + * |
|
| 18 | + * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data |
|
| 19 | + * @param string $tpl_var the template variable name |
|
| 20 | + * @param $value |
|
| 21 | + * @param boolean $nocache if true any output of this variable will be not cached |
|
| 22 | + * |
|
| 23 | + * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty |
|
| 24 | + */ |
|
| 25 | + public function assignByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $nocache) |
|
| 26 | + { |
|
| 27 | + if ($tpl_var != '') { |
|
| 28 | + $data->tpl_vars[ $tpl_var ] = new Smarty_Variable(null, $nocache); |
|
| 29 | + $data->tpl_vars[ $tpl_var ]->value = &$value; |
|
| 30 | + if ($data->_objType == 2 && $data->scope) { |
|
| 31 | + $data->ext->_updateScope->_updateScope($data, $tpl_var); |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | + return $data; |
|
| 35 | + } |
|
| 36 | 36 | } |
| 37 | 37 | \ No newline at end of file |
@@ -25,8 +25,8 @@ |
||
| 25 | 25 | public function assignByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $nocache) |
| 26 | 26 | { |
| 27 | 27 | if ($tpl_var != '') { |
| 28 | - $data->tpl_vars[ $tpl_var ] = new Smarty_Variable(null, $nocache); |
|
| 29 | - $data->tpl_vars[ $tpl_var ]->value = &$value; |
|
| 28 | + $data->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache); |
|
| 29 | + $data->tpl_vars[$tpl_var]->value = &$value; |
|
| 30 | 30 | if ($data->_objType == 2 && $data->scope) { |
| 31 | 31 | $data->ext->_updateScope->_updateScope($data, $tpl_var); |
| 32 | 32 | } |
@@ -16,55 +16,55 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Compiles code for the {if} tag |
|
| 21 | - * |
|
| 22 | - * @param array $args array with attributes from parser |
|
| 23 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 24 | - * @param array $parameter array with compilation parameter |
|
| 25 | - * |
|
| 26 | - * @return string compiled code |
|
| 27 | - * @throws \SmartyCompilerException |
|
| 28 | - */ |
|
| 29 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 30 | - { |
|
| 31 | - // check and get attributes |
|
| 32 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 33 | - $this->openTag($compiler, 'if', array(1, $compiler->nocache)); |
|
| 34 | - // must whole block be nocache ? |
|
| 35 | - $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; |
|
| 19 | + /** |
|
| 20 | + * Compiles code for the {if} tag |
|
| 21 | + * |
|
| 22 | + * @param array $args array with attributes from parser |
|
| 23 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 24 | + * @param array $parameter array with compilation parameter |
|
| 25 | + * |
|
| 26 | + * @return string compiled code |
|
| 27 | + * @throws \SmartyCompilerException |
|
| 28 | + */ |
|
| 29 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 30 | + { |
|
| 31 | + // check and get attributes |
|
| 32 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 33 | + $this->openTag($compiler, 'if', array(1, $compiler->nocache)); |
|
| 34 | + // must whole block be nocache ? |
|
| 35 | + $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; |
|
| 36 | 36 | |
| 37 | - if (!array_key_exists("if condition", $parameter)) { |
|
| 38 | - $compiler->trigger_template_error("missing if condition", null, true); |
|
| 39 | - } |
|
| 37 | + if (!array_key_exists("if condition", $parameter)) { |
|
| 38 | + $compiler->trigger_template_error("missing if condition", null, true); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - if (is_array($parameter[ 'if condition' ])) { |
|
| 42 | - if ($compiler->nocache) { |
|
| 43 | - // create nocache var to make it know for further compiling |
|
| 44 | - if (is_array($parameter[ 'if condition' ][ 'var' ])) { |
|
| 45 | - $var = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; |
|
| 46 | - } else { |
|
| 47 | - $var = $parameter[ 'if condition' ][ 'var' ]; |
|
| 48 | - } |
|
| 49 | - $compiler->setNocacheInVariable($var); |
|
| 50 | - } |
|
| 51 | - $assignCompiler = new Smarty_Internal_Compile_Assign(); |
|
| 52 | - $assignAttr = array(); |
|
| 53 | - $assignAttr[][ 'value' ] = $parameter[ 'if condition' ][ 'value' ]; |
|
| 54 | - if (is_array($parameter[ 'if condition' ][ 'var' ])) { |
|
| 55 | - $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; |
|
| 56 | - $_output = $assignCompiler->compile($assignAttr, $compiler, |
|
| 57 | - array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])); |
|
| 58 | - } else { |
|
| 59 | - $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ]; |
|
| 60 | - $_output = $assignCompiler->compile($assignAttr, $compiler, array()); |
|
| 61 | - } |
|
| 62 | - $_output .= "<?php if (" . $parameter[ 'if condition' ][ 'value' ] . ") {?>"; |
|
| 63 | - return $_output; |
|
| 64 | - } else { |
|
| 65 | - return "<?php if ({$parameter['if condition']}) {?>"; |
|
| 66 | - } |
|
| 67 | - } |
|
| 41 | + if (is_array($parameter[ 'if condition' ])) { |
|
| 42 | + if ($compiler->nocache) { |
|
| 43 | + // create nocache var to make it know for further compiling |
|
| 44 | + if (is_array($parameter[ 'if condition' ][ 'var' ])) { |
|
| 45 | + $var = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; |
|
| 46 | + } else { |
|
| 47 | + $var = $parameter[ 'if condition' ][ 'var' ]; |
|
| 48 | + } |
|
| 49 | + $compiler->setNocacheInVariable($var); |
|
| 50 | + } |
|
| 51 | + $assignCompiler = new Smarty_Internal_Compile_Assign(); |
|
| 52 | + $assignAttr = array(); |
|
| 53 | + $assignAttr[][ 'value' ] = $parameter[ 'if condition' ][ 'value' ]; |
|
| 54 | + if (is_array($parameter[ 'if condition' ][ 'var' ])) { |
|
| 55 | + $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; |
|
| 56 | + $_output = $assignCompiler->compile($assignAttr, $compiler, |
|
| 57 | + array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])); |
|
| 58 | + } else { |
|
| 59 | + $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ]; |
|
| 60 | + $_output = $assignCompiler->compile($assignAttr, $compiler, array()); |
|
| 61 | + } |
|
| 62 | + $_output .= "<?php if (" . $parameter[ 'if condition' ][ 'value' ] . ") {?>"; |
|
| 63 | + return $_output; |
|
| 64 | + } else { |
|
| 65 | + return "<?php if ({$parameter['if condition']}) {?>"; |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -75,22 +75,22 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase |
| 77 | 77 | { |
| 78 | - /** |
|
| 79 | - * Compiles code for the {else} tag |
|
| 80 | - * |
|
| 81 | - * @param array $args array with attributes from parser |
|
| 82 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 83 | - * @param array $parameter array with compilation parameter |
|
| 84 | - * |
|
| 85 | - * @return string compiled code |
|
| 86 | - */ |
|
| 87 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 88 | - { |
|
| 89 | - list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif')); |
|
| 90 | - $this->openTag($compiler, 'else', array($nesting, $compiler->tag_nocache)); |
|
| 78 | + /** |
|
| 79 | + * Compiles code for the {else} tag |
|
| 80 | + * |
|
| 81 | + * @param array $args array with attributes from parser |
|
| 82 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 83 | + * @param array $parameter array with compilation parameter |
|
| 84 | + * |
|
| 85 | + * @return string compiled code |
|
| 86 | + */ |
|
| 87 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 88 | + { |
|
| 89 | + list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif')); |
|
| 90 | + $this->openTag($compiler, 'else', array($nesting, $compiler->tag_nocache)); |
|
| 91 | 91 | |
| 92 | - return "<?php } else { ?>"; |
|
| 93 | - } |
|
| 92 | + return "<?php } else { ?>"; |
|
| 93 | + } |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -101,77 +101,77 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase |
| 103 | 103 | { |
| 104 | - /** |
|
| 105 | - * Compiles code for the {elseif} tag |
|
| 106 | - * |
|
| 107 | - * @param array $args array with attributes from parser |
|
| 108 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 109 | - * @param array $parameter array with compilation parameter |
|
| 110 | - * |
|
| 111 | - * @return string compiled code |
|
| 112 | - * @throws \SmartyCompilerException |
|
| 113 | - */ |
|
| 114 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 115 | - { |
|
| 116 | - // check and get attributes |
|
| 117 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 104 | + /** |
|
| 105 | + * Compiles code for the {elseif} tag |
|
| 106 | + * |
|
| 107 | + * @param array $args array with attributes from parser |
|
| 108 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 109 | + * @param array $parameter array with compilation parameter |
|
| 110 | + * |
|
| 111 | + * @return string compiled code |
|
| 112 | + * @throws \SmartyCompilerException |
|
| 113 | + */ |
|
| 114 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 115 | + { |
|
| 116 | + // check and get attributes |
|
| 117 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 118 | 118 | |
| 119 | - list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif')); |
|
| 119 | + list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif')); |
|
| 120 | 120 | |
| 121 | - if (!array_key_exists("if condition", $parameter)) { |
|
| 122 | - $compiler->trigger_template_error("missing elseif condition", null, true); |
|
| 123 | - } |
|
| 121 | + if (!array_key_exists("if condition", $parameter)) { |
|
| 122 | + $compiler->trigger_template_error("missing elseif condition", null, true); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - $assignCode = ''; |
|
| 126 | - if (is_array($parameter[ 'if condition' ])) { |
|
| 127 | - $condition_by_assign = true; |
|
| 128 | - if ($compiler->nocache) { |
|
| 129 | - // create nocache var to make it know for further compiling |
|
| 130 | - if (is_array($parameter[ 'if condition' ][ 'var' ])) { |
|
| 131 | - $var = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; |
|
| 132 | - } else { |
|
| 133 | - $var = $parameter[ 'if condition' ][ 'var' ]; |
|
| 134 | - } |
|
| 135 | - $compiler->setNocacheInVariable($var); |
|
| 136 | - } |
|
| 137 | - $assignCompiler = new Smarty_Internal_Compile_Assign(); |
|
| 138 | - $assignAttr = array(); |
|
| 139 | - $assignAttr[][ 'value' ] = $parameter[ 'if condition' ][ 'value' ]; |
|
| 140 | - if (is_array($parameter[ 'if condition' ][ 'var' ])) { |
|
| 141 | - $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; |
|
| 142 | - $assignCode = $assignCompiler->compile($assignAttr, $compiler, |
|
| 143 | - array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])); |
|
| 144 | - } else { |
|
| 145 | - $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ]; |
|
| 146 | - $assignCode = $assignCompiler->compile($assignAttr, $compiler, array()); |
|
| 147 | - } |
|
| 148 | - } else { |
|
| 149 | - $condition_by_assign = false; |
|
| 150 | - } |
|
| 125 | + $assignCode = ''; |
|
| 126 | + if (is_array($parameter[ 'if condition' ])) { |
|
| 127 | + $condition_by_assign = true; |
|
| 128 | + if ($compiler->nocache) { |
|
| 129 | + // create nocache var to make it know for further compiling |
|
| 130 | + if (is_array($parameter[ 'if condition' ][ 'var' ])) { |
|
| 131 | + $var = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; |
|
| 132 | + } else { |
|
| 133 | + $var = $parameter[ 'if condition' ][ 'var' ]; |
|
| 134 | + } |
|
| 135 | + $compiler->setNocacheInVariable($var); |
|
| 136 | + } |
|
| 137 | + $assignCompiler = new Smarty_Internal_Compile_Assign(); |
|
| 138 | + $assignAttr = array(); |
|
| 139 | + $assignAttr[][ 'value' ] = $parameter[ 'if condition' ][ 'value' ]; |
|
| 140 | + if (is_array($parameter[ 'if condition' ][ 'var' ])) { |
|
| 141 | + $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; |
|
| 142 | + $assignCode = $assignCompiler->compile($assignAttr, $compiler, |
|
| 143 | + array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])); |
|
| 144 | + } else { |
|
| 145 | + $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ]; |
|
| 146 | + $assignCode = $assignCompiler->compile($assignAttr, $compiler, array()); |
|
| 147 | + } |
|
| 148 | + } else { |
|
| 149 | + $condition_by_assign = false; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - $prefixCode = $compiler->getPrefixCode(); |
|
| 153 | - if (empty($prefixCode)) { |
|
| 154 | - if ($condition_by_assign) { |
|
| 155 | - $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache)); |
|
| 156 | - $_output = $compiler->appendCode("<?php } else {\n?>", $assignCode); |
|
| 157 | - return $compiler->appendCode($_output, |
|
| 158 | - "<?php if (" . $parameter[ 'if condition' ][ 'value' ] . ") {\n?>"); |
|
| 159 | - } else { |
|
| 160 | - $this->openTag($compiler, 'elseif', array($nesting, $compiler->tag_nocache)); |
|
| 161 | - return "<?php } elseif ({$parameter['if condition']}) {?>"; |
|
| 162 | - } |
|
| 163 | - } else { |
|
| 164 | - $_output = $compiler->appendCode("<?php } else {\n?>", $prefixCode); |
|
| 165 | - $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache)); |
|
| 166 | - if ($condition_by_assign) { |
|
| 167 | - $_output = $compiler->appendCode($_output, $assignCode); |
|
| 168 | - return $compiler->appendCode($_output, |
|
| 169 | - "<?php if (" . $parameter[ 'if condition' ][ 'value' ] . ") {\n?>"); |
|
| 170 | - } else { |
|
| 171 | - return $compiler->appendCode($_output, "<?php if ({$parameter['if condition']}) {?>"); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - } |
|
| 152 | + $prefixCode = $compiler->getPrefixCode(); |
|
| 153 | + if (empty($prefixCode)) { |
|
| 154 | + if ($condition_by_assign) { |
|
| 155 | + $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache)); |
|
| 156 | + $_output = $compiler->appendCode("<?php } else {\n?>", $assignCode); |
|
| 157 | + return $compiler->appendCode($_output, |
|
| 158 | + "<?php if (" . $parameter[ 'if condition' ][ 'value' ] . ") {\n?>"); |
|
| 159 | + } else { |
|
| 160 | + $this->openTag($compiler, 'elseif', array($nesting, $compiler->tag_nocache)); |
|
| 161 | + return "<?php } elseif ({$parameter['if condition']}) {?>"; |
|
| 162 | + } |
|
| 163 | + } else { |
|
| 164 | + $_output = $compiler->appendCode("<?php } else {\n?>", $prefixCode); |
|
| 165 | + $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache)); |
|
| 166 | + if ($condition_by_assign) { |
|
| 167 | + $_output = $compiler->appendCode($_output, $assignCode); |
|
| 168 | + return $compiler->appendCode($_output, |
|
| 169 | + "<?php if (" . $parameter[ 'if condition' ][ 'value' ] . ") {\n?>"); |
|
| 170 | + } else { |
|
| 171 | + return $compiler->appendCode($_output, "<?php if ({$parameter['if condition']}) {?>"); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -182,27 +182,27 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase |
| 184 | 184 | { |
| 185 | - /** |
|
| 186 | - * Compiles code for the {/if} tag |
|
| 187 | - * |
|
| 188 | - * @param array $args array with attributes from parser |
|
| 189 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 190 | - * @param array $parameter array with compilation parameter |
|
| 191 | - * |
|
| 192 | - * @return string compiled code |
|
| 193 | - */ |
|
| 194 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 195 | - { |
|
| 196 | - // must endblock be nocache? |
|
| 197 | - if ($compiler->nocache) { |
|
| 198 | - $compiler->tag_nocache = true; |
|
| 199 | - } |
|
| 200 | - list($nesting, $compiler->nocache) = $this->closeTag($compiler, array('if', 'else', 'elseif')); |
|
| 201 | - $tmp = ''; |
|
| 202 | - for ($i = 0; $i < $nesting; $i ++) { |
|
| 203 | - $tmp .= '}'; |
|
| 204 | - } |
|
| 185 | + /** |
|
| 186 | + * Compiles code for the {/if} tag |
|
| 187 | + * |
|
| 188 | + * @param array $args array with attributes from parser |
|
| 189 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 190 | + * @param array $parameter array with compilation parameter |
|
| 191 | + * |
|
| 192 | + * @return string compiled code |
|
| 193 | + */ |
|
| 194 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 195 | + { |
|
| 196 | + // must endblock be nocache? |
|
| 197 | + if ($compiler->nocache) { |
|
| 198 | + $compiler->tag_nocache = true; |
|
| 199 | + } |
|
| 200 | + list($nesting, $compiler->nocache) = $this->closeTag($compiler, array('if', 'else', 'elseif')); |
|
| 201 | + $tmp = ''; |
|
| 202 | + for ($i = 0; $i < $nesting; $i ++) { |
|
| 203 | + $tmp .= '}'; |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - return "<?php {$tmp}?>"; |
|
| 207 | - } |
|
| 206 | + return "<?php {$tmp}?>"; |
|
| 207 | + } |
|
| 208 | 208 | } |
@@ -38,28 +38,28 @@ discard block |
||
| 38 | 38 | $compiler->trigger_template_error("missing if condition", null, true); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - if (is_array($parameter[ 'if condition' ])) { |
|
| 41 | + if (is_array($parameter['if condition'])) { |
|
| 42 | 42 | if ($compiler->nocache) { |
| 43 | 43 | // create nocache var to make it know for further compiling |
| 44 | - if (is_array($parameter[ 'if condition' ][ 'var' ])) { |
|
| 45 | - $var = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; |
|
| 44 | + if (is_array($parameter['if condition']['var'])) { |
|
| 45 | + $var = $parameter['if condition']['var']['var']; |
|
| 46 | 46 | } else { |
| 47 | - $var = $parameter[ 'if condition' ][ 'var' ]; |
|
| 47 | + $var = $parameter['if condition']['var']; |
|
| 48 | 48 | } |
| 49 | 49 | $compiler->setNocacheInVariable($var); |
| 50 | 50 | } |
| 51 | 51 | $assignCompiler = new Smarty_Internal_Compile_Assign(); |
| 52 | 52 | $assignAttr = array(); |
| 53 | - $assignAttr[][ 'value' ] = $parameter[ 'if condition' ][ 'value' ]; |
|
| 54 | - if (is_array($parameter[ 'if condition' ][ 'var' ])) { |
|
| 55 | - $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; |
|
| 53 | + $assignAttr[]['value'] = $parameter['if condition']['value']; |
|
| 54 | + if (is_array($parameter['if condition']['var'])) { |
|
| 55 | + $assignAttr[]['var'] = $parameter['if condition']['var']['var']; |
|
| 56 | 56 | $_output = $assignCompiler->compile($assignAttr, $compiler, |
| 57 | - array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])); |
|
| 57 | + array('smarty_internal_index' => $parameter['if condition']['var']['smarty_internal_index'])); |
|
| 58 | 58 | } else { |
| 59 | - $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ]; |
|
| 59 | + $assignAttr[]['var'] = $parameter['if condition']['var']; |
|
| 60 | 60 | $_output = $assignCompiler->compile($assignAttr, $compiler, array()); |
| 61 | 61 | } |
| 62 | - $_output .= "<?php if (" . $parameter[ 'if condition' ][ 'value' ] . ") {?>"; |
|
| 62 | + $_output .= "<?php if (" . $parameter['if condition']['value'] . ") {?>"; |
|
| 63 | 63 | return $_output; |
| 64 | 64 | } else { |
| 65 | 65 | return "<?php if ({$parameter['if condition']}) {?>"; |
@@ -123,26 +123,26 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $assignCode = ''; |
| 126 | - if (is_array($parameter[ 'if condition' ])) { |
|
| 126 | + if (is_array($parameter['if condition'])) { |
|
| 127 | 127 | $condition_by_assign = true; |
| 128 | 128 | if ($compiler->nocache) { |
| 129 | 129 | // create nocache var to make it know for further compiling |
| 130 | - if (is_array($parameter[ 'if condition' ][ 'var' ])) { |
|
| 131 | - $var = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; |
|
| 130 | + if (is_array($parameter['if condition']['var'])) { |
|
| 131 | + $var = $parameter['if condition']['var']['var']; |
|
| 132 | 132 | } else { |
| 133 | - $var = $parameter[ 'if condition' ][ 'var' ]; |
|
| 133 | + $var = $parameter['if condition']['var']; |
|
| 134 | 134 | } |
| 135 | 135 | $compiler->setNocacheInVariable($var); |
| 136 | 136 | } |
| 137 | 137 | $assignCompiler = new Smarty_Internal_Compile_Assign(); |
| 138 | 138 | $assignAttr = array(); |
| 139 | - $assignAttr[][ 'value' ] = $parameter[ 'if condition' ][ 'value' ]; |
|
| 140 | - if (is_array($parameter[ 'if condition' ][ 'var' ])) { |
|
| 141 | - $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; |
|
| 139 | + $assignAttr[]['value'] = $parameter['if condition']['value']; |
|
| 140 | + if (is_array($parameter['if condition']['var'])) { |
|
| 141 | + $assignAttr[]['var'] = $parameter['if condition']['var']['var']; |
|
| 142 | 142 | $assignCode = $assignCompiler->compile($assignAttr, $compiler, |
| 143 | - array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])); |
|
| 143 | + array('smarty_internal_index' => $parameter['if condition']['var']['smarty_internal_index'])); |
|
| 144 | 144 | } else { |
| 145 | - $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ]; |
|
| 145 | + $assignAttr[]['var'] = $parameter['if condition']['var']; |
|
| 146 | 146 | $assignCode = $assignCompiler->compile($assignAttr, $compiler, array()); |
| 147 | 147 | } |
| 148 | 148 | } else { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache)); |
| 156 | 156 | $_output = $compiler->appendCode("<?php } else {\n?>", $assignCode); |
| 157 | 157 | return $compiler->appendCode($_output, |
| 158 | - "<?php if (" . $parameter[ 'if condition' ][ 'value' ] . ") {\n?>"); |
|
| 158 | + "<?php if (" . $parameter['if condition']['value'] . ") {\n?>"); |
|
| 159 | 159 | } else { |
| 160 | 160 | $this->openTag($compiler, 'elseif', array($nesting, $compiler->tag_nocache)); |
| 161 | 161 | return "<?php } elseif ({$parameter['if condition']}) {?>"; |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | if ($condition_by_assign) { |
| 167 | 167 | $_output = $compiler->appendCode($_output, $assignCode); |
| 168 | 168 | return $compiler->appendCode($_output, |
| 169 | - "<?php if (" . $parameter[ 'if condition' ][ 'value' ] . ") {\n?>"); |
|
| 169 | + "<?php if (" . $parameter['if condition']['value'] . ") {\n?>"); |
|
| 170 | 170 | } else { |
| 171 | 171 | return $compiler->appendCode($_output, "<?php if ({$parameter['if condition']}) {?>"); |
| 172 | 172 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | list($nesting, $compiler->nocache) = $this->closeTag($compiler, array('if', 'else', 'elseif')); |
| 201 | 201 | $tmp = ''; |
| 202 | - for ($i = 0; $i < $nesting; $i ++) { |
|
| 202 | + for ($i = 0; $i < $nesting; $i++) { |
|
| 203 | 203 | $tmp .= '}'; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -9,40 +9,40 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class Smarty_Variable |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * template variable |
|
| 14 | - * |
|
| 15 | - * @var mixed |
|
| 16 | - */ |
|
| 17 | - public $value = null; |
|
| 12 | + /** |
|
| 13 | + * template variable |
|
| 14 | + * |
|
| 15 | + * @var mixed |
|
| 16 | + */ |
|
| 17 | + public $value = null; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * if true any output of this variable will be not cached |
|
| 21 | - * |
|
| 22 | - * @var boolean |
|
| 23 | - */ |
|
| 24 | - public $nocache = false; |
|
| 19 | + /** |
|
| 20 | + * if true any output of this variable will be not cached |
|
| 21 | + * |
|
| 22 | + * @var boolean |
|
| 23 | + */ |
|
| 24 | + public $nocache = false; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * create Smarty variable object |
|
| 28 | - * |
|
| 29 | - * @param mixed $value the value to assign |
|
| 30 | - * @param boolean $nocache if true any output of this variable will be not cached |
|
| 31 | - */ |
|
| 32 | - public function __construct($value = null, $nocache = false) |
|
| 33 | - { |
|
| 34 | - $this->value = $value; |
|
| 35 | - $this->nocache = $nocache; |
|
| 36 | - } |
|
| 26 | + /** |
|
| 27 | + * create Smarty variable object |
|
| 28 | + * |
|
| 29 | + * @param mixed $value the value to assign |
|
| 30 | + * @param boolean $nocache if true any output of this variable will be not cached |
|
| 31 | + */ |
|
| 32 | + public function __construct($value = null, $nocache = false) |
|
| 33 | + { |
|
| 34 | + $this->value = $value; |
|
| 35 | + $this->nocache = $nocache; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * <<magic>> String conversion |
|
| 40 | - * |
|
| 41 | - * @return string |
|
| 42 | - */ |
|
| 43 | - public function __toString() |
|
| 44 | - { |
|
| 45 | - return (string) $this->value; |
|
| 46 | - } |
|
| 38 | + /** |
|
| 39 | + * <<magic>> String conversion |
|
| 40 | + * |
|
| 41 | + * @return string |
|
| 42 | + */ |
|
| 43 | + public function __toString() |
|
| 44 | + { |
|
| 45 | + return (string) $this->value; |
|
| 46 | + } |
|
| 47 | 47 | } |
| 48 | 48 | |
@@ -11,48 +11,48 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_GetConfigVars |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Valid for all objects |
|
| 16 | - * |
|
| 17 | - * @var int |
|
| 18 | - */ |
|
| 19 | - public $objMap = 7; |
|
| 14 | + /** |
|
| 15 | + * Valid for all objects |
|
| 16 | + * |
|
| 17 | + * @var int |
|
| 18 | + */ |
|
| 19 | + public $objMap = 7; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Returns a single or all config variables |
|
| 23 | - * |
|
| 24 | - * @api Smarty::getConfigVars() |
|
| 25 | - * @link http://www.smarty.net/docs/en/api.get.config.vars.tpl |
|
| 26 | - * |
|
| 27 | - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data |
|
| 28 | - * @param string $varname variable name or null |
|
| 29 | - * @param bool $search_parents include parent templates? |
|
| 30 | - * |
|
| 31 | - * @return mixed variable value or or array of variables |
|
| 32 | - */ |
|
| 33 | - public function getConfigVars(Smarty_Internal_Data $data, $varname = null, $search_parents = true) |
|
| 34 | - { |
|
| 35 | - $_ptr = $data; |
|
| 36 | - $var_array = array(); |
|
| 37 | - while ($_ptr !== null) { |
|
| 38 | - if (isset($varname)) { |
|
| 39 | - if (isset($_ptr->config_vars[ $varname ])) { |
|
| 40 | - return $_ptr->config_vars[ $varname ]; |
|
| 41 | - } |
|
| 42 | - } else { |
|
| 43 | - $var_array = array_merge($_ptr->config_vars, $var_array); |
|
| 44 | - } |
|
| 45 | - // not found, try at parent |
|
| 46 | - if ($search_parents) { |
|
| 47 | - $_ptr = $_ptr->parent; |
|
| 48 | - } else { |
|
| 49 | - $_ptr = null; |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - if (isset($varname)) { |
|
| 53 | - return ''; |
|
| 54 | - } else { |
|
| 55 | - return $var_array; |
|
| 56 | - } |
|
| 57 | - } |
|
| 21 | + /** |
|
| 22 | + * Returns a single or all config variables |
|
| 23 | + * |
|
| 24 | + * @api Smarty::getConfigVars() |
|
| 25 | + * @link http://www.smarty.net/docs/en/api.get.config.vars.tpl |
|
| 26 | + * |
|
| 27 | + * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data |
|
| 28 | + * @param string $varname variable name or null |
|
| 29 | + * @param bool $search_parents include parent templates? |
|
| 30 | + * |
|
| 31 | + * @return mixed variable value or or array of variables |
|
| 32 | + */ |
|
| 33 | + public function getConfigVars(Smarty_Internal_Data $data, $varname = null, $search_parents = true) |
|
| 34 | + { |
|
| 35 | + $_ptr = $data; |
|
| 36 | + $var_array = array(); |
|
| 37 | + while ($_ptr !== null) { |
|
| 38 | + if (isset($varname)) { |
|
| 39 | + if (isset($_ptr->config_vars[ $varname ])) { |
|
| 40 | + return $_ptr->config_vars[ $varname ]; |
|
| 41 | + } |
|
| 42 | + } else { |
|
| 43 | + $var_array = array_merge($_ptr->config_vars, $var_array); |
|
| 44 | + } |
|
| 45 | + // not found, try at parent |
|
| 46 | + if ($search_parents) { |
|
| 47 | + $_ptr = $_ptr->parent; |
|
| 48 | + } else { |
|
| 49 | + $_ptr = null; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + if (isset($varname)) { |
|
| 53 | + return ''; |
|
| 54 | + } else { |
|
| 55 | + return $var_array; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | } |
| 59 | 59 | \ No newline at end of file |
@@ -36,8 +36,8 @@ |
||
| 36 | 36 | $var_array = array(); |
| 37 | 37 | while ($_ptr !== null) { |
| 38 | 38 | if (isset($varname)) { |
| 39 | - if (isset($_ptr->config_vars[ $varname ])) { |
|
| 40 | - return $_ptr->config_vars[ $varname ]; |
|
| 39 | + if (isset($_ptr->config_vars[$varname])) { |
|
| 40 | + return $_ptr->config_vars[$varname]; |
|
| 41 | 41 | } |
| 42 | 42 | } else { |
| 43 | 43 | $var_array = array_merge($_ptr->config_vars, $var_array); |
@@ -11,34 +11,34 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_ClearAssign |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Valid for all objects |
|
| 16 | - * |
|
| 17 | - * @var int |
|
| 18 | - */ |
|
| 19 | - public $objMap = 7; |
|
| 14 | + /** |
|
| 15 | + * Valid for all objects |
|
| 16 | + * |
|
| 17 | + * @var int |
|
| 18 | + */ |
|
| 19 | + public $objMap = 7; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * clear the given assigned template variable(s). |
|
| 23 | - * |
|
| 24 | - * @api Smarty::clearAssign() |
|
| 25 | - * @link http://www.smarty.net/docs/en/api.clear.assign.tpl |
|
| 26 | - * |
|
| 27 | - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data |
|
| 28 | - * @param string|array $tpl_var the template variable(s) to clear |
|
| 29 | - * |
|
| 30 | - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty |
|
| 31 | - */ |
|
| 32 | - public function clearAssign(Smarty_Internal_Data $data, $tpl_var) |
|
| 33 | - { |
|
| 34 | - if (is_array($tpl_var)) { |
|
| 35 | - foreach ($tpl_var as $curr_var) { |
|
| 36 | - unset($data->tpl_vars[ $curr_var ]); |
|
| 37 | - } |
|
| 38 | - } else { |
|
| 39 | - unset($data->tpl_vars[ $tpl_var ]); |
|
| 40 | - } |
|
| 21 | + /** |
|
| 22 | + * clear the given assigned template variable(s). |
|
| 23 | + * |
|
| 24 | + * @api Smarty::clearAssign() |
|
| 25 | + * @link http://www.smarty.net/docs/en/api.clear.assign.tpl |
|
| 26 | + * |
|
| 27 | + * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data |
|
| 28 | + * @param string|array $tpl_var the template variable(s) to clear |
|
| 29 | + * |
|
| 30 | + * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty |
|
| 31 | + */ |
|
| 32 | + public function clearAssign(Smarty_Internal_Data $data, $tpl_var) |
|
| 33 | + { |
|
| 34 | + if (is_array($tpl_var)) { |
|
| 35 | + foreach ($tpl_var as $curr_var) { |
|
| 36 | + unset($data->tpl_vars[ $curr_var ]); |
|
| 37 | + } |
|
| 38 | + } else { |
|
| 39 | + unset($data->tpl_vars[ $tpl_var ]); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - return $data; |
|
| 43 | - } |
|
| 42 | + return $data; |
|
| 43 | + } |
|
| 44 | 44 | } |
| 45 | 45 | \ No newline at end of file |
@@ -33,10 +33,10 @@ |
||
| 33 | 33 | { |
| 34 | 34 | if (is_array($tpl_var)) { |
| 35 | 35 | foreach ($tpl_var as $curr_var) { |
| 36 | - unset($data->tpl_vars[ $curr_var ]); |
|
| 36 | + unset($data->tpl_vars[$curr_var]); |
|
| 37 | 37 | } |
| 38 | 38 | } else { |
| 39 | - unset($data->tpl_vars[ $tpl_var ]); |
|
| 39 | + unset($data->tpl_vars[$tpl_var]); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | return $data; |
@@ -16,36 +16,36 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Compiles code for the {append} tag |
|
| 21 | - * |
|
| 22 | - * @param array $args array with attributes from parser |
|
| 23 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 24 | - * @param array $parameter array with compilation parameter |
|
| 25 | - * |
|
| 26 | - * @return string compiled code |
|
| 27 | - */ |
|
| 28 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 29 | - { |
|
| 30 | - // the following must be assigned at runtime because it will be overwritten in parent class |
|
| 31 | - $this->required_attributes = array('var', 'value'); |
|
| 32 | - $this->shorttag_order = array('var', 'value'); |
|
| 33 | - $this->optional_attributes = array('scope', 'index'); |
|
| 34 | - $this->mapCache = array(); |
|
| 35 | - // check and get attributes |
|
| 36 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 37 | - // map to compile assign attributes |
|
| 38 | - if (isset($_attr[ 'index' ])) { |
|
| 39 | - $_params[ 'smarty_internal_index' ] = '[' . $_attr[ 'index' ] . ']'; |
|
| 40 | - unset($_attr[ 'index' ]); |
|
| 41 | - } else { |
|
| 42 | - $_params[ 'smarty_internal_index' ] = '[]'; |
|
| 43 | - } |
|
| 44 | - $_new_attr = array(); |
|
| 45 | - foreach ($_attr as $key => $value) { |
|
| 46 | - $_new_attr[] = array($key => $value); |
|
| 47 | - } |
|
| 48 | - // call compile assign |
|
| 49 | - return parent::compile($_new_attr, $compiler, $_params); |
|
| 50 | - } |
|
| 19 | + /** |
|
| 20 | + * Compiles code for the {append} tag |
|
| 21 | + * |
|
| 22 | + * @param array $args array with attributes from parser |
|
| 23 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 24 | + * @param array $parameter array with compilation parameter |
|
| 25 | + * |
|
| 26 | + * @return string compiled code |
|
| 27 | + */ |
|
| 28 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 29 | + { |
|
| 30 | + // the following must be assigned at runtime because it will be overwritten in parent class |
|
| 31 | + $this->required_attributes = array('var', 'value'); |
|
| 32 | + $this->shorttag_order = array('var', 'value'); |
|
| 33 | + $this->optional_attributes = array('scope', 'index'); |
|
| 34 | + $this->mapCache = array(); |
|
| 35 | + // check and get attributes |
|
| 36 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 37 | + // map to compile assign attributes |
|
| 38 | + if (isset($_attr[ 'index' ])) { |
|
| 39 | + $_params[ 'smarty_internal_index' ] = '[' . $_attr[ 'index' ] . ']'; |
|
| 40 | + unset($_attr[ 'index' ]); |
|
| 41 | + } else { |
|
| 42 | + $_params[ 'smarty_internal_index' ] = '[]'; |
|
| 43 | + } |
|
| 44 | + $_new_attr = array(); |
|
| 45 | + foreach ($_attr as $key => $value) { |
|
| 46 | + $_new_attr[] = array($key => $value); |
|
| 47 | + } |
|
| 48 | + // call compile assign |
|
| 49 | + return parent::compile($_new_attr, $compiler, $_params); |
|
| 50 | + } |
|
| 51 | 51 | } |
@@ -35,11 +35,11 @@ |
||
| 35 | 35 | // check and get attributes |
| 36 | 36 | $_attr = $this->getAttributes($compiler, $args); |
| 37 | 37 | // map to compile assign attributes |
| 38 | - if (isset($_attr[ 'index' ])) { |
|
| 39 | - $_params[ 'smarty_internal_index' ] = '[' . $_attr[ 'index' ] . ']'; |
|
| 40 | - unset($_attr[ 'index' ]); |
|
| 38 | + if (isset($_attr['index'])) { |
|
| 39 | + $_params['smarty_internal_index'] = '[' . $_attr['index'] . ']'; |
|
| 40 | + unset($_attr['index']); |
|
| 41 | 41 | } else { |
| 42 | - $_params[ 'smarty_internal_index' ] = '[]'; |
|
| 42 | + $_params['smarty_internal_index'] = '[]'; |
|
| 43 | 43 | } |
| 44 | 44 | $_new_attr = array(); |
| 45 | 45 | foreach ($_attr as $key => $value) { |
@@ -11,72 +11,72 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_RegisterDefaultTemplateHandler |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Valid for Smarty and template object |
|
| 16 | - * |
|
| 17 | - * @var int |
|
| 18 | - */ |
|
| 19 | - public $objMap = 3; |
|
| 14 | + /** |
|
| 15 | + * Valid for Smarty and template object |
|
| 16 | + * |
|
| 17 | + * @var int |
|
| 18 | + */ |
|
| 19 | + public $objMap = 3; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Register template default handler |
|
| 23 | - * |
|
| 24 | - * @api Smarty::registerDefaultTemplateHandler() |
|
| 25 | - * |
|
| 26 | - * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 27 | - * @param callable $callback class/method name |
|
| 28 | - * |
|
| 29 | - * @return \Smarty|\Smarty_Internal_Template |
|
| 30 | - * @throws SmartyException if $callback is not callable |
|
| 31 | - */ |
|
| 32 | - public function registerDefaultTemplateHandler(Smarty_Internal_TemplateBase $obj, $callback) |
|
| 33 | - { |
|
| 34 | - $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 35 | - if (is_callable($callback)) { |
|
| 36 | - $smarty->default_template_handler_func = $callback; |
|
| 37 | - } else { |
|
| 38 | - throw new SmartyException("Default template handler not callable"); |
|
| 39 | - } |
|
| 40 | - return $obj; |
|
| 41 | - } |
|
| 21 | + /** |
|
| 22 | + * Register template default handler |
|
| 23 | + * |
|
| 24 | + * @api Smarty::registerDefaultTemplateHandler() |
|
| 25 | + * |
|
| 26 | + * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 27 | + * @param callable $callback class/method name |
|
| 28 | + * |
|
| 29 | + * @return \Smarty|\Smarty_Internal_Template |
|
| 30 | + * @throws SmartyException if $callback is not callable |
|
| 31 | + */ |
|
| 32 | + public function registerDefaultTemplateHandler(Smarty_Internal_TemplateBase $obj, $callback) |
|
| 33 | + { |
|
| 34 | + $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 35 | + if (is_callable($callback)) { |
|
| 36 | + $smarty->default_template_handler_func = $callback; |
|
| 37 | + } else { |
|
| 38 | + throw new SmartyException("Default template handler not callable"); |
|
| 39 | + } |
|
| 40 | + return $obj; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * get default content from template or config resource handler |
|
| 45 | - * |
|
| 46 | - * @param Smarty_Template_Source $source |
|
| 47 | - * |
|
| 48 | - * @throws \SmartyException |
|
| 49 | - */ |
|
| 50 | - public static function _getDefaultTemplate(Smarty_Template_Source $source) |
|
| 51 | - { |
|
| 52 | - if ($source->isConfig) { |
|
| 53 | - $default_handler = $source->smarty->default_config_handler_func; |
|
| 54 | - } else { |
|
| 55 | - $default_handler = $source->smarty->default_template_handler_func; |
|
| 56 | - } |
|
| 57 | - $_content = $_timestamp = null; |
|
| 58 | - $_return = call_user_func_array($default_handler, |
|
| 59 | - array($source->type, $source->name, &$_content, &$_timestamp, $source->smarty)); |
|
| 60 | - if (is_string($_return)) { |
|
| 61 | - $source->exists = is_file($_return); |
|
| 62 | - if ($source->exists) { |
|
| 63 | - $source->timestamp = filemtime($_return); |
|
| 64 | - } else { |
|
| 65 | - throw new SmartyException("Default handler: Unable to load " . |
|
| 66 | - ($source->isConfig ? 'config' : 'template') . |
|
| 67 | - " default file '{$_return}' for '{$source->type}:{$source->name}'"); |
|
| 68 | - } |
|
| 69 | - $source->name = $source->filepath = $_return; |
|
| 70 | - $source->uid = sha1($source->filepath); |
|
| 71 | - } elseif ($_return === true) { |
|
| 72 | - $source->content = $_content; |
|
| 73 | - $source->exists = true; |
|
| 74 | - $source->uid = $source->name = sha1($_content); |
|
| 75 | - $source->handler = Smarty_Resource::load($source->smarty, 'eval'); |
|
| 76 | - } else { |
|
| 77 | - $source->exists = false; |
|
| 78 | - throw new SmartyException('Default handler: No ' . ($source->isConfig ? 'config' : 'template') . |
|
| 79 | - " default content for '{$source->type}:{$source->name}'"); |
|
| 80 | - } |
|
| 81 | - } |
|
| 43 | + /** |
|
| 44 | + * get default content from template or config resource handler |
|
| 45 | + * |
|
| 46 | + * @param Smarty_Template_Source $source |
|
| 47 | + * |
|
| 48 | + * @throws \SmartyException |
|
| 49 | + */ |
|
| 50 | + public static function _getDefaultTemplate(Smarty_Template_Source $source) |
|
| 51 | + { |
|
| 52 | + if ($source->isConfig) { |
|
| 53 | + $default_handler = $source->smarty->default_config_handler_func; |
|
| 54 | + } else { |
|
| 55 | + $default_handler = $source->smarty->default_template_handler_func; |
|
| 56 | + } |
|
| 57 | + $_content = $_timestamp = null; |
|
| 58 | + $_return = call_user_func_array($default_handler, |
|
| 59 | + array($source->type, $source->name, &$_content, &$_timestamp, $source->smarty)); |
|
| 60 | + if (is_string($_return)) { |
|
| 61 | + $source->exists = is_file($_return); |
|
| 62 | + if ($source->exists) { |
|
| 63 | + $source->timestamp = filemtime($_return); |
|
| 64 | + } else { |
|
| 65 | + throw new SmartyException("Default handler: Unable to load " . |
|
| 66 | + ($source->isConfig ? 'config' : 'template') . |
|
| 67 | + " default file '{$_return}' for '{$source->type}:{$source->name}'"); |
|
| 68 | + } |
|
| 69 | + $source->name = $source->filepath = $_return; |
|
| 70 | + $source->uid = sha1($source->filepath); |
|
| 71 | + } elseif ($_return === true) { |
|
| 72 | + $source->content = $_content; |
|
| 73 | + $source->exists = true; |
|
| 74 | + $source->uid = $source->name = sha1($_content); |
|
| 75 | + $source->handler = Smarty_Resource::load($source->smarty, 'eval'); |
|
| 76 | + } else { |
|
| 77 | + $source->exists = false; |
|
| 78 | + throw new SmartyException('Default handler: No ' . ($source->isConfig ? 'config' : 'template') . |
|
| 79 | + " default content for '{$source->type}:{$source->name}'"); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | } |
| 83 | 83 | \ No newline at end of file |
@@ -18,82 +18,82 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Smarty_Template_Config extends Smarty_Template_Source |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * array of section names, single section or null |
|
| 23 | - * |
|
| 24 | - * @var null|string|array |
|
| 25 | - */ |
|
| 26 | - public $config_sections = null; |
|
| 21 | + /** |
|
| 22 | + * array of section names, single section or null |
|
| 23 | + * |
|
| 24 | + * @var null|string|array |
|
| 25 | + */ |
|
| 26 | + public $config_sections = null; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * scope into which the config variables shall be loaded |
|
| 30 | - * |
|
| 31 | - * @var int |
|
| 32 | - */ |
|
| 33 | - public $scope = 0; |
|
| 28 | + /** |
|
| 29 | + * scope into which the config variables shall be loaded |
|
| 30 | + * |
|
| 31 | + * @var int |
|
| 32 | + */ |
|
| 33 | + public $scope = 0; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Flag that source is a config file |
|
| 37 | - * |
|
| 38 | - * @var bool |
|
| 39 | - */ |
|
| 40 | - public $isConfig = true; |
|
| 35 | + /** |
|
| 36 | + * Flag that source is a config file |
|
| 37 | + * |
|
| 38 | + * @var bool |
|
| 39 | + */ |
|
| 40 | + public $isConfig = true; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Name of the Class to compile this resource's contents with |
|
| 44 | - * |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - public $compiler_class = 'Smarty_Internal_Config_File_Compiler'; |
|
| 42 | + /** |
|
| 43 | + * Name of the Class to compile this resource's contents with |
|
| 44 | + * |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + public $compiler_class = 'Smarty_Internal_Config_File_Compiler'; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Name of the Class to tokenize this resource's contents with |
|
| 51 | - * |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 54 | - public $template_lexer_class = 'Smarty_Internal_Configfilelexer'; |
|
| 49 | + /** |
|
| 50 | + * Name of the Class to tokenize this resource's contents with |
|
| 51 | + * |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | + public $template_lexer_class = 'Smarty_Internal_Configfilelexer'; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Name of the Class to parse this resource's contents with |
|
| 58 | - * |
|
| 59 | - * @var string |
|
| 60 | - */ |
|
| 61 | - public $template_parser_class = 'Smarty_Internal_Configfileparser'; |
|
| 56 | + /** |
|
| 57 | + * Name of the Class to parse this resource's contents with |
|
| 58 | + * |
|
| 59 | + * @var string |
|
| 60 | + */ |
|
| 61 | + public $template_parser_class = 'Smarty_Internal_Configfileparser'; |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * initialize Source Object for given resource |
|
| 65 | - * Either [$_template] or [$smarty, $template_resource] must be specified |
|
| 66 | - * |
|
| 67 | - * @param Smarty_Internal_Template $_template template object |
|
| 68 | - * @param Smarty $smarty smarty object |
|
| 69 | - * @param string $template_resource resource identifier |
|
| 70 | - * |
|
| 71 | - * @return Smarty_Template_Config Source Object |
|
| 72 | - * @throws SmartyException |
|
| 73 | - */ |
|
| 74 | - public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, |
|
| 75 | - $template_resource = null) |
|
| 76 | - { |
|
| 77 | - static $_incompatible_resources = array('extends' => true, 'php' => true); |
|
| 78 | - if ($_template) { |
|
| 79 | - $smarty = $_template->smarty; |
|
| 80 | - $template_resource = $_template->template_resource; |
|
| 81 | - } |
|
| 82 | - if (empty($template_resource)) { |
|
| 83 | - throw new SmartyException('Source: Missing name'); |
|
| 84 | - } |
|
| 85 | - // parse resource_name, load resource handler |
|
| 86 | - list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_config_type); |
|
| 87 | - // make sure configs are not loaded via anything smarty can't handle |
|
| 88 | - if (isset($_incompatible_resources[ $type ])) { |
|
| 89 | - throw new SmartyException ("Unable to use resource '{$type}' for config"); |
|
| 90 | - } |
|
| 91 | - $source = new Smarty_Template_Config($smarty, $template_resource, $type, $name); |
|
| 92 | - $source->handler->populate($source, $_template); |
|
| 93 | - if (!$source->exists && isset($smarty->default_config_handler_func)) { |
|
| 94 | - Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source); |
|
| 95 | - $source->handler->populate($source, $_template); |
|
| 96 | - } |
|
| 97 | - return $source; |
|
| 98 | - } |
|
| 63 | + /** |
|
| 64 | + * initialize Source Object for given resource |
|
| 65 | + * Either [$_template] or [$smarty, $template_resource] must be specified |
|
| 66 | + * |
|
| 67 | + * @param Smarty_Internal_Template $_template template object |
|
| 68 | + * @param Smarty $smarty smarty object |
|
| 69 | + * @param string $template_resource resource identifier |
|
| 70 | + * |
|
| 71 | + * @return Smarty_Template_Config Source Object |
|
| 72 | + * @throws SmartyException |
|
| 73 | + */ |
|
| 74 | + public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, |
|
| 75 | + $template_resource = null) |
|
| 76 | + { |
|
| 77 | + static $_incompatible_resources = array('extends' => true, 'php' => true); |
|
| 78 | + if ($_template) { |
|
| 79 | + $smarty = $_template->smarty; |
|
| 80 | + $template_resource = $_template->template_resource; |
|
| 81 | + } |
|
| 82 | + if (empty($template_resource)) { |
|
| 83 | + throw new SmartyException('Source: Missing name'); |
|
| 84 | + } |
|
| 85 | + // parse resource_name, load resource handler |
|
| 86 | + list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_config_type); |
|
| 87 | + // make sure configs are not loaded via anything smarty can't handle |
|
| 88 | + if (isset($_incompatible_resources[ $type ])) { |
|
| 89 | + throw new SmartyException ("Unable to use resource '{$type}' for config"); |
|
| 90 | + } |
|
| 91 | + $source = new Smarty_Template_Config($smarty, $template_resource, $type, $name); |
|
| 92 | + $source->handler->populate($source, $_template); |
|
| 93 | + if (!$source->exists && isset($smarty->default_config_handler_func)) { |
|
| 94 | + Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source); |
|
| 95 | + $source->handler->populate($source, $_template); |
|
| 96 | + } |
|
| 97 | + return $source; |
|
| 98 | + } |
|
| 99 | 99 | } |
@@ -85,8 +85,8 @@ |
||
| 85 | 85 | // parse resource_name, load resource handler |
| 86 | 86 | list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_config_type); |
| 87 | 87 | // make sure configs are not loaded via anything smarty can't handle |
| 88 | - if (isset($_incompatible_resources[ $type ])) { |
|
| 89 | - throw new SmartyException ("Unable to use resource '{$type}' for config"); |
|
| 88 | + if (isset($_incompatible_resources[$type])) { |
|
| 89 | + throw new SmartyException("Unable to use resource '{$type}' for config"); |
|
| 90 | 90 | } |
| 91 | 91 | $source = new Smarty_Template_Config($smarty, $template_resource, $type, $name); |
| 92 | 92 | $source->handler->populate($source, $_template); |