@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Array of names of valid option flags |
|
| 21 | - * |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 24 | - public $option_flags = array(); |
|
| 19 | + /** |
|
| 20 | + * Array of names of valid option flags |
|
| 21 | + * |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | + public $option_flags = array(); |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Compiles code for the {nocache} tag |
|
| 28 | - * This tag does not generate compiled output. It only sets a compiler flag. |
|
| 29 | - * |
|
| 30 | - * @param array $args array with attributes from parser |
|
| 31 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 32 | - * |
|
| 33 | - * @return bool |
|
| 34 | - */ |
|
| 35 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 36 | - { |
|
| 37 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 38 | - $this->openTag($compiler, 'nocache', array($compiler->nocache)); |
|
| 39 | - // enter nocache mode |
|
| 40 | - $compiler->nocache = true; |
|
| 41 | - // this tag does not return compiled code |
|
| 42 | - $compiler->has_code = false; |
|
| 26 | + /** |
|
| 27 | + * Compiles code for the {nocache} tag |
|
| 28 | + * This tag does not generate compiled output. It only sets a compiler flag. |
|
| 29 | + * |
|
| 30 | + * @param array $args array with attributes from parser |
|
| 31 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 32 | + * |
|
| 33 | + * @return bool |
|
| 34 | + */ |
|
| 35 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 36 | + { |
|
| 37 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 38 | + $this->openTag($compiler, 'nocache', array($compiler->nocache)); |
|
| 39 | + // enter nocache mode |
|
| 40 | + $compiler->nocache = true; |
|
| 41 | + // this tag does not return compiled code |
|
| 42 | + $compiler->has_code = false; |
|
| 43 | 43 | |
| 44 | - return true; |
|
| 45 | - } |
|
| 44 | + return true; |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -53,23 +53,23 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase |
| 55 | 55 | { |
| 56 | - /** |
|
| 57 | - * Compiles code for the {/nocache} tag |
|
| 58 | - * This tag does not generate compiled output. It only sets a compiler flag. |
|
| 59 | - * |
|
| 60 | - * @param array $args array with attributes from parser |
|
| 61 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 62 | - * |
|
| 63 | - * @return bool |
|
| 64 | - */ |
|
| 65 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 66 | - { |
|
| 67 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 68 | - // leave nocache mode |
|
| 69 | - list($compiler->nocache) = $this->closeTag($compiler, array('nocache')); |
|
| 70 | - // this tag does not return compiled code |
|
| 71 | - $compiler->has_code = false; |
|
| 56 | + /** |
|
| 57 | + * Compiles code for the {/nocache} tag |
|
| 58 | + * This tag does not generate compiled output. It only sets a compiler flag. |
|
| 59 | + * |
|
| 60 | + * @param array $args array with attributes from parser |
|
| 61 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 62 | + * |
|
| 63 | + * @return bool |
|
| 64 | + */ |
|
| 65 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 66 | + { |
|
| 67 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 68 | + // leave nocache mode |
|
| 69 | + list($compiler->nocache) = $this->closeTag($compiler, array('nocache')); |
|
| 70 | + // this tag does not return compiled code |
|
| 71 | + $compiler->has_code = false; |
|
| 72 | 72 | |
| 73 | - return true; |
|
| 74 | - } |
|
| 73 | + return true; |
|
| 74 | + } |
|
| 75 | 75 | } |
@@ -11,106 +11,106 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_GetTemplateVars |
| 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 template variables |
|
| 23 | - * |
|
| 24 | - * @api Smarty::getTemplateVars() |
|
| 25 | - * @link http://www.smarty.net/docs/en/api.get.template.vars.tpl |
|
| 26 | - * |
|
| 27 | - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data |
|
| 28 | - * @param string $varName variable name or null |
|
| 29 | - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object |
|
| 30 | - * @param bool $searchParents include parent templates? |
|
| 31 | - * |
|
| 32 | - * @return mixed variable value or or array of variables |
|
| 33 | - */ |
|
| 34 | - public function getTemplateVars(Smarty_Internal_Data $data, $varName = null, Smarty_Internal_Data $_ptr = null, |
|
| 35 | - $searchParents = true) |
|
| 36 | - { |
|
| 37 | - if (isset($varName)) { |
|
| 38 | - $_var = $this->_getVariable($data, $varName, $_ptr, $searchParents, false); |
|
| 39 | - if (is_object($_var)) { |
|
| 40 | - return $_var->value; |
|
| 41 | - } else { |
|
| 42 | - return null; |
|
| 43 | - } |
|
| 44 | - } else { |
|
| 45 | - $_result = array(); |
|
| 46 | - if ($_ptr === null) { |
|
| 47 | - $_ptr = $data; |
|
| 48 | - } |
|
| 49 | - while ($_ptr !== null) { |
|
| 50 | - foreach ($_ptr->tpl_vars AS $key => $var) { |
|
| 51 | - if (!array_key_exists($key, $_result)) { |
|
| 52 | - $_result[ $key ] = $var->value; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - // not found, try at parent |
|
| 56 | - if ($searchParents) { |
|
| 57 | - $_ptr = $_ptr->parent; |
|
| 58 | - } else { |
|
| 59 | - $_ptr = null; |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - if ($searchParents && isset(Smarty::$global_tpl_vars)) { |
|
| 63 | - foreach (Smarty::$global_tpl_vars AS $key => $var) { |
|
| 64 | - if (!array_key_exists($key, $_result)) { |
|
| 65 | - $_result[ $key ] = $var->value; |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - return $_result; |
|
| 70 | - } |
|
| 71 | - } |
|
| 21 | + /** |
|
| 22 | + * Returns a single or all template variables |
|
| 23 | + * |
|
| 24 | + * @api Smarty::getTemplateVars() |
|
| 25 | + * @link http://www.smarty.net/docs/en/api.get.template.vars.tpl |
|
| 26 | + * |
|
| 27 | + * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data |
|
| 28 | + * @param string $varName variable name or null |
|
| 29 | + * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object |
|
| 30 | + * @param bool $searchParents include parent templates? |
|
| 31 | + * |
|
| 32 | + * @return mixed variable value or or array of variables |
|
| 33 | + */ |
|
| 34 | + public function getTemplateVars(Smarty_Internal_Data $data, $varName = null, Smarty_Internal_Data $_ptr = null, |
|
| 35 | + $searchParents = true) |
|
| 36 | + { |
|
| 37 | + if (isset($varName)) { |
|
| 38 | + $_var = $this->_getVariable($data, $varName, $_ptr, $searchParents, false); |
|
| 39 | + if (is_object($_var)) { |
|
| 40 | + return $_var->value; |
|
| 41 | + } else { |
|
| 42 | + return null; |
|
| 43 | + } |
|
| 44 | + } else { |
|
| 45 | + $_result = array(); |
|
| 46 | + if ($_ptr === null) { |
|
| 47 | + $_ptr = $data; |
|
| 48 | + } |
|
| 49 | + while ($_ptr !== null) { |
|
| 50 | + foreach ($_ptr->tpl_vars AS $key => $var) { |
|
| 51 | + if (!array_key_exists($key, $_result)) { |
|
| 52 | + $_result[ $key ] = $var->value; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + // not found, try at parent |
|
| 56 | + if ($searchParents) { |
|
| 57 | + $_ptr = $_ptr->parent; |
|
| 58 | + } else { |
|
| 59 | + $_ptr = null; |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + if ($searchParents && isset(Smarty::$global_tpl_vars)) { |
|
| 63 | + foreach (Smarty::$global_tpl_vars AS $key => $var) { |
|
| 64 | + if (!array_key_exists($key, $_result)) { |
|
| 65 | + $_result[ $key ] = $var->value; |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + return $_result; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * gets the object of a Smarty variable |
|
| 75 | - * |
|
| 76 | - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data |
|
| 77 | - * @param string $varName the name of the Smarty variable |
|
| 78 | - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object |
|
| 79 | - * @param bool $searchParents search also in parent data |
|
| 80 | - * @param bool $errorEnable |
|
| 81 | - * |
|
| 82 | - * @return \Smarty_Variable |
|
| 83 | - */ |
|
| 84 | - public function _getVariable(Smarty_Internal_Data $data, $varName, Smarty_Internal_Data $_ptr = null, |
|
| 85 | - $searchParents = true, $errorEnable = true) |
|
| 86 | - { |
|
| 87 | - if ($_ptr === null) { |
|
| 88 | - $_ptr = $data; |
|
| 89 | - } |
|
| 90 | - while ($_ptr !== null) { |
|
| 91 | - if (isset($_ptr->tpl_vars[ $varName ])) { |
|
| 92 | - // found it, return it |
|
| 93 | - return $_ptr->tpl_vars[ $varName ]; |
|
| 94 | - } |
|
| 95 | - // not found, try at parent |
|
| 96 | - if ($searchParents) { |
|
| 97 | - $_ptr = $_ptr->parent; |
|
| 98 | - } else { |
|
| 99 | - $_ptr = null; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - if (isset(Smarty::$global_tpl_vars[ $varName ])) { |
|
| 103 | - // found it, return it |
|
| 104 | - return Smarty::$global_tpl_vars[ $varName ]; |
|
| 105 | - } |
|
| 106 | - /* @var \Smarty $smarty */ |
|
| 107 | - $smarty = isset($data->smarty) ? $data->smarty : $data; |
|
| 108 | - if ($smarty->error_unassigned && $errorEnable) { |
|
| 109 | - // force a notice |
|
| 110 | - $x = $$varName; |
|
| 111 | - } |
|
| 73 | + /** |
|
| 74 | + * gets the object of a Smarty variable |
|
| 75 | + * |
|
| 76 | + * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data |
|
| 77 | + * @param string $varName the name of the Smarty variable |
|
| 78 | + * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object |
|
| 79 | + * @param bool $searchParents search also in parent data |
|
| 80 | + * @param bool $errorEnable |
|
| 81 | + * |
|
| 82 | + * @return \Smarty_Variable |
|
| 83 | + */ |
|
| 84 | + public function _getVariable(Smarty_Internal_Data $data, $varName, Smarty_Internal_Data $_ptr = null, |
|
| 85 | + $searchParents = true, $errorEnable = true) |
|
| 86 | + { |
|
| 87 | + if ($_ptr === null) { |
|
| 88 | + $_ptr = $data; |
|
| 89 | + } |
|
| 90 | + while ($_ptr !== null) { |
|
| 91 | + if (isset($_ptr->tpl_vars[ $varName ])) { |
|
| 92 | + // found it, return it |
|
| 93 | + return $_ptr->tpl_vars[ $varName ]; |
|
| 94 | + } |
|
| 95 | + // not found, try at parent |
|
| 96 | + if ($searchParents) { |
|
| 97 | + $_ptr = $_ptr->parent; |
|
| 98 | + } else { |
|
| 99 | + $_ptr = null; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + if (isset(Smarty::$global_tpl_vars[ $varName ])) { |
|
| 103 | + // found it, return it |
|
| 104 | + return Smarty::$global_tpl_vars[ $varName ]; |
|
| 105 | + } |
|
| 106 | + /* @var \Smarty $smarty */ |
|
| 107 | + $smarty = isset($data->smarty) ? $data->smarty : $data; |
|
| 108 | + if ($smarty->error_unassigned && $errorEnable) { |
|
| 109 | + // force a notice |
|
| 110 | + $x = $$varName; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - return new Smarty_Undefined_Variable; |
|
| 114 | - } |
|
| 113 | + return new Smarty_Undefined_Variable; |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | } |
| 117 | 117 | \ No newline at end of file |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | while ($_ptr !== null) { |
| 50 | 50 | foreach ($_ptr->tpl_vars AS $key => $var) { |
| 51 | 51 | if (!array_key_exists($key, $_result)) { |
| 52 | - $_result[ $key ] = $var->value; |
|
| 52 | + $_result[$key] = $var->value; |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | // not found, try at parent |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | if ($searchParents && isset(Smarty::$global_tpl_vars)) { |
| 63 | 63 | foreach (Smarty::$global_tpl_vars AS $key => $var) { |
| 64 | 64 | if (!array_key_exists($key, $_result)) { |
| 65 | - $_result[ $key ] = $var->value; |
|
| 65 | + $_result[$key] = $var->value; |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | $_ptr = $data; |
| 89 | 89 | } |
| 90 | 90 | while ($_ptr !== null) { |
| 91 | - if (isset($_ptr->tpl_vars[ $varName ])) { |
|
| 91 | + if (isset($_ptr->tpl_vars[$varName])) { |
|
| 92 | 92 | // found it, return it |
| 93 | - return $_ptr->tpl_vars[ $varName ]; |
|
| 93 | + return $_ptr->tpl_vars[$varName]; |
|
| 94 | 94 | } |
| 95 | 95 | // not found, try at parent |
| 96 | 96 | if ($searchParents) { |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | $_ptr = null; |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | - if (isset(Smarty::$global_tpl_vars[ $varName ])) { |
|
| 102 | + if (isset(Smarty::$global_tpl_vars[$varName])) { |
|
| 103 | 103 | // found it, return it |
| 104 | - return Smarty::$global_tpl_vars[ $varName ]; |
|
| 104 | + return Smarty::$global_tpl_vars[$varName]; |
|
| 105 | 105 | } |
| 106 | 106 | /* @var \Smarty $smarty */ |
| 107 | 107 | $smarty = isset($data->smarty) ? $data->smarty : $data; |
@@ -11,32 +11,32 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_RegisterDefaultConfigHandler |
| 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 config default handler |
|
| 23 | - * |
|
| 24 | - * @api Smarty::registerDefaultConfigHandler() |
|
| 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 registerDefaultConfigHandler(Smarty_Internal_TemplateBase $obj, $callback) |
|
| 33 | - { |
|
| 34 | - $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 35 | - if (is_callable($callback)) { |
|
| 36 | - $smarty->default_config_handler_func = $callback; |
|
| 37 | - } else { |
|
| 38 | - throw new SmartyException("Default config handler not callable"); |
|
| 39 | - } |
|
| 40 | - return $obj; |
|
| 41 | - } |
|
| 21 | + /** |
|
| 22 | + * Register config default handler |
|
| 23 | + * |
|
| 24 | + * @api Smarty::registerDefaultConfigHandler() |
|
| 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 registerDefaultConfigHandler(Smarty_Internal_TemplateBase $obj, $callback) |
|
| 33 | + { |
|
| 34 | + $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 35 | + if (is_callable($callback)) { |
|
| 36 | + $smarty->default_config_handler_func = $callback; |
|
| 37 | + } else { |
|
| 38 | + throw new SmartyException("Default config handler not callable"); |
|
| 39 | + } |
|
| 40 | + return $obj; |
|
| 41 | + } |
|
| 42 | 42 | } |
| 43 | 43 | \ No newline at end of file |
@@ -11,31 +11,31 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_SetDebugTemplate |
| 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 | - * set the debug template |
|
| 23 | - * |
|
| 24 | - * @api Smarty::setDebugTemplate() |
|
| 25 | - * |
|
| 26 | - * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 27 | - * @param string $tpl_name |
|
| 28 | - * |
|
| 29 | - * @return \Smarty|\Smarty_Internal_Template |
|
| 30 | - * @throws SmartyException if file is not readable |
|
| 31 | - */ |
|
| 32 | - public function setDebugTemplate(Smarty_Internal_TemplateBase $obj, $tpl_name) |
|
| 33 | - { |
|
| 34 | - $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 35 | - if (!is_readable($tpl_name)) { |
|
| 36 | - throw new SmartyException("Unknown file '{$tpl_name}'"); |
|
| 37 | - } |
|
| 38 | - $smarty->debug_tpl = $tpl_name; |
|
| 39 | - return $obj; |
|
| 40 | - } |
|
| 21 | + /** |
|
| 22 | + * set the debug template |
|
| 23 | + * |
|
| 24 | + * @api Smarty::setDebugTemplate() |
|
| 25 | + * |
|
| 26 | + * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 27 | + * @param string $tpl_name |
|
| 28 | + * |
|
| 29 | + * @return \Smarty|\Smarty_Internal_Template |
|
| 30 | + * @throws SmartyException if file is not readable |
|
| 31 | + */ |
|
| 32 | + public function setDebugTemplate(Smarty_Internal_TemplateBase $obj, $tpl_name) |
|
| 33 | + { |
|
| 34 | + $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 35 | + if (!is_readable($tpl_name)) { |
|
| 36 | + throw new SmartyException("Unknown file '{$tpl_name}'"); |
|
| 37 | + } |
|
| 38 | + $smarty->debug_tpl = $tpl_name; |
|
| 39 | + return $obj; |
|
| 40 | + } |
|
| 41 | 41 | } |
| 42 | 42 | \ No newline at end of file |
@@ -11,34 +11,34 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_RegisterResource |
| 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 | - * Registers a resource to fetch a template |
|
| 23 | - * |
|
| 24 | - * @api Smarty::registerResource() |
|
| 25 | - * @link http://www.smarty.net/docs/en/api.register.resource.tpl |
|
| 26 | - * |
|
| 27 | - * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 28 | - * @param string $name name of resource type |
|
| 29 | - * @param Smarty_Resource|array $resource_handler or instance of |
|
| 30 | - * Smarty_Resource, or |
|
| 31 | - * array of callbacks to |
|
| 32 | - * handle resource |
|
| 33 | - * (deprecated) |
|
| 34 | - * |
|
| 35 | - * @return \Smarty|\Smarty_Internal_Template |
|
| 36 | - */ |
|
| 37 | - public function registerResource(Smarty_Internal_TemplateBase $obj, $name, $resource_handler) |
|
| 38 | - { |
|
| 39 | - $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 40 | - $smarty->registered_resources[ $name ] = |
|
| 41 | - $resource_handler instanceof Smarty_Resource ? $resource_handler : array($resource_handler, false); |
|
| 42 | - return $obj; |
|
| 43 | - } |
|
| 21 | + /** |
|
| 22 | + * Registers a resource to fetch a template |
|
| 23 | + * |
|
| 24 | + * @api Smarty::registerResource() |
|
| 25 | + * @link http://www.smarty.net/docs/en/api.register.resource.tpl |
|
| 26 | + * |
|
| 27 | + * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 28 | + * @param string $name name of resource type |
|
| 29 | + * @param Smarty_Resource|array $resource_handler or instance of |
|
| 30 | + * Smarty_Resource, or |
|
| 31 | + * array of callbacks to |
|
| 32 | + * handle resource |
|
| 33 | + * (deprecated) |
|
| 34 | + * |
|
| 35 | + * @return \Smarty|\Smarty_Internal_Template |
|
| 36 | + */ |
|
| 37 | + public function registerResource(Smarty_Internal_TemplateBase $obj, $name, $resource_handler) |
|
| 38 | + { |
|
| 39 | + $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 40 | + $smarty->registered_resources[ $name ] = |
|
| 41 | + $resource_handler instanceof Smarty_Resource ? $resource_handler : array($resource_handler, false); |
|
| 42 | + return $obj; |
|
| 43 | + } |
|
| 44 | 44 | } |
| 45 | 45 | \ No newline at end of file |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | public function registerResource(Smarty_Internal_TemplateBase $obj, $name, $resource_handler) |
| 38 | 38 | { |
| 39 | 39 | $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
| 40 | - $smarty->registered_resources[ $name ] = |
|
| 40 | + $smarty->registered_resources[$name] = |
|
| 41 | 41 | $resource_handler instanceof Smarty_Resource ? $resource_handler : array($resource_handler, false); |
| 42 | 42 | return $obj; |
| 43 | 43 | } |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | } else { |
| 45 | 45 | $handler = Smarty_Resource::load($tpl->smarty, $_file_to_check[2]); |
| 46 | 46 | if ($handler->checkTimestamps()) { |
| 47 | - $source = Smarty_Template_Source::load($tpl, $tpl->smarty, $_file_to_check[ 0 ]); |
|
| 47 | + $source = Smarty_Template_Source::load($tpl, $tpl->smarty, $_file_to_check[0]); |
|
| 48 | 48 | $mtime = $source->getTimeStamp(); |
| 49 | 49 | } else { |
| 50 | 50 | continue; |
@@ -10,75 +10,75 @@ |
||
| 10 | 10 | **/ |
| 11 | 11 | class Smarty_Internal_Runtime_ValidateCompiled |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * This function is executed automatically when a compiled or cached template file is included |
|
| 15 | - * - Decode saved properties from compiled template and cache files |
|
| 16 | - * - Check if compiled or cache file is valid |
|
| 17 | - * |
|
| 18 | - * @param array $properties special template properties |
|
| 19 | - * @param bool $cache flag if called from cache file |
|
| 20 | - * |
|
| 21 | - * @return bool flag if compiled or cache file is valid |
|
| 22 | - */ |
|
| 23 | - public function decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false) |
|
| 24 | - { |
|
| 25 | - $is_valid = true; |
|
| 26 | - if (Smarty::SMARTY_VERSION != $properties['version']) { |
|
| 27 | - // new version must rebuild |
|
| 28 | - $is_valid = false; |
|
| 29 | - } elseif ($is_valid && !empty($properties['file_dependency']) && |
|
| 30 | - ((!$cache && $tpl->smarty->compile_check) || $tpl->smarty->compile_check == 1) |
|
| 31 | - ) { |
|
| 32 | - // check file dependencies at compiled code |
|
| 33 | - foreach ($properties['file_dependency'] as $_file_to_check) { |
|
| 34 | - if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'extends' || $_file_to_check[2] == 'php') { |
|
| 35 | - if ($tpl->source->filepath == $_file_to_check[0]) { |
|
| 36 | - // do not recheck current template |
|
| 37 | - continue; |
|
| 38 | - } else { |
|
| 39 | - // file and php types can be checked without loading the respective resource handlers |
|
| 40 | - $mtime = is_file($_file_to_check[0]) ? filemtime($_file_to_check[0]) : false; |
|
| 41 | - } |
|
| 42 | - } elseif ($_file_to_check[2] == 'string') { |
|
| 43 | - continue; |
|
| 44 | - } else { |
|
| 45 | - $handler = Smarty_Resource::load($tpl->smarty, $_file_to_check[2]); |
|
| 46 | - if ($handler->checkTimestamps()) { |
|
| 47 | - $source = Smarty_Template_Source::load($tpl, $tpl->smarty, $_file_to_check[ 0 ]); |
|
| 48 | - $mtime = $source->getTimeStamp(); |
|
| 49 | - } else { |
|
| 50 | - continue; |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - if (!$mtime || $mtime > $_file_to_check[1]) { |
|
| 54 | - $is_valid = false; |
|
| 55 | - break; |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - if ($cache) { |
|
| 60 | - // CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc |
|
| 61 | - if ($tpl->caching === Smarty::CACHING_LIFETIME_SAVED && $properties['cache_lifetime'] >= 0 && |
|
| 62 | - (time() > ($tpl->cached->timestamp + $properties['cache_lifetime'])) |
|
| 63 | - ) { |
|
| 64 | - $is_valid = false; |
|
| 65 | - } |
|
| 66 | - $tpl->cached->cache_lifetime = $properties['cache_lifetime']; |
|
| 67 | - $tpl->cached->valid = $is_valid; |
|
| 68 | - $resource = $tpl->cached; |
|
| 69 | - } else { |
|
| 70 | - $tpl->mustCompile = !$is_valid; |
|
| 71 | - $resource = $tpl->compiled; |
|
| 72 | - $resource->includes = isset($properties['includes']) ? $properties['includes'] : array(); |
|
| 73 | - } |
|
| 74 | - if ($is_valid) { |
|
| 75 | - $resource->unifunc = $properties['unifunc']; |
|
| 76 | - $resource->has_nocache_code = $properties['has_nocache_code']; |
|
| 77 | - $resource->file_dependency = $properties['file_dependency']; |
|
| 78 | - if (isset($properties['tpl_function'])) { |
|
| 79 | - $tpl->tpl_function = $properties['tpl_function']; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - return $is_valid && !function_exists($properties['unifunc']); |
|
| 83 | - } |
|
| 13 | + /** |
|
| 14 | + * This function is executed automatically when a compiled or cached template file is included |
|
| 15 | + * - Decode saved properties from compiled template and cache files |
|
| 16 | + * - Check if compiled or cache file is valid |
|
| 17 | + * |
|
| 18 | + * @param array $properties special template properties |
|
| 19 | + * @param bool $cache flag if called from cache file |
|
| 20 | + * |
|
| 21 | + * @return bool flag if compiled or cache file is valid |
|
| 22 | + */ |
|
| 23 | + public function decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false) |
|
| 24 | + { |
|
| 25 | + $is_valid = true; |
|
| 26 | + if (Smarty::SMARTY_VERSION != $properties['version']) { |
|
| 27 | + // new version must rebuild |
|
| 28 | + $is_valid = false; |
|
| 29 | + } elseif ($is_valid && !empty($properties['file_dependency']) && |
|
| 30 | + ((!$cache && $tpl->smarty->compile_check) || $tpl->smarty->compile_check == 1) |
|
| 31 | + ) { |
|
| 32 | + // check file dependencies at compiled code |
|
| 33 | + foreach ($properties['file_dependency'] as $_file_to_check) { |
|
| 34 | + if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'extends' || $_file_to_check[2] == 'php') { |
|
| 35 | + if ($tpl->source->filepath == $_file_to_check[0]) { |
|
| 36 | + // do not recheck current template |
|
| 37 | + continue; |
|
| 38 | + } else { |
|
| 39 | + // file and php types can be checked without loading the respective resource handlers |
|
| 40 | + $mtime = is_file($_file_to_check[0]) ? filemtime($_file_to_check[0]) : false; |
|
| 41 | + } |
|
| 42 | + } elseif ($_file_to_check[2] == 'string') { |
|
| 43 | + continue; |
|
| 44 | + } else { |
|
| 45 | + $handler = Smarty_Resource::load($tpl->smarty, $_file_to_check[2]); |
|
| 46 | + if ($handler->checkTimestamps()) { |
|
| 47 | + $source = Smarty_Template_Source::load($tpl, $tpl->smarty, $_file_to_check[ 0 ]); |
|
| 48 | + $mtime = $source->getTimeStamp(); |
|
| 49 | + } else { |
|
| 50 | + continue; |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + if (!$mtime || $mtime > $_file_to_check[1]) { |
|
| 54 | + $is_valid = false; |
|
| 55 | + break; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + if ($cache) { |
|
| 60 | + // CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc |
|
| 61 | + if ($tpl->caching === Smarty::CACHING_LIFETIME_SAVED && $properties['cache_lifetime'] >= 0 && |
|
| 62 | + (time() > ($tpl->cached->timestamp + $properties['cache_lifetime'])) |
|
| 63 | + ) { |
|
| 64 | + $is_valid = false; |
|
| 65 | + } |
|
| 66 | + $tpl->cached->cache_lifetime = $properties['cache_lifetime']; |
|
| 67 | + $tpl->cached->valid = $is_valid; |
|
| 68 | + $resource = $tpl->cached; |
|
| 69 | + } else { |
|
| 70 | + $tpl->mustCompile = !$is_valid; |
|
| 71 | + $resource = $tpl->compiled; |
|
| 72 | + $resource->includes = isset($properties['includes']) ? $properties['includes'] : array(); |
|
| 73 | + } |
|
| 74 | + if ($is_valid) { |
|
| 75 | + $resource->unifunc = $properties['unifunc']; |
|
| 76 | + $resource->has_nocache_code = $properties['has_nocache_code']; |
|
| 77 | + $resource->file_dependency = $properties['file_dependency']; |
|
| 78 | + if (isset($properties['tpl_function'])) { |
|
| 79 | + $tpl->tpl_function = $properties['tpl_function']; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + return $is_valid && !function_exists($properties['unifunc']); |
|
| 83 | + } |
|
| 84 | 84 | } |
@@ -11,62 +11,62 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_RegisterObject |
| 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 | - * Registers object to be used in templates |
|
| 23 | - * |
|
| 24 | - * @api Smarty::registerObject() |
|
| 25 | - * @link http://www.smarty.net/docs/en/api.register.object.tpl |
|
| 26 | - * |
|
| 27 | - * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 28 | - * @param string $object_name |
|
| 29 | - * @param object $object the |
|
| 30 | - * referenced |
|
| 31 | - * PHP object to |
|
| 32 | - * register |
|
| 33 | - * @param array $allowed_methods_properties list of |
|
| 34 | - * allowed |
|
| 35 | - * methods |
|
| 36 | - * (empty = all) |
|
| 37 | - * @param bool $format smarty |
|
| 38 | - * argument |
|
| 39 | - * format, else |
|
| 40 | - * traditional |
|
| 41 | - * @param array $block_methods list of |
|
| 42 | - * block-methods |
|
| 43 | - * |
|
| 44 | - * @return \Smarty|\Smarty_Internal_Template |
|
| 45 | - * @throws \SmartyException |
|
| 46 | - */ |
|
| 47 | - public function registerObject(Smarty_Internal_TemplateBase $obj, $object_name, $object, |
|
| 48 | - $allowed_methods_properties = array(), $format = true, $block_methods = array()) |
|
| 49 | - { |
|
| 50 | - $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 51 | - // test if allowed methods callable |
|
| 52 | - if (!empty($allowed_methods_properties)) { |
|
| 53 | - foreach ((array) $allowed_methods_properties as $method) { |
|
| 54 | - if (!is_callable(array($object, $method)) && !property_exists($object, $method)) { |
|
| 55 | - throw new SmartyException("Undefined method or property '$method' in registered object"); |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - // test if block methods callable |
|
| 60 | - if (!empty($block_methods)) { |
|
| 61 | - foreach ((array) $block_methods as $method) { |
|
| 62 | - if (!is_callable(array($object, $method))) { |
|
| 63 | - throw new SmartyException("Undefined method '$method' in registered object"); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - // register the object |
|
| 68 | - $smarty->registered_objects[ $object_name ] = |
|
| 69 | - array($object, (array) $allowed_methods_properties, (boolean) $format, (array) $block_methods); |
|
| 70 | - return $obj; |
|
| 71 | - } |
|
| 21 | + /** |
|
| 22 | + * Registers object to be used in templates |
|
| 23 | + * |
|
| 24 | + * @api Smarty::registerObject() |
|
| 25 | + * @link http://www.smarty.net/docs/en/api.register.object.tpl |
|
| 26 | + * |
|
| 27 | + * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 28 | + * @param string $object_name |
|
| 29 | + * @param object $object the |
|
| 30 | + * referenced |
|
| 31 | + * PHP object to |
|
| 32 | + * register |
|
| 33 | + * @param array $allowed_methods_properties list of |
|
| 34 | + * allowed |
|
| 35 | + * methods |
|
| 36 | + * (empty = all) |
|
| 37 | + * @param bool $format smarty |
|
| 38 | + * argument |
|
| 39 | + * format, else |
|
| 40 | + * traditional |
|
| 41 | + * @param array $block_methods list of |
|
| 42 | + * block-methods |
|
| 43 | + * |
|
| 44 | + * @return \Smarty|\Smarty_Internal_Template |
|
| 45 | + * @throws \SmartyException |
|
| 46 | + */ |
|
| 47 | + public function registerObject(Smarty_Internal_TemplateBase $obj, $object_name, $object, |
|
| 48 | + $allowed_methods_properties = array(), $format = true, $block_methods = array()) |
|
| 49 | + { |
|
| 50 | + $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 51 | + // test if allowed methods callable |
|
| 52 | + if (!empty($allowed_methods_properties)) { |
|
| 53 | + foreach ((array) $allowed_methods_properties as $method) { |
|
| 54 | + if (!is_callable(array($object, $method)) && !property_exists($object, $method)) { |
|
| 55 | + throw new SmartyException("Undefined method or property '$method' in registered object"); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + // test if block methods callable |
|
| 60 | + if (!empty($block_methods)) { |
|
| 61 | + foreach ((array) $block_methods as $method) { |
|
| 62 | + if (!is_callable(array($object, $method))) { |
|
| 63 | + throw new SmartyException("Undefined method '$method' in registered object"); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + // register the object |
|
| 68 | + $smarty->registered_objects[ $object_name ] = |
|
| 69 | + array($object, (array) $allowed_methods_properties, (boolean) $format, (array) $block_methods); |
|
| 70 | + return $obj; |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | \ No newline at end of file |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | // register the object |
| 68 | - $smarty->registered_objects[ $object_name ] = |
|
| 68 | + $smarty->registered_objects[$object_name] = |
|
| 69 | 69 | array($object, (array) $allowed_methods_properties, (boolean) $format, (array) $block_methods); |
| 70 | 70 | return $obj; |
| 71 | 71 | } |
@@ -10,24 +10,24 @@ |
||
| 10 | 10 | **/ |
| 11 | 11 | class Smarty_Internal_Runtime_Var |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * Template code runtime function to create a local Smarty variable for array assignments |
|
| 15 | - * |
|
| 16 | - * @param \Smarty_Internal_Template $tpl template object |
|
| 17 | - * @param string $varName template variable name |
|
| 18 | - * @param bool $nocache cache mode of variable |
|
| 19 | - */ |
|
| 20 | - public function createLocalArrayVariable(Smarty_Internal_Template $tpl, $varName, $nocache = false) |
|
| 21 | - { |
|
| 22 | - if (!isset($tpl->tpl_vars[$varName])) { |
|
| 23 | - $tpl->tpl_vars[$varName] = new Smarty_Variable(array(), $nocache); |
|
| 24 | - } else { |
|
| 25 | - $tpl->tpl_vars[$varName] = clone $tpl->tpl_vars[$varName]; |
|
| 26 | - if (!(is_array($tpl->tpl_vars[$varName]->value) || |
|
| 27 | - $tpl->tpl_vars[$varName]->value instanceof ArrayAccess) |
|
| 28 | - ) { |
|
| 29 | - settype($tpl->tpl_vars[$varName]->value, 'array'); |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - } |
|
| 13 | + /** |
|
| 14 | + * Template code runtime function to create a local Smarty variable for array assignments |
|
| 15 | + * |
|
| 16 | + * @param \Smarty_Internal_Template $tpl template object |
|
| 17 | + * @param string $varName template variable name |
|
| 18 | + * @param bool $nocache cache mode of variable |
|
| 19 | + */ |
|
| 20 | + public function createLocalArrayVariable(Smarty_Internal_Template $tpl, $varName, $nocache = false) |
|
| 21 | + { |
|
| 22 | + if (!isset($tpl->tpl_vars[$varName])) { |
|
| 23 | + $tpl->tpl_vars[$varName] = new Smarty_Variable(array(), $nocache); |
|
| 24 | + } else { |
|
| 25 | + $tpl->tpl_vars[$varName] = clone $tpl->tpl_vars[$varName]; |
|
| 26 | + if (!(is_array($tpl->tpl_vars[$varName]->value) || |
|
| 27 | + $tpl->tpl_vars[$varName]->value instanceof ArrayAccess) |
|
| 28 | + ) { |
|
| 29 | + settype($tpl->tpl_vars[$varName]->value, 'array'); |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -16,27 +16,27 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Internal_Compile_Private_Block_Plugin |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Setup callback and parameter array |
|
| 21 | - * |
|
| 22 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 23 | - * @param array $_attr attributes |
|
| 24 | - * @param string $tag |
|
| 25 | - * @param string $method |
|
| 26 | - * |
|
| 27 | - * @return array |
|
| 28 | - */ |
|
| 29 | - public function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $method) |
|
| 30 | - { |
|
| 31 | - $_paramsArray = array(); |
|
| 32 | - foreach ($_attr as $_key => $_value) { |
|
| 33 | - if (is_int($_key)) { |
|
| 34 | - $_paramsArray[] = "$_key=>$_value"; |
|
| 35 | - } else { |
|
| 36 | - $_paramsArray[] = "'$_key'=>$_value"; |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - $callback = array("\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]", "->{$method}"); |
|
| 40 | - return array($callback, $_paramsArray, "array(\$_block_plugin{$this->nesting}, '{$method}')"); |
|
| 41 | - } |
|
| 19 | + /** |
|
| 20 | + * Setup callback and parameter array |
|
| 21 | + * |
|
| 22 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 23 | + * @param array $_attr attributes |
|
| 24 | + * @param string $tag |
|
| 25 | + * @param string $method |
|
| 26 | + * |
|
| 27 | + * @return array |
|
| 28 | + */ |
|
| 29 | + public function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $method) |
|
| 30 | + { |
|
| 31 | + $_paramsArray = array(); |
|
| 32 | + foreach ($_attr as $_key => $_value) { |
|
| 33 | + if (is_int($_key)) { |
|
| 34 | + $_paramsArray[] = "$_key=>$_value"; |
|
| 35 | + } else { |
|
| 36 | + $_paramsArray[] = "'$_key'=>$_value"; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + $callback = array("\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]", "->{$method}"); |
|
| 40 | + return array($callback, $_paramsArray, "array(\$_block_plugin{$this->nesting}, '{$method}')"); |
|
| 41 | + } |
|
| 42 | 42 | } |