@@ -17,118 +17,118 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inheritance |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Attribute definition: Overwrites base class. |
|
| 22 | - * |
|
| 23 | - * @var array |
|
| 24 | - * @see Smarty_Internal_CompileBase |
|
| 25 | - */ |
|
| 26 | - public $required_attributes = array('file'); |
|
| 20 | + /** |
|
| 21 | + * Attribute definition: Overwrites base class. |
|
| 22 | + * |
|
| 23 | + * @var array |
|
| 24 | + * @see Smarty_Internal_CompileBase |
|
| 25 | + */ |
|
| 26 | + public $required_attributes = array('file'); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Array of names of optional attribute required by tag |
|
| 30 | - * use array('_any') if there is no restriction of attributes names |
|
| 31 | - * |
|
| 32 | - * @var array |
|
| 33 | - */ |
|
| 34 | - public $optional_attributes = array('extends_resource'); |
|
| 28 | + /** |
|
| 29 | + * Array of names of optional attribute required by tag |
|
| 30 | + * use array('_any') if there is no restriction of attributes names |
|
| 31 | + * |
|
| 32 | + * @var array |
|
| 33 | + */ |
|
| 34 | + public $optional_attributes = array('extends_resource'); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Attribute definition: Overwrites base class. |
|
| 38 | - * |
|
| 39 | - * @var array |
|
| 40 | - * @see Smarty_Internal_CompileBase |
|
| 41 | - */ |
|
| 42 | - public $shorttag_order = array('file'); |
|
| 36 | + /** |
|
| 37 | + * Attribute definition: Overwrites base class. |
|
| 38 | + * |
|
| 39 | + * @var array |
|
| 40 | + * @see Smarty_Internal_CompileBase |
|
| 41 | + */ |
|
| 42 | + public $shorttag_order = array('file'); |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Compiles code for the {extends} tag extends: resource |
|
| 46 | - * |
|
| 47 | - * @param array $args array with attributes from parser |
|
| 48 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 49 | - * |
|
| 50 | - * @return string compiled code |
|
| 51 | - * @throws \SmartyCompilerException |
|
| 52 | - * @throws \SmartyException |
|
| 53 | - */ |
|
| 54 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 55 | - { |
|
| 56 | - // check and get attributes |
|
| 57 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 58 | - if ($_attr[ 'nocache' ] === true) { |
|
| 59 | - $compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->line - 1); |
|
| 60 | - } |
|
| 61 | - if (strpos($_attr[ 'file' ], '$_tmp') !== false) { |
|
| 62 | - $compiler->trigger_template_error('illegal value for file attribute', $compiler->parser->lex->line - 1); |
|
| 63 | - } |
|
| 64 | - // add code to initialize inheritance |
|
| 65 | - $this->registerInit($compiler, true); |
|
| 66 | - $file = trim($_attr[ 'file' ], '\'"'); |
|
| 67 | - if (strlen($file) > 8 && substr($file, 0, 8) == 'extends:') { |
|
| 68 | - // generate code for each template |
|
| 69 | - $files = array_reverse(explode('|', substr($file, 8))); |
|
| 70 | - $i = 0; |
|
| 71 | - foreach ($files as $file) { |
|
| 72 | - if ($file[ 0 ] == '"') { |
|
| 73 | - $file = trim($file, '".'); |
|
| 74 | - } else { |
|
| 75 | - $file = "'{$file}'"; |
|
| 76 | - } |
|
| 77 | - $i ++; |
|
| 78 | - if ($i == count($files) && isset($_attr[ 'extends_resource' ])) { |
|
| 79 | - $this->compileEndChild($compiler); |
|
| 80 | - } |
|
| 81 | - $this->compileInclude($compiler, $file); |
|
| 82 | - } |
|
| 83 | - if (!isset($_attr[ 'extends_resource' ])) { |
|
| 84 | - $this->compileEndChild($compiler); |
|
| 85 | - } |
|
| 86 | - } else { |
|
| 87 | - $this->compileEndChild($compiler); |
|
| 88 | - $this->compileInclude($compiler, $_attr[ 'file' ]); |
|
| 89 | - } |
|
| 90 | - $compiler->has_code = false; |
|
| 91 | - return ''; |
|
| 92 | - } |
|
| 44 | + /** |
|
| 45 | + * Compiles code for the {extends} tag extends: resource |
|
| 46 | + * |
|
| 47 | + * @param array $args array with attributes from parser |
|
| 48 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 49 | + * |
|
| 50 | + * @return string compiled code |
|
| 51 | + * @throws \SmartyCompilerException |
|
| 52 | + * @throws \SmartyException |
|
| 53 | + */ |
|
| 54 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 55 | + { |
|
| 56 | + // check and get attributes |
|
| 57 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 58 | + if ($_attr[ 'nocache' ] === true) { |
|
| 59 | + $compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->line - 1); |
|
| 60 | + } |
|
| 61 | + if (strpos($_attr[ 'file' ], '$_tmp') !== false) { |
|
| 62 | + $compiler->trigger_template_error('illegal value for file attribute', $compiler->parser->lex->line - 1); |
|
| 63 | + } |
|
| 64 | + // add code to initialize inheritance |
|
| 65 | + $this->registerInit($compiler, true); |
|
| 66 | + $file = trim($_attr[ 'file' ], '\'"'); |
|
| 67 | + if (strlen($file) > 8 && substr($file, 0, 8) == 'extends:') { |
|
| 68 | + // generate code for each template |
|
| 69 | + $files = array_reverse(explode('|', substr($file, 8))); |
|
| 70 | + $i = 0; |
|
| 71 | + foreach ($files as $file) { |
|
| 72 | + if ($file[ 0 ] == '"') { |
|
| 73 | + $file = trim($file, '".'); |
|
| 74 | + } else { |
|
| 75 | + $file = "'{$file}'"; |
|
| 76 | + } |
|
| 77 | + $i ++; |
|
| 78 | + if ($i == count($files) && isset($_attr[ 'extends_resource' ])) { |
|
| 79 | + $this->compileEndChild($compiler); |
|
| 80 | + } |
|
| 81 | + $this->compileInclude($compiler, $file); |
|
| 82 | + } |
|
| 83 | + if (!isset($_attr[ 'extends_resource' ])) { |
|
| 84 | + $this->compileEndChild($compiler); |
|
| 85 | + } |
|
| 86 | + } else { |
|
| 87 | + $this->compileEndChild($compiler); |
|
| 88 | + $this->compileInclude($compiler, $_attr[ 'file' ]); |
|
| 89 | + } |
|
| 90 | + $compiler->has_code = false; |
|
| 91 | + return ''; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Add code for inheritance endChild() method to end of template |
|
| 96 | - * |
|
| 97 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 98 | - */ |
|
| 99 | - private function compileEndChild(Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 100 | - { |
|
| 101 | - $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 102 | - "<?php \$_smarty_tpl->inheritance->endChild();\n?>\n"); |
|
| 103 | - } |
|
| 94 | + /** |
|
| 95 | + * Add code for inheritance endChild() method to end of template |
|
| 96 | + * |
|
| 97 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 98 | + */ |
|
| 99 | + private function compileEndChild(Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 100 | + { |
|
| 101 | + $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 102 | + "<?php \$_smarty_tpl->inheritance->endChild();\n?>\n"); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Add code for including subtemplate to end of template |
|
| 107 | - * |
|
| 108 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 109 | - * @param string $file subtemplate name |
|
| 110 | - */ |
|
| 111 | - private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $file) |
|
| 112 | - { |
|
| 113 | - $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 114 | - $compiler->compileTag('include', |
|
| 115 | - array($file, |
|
| 116 | - array('scope' => 'parent')))); |
|
| 117 | - } |
|
| 105 | + /** |
|
| 106 | + * Add code for including subtemplate to end of template |
|
| 107 | + * |
|
| 108 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 109 | + * @param string $file subtemplate name |
|
| 110 | + */ |
|
| 111 | + private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $file) |
|
| 112 | + { |
|
| 113 | + $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 114 | + $compiler->compileTag('include', |
|
| 115 | + array($file, |
|
| 116 | + array('scope' => 'parent')))); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Create source code for {extends} from source components array |
|
| 121 | - * |
|
| 122 | - * @param []\Smarty_Internal_Template_Source $components |
|
| 123 | - * |
|
| 124 | - * @return string |
|
| 125 | - */ |
|
| 126 | - public static function extendsSourceArrayCode($components) |
|
| 127 | - { |
|
| 128 | - $resources = array(); |
|
| 129 | - foreach ($components as $source) { |
|
| 130 | - $resources[] = $source->resource; |
|
| 131 | - } |
|
| 132 | - return '{extends file=\'extends:' . join('|', $resources) . '\' extends_resource=true}'; |
|
| 133 | - } |
|
| 119 | + /** |
|
| 120 | + * Create source code for {extends} from source components array |
|
| 121 | + * |
|
| 122 | + * @param []\Smarty_Internal_Template_Source $components |
|
| 123 | + * |
|
| 124 | + * @return string |
|
| 125 | + */ |
|
| 126 | + public static function extendsSourceArrayCode($components) |
|
| 127 | + { |
|
| 128 | + $resources = array(); |
|
| 129 | + foreach ($components as $source) { |
|
| 130 | + $resources[] = $source->resource; |
|
| 131 | + } |
|
| 132 | + return '{extends file=\'extends:' . join('|', $resources) . '\' extends_resource=true}'; |
|
| 133 | + } |
|
| 134 | 134 | } |
@@ -55,37 +55,37 @@ |
||
| 55 | 55 | { |
| 56 | 56 | // check and get attributes |
| 57 | 57 | $_attr = $this->getAttributes($compiler, $args); |
| 58 | - if ($_attr[ 'nocache' ] === true) { |
|
| 58 | + if ($_attr['nocache'] === true) { |
|
| 59 | 59 | $compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->line - 1); |
| 60 | 60 | } |
| 61 | - if (strpos($_attr[ 'file' ], '$_tmp') !== false) { |
|
| 61 | + if (strpos($_attr['file'], '$_tmp') !== false) { |
|
| 62 | 62 | $compiler->trigger_template_error('illegal value for file attribute', $compiler->parser->lex->line - 1); |
| 63 | 63 | } |
| 64 | 64 | // add code to initialize inheritance |
| 65 | 65 | $this->registerInit($compiler, true); |
| 66 | - $file = trim($_attr[ 'file' ], '\'"'); |
|
| 66 | + $file = trim($_attr['file'], '\'"'); |
|
| 67 | 67 | if (strlen($file) > 8 && substr($file, 0, 8) == 'extends:') { |
| 68 | 68 | // generate code for each template |
| 69 | 69 | $files = array_reverse(explode('|', substr($file, 8))); |
| 70 | 70 | $i = 0; |
| 71 | 71 | foreach ($files as $file) { |
| 72 | - if ($file[ 0 ] == '"') { |
|
| 72 | + if ($file[0] == '"') { |
|
| 73 | 73 | $file = trim($file, '".'); |
| 74 | 74 | } else { |
| 75 | 75 | $file = "'{$file}'"; |
| 76 | 76 | } |
| 77 | - $i ++; |
|
| 78 | - if ($i == count($files) && isset($_attr[ 'extends_resource' ])) { |
|
| 77 | + $i++; |
|
| 78 | + if ($i == count($files) && isset($_attr['extends_resource'])) { |
|
| 79 | 79 | $this->compileEndChild($compiler); |
| 80 | 80 | } |
| 81 | 81 | $this->compileInclude($compiler, $file); |
| 82 | 82 | } |
| 83 | - if (!isset($_attr[ 'extends_resource' ])) { |
|
| 83 | + if (!isset($_attr['extends_resource'])) { |
|
| 84 | 84 | $this->compileEndChild($compiler); |
| 85 | 85 | } |
| 86 | 86 | } else { |
| 87 | 87 | $this->compileEndChild($compiler); |
| 88 | - $this->compileInclude($compiler, $_attr[ 'file' ]); |
|
| 88 | + $this->compileInclude($compiler, $_attr['file']); |
|
| 89 | 89 | } |
| 90 | 90 | $compiler->has_code = false; |
| 91 | 91 | return ''; |
@@ -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); |
@@ -11,32 +11,32 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_UnloadFilter extends Smarty_Internal_Method_LoadFilter |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * load a filter of specified type and name |
|
| 16 | - * |
|
| 17 | - * @api Smarty::unloadFilter() |
|
| 18 | - * |
|
| 19 | - * @link http://www.smarty.net/docs/en/api.unload.filter.tpl |
|
| 20 | - * |
|
| 21 | - * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 22 | - * @param string $type filter type |
|
| 23 | - * @param string $name filter name |
|
| 24 | - * |
|
| 25 | - * @return bool |
|
| 26 | - */ |
|
| 27 | - public function unloadFilter(Smarty_Internal_TemplateBase $obj, $type, $name) |
|
| 28 | - { |
|
| 29 | - $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 30 | - $this->_checkFilterType($type); |
|
| 31 | - if (isset($smarty->registered_filters[ $type ])) { |
|
| 32 | - $_filter_name = "smarty_{$type}filter_{$name}"; |
|
| 33 | - if (isset($smarty->registered_filters[ $type ][ $_filter_name ])) { |
|
| 34 | - unset ($smarty->registered_filters[ $type ][ $_filter_name ]); |
|
| 35 | - if (empty($smarty->registered_filters[ $type ])) { |
|
| 36 | - unset($smarty->registered_filters[ $type ]); |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - return $obj; |
|
| 41 | - } |
|
| 14 | + /** |
|
| 15 | + * load a filter of specified type and name |
|
| 16 | + * |
|
| 17 | + * @api Smarty::unloadFilter() |
|
| 18 | + * |
|
| 19 | + * @link http://www.smarty.net/docs/en/api.unload.filter.tpl |
|
| 20 | + * |
|
| 21 | + * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 22 | + * @param string $type filter type |
|
| 23 | + * @param string $name filter name |
|
| 24 | + * |
|
| 25 | + * @return bool |
|
| 26 | + */ |
|
| 27 | + public function unloadFilter(Smarty_Internal_TemplateBase $obj, $type, $name) |
|
| 28 | + { |
|
| 29 | + $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 30 | + $this->_checkFilterType($type); |
|
| 31 | + if (isset($smarty->registered_filters[ $type ])) { |
|
| 32 | + $_filter_name = "smarty_{$type}filter_{$name}"; |
|
| 33 | + if (isset($smarty->registered_filters[ $type ][ $_filter_name ])) { |
|
| 34 | + unset ($smarty->registered_filters[ $type ][ $_filter_name ]); |
|
| 35 | + if (empty($smarty->registered_filters[ $type ])) { |
|
| 36 | + unset($smarty->registered_filters[ $type ]); |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + return $obj; |
|
| 41 | + } |
|
| 42 | 42 | } |
| 43 | 43 | \ No newline at end of file |
@@ -28,12 +28,12 @@ |
||
| 28 | 28 | { |
| 29 | 29 | $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
| 30 | 30 | $this->_checkFilterType($type); |
| 31 | - if (isset($smarty->registered_filters[ $type ])) { |
|
| 31 | + if (isset($smarty->registered_filters[$type])) { |
|
| 32 | 32 | $_filter_name = "smarty_{$type}filter_{$name}"; |
| 33 | - if (isset($smarty->registered_filters[ $type ][ $_filter_name ])) { |
|
| 34 | - unset ($smarty->registered_filters[ $type ][ $_filter_name ]); |
|
| 35 | - if (empty($smarty->registered_filters[ $type ])) { |
|
| 36 | - unset($smarty->registered_filters[ $type ]); |
|
| 33 | + if (isset($smarty->registered_filters[$type][$_filter_name])) { |
|
| 34 | + unset ($smarty->registered_filters[$type][$_filter_name]); |
|
| 35 | + if (empty($smarty->registered_filters[$type])) { |
|
| 36 | + unset($smarty->registered_filters[$type]); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -17,26 +17,26 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Compiles code for the {debug} tag |
|
| 22 | - * |
|
| 23 | - * @param array $args array with attributes from parser |
|
| 24 | - * @param object $compiler compiler object |
|
| 25 | - * |
|
| 26 | - * @return string compiled code |
|
| 27 | - */ |
|
| 28 | - public function compile($args, $compiler) |
|
| 29 | - { |
|
| 30 | - // check and get attributes |
|
| 31 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 20 | + /** |
|
| 21 | + * Compiles code for the {debug} tag |
|
| 22 | + * |
|
| 23 | + * @param array $args array with attributes from parser |
|
| 24 | + * @param object $compiler compiler object |
|
| 25 | + * |
|
| 26 | + * @return string compiled code |
|
| 27 | + */ |
|
| 28 | + public function compile($args, $compiler) |
|
| 29 | + { |
|
| 30 | + // check and get attributes |
|
| 31 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 32 | 32 | |
| 33 | - // compile always as nocache |
|
| 34 | - $compiler->tag_nocache = true; |
|
| 33 | + // compile always as nocache |
|
| 34 | + $compiler->tag_nocache = true; |
|
| 35 | 35 | |
| 36 | - // display debug template |
|
| 37 | - $_output = |
|
| 38 | - "<?php \$_smarty_debug = new Smarty_Internal_Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n"; |
|
| 39 | - $_output .= "unset(\$_smarty_debug);\n?>"; |
|
| 40 | - return $_output; |
|
| 41 | - } |
|
| 36 | + // display debug template |
|
| 37 | + $_output = |
|
| 38 | + "<?php \$_smarty_debug = new Smarty_Internal_Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n"; |
|
| 39 | + $_output .= "unset(\$_smarty_debug);\n?>"; |
|
| 40 | + return $_output; |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -10,156 +10,156 @@ |
||
| 10 | 10 | **/ |
| 11 | 11 | class Smarty_Internal_Runtime_UpdateCache |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * check client side cache |
|
| 15 | - * |
|
| 16 | - * @param \Smarty_Template_Cached $cached |
|
| 17 | - * @param Smarty_Internal_Template $_template |
|
| 18 | - * @param string $content |
|
| 19 | - */ |
|
| 20 | - public function cacheModifiedCheck(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, $content) |
|
| 21 | - { |
|
| 22 | - } |
|
| 13 | + /** |
|
| 14 | + * check client side cache |
|
| 15 | + * |
|
| 16 | + * @param \Smarty_Template_Cached $cached |
|
| 17 | + * @param Smarty_Internal_Template $_template |
|
| 18 | + * @param string $content |
|
| 19 | + */ |
|
| 20 | + public function cacheModifiedCheck(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, $content) |
|
| 21 | + { |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Sanitize content and write it to cache resource |
|
| 26 | - * |
|
| 27 | - * @param \Smarty_Template_Cached $cached |
|
| 28 | - * @param Smarty_Internal_Template $_template |
|
| 29 | - * @param bool $no_output_filter |
|
| 30 | - * |
|
| 31 | - * @throws \SmartyException |
|
| 32 | - */ |
|
| 33 | - public function removeNoCacheHash(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, |
|
| 34 | - $no_output_filter) |
|
| 35 | - { |
|
| 36 | - $content = ob_get_clean(); |
|
| 37 | - unset($cached->hashes[ $_template->compiled->nocache_hash ]); |
|
| 38 | - if (!empty($cached->hashes)) { |
|
| 39 | - $hash_array = array(); |
|
| 40 | - foreach ($cached->hashes as $hash => $foo) { |
|
| 41 | - $hash_array[] = "/{$hash}/"; |
|
| 42 | - } |
|
| 43 | - $content = preg_replace($hash_array, $_template->compiled->nocache_hash, $content); |
|
| 44 | - } |
|
| 45 | - $_template->cached->has_nocache_code = false; |
|
| 46 | - // get text between non-cached items |
|
| 47 | - $cache_split = |
|
| 48 | - preg_split("!/\*%%SmartyNocache:{$_template->compiled->nocache_hash}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->compiled->nocache_hash}%%\*/!s", |
|
| 49 | - $content); |
|
| 50 | - // get non-cached items |
|
| 51 | - preg_match_all("!/\*%%SmartyNocache:{$_template->compiled->nocache_hash}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->compiled->nocache_hash}%%\*/!s", |
|
| 52 | - $content, $cache_parts); |
|
| 53 | - $content = ''; |
|
| 54 | - // loop over items, stitch back together |
|
| 55 | - foreach ($cache_split as $curr_idx => $curr_split) { |
|
| 56 | - // escape PHP tags in template content |
|
| 57 | - $content .= preg_replace('/(<%|%>|<\?php|<\?|\?>|<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>)/', |
|
| 58 | - "<?php echo '\$1'; ?>\n", $curr_split); |
|
| 59 | - if (isset($cache_parts[ 0 ][ $curr_idx ])) { |
|
| 60 | - $_template->cached->has_nocache_code = true; |
|
| 61 | - $content .= $cache_parts[ 1 ][ $curr_idx ]; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - if (!$no_output_filter && !$_template->cached->has_nocache_code && |
|
| 65 | - (isset($_template->smarty->autoload_filters[ 'output' ]) || |
|
| 66 | - isset($_template->smarty->registered_filters[ 'output' ])) |
|
| 67 | - ) { |
|
| 68 | - $content = $_template->smarty->ext->_filterHandler->runFilter('output', $content, $_template); |
|
| 69 | - } |
|
| 70 | - // write cache file content |
|
| 71 | - $this->writeCachedContent($cached, $_template, $content); |
|
| 72 | - } |
|
| 24 | + /** |
|
| 25 | + * Sanitize content and write it to cache resource |
|
| 26 | + * |
|
| 27 | + * @param \Smarty_Template_Cached $cached |
|
| 28 | + * @param Smarty_Internal_Template $_template |
|
| 29 | + * @param bool $no_output_filter |
|
| 30 | + * |
|
| 31 | + * @throws \SmartyException |
|
| 32 | + */ |
|
| 33 | + public function removeNoCacheHash(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, |
|
| 34 | + $no_output_filter) |
|
| 35 | + { |
|
| 36 | + $content = ob_get_clean(); |
|
| 37 | + unset($cached->hashes[ $_template->compiled->nocache_hash ]); |
|
| 38 | + if (!empty($cached->hashes)) { |
|
| 39 | + $hash_array = array(); |
|
| 40 | + foreach ($cached->hashes as $hash => $foo) { |
|
| 41 | + $hash_array[] = "/{$hash}/"; |
|
| 42 | + } |
|
| 43 | + $content = preg_replace($hash_array, $_template->compiled->nocache_hash, $content); |
|
| 44 | + } |
|
| 45 | + $_template->cached->has_nocache_code = false; |
|
| 46 | + // get text between non-cached items |
|
| 47 | + $cache_split = |
|
| 48 | + preg_split("!/\*%%SmartyNocache:{$_template->compiled->nocache_hash}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->compiled->nocache_hash}%%\*/!s", |
|
| 49 | + $content); |
|
| 50 | + // get non-cached items |
|
| 51 | + preg_match_all("!/\*%%SmartyNocache:{$_template->compiled->nocache_hash}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->compiled->nocache_hash}%%\*/!s", |
|
| 52 | + $content, $cache_parts); |
|
| 53 | + $content = ''; |
|
| 54 | + // loop over items, stitch back together |
|
| 55 | + foreach ($cache_split as $curr_idx => $curr_split) { |
|
| 56 | + // escape PHP tags in template content |
|
| 57 | + $content .= preg_replace('/(<%|%>|<\?php|<\?|\?>|<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>)/', |
|
| 58 | + "<?php echo '\$1'; ?>\n", $curr_split); |
|
| 59 | + if (isset($cache_parts[ 0 ][ $curr_idx ])) { |
|
| 60 | + $_template->cached->has_nocache_code = true; |
|
| 61 | + $content .= $cache_parts[ 1 ][ $curr_idx ]; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + if (!$no_output_filter && !$_template->cached->has_nocache_code && |
|
| 65 | + (isset($_template->smarty->autoload_filters[ 'output' ]) || |
|
| 66 | + isset($_template->smarty->registered_filters[ 'output' ])) |
|
| 67 | + ) { |
|
| 68 | + $content = $_template->smarty->ext->_filterHandler->runFilter('output', $content, $_template); |
|
| 69 | + } |
|
| 70 | + // write cache file content |
|
| 71 | + $this->writeCachedContent($cached, $_template, $content); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Cache was invalid , so render from compiled and write to cache |
|
| 76 | - * |
|
| 77 | - * @param \Smarty_Template_Cached $cached |
|
| 78 | - * @param \Smarty_Internal_Template $_template |
|
| 79 | - * @param $no_output_filter |
|
| 80 | - * |
|
| 81 | - * @throws \Exception |
|
| 82 | - */ |
|
| 83 | - public function updateCache(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, $no_output_filter) |
|
| 84 | - { |
|
| 85 | - ob_start(); |
|
| 86 | - if (!isset($_template->compiled)) { |
|
| 87 | - $_template->loadCompiled(); |
|
| 88 | - } |
|
| 89 | - $_template->compiled->render($_template); |
|
| 90 | - if ($_template->smarty->debugging) { |
|
| 91 | - $_template->smarty->_debug->start_cache($_template); |
|
| 92 | - } |
|
| 93 | - $this->removeNoCacheHash($cached, $_template, $no_output_filter); |
|
| 94 | - $compile_check = $_template->smarty->compile_check; |
|
| 95 | - $_template->smarty->compile_check = false; |
|
| 96 | - if (isset($_template->parent) && $_template->parent->_objType == 2) { |
|
| 97 | - $_template->compiled->unifunc = $_template->parent->compiled->unifunc; |
|
| 98 | - } |
|
| 99 | - if (!$_template->cached->processed) { |
|
| 100 | - $_template->cached->process($_template, true); |
|
| 101 | - } |
|
| 102 | - $_template->smarty->compile_check = $compile_check; |
|
| 103 | - $cached->getRenderedTemplateCode($_template); |
|
| 104 | - if ($_template->smarty->debugging) { |
|
| 105 | - $_template->smarty->_debug->end_cache($_template); |
|
| 106 | - } |
|
| 107 | - } |
|
| 74 | + /** |
|
| 75 | + * Cache was invalid , so render from compiled and write to cache |
|
| 76 | + * |
|
| 77 | + * @param \Smarty_Template_Cached $cached |
|
| 78 | + * @param \Smarty_Internal_Template $_template |
|
| 79 | + * @param $no_output_filter |
|
| 80 | + * |
|
| 81 | + * @throws \Exception |
|
| 82 | + */ |
|
| 83 | + public function updateCache(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, $no_output_filter) |
|
| 84 | + { |
|
| 85 | + ob_start(); |
|
| 86 | + if (!isset($_template->compiled)) { |
|
| 87 | + $_template->loadCompiled(); |
|
| 88 | + } |
|
| 89 | + $_template->compiled->render($_template); |
|
| 90 | + if ($_template->smarty->debugging) { |
|
| 91 | + $_template->smarty->_debug->start_cache($_template); |
|
| 92 | + } |
|
| 93 | + $this->removeNoCacheHash($cached, $_template, $no_output_filter); |
|
| 94 | + $compile_check = $_template->smarty->compile_check; |
|
| 95 | + $_template->smarty->compile_check = false; |
|
| 96 | + if (isset($_template->parent) && $_template->parent->_objType == 2) { |
|
| 97 | + $_template->compiled->unifunc = $_template->parent->compiled->unifunc; |
|
| 98 | + } |
|
| 99 | + if (!$_template->cached->processed) { |
|
| 100 | + $_template->cached->process($_template, true); |
|
| 101 | + } |
|
| 102 | + $_template->smarty->compile_check = $compile_check; |
|
| 103 | + $cached->getRenderedTemplateCode($_template); |
|
| 104 | + if ($_template->smarty->debugging) { |
|
| 105 | + $_template->smarty->_debug->end_cache($_template); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Writes the content to cache resource |
|
| 111 | - * |
|
| 112 | - * @param \Smarty_Template_Cached $cached |
|
| 113 | - * @param Smarty_Internal_Template $_template |
|
| 114 | - * @param string $content |
|
| 115 | - * |
|
| 116 | - * @return bool |
|
| 117 | - */ |
|
| 118 | - public function writeCachedContent(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, $content) |
|
| 119 | - { |
|
| 120 | - if ($_template->source->handler->recompiled || !($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || |
|
| 121 | - $_template->caching == Smarty::CACHING_LIFETIME_SAVED) |
|
| 122 | - ) { |
|
| 123 | - // don't write cache file |
|
| 124 | - return false; |
|
| 125 | - } |
|
| 126 | - $content = $_template->smarty->ext->_codeFrame->create($_template, $content, '', true); |
|
| 127 | - return $this->write($cached, $_template, $content); |
|
| 128 | - } |
|
| 109 | + /** |
|
| 110 | + * Writes the content to cache resource |
|
| 111 | + * |
|
| 112 | + * @param \Smarty_Template_Cached $cached |
|
| 113 | + * @param Smarty_Internal_Template $_template |
|
| 114 | + * @param string $content |
|
| 115 | + * |
|
| 116 | + * @return bool |
|
| 117 | + */ |
|
| 118 | + public function writeCachedContent(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, $content) |
|
| 119 | + { |
|
| 120 | + if ($_template->source->handler->recompiled || !($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || |
|
| 121 | + $_template->caching == Smarty::CACHING_LIFETIME_SAVED) |
|
| 122 | + ) { |
|
| 123 | + // don't write cache file |
|
| 124 | + return false; |
|
| 125 | + } |
|
| 126 | + $content = $_template->smarty->ext->_codeFrame->create($_template, $content, '', true); |
|
| 127 | + return $this->write($cached, $_template, $content); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Write this cache object to handler |
|
| 132 | - * |
|
| 133 | - * @param \Smarty_Template_Cached $cached |
|
| 134 | - * @param Smarty_Internal_Template $_template template object |
|
| 135 | - * @param string $content content to cache |
|
| 136 | - * |
|
| 137 | - * @return bool success |
|
| 138 | - */ |
|
| 139 | - public function write(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, $content) |
|
| 140 | - { |
|
| 141 | - if (!$_template->source->handler->recompiled) { |
|
| 142 | - if ($cached->handler->writeCachedContent($_template, $content)) { |
|
| 143 | - $cached->content = null; |
|
| 144 | - $cached->timestamp = time(); |
|
| 145 | - $cached->exists = true; |
|
| 146 | - $cached->valid = true; |
|
| 147 | - $cached->cache_lifetime = $_template->cache_lifetime; |
|
| 148 | - $cached->processed = false; |
|
| 149 | - if ($_template->smarty->cache_locking) { |
|
| 150 | - $cached->handler->releaseLock($_template->smarty, $cached); |
|
| 151 | - } |
|
| 130 | + /** |
|
| 131 | + * Write this cache object to handler |
|
| 132 | + * |
|
| 133 | + * @param \Smarty_Template_Cached $cached |
|
| 134 | + * @param Smarty_Internal_Template $_template template object |
|
| 135 | + * @param string $content content to cache |
|
| 136 | + * |
|
| 137 | + * @return bool success |
|
| 138 | + */ |
|
| 139 | + public function write(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, $content) |
|
| 140 | + { |
|
| 141 | + if (!$_template->source->handler->recompiled) { |
|
| 142 | + if ($cached->handler->writeCachedContent($_template, $content)) { |
|
| 143 | + $cached->content = null; |
|
| 144 | + $cached->timestamp = time(); |
|
| 145 | + $cached->exists = true; |
|
| 146 | + $cached->valid = true; |
|
| 147 | + $cached->cache_lifetime = $_template->cache_lifetime; |
|
| 148 | + $cached->processed = false; |
|
| 149 | + if ($_template->smarty->cache_locking) { |
|
| 150 | + $cached->handler->releaseLock($_template->smarty, $cached); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - return true; |
|
| 154 | - } |
|
| 155 | - $cached->content = null; |
|
| 156 | - $cached->timestamp = false; |
|
| 157 | - $cached->exists = false; |
|
| 158 | - $cached->valid = false; |
|
| 159 | - $cached->processed = false; |
|
| 160 | - } |
|
| 153 | + return true; |
|
| 154 | + } |
|
| 155 | + $cached->content = null; |
|
| 156 | + $cached->timestamp = false; |
|
| 157 | + $cached->exists = false; |
|
| 158 | + $cached->valid = false; |
|
| 159 | + $cached->processed = false; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - return false; |
|
| 163 | - } |
|
| 162 | + return false; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | \ No newline at end of file |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $no_output_filter) |
| 35 | 35 | { |
| 36 | 36 | $content = ob_get_clean(); |
| 37 | - unset($cached->hashes[ $_template->compiled->nocache_hash ]); |
|
| 37 | + unset($cached->hashes[$_template->compiled->nocache_hash]); |
|
| 38 | 38 | if (!empty($cached->hashes)) { |
| 39 | 39 | $hash_array = array(); |
| 40 | 40 | foreach ($cached->hashes as $hash => $foo) { |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | // escape PHP tags in template content |
| 57 | 57 | $content .= preg_replace('/(<%|%>|<\?php|<\?|\?>|<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>)/', |
| 58 | 58 | "<?php echo '\$1'; ?>\n", $curr_split); |
| 59 | - if (isset($cache_parts[ 0 ][ $curr_idx ])) { |
|
| 59 | + if (isset($cache_parts[0][$curr_idx])) { |
|
| 60 | 60 | $_template->cached->has_nocache_code = true; |
| 61 | - $content .= $cache_parts[ 1 ][ $curr_idx ]; |
|
| 61 | + $content .= $cache_parts[1][$curr_idx]; |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | if (!$no_output_filter && !$_template->cached->has_nocache_code && |
| 65 | - (isset($_template->smarty->autoload_filters[ 'output' ]) || |
|
| 66 | - isset($_template->smarty->registered_filters[ 'output' ])) |
|
| 65 | + (isset($_template->smarty->autoload_filters['output']) || |
|
| 66 | + isset($_template->smarty->registered_filters['output'])) |
|
| 67 | 67 | ) { |
| 68 | 68 | $content = $_template->smarty->ext->_filterHandler->runFilter('output', $content, $_template); |
| 69 | 69 | } |