@@ -11,30 +11,30 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_RegisterCacheResource |
| 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::registerCacheResource() |
|
| 25 | - * @link http://www.smarty.net/docs/en/api.register.cacheresource.tpl |
|
| 26 | - * |
|
| 27 | - * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 28 | - * @param string $name name of resource type |
|
| 29 | - * @param \Smarty_CacheResource $resource_handler |
|
| 30 | - * |
|
| 31 | - * @return \Smarty|\Smarty_Internal_Template |
|
| 32 | - */ |
|
| 33 | - public function registerCacheResource(Smarty_Internal_TemplateBase $obj, $name, |
|
| 34 | - Smarty_CacheResource $resource_handler) |
|
| 35 | - { |
|
| 36 | - $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 37 | - $smarty->registered_cache_resources[ $name ] = $resource_handler; |
|
| 38 | - return $obj; |
|
| 39 | - } |
|
| 21 | + /** |
|
| 22 | + * Registers a resource to fetch a template |
|
| 23 | + * |
|
| 24 | + * @api Smarty::registerCacheResource() |
|
| 25 | + * @link http://www.smarty.net/docs/en/api.register.cacheresource.tpl |
|
| 26 | + * |
|
| 27 | + * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 28 | + * @param string $name name of resource type |
|
| 29 | + * @param \Smarty_CacheResource $resource_handler |
|
| 30 | + * |
|
| 31 | + * @return \Smarty|\Smarty_Internal_Template |
|
| 32 | + */ |
|
| 33 | + public function registerCacheResource(Smarty_Internal_TemplateBase $obj, $name, |
|
| 34 | + Smarty_CacheResource $resource_handler) |
|
| 35 | + { |
|
| 36 | + $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 37 | + $smarty->registered_cache_resources[ $name ] = $resource_handler; |
|
| 38 | + return $obj; |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | \ No newline at end of file |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | Smarty_CacheResource $resource_handler) |
| 35 | 35 | { |
| 36 | 36 | $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
| 37 | - $smarty->registered_cache_resources[ $name ] = $resource_handler; |
|
| 37 | + $smarty->registered_cache_resources[$name] = $resource_handler; |
|
| 38 | 38 | return $obj; |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | \ No newline at end of file |
@@ -11,25 +11,25 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_GetDebugTemplate |
| 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 | - * return name of debugging template |
|
| 23 | - * |
|
| 24 | - * @api Smarty::getDebugTemplate() |
|
| 25 | - * |
|
| 26 | - * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 27 | - * |
|
| 28 | - * @return string |
|
| 29 | - */ |
|
| 30 | - public function getDebugTemplate(Smarty_Internal_TemplateBase $obj) |
|
| 31 | - { |
|
| 32 | - $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 33 | - return $smarty->debug_tpl; |
|
| 34 | - } |
|
| 21 | + /** |
|
| 22 | + * return name of debugging template |
|
| 23 | + * |
|
| 24 | + * @api Smarty::getDebugTemplate() |
|
| 25 | + * |
|
| 26 | + * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 27 | + * |
|
| 28 | + * @return string |
|
| 29 | + */ |
|
| 30 | + public function getDebugTemplate(Smarty_Internal_TemplateBase $obj) |
|
| 31 | + { |
|
| 32 | + $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 33 | + return $smarty->debug_tpl; |
|
| 34 | + } |
|
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -9,153 +9,153 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class Smarty_Internal_Runtime_Capture |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * Flag that this instance will not be cached |
|
| 14 | - * |
|
| 15 | - * @var bool |
|
| 16 | - */ |
|
| 17 | - public $isPrivateExtension = true; |
|
| 12 | + /** |
|
| 13 | + * Flag that this instance will not be cached |
|
| 14 | + * |
|
| 15 | + * @var bool |
|
| 16 | + */ |
|
| 17 | + public $isPrivateExtension = true; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Stack of capture parameter |
|
| 21 | - * |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 24 | - private $captureStack = array(); |
|
| 19 | + /** |
|
| 20 | + * Stack of capture parameter |
|
| 21 | + * |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | + private $captureStack = array(); |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Current open capture sections |
|
| 28 | - * |
|
| 29 | - * @var int |
|
| 30 | - */ |
|
| 31 | - private $captureCount = 0; |
|
| 26 | + /** |
|
| 27 | + * Current open capture sections |
|
| 28 | + * |
|
| 29 | + * @var int |
|
| 30 | + */ |
|
| 31 | + private $captureCount = 0; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Count stack |
|
| 35 | - * |
|
| 36 | - * @var int[] |
|
| 37 | - */ |
|
| 38 | - private $countStack = array(); |
|
| 33 | + /** |
|
| 34 | + * Count stack |
|
| 35 | + * |
|
| 36 | + * @var int[] |
|
| 37 | + */ |
|
| 38 | + private $countStack = array(); |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Named buffer |
|
| 42 | - * |
|
| 43 | - * @var string[] |
|
| 44 | - */ |
|
| 45 | - private $namedBuffer = array(); |
|
| 40 | + /** |
|
| 41 | + * Named buffer |
|
| 42 | + * |
|
| 43 | + * @var string[] |
|
| 44 | + */ |
|
| 45 | + private $namedBuffer = array(); |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Flag if callbacks are registered |
|
| 49 | - * |
|
| 50 | - * @var bool |
|
| 51 | - */ |
|
| 52 | - private $isRegistered = false; |
|
| 47 | + /** |
|
| 48 | + * Flag if callbacks are registered |
|
| 49 | + * |
|
| 50 | + * @var bool |
|
| 51 | + */ |
|
| 52 | + private $isRegistered = false; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Open capture section |
|
| 56 | - * |
|
| 57 | - * @param \Smarty_Internal_Template $_template |
|
| 58 | - * @param string $buffer capture name |
|
| 59 | - * @param string $assign variable name |
|
| 60 | - * @param string $append variable name |
|
| 61 | - */ |
|
| 62 | - public function open(Smarty_Internal_Template $_template, $buffer, $assign, $append) |
|
| 63 | - { |
|
| 64 | - if (!$this->isRegistered) { |
|
| 65 | - $this->register($_template); |
|
| 66 | - } |
|
| 67 | - $this->captureStack[] = array($buffer, $assign, $append); |
|
| 68 | - $this->captureCount ++; |
|
| 69 | - ob_start(); |
|
| 70 | - } |
|
| 54 | + /** |
|
| 55 | + * Open capture section |
|
| 56 | + * |
|
| 57 | + * @param \Smarty_Internal_Template $_template |
|
| 58 | + * @param string $buffer capture name |
|
| 59 | + * @param string $assign variable name |
|
| 60 | + * @param string $append variable name |
|
| 61 | + */ |
|
| 62 | + public function open(Smarty_Internal_Template $_template, $buffer, $assign, $append) |
|
| 63 | + { |
|
| 64 | + if (!$this->isRegistered) { |
|
| 65 | + $this->register($_template); |
|
| 66 | + } |
|
| 67 | + $this->captureStack[] = array($buffer, $assign, $append); |
|
| 68 | + $this->captureCount ++; |
|
| 69 | + ob_start(); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Register callbacks in template class |
|
| 74 | - * |
|
| 75 | - * @param \Smarty_Internal_Template $_template |
|
| 76 | - */ |
|
| 77 | - private function register(Smarty_Internal_Template $_template) |
|
| 78 | - { |
|
| 79 | - $_template->startRenderCallbacks[] = array($this, 'startRender'); |
|
| 80 | - $_template->endRenderCallbacks[] = array($this, 'endRender'); |
|
| 81 | - $this->startRender($_template); |
|
| 82 | - $this->isRegistered = true; |
|
| 83 | - } |
|
| 72 | + /** |
|
| 73 | + * Register callbacks in template class |
|
| 74 | + * |
|
| 75 | + * @param \Smarty_Internal_Template $_template |
|
| 76 | + */ |
|
| 77 | + private function register(Smarty_Internal_Template $_template) |
|
| 78 | + { |
|
| 79 | + $_template->startRenderCallbacks[] = array($this, 'startRender'); |
|
| 80 | + $_template->endRenderCallbacks[] = array($this, 'endRender'); |
|
| 81 | + $this->startRender($_template); |
|
| 82 | + $this->isRegistered = true; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Start render callback |
|
| 87 | - * |
|
| 88 | - * @param \Smarty_Internal_Template $_template |
|
| 89 | - */ |
|
| 90 | - public function startRender(Smarty_Internal_Template $_template) |
|
| 91 | - { |
|
| 92 | - $this->countStack[] = $this->captureCount; |
|
| 93 | - $this->captureCount = 0; |
|
| 94 | - } |
|
| 85 | + /** |
|
| 86 | + * Start render callback |
|
| 87 | + * |
|
| 88 | + * @param \Smarty_Internal_Template $_template |
|
| 89 | + */ |
|
| 90 | + public function startRender(Smarty_Internal_Template $_template) |
|
| 91 | + { |
|
| 92 | + $this->countStack[] = $this->captureCount; |
|
| 93 | + $this->captureCount = 0; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Close capture section |
|
| 98 | - * |
|
| 99 | - * @param \Smarty_Internal_Template $_template |
|
| 100 | - * |
|
| 101 | - * @throws \SmartyException |
|
| 102 | - */ |
|
| 103 | - public function close(Smarty_Internal_Template $_template) |
|
| 104 | - { |
|
| 105 | - if ($this->captureCount) { |
|
| 106 | - list($buffer, $assign, $append) = array_pop($this->captureStack); |
|
| 107 | - $this->captureCount --; |
|
| 108 | - if (isset($assign)) { |
|
| 109 | - $_template->assign($assign, ob_get_contents()); |
|
| 110 | - } |
|
| 111 | - if (isset($append)) { |
|
| 112 | - $_template->append($append, ob_get_contents()); |
|
| 113 | - } |
|
| 114 | - $this->namedBuffer[ $buffer ] = ob_get_clean(); |
|
| 115 | - } else { |
|
| 116 | - $this->error($_template); |
|
| 117 | - } |
|
| 118 | - } |
|
| 96 | + /** |
|
| 97 | + * Close capture section |
|
| 98 | + * |
|
| 99 | + * @param \Smarty_Internal_Template $_template |
|
| 100 | + * |
|
| 101 | + * @throws \SmartyException |
|
| 102 | + */ |
|
| 103 | + public function close(Smarty_Internal_Template $_template) |
|
| 104 | + { |
|
| 105 | + if ($this->captureCount) { |
|
| 106 | + list($buffer, $assign, $append) = array_pop($this->captureStack); |
|
| 107 | + $this->captureCount --; |
|
| 108 | + if (isset($assign)) { |
|
| 109 | + $_template->assign($assign, ob_get_contents()); |
|
| 110 | + } |
|
| 111 | + if (isset($append)) { |
|
| 112 | + $_template->append($append, ob_get_contents()); |
|
| 113 | + } |
|
| 114 | + $this->namedBuffer[ $buffer ] = ob_get_clean(); |
|
| 115 | + } else { |
|
| 116 | + $this->error($_template); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Error exception on not matching {capture}{/capture} |
|
| 122 | - * |
|
| 123 | - * @param \Smarty_Internal_Template $_template |
|
| 124 | - * |
|
| 125 | - * @throws \SmartyException |
|
| 126 | - */ |
|
| 127 | - public function error(Smarty_Internal_Template $_template) |
|
| 128 | - { |
|
| 129 | - throw new SmartyException("Not matching {capture}{/capture} in \"{$_template->template_resource}\""); |
|
| 130 | - } |
|
| 120 | + /** |
|
| 121 | + * Error exception on not matching {capture}{/capture} |
|
| 122 | + * |
|
| 123 | + * @param \Smarty_Internal_Template $_template |
|
| 124 | + * |
|
| 125 | + * @throws \SmartyException |
|
| 126 | + */ |
|
| 127 | + public function error(Smarty_Internal_Template $_template) |
|
| 128 | + { |
|
| 129 | + throw new SmartyException("Not matching {capture}{/capture} in \"{$_template->template_resource}\""); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Return content of named capture buffer |
|
| 134 | - * |
|
| 135 | - * @param \Smarty_Internal_Template $_template |
|
| 136 | - * @param $name |
|
| 137 | - * |
|
| 138 | - * @return null |
|
| 139 | - */ |
|
| 140 | - public function getBuffer(Smarty_Internal_Template $_template, $name) |
|
| 141 | - { |
|
| 142 | - return isset($this->namedBuffer[ $name ]) ? $this->namedBuffer[ $name ] : null; |
|
| 143 | - } |
|
| 132 | + /** |
|
| 133 | + * Return content of named capture buffer |
|
| 134 | + * |
|
| 135 | + * @param \Smarty_Internal_Template $_template |
|
| 136 | + * @param $name |
|
| 137 | + * |
|
| 138 | + * @return null |
|
| 139 | + */ |
|
| 140 | + public function getBuffer(Smarty_Internal_Template $_template, $name) |
|
| 141 | + { |
|
| 142 | + return isset($this->namedBuffer[ $name ]) ? $this->namedBuffer[ $name ] : null; |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * End render callback |
|
| 147 | - * |
|
| 148 | - * @param \Smarty_Internal_Template $_template |
|
| 149 | - * |
|
| 150 | - * @throws \SmartyException |
|
| 151 | - */ |
|
| 152 | - public function endRender(Smarty_Internal_Template $_template) |
|
| 153 | - { |
|
| 154 | - if ($this->captureCount) { |
|
| 155 | - $this->error($_template); |
|
| 156 | - } else { |
|
| 157 | - $this->captureCount = array_pop($this->countStack); |
|
| 158 | - } |
|
| 159 | - } |
|
| 145 | + /** |
|
| 146 | + * End render callback |
|
| 147 | + * |
|
| 148 | + * @param \Smarty_Internal_Template $_template |
|
| 149 | + * |
|
| 150 | + * @throws \SmartyException |
|
| 151 | + */ |
|
| 152 | + public function endRender(Smarty_Internal_Template $_template) |
|
| 153 | + { |
|
| 154 | + if ($this->captureCount) { |
|
| 155 | + $this->error($_template); |
|
| 156 | + } else { |
|
| 157 | + $this->captureCount = array_pop($this->countStack); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | 161 | } |
| 162 | 162 | \ No newline at end of file |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $this->register($_template); |
| 66 | 66 | } |
| 67 | 67 | $this->captureStack[] = array($buffer, $assign, $append); |
| 68 | - $this->captureCount ++; |
|
| 68 | + $this->captureCount++; |
|
| 69 | 69 | ob_start(); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | { |
| 105 | 105 | if ($this->captureCount) { |
| 106 | 106 | list($buffer, $assign, $append) = array_pop($this->captureStack); |
| 107 | - $this->captureCount --; |
|
| 107 | + $this->captureCount--; |
|
| 108 | 108 | if (isset($assign)) { |
| 109 | 109 | $_template->assign($assign, ob_get_contents()); |
| 110 | 110 | } |
| 111 | 111 | if (isset($append)) { |
| 112 | 112 | $_template->append($append, ob_get_contents()); |
| 113 | 113 | } |
| 114 | - $this->namedBuffer[ $buffer ] = ob_get_clean(); |
|
| 114 | + $this->namedBuffer[$buffer] = ob_get_clean(); |
|
| 115 | 115 | } else { |
| 116 | 116 | $this->error($_template); |
| 117 | 117 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function getBuffer(Smarty_Internal_Template $_template, $name) |
| 141 | 141 | { |
| 142 | - return isset($this->namedBuffer[ $name ]) ? $this->namedBuffer[ $name ] : null; |
|
| 142 | + return isset($this->namedBuffer[$name]) ? $this->namedBuffer[$name] : null; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -11,34 +11,34 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_ClearCache |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Valid for Smarty object |
|
| 16 | - * |
|
| 17 | - * @var int |
|
| 18 | - */ |
|
| 19 | - public $objMap = 1; |
|
| 14 | + /** |
|
| 15 | + * Valid for Smarty object |
|
| 16 | + * |
|
| 17 | + * @var int |
|
| 18 | + */ |
|
| 19 | + public $objMap = 1; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Empty cache for a specific template |
|
| 23 | - * |
|
| 24 | - * @api Smarty::clearCache() |
|
| 25 | - * @link http://www.smarty.net/docs/en/api.clear.cache.tpl |
|
| 26 | - * |
|
| 27 | - * @param \Smarty $smarty |
|
| 28 | - * @param string $template_name template name |
|
| 29 | - * @param string $cache_id cache id |
|
| 30 | - * @param string $compile_id compile id |
|
| 31 | - * @param integer $exp_time expiration time |
|
| 32 | - * @param string $type resource type |
|
| 33 | - * |
|
| 34 | - * @return integer number of cache files deleted |
|
| 35 | - */ |
|
| 36 | - public function clearCache(Smarty $smarty, $template_name, $cache_id = null, $compile_id = null, $exp_time = null, |
|
| 37 | - $type = null) |
|
| 38 | - { |
|
| 39 | - $smarty->_clearTemplateCache(); |
|
| 40 | - // load cache resource and call clear |
|
| 41 | - $_cache_resource = Smarty_CacheResource::load($smarty, $type); |
|
| 42 | - return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time); |
|
| 43 | - } |
|
| 21 | + /** |
|
| 22 | + * Empty cache for a specific template |
|
| 23 | + * |
|
| 24 | + * @api Smarty::clearCache() |
|
| 25 | + * @link http://www.smarty.net/docs/en/api.clear.cache.tpl |
|
| 26 | + * |
|
| 27 | + * @param \Smarty $smarty |
|
| 28 | + * @param string $template_name template name |
|
| 29 | + * @param string $cache_id cache id |
|
| 30 | + * @param string $compile_id compile id |
|
| 31 | + * @param integer $exp_time expiration time |
|
| 32 | + * @param string $type resource type |
|
| 33 | + * |
|
| 34 | + * @return integer number of cache files deleted |
|
| 35 | + */ |
|
| 36 | + public function clearCache(Smarty $smarty, $template_name, $cache_id = null, $compile_id = null, $exp_time = null, |
|
| 37 | + $type = null) |
|
| 38 | + { |
|
| 39 | + $smarty->_clearTemplateCache(); |
|
| 40 | + // load cache resource and call clear |
|
| 41 | + $_cache_resource = Smarty_CacheResource::load($smarty, $type); |
|
| 42 | + return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time); |
|
| 43 | + } |
|
| 44 | 44 | } |
| 45 | 45 | \ No newline at end of file |
@@ -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 | } |
@@ -16,155 +16,155 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCompilerBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Lexer class name |
|
| 21 | - * |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - public $lexer_class; |
|
| 19 | + /** |
|
| 20 | + * Lexer class name |
|
| 21 | + * |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + public $lexer_class; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Parser class name |
|
| 28 | - * |
|
| 29 | - * @var string |
|
| 30 | - */ |
|
| 31 | - public $parser_class; |
|
| 26 | + /** |
|
| 27 | + * Parser class name |
|
| 28 | + * |
|
| 29 | + * @var string |
|
| 30 | + */ |
|
| 31 | + public $parser_class; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * array of vars which can be compiled in local scope |
|
| 35 | - * |
|
| 36 | - * @var array |
|
| 37 | - */ |
|
| 38 | - public $local_var = array(); |
|
| 33 | + /** |
|
| 34 | + * array of vars which can be compiled in local scope |
|
| 35 | + * |
|
| 36 | + * @var array |
|
| 37 | + */ |
|
| 38 | + public $local_var = array(); |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * array of callbacks called when the normal compile process of template is finished |
|
| 42 | - * |
|
| 43 | - * @var array |
|
| 44 | - */ |
|
| 45 | - public $postCompileCallbacks = array(); |
|
| 40 | + /** |
|
| 41 | + * array of callbacks called when the normal compile process of template is finished |
|
| 42 | + * |
|
| 43 | + * @var array |
|
| 44 | + */ |
|
| 45 | + public $postCompileCallbacks = array(); |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * prefix code |
|
| 49 | - * |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - public $prefixCompiledCode = ''; |
|
| 47 | + /** |
|
| 48 | + * prefix code |
|
| 49 | + * |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + public $prefixCompiledCode = ''; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * postfix code |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - public $postfixCompiledCode = ''; |
|
| 54 | + /** |
|
| 55 | + * postfix code |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + public $postfixCompiledCode = ''; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Initialize compiler |
|
| 63 | - * |
|
| 64 | - * @param string $lexer_class class name |
|
| 65 | - * @param string $parser_class class name |
|
| 66 | - * @param Smarty $smarty global instance |
|
| 67 | - */ |
|
| 68 | - public function __construct($lexer_class, $parser_class, Smarty $smarty) |
|
| 69 | - { |
|
| 70 | - parent::__construct($smarty); |
|
| 71 | - // get required plugins |
|
| 72 | - $this->lexer_class = $lexer_class; |
|
| 73 | - $this->parser_class = $parser_class; |
|
| 74 | - } |
|
| 61 | + /** |
|
| 62 | + * Initialize compiler |
|
| 63 | + * |
|
| 64 | + * @param string $lexer_class class name |
|
| 65 | + * @param string $parser_class class name |
|
| 66 | + * @param Smarty $smarty global instance |
|
| 67 | + */ |
|
| 68 | + public function __construct($lexer_class, $parser_class, Smarty $smarty) |
|
| 69 | + { |
|
| 70 | + parent::__construct($smarty); |
|
| 71 | + // get required plugins |
|
| 72 | + $this->lexer_class = $lexer_class; |
|
| 73 | + $this->parser_class = $parser_class; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * method to compile a Smarty template |
|
| 78 | - * |
|
| 79 | - * @param mixed $_content template source |
|
| 80 | - * @param bool $isTemplateSource |
|
| 81 | - * |
|
| 82 | - * @return bool true if compiling succeeded, false if it failed |
|
| 83 | - * @throws \SmartyCompilerException |
|
| 84 | - */ |
|
| 85 | - protected function doCompile($_content, $isTemplateSource = false) |
|
| 86 | - { |
|
| 87 | - /* here is where the compiling takes place. Smarty |
|
| 76 | + /** |
|
| 77 | + * method to compile a Smarty template |
|
| 78 | + * |
|
| 79 | + * @param mixed $_content template source |
|
| 80 | + * @param bool $isTemplateSource |
|
| 81 | + * |
|
| 82 | + * @return bool true if compiling succeeded, false if it failed |
|
| 83 | + * @throws \SmartyCompilerException |
|
| 84 | + */ |
|
| 85 | + protected function doCompile($_content, $isTemplateSource = false) |
|
| 86 | + { |
|
| 87 | + /* here is where the compiling takes place. Smarty |
|
| 88 | 88 | tags in the templates are replaces with PHP code, |
| 89 | 89 | then written to compiled files. */ |
| 90 | - // init the lexer/parser to compile the template |
|
| 91 | - $this->parser = |
|
| 92 | - new $this->parser_class(new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $_content), $this), |
|
| 93 | - $this); |
|
| 94 | - if ($isTemplateSource && $this->template->caching) { |
|
| 95 | - $this->parser->insertPhpCode("<?php\n\$_smarty_tpl->compiled->nocache_hash = '{$this->nocache_hash}';\n?>\n"); |
|
| 96 | - } |
|
| 97 | - if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { |
|
| 98 | - $mbEncoding = mb_internal_encoding(); |
|
| 99 | - mb_internal_encoding('ASCII'); |
|
| 100 | - } else { |
|
| 101 | - $mbEncoding = null; |
|
| 102 | - } |
|
| 90 | + // init the lexer/parser to compile the template |
|
| 91 | + $this->parser = |
|
| 92 | + new $this->parser_class(new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $_content), $this), |
|
| 93 | + $this); |
|
| 94 | + if ($isTemplateSource && $this->template->caching) { |
|
| 95 | + $this->parser->insertPhpCode("<?php\n\$_smarty_tpl->compiled->nocache_hash = '{$this->nocache_hash}';\n?>\n"); |
|
| 96 | + } |
|
| 97 | + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { |
|
| 98 | + $mbEncoding = mb_internal_encoding(); |
|
| 99 | + mb_internal_encoding('ASCII'); |
|
| 100 | + } else { |
|
| 101 | + $mbEncoding = null; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - if ($this->smarty->_parserdebug) { |
|
| 105 | - $this->parser->PrintTrace(); |
|
| 106 | - $this->parser->lex->PrintTrace(); |
|
| 107 | - } |
|
| 108 | - // get tokens from lexer and parse them |
|
| 109 | - while ($this->parser->lex->yylex()) { |
|
| 110 | - if ($this->smarty->_parserdebug) { |
|
| 111 | - echo "<pre>Line {$this->parser->lex->line} Parsing {$this->parser->yyTokenName[$this->parser->lex->token]} Token " . |
|
| 112 | - htmlentities($this->parser->lex->value) . "</pre>"; |
|
| 113 | - } |
|
| 114 | - $this->parser->doParse($this->parser->lex->token, $this->parser->lex->value); |
|
| 115 | - } |
|
| 104 | + if ($this->smarty->_parserdebug) { |
|
| 105 | + $this->parser->PrintTrace(); |
|
| 106 | + $this->parser->lex->PrintTrace(); |
|
| 107 | + } |
|
| 108 | + // get tokens from lexer and parse them |
|
| 109 | + while ($this->parser->lex->yylex()) { |
|
| 110 | + if ($this->smarty->_parserdebug) { |
|
| 111 | + echo "<pre>Line {$this->parser->lex->line} Parsing {$this->parser->yyTokenName[$this->parser->lex->token]} Token " . |
|
| 112 | + htmlentities($this->parser->lex->value) . "</pre>"; |
|
| 113 | + } |
|
| 114 | + $this->parser->doParse($this->parser->lex->token, $this->parser->lex->value); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - // finish parsing process |
|
| 118 | - $this->parser->doParse(0, 0); |
|
| 119 | - if ($mbEncoding) { |
|
| 120 | - mb_internal_encoding($mbEncoding); |
|
| 121 | - } |
|
| 122 | - // check for unclosed tags |
|
| 123 | - if (count($this->_tag_stack) > 0) { |
|
| 124 | - // get stacked info |
|
| 125 | - list($openTag, $_data) = array_pop($this->_tag_stack); |
|
| 126 | - $this->trigger_template_error("unclosed {$this->smarty->left_delimiter}" . $openTag . |
|
| 127 | - "{$this->smarty->right_delimiter} tag"); |
|
| 128 | - } |
|
| 129 | - // call post compile callbacks |
|
| 130 | - foreach ($this->postCompileCallbacks as $cb) { |
|
| 131 | - $parameter = $cb; |
|
| 132 | - $parameter[ 0 ] = $this; |
|
| 133 | - call_user_func_array($cb[ 0 ], $parameter); |
|
| 134 | - } |
|
| 135 | - // return compiled code |
|
| 136 | - return $this->prefixCompiledCode . $this->parser->retvalue . $this->postfixCompiledCode; |
|
| 137 | - } |
|
| 117 | + // finish parsing process |
|
| 118 | + $this->parser->doParse(0, 0); |
|
| 119 | + if ($mbEncoding) { |
|
| 120 | + mb_internal_encoding($mbEncoding); |
|
| 121 | + } |
|
| 122 | + // check for unclosed tags |
|
| 123 | + if (count($this->_tag_stack) > 0) { |
|
| 124 | + // get stacked info |
|
| 125 | + list($openTag, $_data) = array_pop($this->_tag_stack); |
|
| 126 | + $this->trigger_template_error("unclosed {$this->smarty->left_delimiter}" . $openTag . |
|
| 127 | + "{$this->smarty->right_delimiter} tag"); |
|
| 128 | + } |
|
| 129 | + // call post compile callbacks |
|
| 130 | + foreach ($this->postCompileCallbacks as $cb) { |
|
| 131 | + $parameter = $cb; |
|
| 132 | + $parameter[ 0 ] = $this; |
|
| 133 | + call_user_func_array($cb[ 0 ], $parameter); |
|
| 134 | + } |
|
| 135 | + // return compiled code |
|
| 136 | + return $this->prefixCompiledCode . $this->parser->retvalue . $this->postfixCompiledCode; |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Register a post compile callback |
|
| 141 | - * - when the callback is called after template compiling the compiler object will be inserted as first parameter |
|
| 142 | - * |
|
| 143 | - * @param callback $callback |
|
| 144 | - * @param array $parameter optional parameter array |
|
| 145 | - * @param string $key optional key for callback |
|
| 146 | - * @param bool $replace if true replace existing keyed callback |
|
| 147 | - * |
|
| 148 | - */ |
|
| 149 | - public function registerPostCompileCallback($callback, $parameter = array(), $key = null, $replace = false) |
|
| 150 | - { |
|
| 151 | - array_unshift($parameter, $callback); |
|
| 152 | - if (isset($key)) { |
|
| 153 | - if ($replace || !isset($this->postCompileCallbacks[ $key ])) { |
|
| 154 | - $this->postCompileCallbacks[ $key ] = $parameter; |
|
| 155 | - } |
|
| 156 | - } else { |
|
| 157 | - $this->postCompileCallbacks[] = $parameter; |
|
| 158 | - } |
|
| 159 | - } |
|
| 139 | + /** |
|
| 140 | + * Register a post compile callback |
|
| 141 | + * - when the callback is called after template compiling the compiler object will be inserted as first parameter |
|
| 142 | + * |
|
| 143 | + * @param callback $callback |
|
| 144 | + * @param array $parameter optional parameter array |
|
| 145 | + * @param string $key optional key for callback |
|
| 146 | + * @param bool $replace if true replace existing keyed callback |
|
| 147 | + * |
|
| 148 | + */ |
|
| 149 | + public function registerPostCompileCallback($callback, $parameter = array(), $key = null, $replace = false) |
|
| 150 | + { |
|
| 151 | + array_unshift($parameter, $callback); |
|
| 152 | + if (isset($key)) { |
|
| 153 | + if ($replace || !isset($this->postCompileCallbacks[ $key ])) { |
|
| 154 | + $this->postCompileCallbacks[ $key ] = $parameter; |
|
| 155 | + } |
|
| 156 | + } else { |
|
| 157 | + $this->postCompileCallbacks[] = $parameter; |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * Remove a post compile callback |
|
| 163 | - * |
|
| 164 | - * @param string $key callback key |
|
| 165 | - */ |
|
| 166 | - public function unregisterPostCompileCallback($key) |
|
| 167 | - { |
|
| 168 | - unset($this->postCompileCallbacks[ $key ]); |
|
| 169 | - } |
|
| 161 | + /** |
|
| 162 | + * Remove a post compile callback |
|
| 163 | + * |
|
| 164 | + * @param string $key callback key |
|
| 165 | + */ |
|
| 166 | + public function unregisterPostCompileCallback($key) |
|
| 167 | + { |
|
| 168 | + unset($this->postCompileCallbacks[ $key ]); |
|
| 169 | + } |
|
| 170 | 170 | } |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | // call post compile callbacks |
| 130 | 130 | foreach ($this->postCompileCallbacks as $cb) { |
| 131 | 131 | $parameter = $cb; |
| 132 | - $parameter[ 0 ] = $this; |
|
| 133 | - call_user_func_array($cb[ 0 ], $parameter); |
|
| 132 | + $parameter[0] = $this; |
|
| 133 | + call_user_func_array($cb[0], $parameter); |
|
| 134 | 134 | } |
| 135 | 135 | // return compiled code |
| 136 | 136 | return $this->prefixCompiledCode . $this->parser->retvalue . $this->postfixCompiledCode; |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | { |
| 151 | 151 | array_unshift($parameter, $callback); |
| 152 | 152 | if (isset($key)) { |
| 153 | - if ($replace || !isset($this->postCompileCallbacks[ $key ])) { |
|
| 154 | - $this->postCompileCallbacks[ $key ] = $parameter; |
|
| 153 | + if ($replace || !isset($this->postCompileCallbacks[$key])) { |
|
| 154 | + $this->postCompileCallbacks[$key] = $parameter; |
|
| 155 | 155 | } |
| 156 | 156 | } else { |
| 157 | 157 | $this->postCompileCallbacks[] = $parameter; |
@@ -165,6 +165,6 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | public function unregisterPostCompileCallback($key) |
| 167 | 167 | { |
| 168 | - unset($this->postCompileCallbacks[ $key ]); |
|
| 168 | + unset($this->postCompileCallbacks[$key]); |
|
| 169 | 169 | } |
| 170 | 170 | } |
@@ -16,24 +16,24 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Compiles code for setfilter 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 | - $compiler->variable_filter_stack[] = $compiler->variable_filters; |
|
| 31 | - $compiler->variable_filters = $parameter[ 'modifier_list' ]; |
|
| 32 | - // this tag does not return compiled code |
|
| 33 | - $compiler->has_code = false; |
|
| 19 | + /** |
|
| 20 | + * Compiles code for setfilter 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 | + $compiler->variable_filter_stack[] = $compiler->variable_filters; |
|
| 31 | + $compiler->variable_filters = $parameter[ 'modifier_list' ]; |
|
| 32 | + // this tag does not return compiled code |
|
| 33 | + $compiler->has_code = false; |
|
| 34 | 34 | |
| 35 | - return true; |
|
| 36 | - } |
|
| 35 | + return true; |
|
| 36 | + } |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -44,27 +44,27 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase |
| 46 | 46 | { |
| 47 | - /** |
|
| 48 | - * Compiles code for the {/setfilter} tag |
|
| 49 | - * This tag does not generate compiled output. It resets variable filter. |
|
| 50 | - * |
|
| 51 | - * @param array $args array with attributes from parser |
|
| 52 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 53 | - * |
|
| 54 | - * @return string compiled code |
|
| 55 | - */ |
|
| 56 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 57 | - { |
|
| 58 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 59 | - // reset variable filter to previous state |
|
| 60 | - if (count($compiler->variable_filter_stack)) { |
|
| 61 | - $compiler->variable_filters = array_pop($compiler->variable_filter_stack); |
|
| 62 | - } else { |
|
| 63 | - $compiler->variable_filters = array(); |
|
| 64 | - } |
|
| 65 | - // this tag does not return compiled code |
|
| 66 | - $compiler->has_code = false; |
|
| 47 | + /** |
|
| 48 | + * Compiles code for the {/setfilter} tag |
|
| 49 | + * This tag does not generate compiled output. It resets variable filter. |
|
| 50 | + * |
|
| 51 | + * @param array $args array with attributes from parser |
|
| 52 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 53 | + * |
|
| 54 | + * @return string compiled code |
|
| 55 | + */ |
|
| 56 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 57 | + { |
|
| 58 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 59 | + // reset variable filter to previous state |
|
| 60 | + if (count($compiler->variable_filter_stack)) { |
|
| 61 | + $compiler->variable_filters = array_pop($compiler->variable_filter_stack); |
|
| 62 | + } else { |
|
| 63 | + $compiler->variable_filters = array(); |
|
| 64 | + } |
|
| 65 | + // this tag does not return compiled code |
|
| 66 | + $compiler->has_code = false; |
|
| 67 | 67 | |
| 68 | - return true; |
|
| 69 | - } |
|
| 68 | + return true; |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
| 29 | 29 | { |
| 30 | 30 | $compiler->variable_filter_stack[] = $compiler->variable_filters; |
| 31 | - $compiler->variable_filters = $parameter[ 'modifier_list' ]; |
|
| 31 | + $compiler->variable_filters = $parameter['modifier_list']; |
|
| 32 | 32 | // this tag does not return compiled code |
| 33 | 33 | $compiler->has_code = false; |
| 34 | 34 | |
@@ -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 |