@@ -16,330 +16,330 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * caching mode to create nocache code but no cache file |
|
| 21 | - */ |
|
| 22 | - const CACHING_NOCACHE_CODE = 9999; |
|
| 19 | + /** |
|
| 20 | + * caching mode to create nocache code but no cache file |
|
| 21 | + */ |
|
| 22 | + const CACHING_NOCACHE_CODE = 9999; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Attribute definition: Overwrites base class. |
|
| 26 | - * |
|
| 27 | - * @var array |
|
| 28 | - * @see Smarty_Internal_CompileBase |
|
| 29 | - */ |
|
| 30 | - public $required_attributes = array('file'); |
|
| 24 | + /** |
|
| 25 | + * Attribute definition: Overwrites base class. |
|
| 26 | + * |
|
| 27 | + * @var array |
|
| 28 | + * @see Smarty_Internal_CompileBase |
|
| 29 | + */ |
|
| 30 | + public $required_attributes = array('file'); |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Attribute definition: Overwrites base class. |
|
| 34 | - * |
|
| 35 | - * @var array |
|
| 36 | - * @see Smarty_Internal_CompileBase |
|
| 37 | - */ |
|
| 38 | - public $shorttag_order = array('file'); |
|
| 32 | + /** |
|
| 33 | + * Attribute definition: Overwrites base class. |
|
| 34 | + * |
|
| 35 | + * @var array |
|
| 36 | + * @see Smarty_Internal_CompileBase |
|
| 37 | + */ |
|
| 38 | + public $shorttag_order = array('file'); |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Attribute definition: Overwrites base class. |
|
| 42 | - * |
|
| 43 | - * @var array |
|
| 44 | - * @see Smarty_Internal_CompileBase |
|
| 45 | - */ |
|
| 46 | - public $option_flags = array('nocache', 'inline', 'caching'); |
|
| 40 | + /** |
|
| 41 | + * Attribute definition: Overwrites base class. |
|
| 42 | + * |
|
| 43 | + * @var array |
|
| 44 | + * @see Smarty_Internal_CompileBase |
|
| 45 | + */ |
|
| 46 | + public $option_flags = array('nocache', 'inline', 'caching'); |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Attribute definition: Overwrites base class. |
|
| 50 | - * |
|
| 51 | - * @var array |
|
| 52 | - * @see Smarty_Internal_CompileBase |
|
| 53 | - */ |
|
| 54 | - public $optional_attributes = array('_any'); |
|
| 48 | + /** |
|
| 49 | + * Attribute definition: Overwrites base class. |
|
| 50 | + * |
|
| 51 | + * @var array |
|
| 52 | + * @see Smarty_Internal_CompileBase |
|
| 53 | + */ |
|
| 54 | + public $optional_attributes = array('_any'); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Valid scope names |
|
| 58 | - * |
|
| 59 | - * @var array |
|
| 60 | - */ |
|
| 61 | - public $valid_scopes = array('parent' => Smarty::SCOPE_PARENT, 'root' => Smarty::SCOPE_ROOT, |
|
| 62 | - 'global' => Smarty::SCOPE_GLOBAL, 'tpl_root' => Smarty::SCOPE_TPL_ROOT, |
|
| 63 | - 'smarty' => Smarty::SCOPE_SMARTY); |
|
| 56 | + /** |
|
| 57 | + * Valid scope names |
|
| 58 | + * |
|
| 59 | + * @var array |
|
| 60 | + */ |
|
| 61 | + public $valid_scopes = array('parent' => Smarty::SCOPE_PARENT, 'root' => Smarty::SCOPE_ROOT, |
|
| 62 | + 'global' => Smarty::SCOPE_GLOBAL, 'tpl_root' => Smarty::SCOPE_TPL_ROOT, |
|
| 63 | + 'smarty' => Smarty::SCOPE_SMARTY); |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Compiles code for the {include} tag |
|
| 67 | - * |
|
| 68 | - * @param array $args array with attributes from parser |
|
| 69 | - * @param Smarty_Internal_SmartyTemplateCompiler $compiler compiler object |
|
| 70 | - * @param array $parameter array with compilation parameter |
|
| 71 | - * |
|
| 72 | - * @throws SmartyCompilerException |
|
| 73 | - * @return string compiled code |
|
| 74 | - */ |
|
| 75 | - public function compile($args, Smarty_Internal_SmartyTemplateCompiler $compiler, $parameter) |
|
| 76 | - { |
|
| 77 | - $uid = $t_hash = null; |
|
| 78 | - // check and get attributes |
|
| 79 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 65 | + /** |
|
| 66 | + * Compiles code for the {include} tag |
|
| 67 | + * |
|
| 68 | + * @param array $args array with attributes from parser |
|
| 69 | + * @param Smarty_Internal_SmartyTemplateCompiler $compiler compiler object |
|
| 70 | + * @param array $parameter array with compilation parameter |
|
| 71 | + * |
|
| 72 | + * @throws SmartyCompilerException |
|
| 73 | + * @return string compiled code |
|
| 74 | + */ |
|
| 75 | + public function compile($args, Smarty_Internal_SmartyTemplateCompiler $compiler, $parameter) |
|
| 76 | + { |
|
| 77 | + $uid = $t_hash = null; |
|
| 78 | + // check and get attributes |
|
| 79 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 80 | 80 | |
| 81 | - $fullResourceName = $source_resource = $_attr[ 'file' ]; |
|
| 82 | - $variable_template = false; |
|
| 83 | - $cache_tpl = false; |
|
| 84 | - // parse resource_name |
|
| 85 | - if (preg_match('/^([\'"])(([A-Za-z0-9_\-]{2,})[:])?(([^$()]+)|(.+))\1$/', $source_resource, $match)) { |
|
| 86 | - $type = !empty($match[ 3 ]) ? $match[ 3 ] : $compiler->template->smarty->default_resource_type; |
|
| 87 | - $name = !empty($match[ 5 ]) ? $match[ 5 ] : $match[ 6 ]; |
|
| 88 | - $handler = Smarty_Resource::load($compiler->smarty, $type); |
|
| 89 | - if ($handler->recompiled || $handler->uncompiled) { |
|
| 90 | - $variable_template = true; |
|
| 91 | - } |
|
| 92 | - if (!$variable_template) { |
|
| 93 | - if ($type != 'string') { |
|
| 94 | - $fullResourceName = "{$type}:{$name}"; |
|
| 95 | - $compiled = $compiler->parent_compiler->template->compiled; |
|
| 96 | - if (isset($compiled->includes[ $fullResourceName ])) { |
|
| 97 | - $compiled->includes[ $fullResourceName ] ++; |
|
| 98 | - $cache_tpl = true; |
|
| 99 | - } else { |
|
| 100 | - if ("{$compiler->template->source->type}:{$compiler->template->source->name}" == |
|
| 101 | - $fullResourceName |
|
| 102 | - ) { |
|
| 103 | - // recursive call of current template |
|
| 104 | - $compiled->includes[ $fullResourceName ] = 2; |
|
| 105 | - $cache_tpl = true; |
|
| 106 | - } else { |
|
| 107 | - $compiled->includes[ $fullResourceName ] = 1; |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - $fullResourceName = '"' . $fullResourceName . '"'; |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - if (empty($match[ 5 ])) { |
|
| 114 | - $variable_template = true; |
|
| 115 | - } |
|
| 116 | - } else { |
|
| 117 | - $variable_template = true; |
|
| 118 | - } |
|
| 81 | + $fullResourceName = $source_resource = $_attr[ 'file' ]; |
|
| 82 | + $variable_template = false; |
|
| 83 | + $cache_tpl = false; |
|
| 84 | + // parse resource_name |
|
| 85 | + if (preg_match('/^([\'"])(([A-Za-z0-9_\-]{2,})[:])?(([^$()]+)|(.+))\1$/', $source_resource, $match)) { |
|
| 86 | + $type = !empty($match[ 3 ]) ? $match[ 3 ] : $compiler->template->smarty->default_resource_type; |
|
| 87 | + $name = !empty($match[ 5 ]) ? $match[ 5 ] : $match[ 6 ]; |
|
| 88 | + $handler = Smarty_Resource::load($compiler->smarty, $type); |
|
| 89 | + if ($handler->recompiled || $handler->uncompiled) { |
|
| 90 | + $variable_template = true; |
|
| 91 | + } |
|
| 92 | + if (!$variable_template) { |
|
| 93 | + if ($type != 'string') { |
|
| 94 | + $fullResourceName = "{$type}:{$name}"; |
|
| 95 | + $compiled = $compiler->parent_compiler->template->compiled; |
|
| 96 | + if (isset($compiled->includes[ $fullResourceName ])) { |
|
| 97 | + $compiled->includes[ $fullResourceName ] ++; |
|
| 98 | + $cache_tpl = true; |
|
| 99 | + } else { |
|
| 100 | + if ("{$compiler->template->source->type}:{$compiler->template->source->name}" == |
|
| 101 | + $fullResourceName |
|
| 102 | + ) { |
|
| 103 | + // recursive call of current template |
|
| 104 | + $compiled->includes[ $fullResourceName ] = 2; |
|
| 105 | + $cache_tpl = true; |
|
| 106 | + } else { |
|
| 107 | + $compiled->includes[ $fullResourceName ] = 1; |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + $fullResourceName = '"' . $fullResourceName . '"'; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + if (empty($match[ 5 ])) { |
|
| 114 | + $variable_template = true; |
|
| 115 | + } |
|
| 116 | + } else { |
|
| 117 | + $variable_template = true; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - // scope setup |
|
| 121 | - $_scope = $compiler->convertScope($_attr, $this->valid_scopes); |
|
| 120 | + // scope setup |
|
| 121 | + $_scope = $compiler->convertScope($_attr, $this->valid_scopes); |
|
| 122 | 122 | |
| 123 | - // set flag to cache subtemplate object when called within loop or template name is variable. |
|
| 124 | - if ($cache_tpl || $variable_template || $compiler->loopNesting > 0) { |
|
| 125 | - $_cache_tpl = 'true'; |
|
| 126 | - } else { |
|
| 127 | - $_cache_tpl = 'false'; |
|
| 128 | - } |
|
| 129 | - // assume caching is off |
|
| 130 | - $_caching = Smarty::CACHING_OFF; |
|
| 123 | + // set flag to cache subtemplate object when called within loop or template name is variable. |
|
| 124 | + if ($cache_tpl || $variable_template || $compiler->loopNesting > 0) { |
|
| 125 | + $_cache_tpl = 'true'; |
|
| 126 | + } else { |
|
| 127 | + $_cache_tpl = 'false'; |
|
| 128 | + } |
|
| 129 | + // assume caching is off |
|
| 130 | + $_caching = Smarty::CACHING_OFF; |
|
| 131 | 131 | |
| 132 | - $call_nocache = $compiler->tag_nocache || $compiler->nocache; |
|
| 132 | + $call_nocache = $compiler->tag_nocache || $compiler->nocache; |
|
| 133 | 133 | |
| 134 | - // caching was on and {include} is not in nocache mode |
|
| 135 | - if ($compiler->template->caching && !$compiler->nocache && !$compiler->tag_nocache) { |
|
| 136 | - $_caching = self::CACHING_NOCACHE_CODE; |
|
| 137 | - } |
|
| 134 | + // caching was on and {include} is not in nocache mode |
|
| 135 | + if ($compiler->template->caching && !$compiler->nocache && !$compiler->tag_nocache) { |
|
| 136 | + $_caching = self::CACHING_NOCACHE_CODE; |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - // flag if included template code should be merged into caller |
|
| 140 | - $merge_compiled_includes = ($compiler->smarty->merge_compiled_includes || $_attr[ 'inline' ] === true) && |
|
| 141 | - !$compiler->template->source->handler->recompiled; |
|
| 139 | + // flag if included template code should be merged into caller |
|
| 140 | + $merge_compiled_includes = ($compiler->smarty->merge_compiled_includes || $_attr[ 'inline' ] === true) && |
|
| 141 | + !$compiler->template->source->handler->recompiled; |
|
| 142 | 142 | |
| 143 | - if ($merge_compiled_includes) { |
|
| 144 | - // variable template name ? |
|
| 145 | - if ($variable_template) { |
|
| 146 | - $merge_compiled_includes = false; |
|
| 147 | - } |
|
| 148 | - // variable compile_id? |
|
| 149 | - if (isset($_attr[ 'compile_id' ]) && $compiler->isVariable($_attr[ 'compile_id' ])) { |
|
| 150 | - $merge_compiled_includes = false; |
|
| 151 | - } |
|
| 152 | - } |
|
| 143 | + if ($merge_compiled_includes) { |
|
| 144 | + // variable template name ? |
|
| 145 | + if ($variable_template) { |
|
| 146 | + $merge_compiled_includes = false; |
|
| 147 | + } |
|
| 148 | + // variable compile_id? |
|
| 149 | + if (isset($_attr[ 'compile_id' ]) && $compiler->isVariable($_attr[ 'compile_id' ])) { |
|
| 150 | + $merge_compiled_includes = false; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - /* |
|
| 154 | + /* |
|
| 155 | 155 | * if the {include} tag provides individual parameter for caching or compile_id |
| 156 | 156 | * the subtemplate must not be included into the common cache file and is treated like |
| 157 | 157 | * a call in nocache mode. |
| 158 | 158 | * |
| 159 | 159 | */ |
| 160 | - if ($_attr[ 'nocache' ] !== true && $_attr[ 'caching' ]) { |
|
| 161 | - $_caching = $_new_caching = (int) $_attr[ 'caching' ]; |
|
| 162 | - $call_nocache = true; |
|
| 163 | - } else { |
|
| 164 | - $_new_caching = Smarty::CACHING_LIFETIME_CURRENT; |
|
| 165 | - } |
|
| 166 | - if (isset($_attr[ 'cache_lifetime' ])) { |
|
| 167 | - $_cache_lifetime = $_attr[ 'cache_lifetime' ]; |
|
| 168 | - $call_nocache = true; |
|
| 169 | - $_caching = $_new_caching; |
|
| 170 | - } else { |
|
| 171 | - $_cache_lifetime = '$_smarty_tpl->cache_lifetime'; |
|
| 172 | - } |
|
| 173 | - if (isset($_attr[ 'cache_id' ])) { |
|
| 174 | - $_cache_id = $_attr[ 'cache_id' ]; |
|
| 175 | - $call_nocache = true; |
|
| 176 | - $_caching = $_new_caching; |
|
| 177 | - } else { |
|
| 178 | - $_cache_id = '$_smarty_tpl->cache_id'; |
|
| 179 | - } |
|
| 180 | - if (isset($_attr[ 'compile_id' ])) { |
|
| 181 | - $_compile_id = $_attr[ 'compile_id' ]; |
|
| 182 | - } else { |
|
| 183 | - $_compile_id = '$_smarty_tpl->compile_id'; |
|
| 184 | - } |
|
| 160 | + if ($_attr[ 'nocache' ] !== true && $_attr[ 'caching' ]) { |
|
| 161 | + $_caching = $_new_caching = (int) $_attr[ 'caching' ]; |
|
| 162 | + $call_nocache = true; |
|
| 163 | + } else { |
|
| 164 | + $_new_caching = Smarty::CACHING_LIFETIME_CURRENT; |
|
| 165 | + } |
|
| 166 | + if (isset($_attr[ 'cache_lifetime' ])) { |
|
| 167 | + $_cache_lifetime = $_attr[ 'cache_lifetime' ]; |
|
| 168 | + $call_nocache = true; |
|
| 169 | + $_caching = $_new_caching; |
|
| 170 | + } else { |
|
| 171 | + $_cache_lifetime = '$_smarty_tpl->cache_lifetime'; |
|
| 172 | + } |
|
| 173 | + if (isset($_attr[ 'cache_id' ])) { |
|
| 174 | + $_cache_id = $_attr[ 'cache_id' ]; |
|
| 175 | + $call_nocache = true; |
|
| 176 | + $_caching = $_new_caching; |
|
| 177 | + } else { |
|
| 178 | + $_cache_id = '$_smarty_tpl->cache_id'; |
|
| 179 | + } |
|
| 180 | + if (isset($_attr[ 'compile_id' ])) { |
|
| 181 | + $_compile_id = $_attr[ 'compile_id' ]; |
|
| 182 | + } else { |
|
| 183 | + $_compile_id = '$_smarty_tpl->compile_id'; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - // if subtemplate will be called in nocache mode do not merge |
|
| 187 | - if ($compiler->template->caching && $call_nocache) { |
|
| 188 | - $merge_compiled_includes = false; |
|
| 189 | - } |
|
| 190 | - // assign attribute |
|
| 191 | - if (isset($_attr[ 'assign' ])) { |
|
| 192 | - // output will be stored in a smarty variable instead of being displayed |
|
| 193 | - if ($_assign = $compiler->getId($_attr[ 'assign' ])) { |
|
| 194 | - $_assign = "'{$_assign}'"; |
|
| 195 | - if ($compiler->tag_nocache || $compiler->nocache || $call_nocache) { |
|
| 196 | - // create nocache var to make it know for further compiling |
|
| 197 | - $compiler->setNocacheInVariable($_attr[ 'assign' ]); |
|
| 198 | - } |
|
| 199 | - } else { |
|
| 200 | - $_assign = $_attr[ 'assign' ]; |
|
| 201 | - } |
|
| 202 | - } |
|
| 186 | + // if subtemplate will be called in nocache mode do not merge |
|
| 187 | + if ($compiler->template->caching && $call_nocache) { |
|
| 188 | + $merge_compiled_includes = false; |
|
| 189 | + } |
|
| 190 | + // assign attribute |
|
| 191 | + if (isset($_attr[ 'assign' ])) { |
|
| 192 | + // output will be stored in a smarty variable instead of being displayed |
|
| 193 | + if ($_assign = $compiler->getId($_attr[ 'assign' ])) { |
|
| 194 | + $_assign = "'{$_assign}'"; |
|
| 195 | + if ($compiler->tag_nocache || $compiler->nocache || $call_nocache) { |
|
| 196 | + // create nocache var to make it know for further compiling |
|
| 197 | + $compiler->setNocacheInVariable($_attr[ 'assign' ]); |
|
| 198 | + } |
|
| 199 | + } else { |
|
| 200 | + $_assign = $_attr[ 'assign' ]; |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - $has_compiled_template = false; |
|
| 205 | - if ($merge_compiled_includes) { |
|
| 206 | - $c_id = isset($_attr[ 'compile_id' ]) ? $_attr[ 'compile_id' ] : $compiler->template->compile_id; |
|
| 207 | - // we must observe different compile_id and caching |
|
| 208 | - $t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching')); |
|
| 209 | - $compiler->smarty->allow_ambiguous_resources = true; |
|
| 210 | - /* @var Smarty_Internal_Template $tpl */ |
|
| 211 | - $tpl = new $compiler->smarty->template_class (trim($fullResourceName, '"\''), $compiler->smarty, |
|
| 212 | - $compiler->template, $compiler->template->cache_id, $c_id, |
|
| 213 | - $_caching); |
|
| 214 | - $uid = $tpl->source->type . $tpl->source->uid; |
|
| 215 | - if (!isset($compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ])) { |
|
| 216 | - $has_compiled_template = $this->compileInlineTemplate($compiler, $tpl, $t_hash); |
|
| 217 | - } else { |
|
| 218 | - $has_compiled_template = true; |
|
| 219 | - } |
|
| 220 | - unset($tpl); |
|
| 221 | - } |
|
| 222 | - // delete {include} standard attributes |
|
| 223 | - unset($_attr[ 'file' ], $_attr[ 'assign' ], $_attr[ 'cache_id' ], $_attr[ 'compile_id' ], $_attr[ 'cache_lifetime' ], $_attr[ 'nocache' ], $_attr[ 'caching' ], $_attr[ 'scope' ], $_attr[ 'inline' ]); |
|
| 224 | - // remaining attributes must be assigned as smarty variable |
|
| 225 | - $_vars = 'array()'; |
|
| 226 | - if (!empty($_attr)) { |
|
| 227 | - $_pairs = array(); |
|
| 228 | - // create variables |
|
| 229 | - foreach ($_attr as $key => $value) { |
|
| 230 | - $_pairs[] = "'$key'=>$value"; |
|
| 231 | - } |
|
| 232 | - $_vars = 'array(' . join(',', $_pairs) . ')'; |
|
| 233 | - } |
|
| 234 | - $update_compile_id = $compiler->template->caching && !$compiler->tag_nocache && !$compiler->nocache && |
|
| 235 | - $_compile_id != '$_smarty_tpl->compile_id'; |
|
| 236 | - if ($has_compiled_template && !$call_nocache) { |
|
| 237 | - $_output = "<?php\n"; |
|
| 238 | - if ($update_compile_id) { |
|
| 239 | - $_output .= $compiler->makeNocacheCode("\$_compile_id_save[] = \$_smarty_tpl->compile_id;\n\$_smarty_tpl->compile_id = {$_compile_id};\n"); |
|
| 240 | - } |
|
| 241 | - if (!empty($_attr) && $_caching == 9999 && $compiler->template->caching) { |
|
| 242 | - $_vars_nc = "foreach ($_vars as \$ik => \$iv) {\n"; |
|
| 243 | - $_vars_nc .= "\$_smarty_tpl->tpl_vars[\$ik] = new Smarty_Variable(\$iv);\n"; |
|
| 244 | - $_vars_nc .= "}\n"; |
|
| 245 | - $_output .= substr($compiler->processNocacheCode('<?php ' . $_vars_nc . "?>\n", true), 6, - 3); |
|
| 246 | - } |
|
| 247 | - if (isset($_assign)) { |
|
| 248 | - $_output .= "ob_start();\n"; |
|
| 249 | - } |
|
| 250 | - $_output .= "\$_smarty_tpl->_subTemplateRender({$fullResourceName}, {$_cache_id}, {$_compile_id}, {$_caching}, {$_cache_lifetime}, {$_vars}, {$_scope}, {$_cache_tpl}, '{$compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['uid']}', '{$compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['func']}');\n"; |
|
| 251 | - if (isset($_assign)) { |
|
| 252 | - $_output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n"; |
|
| 253 | - } |
|
| 254 | - if ($update_compile_id) { |
|
| 255 | - $_output .= $compiler->makeNocacheCode("\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n"); |
|
| 256 | - } |
|
| 257 | - $_output .= "?>\n"; |
|
| 204 | + $has_compiled_template = false; |
|
| 205 | + if ($merge_compiled_includes) { |
|
| 206 | + $c_id = isset($_attr[ 'compile_id' ]) ? $_attr[ 'compile_id' ] : $compiler->template->compile_id; |
|
| 207 | + // we must observe different compile_id and caching |
|
| 208 | + $t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching')); |
|
| 209 | + $compiler->smarty->allow_ambiguous_resources = true; |
|
| 210 | + /* @var Smarty_Internal_Template $tpl */ |
|
| 211 | + $tpl = new $compiler->smarty->template_class (trim($fullResourceName, '"\''), $compiler->smarty, |
|
| 212 | + $compiler->template, $compiler->template->cache_id, $c_id, |
|
| 213 | + $_caching); |
|
| 214 | + $uid = $tpl->source->type . $tpl->source->uid; |
|
| 215 | + if (!isset($compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ])) { |
|
| 216 | + $has_compiled_template = $this->compileInlineTemplate($compiler, $tpl, $t_hash); |
|
| 217 | + } else { |
|
| 218 | + $has_compiled_template = true; |
|
| 219 | + } |
|
| 220 | + unset($tpl); |
|
| 221 | + } |
|
| 222 | + // delete {include} standard attributes |
|
| 223 | + unset($_attr[ 'file' ], $_attr[ 'assign' ], $_attr[ 'cache_id' ], $_attr[ 'compile_id' ], $_attr[ 'cache_lifetime' ], $_attr[ 'nocache' ], $_attr[ 'caching' ], $_attr[ 'scope' ], $_attr[ 'inline' ]); |
|
| 224 | + // remaining attributes must be assigned as smarty variable |
|
| 225 | + $_vars = 'array()'; |
|
| 226 | + if (!empty($_attr)) { |
|
| 227 | + $_pairs = array(); |
|
| 228 | + // create variables |
|
| 229 | + foreach ($_attr as $key => $value) { |
|
| 230 | + $_pairs[] = "'$key'=>$value"; |
|
| 231 | + } |
|
| 232 | + $_vars = 'array(' . join(',', $_pairs) . ')'; |
|
| 233 | + } |
|
| 234 | + $update_compile_id = $compiler->template->caching && !$compiler->tag_nocache && !$compiler->nocache && |
|
| 235 | + $_compile_id != '$_smarty_tpl->compile_id'; |
|
| 236 | + if ($has_compiled_template && !$call_nocache) { |
|
| 237 | + $_output = "<?php\n"; |
|
| 238 | + if ($update_compile_id) { |
|
| 239 | + $_output .= $compiler->makeNocacheCode("\$_compile_id_save[] = \$_smarty_tpl->compile_id;\n\$_smarty_tpl->compile_id = {$_compile_id};\n"); |
|
| 240 | + } |
|
| 241 | + if (!empty($_attr) && $_caching == 9999 && $compiler->template->caching) { |
|
| 242 | + $_vars_nc = "foreach ($_vars as \$ik => \$iv) {\n"; |
|
| 243 | + $_vars_nc .= "\$_smarty_tpl->tpl_vars[\$ik] = new Smarty_Variable(\$iv);\n"; |
|
| 244 | + $_vars_nc .= "}\n"; |
|
| 245 | + $_output .= substr($compiler->processNocacheCode('<?php ' . $_vars_nc . "?>\n", true), 6, - 3); |
|
| 246 | + } |
|
| 247 | + if (isset($_assign)) { |
|
| 248 | + $_output .= "ob_start();\n"; |
|
| 249 | + } |
|
| 250 | + $_output .= "\$_smarty_tpl->_subTemplateRender({$fullResourceName}, {$_cache_id}, {$_compile_id}, {$_caching}, {$_cache_lifetime}, {$_vars}, {$_scope}, {$_cache_tpl}, '{$compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['uid']}', '{$compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['func']}');\n"; |
|
| 251 | + if (isset($_assign)) { |
|
| 252 | + $_output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n"; |
|
| 253 | + } |
|
| 254 | + if ($update_compile_id) { |
|
| 255 | + $_output .= $compiler->makeNocacheCode("\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n"); |
|
| 256 | + } |
|
| 257 | + $_output .= "?>\n"; |
|
| 258 | 258 | |
| 259 | - return $_output; |
|
| 260 | - } |
|
| 259 | + return $_output; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - if ($call_nocache) { |
|
| 263 | - $compiler->tag_nocache = true; |
|
| 264 | - } |
|
| 265 | - $_output = "<?php "; |
|
| 266 | - if ($update_compile_id) { |
|
| 267 | - $_output .= "\$_compile_id_save[] = \$_smarty_tpl->compile_id;\n\$_smarty_tpl->compile_id = {$_compile_id};\n"; |
|
| 268 | - } |
|
| 269 | - // was there an assign attribute |
|
| 270 | - if (isset($_assign)) { |
|
| 271 | - $_output .= "ob_start();\n"; |
|
| 272 | - } |
|
| 273 | - $_output .= "\$_smarty_tpl->_subTemplateRender({$fullResourceName}, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_scope, {$_cache_tpl});\n"; |
|
| 274 | - if (isset($_assign)) { |
|
| 275 | - $_output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n"; |
|
| 276 | - } |
|
| 277 | - if ($update_compile_id) { |
|
| 278 | - $_output .= "\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n"; |
|
| 279 | - } |
|
| 280 | - $_output .= "?>\n"; |
|
| 281 | - return $_output; |
|
| 282 | - } |
|
| 262 | + if ($call_nocache) { |
|
| 263 | + $compiler->tag_nocache = true; |
|
| 264 | + } |
|
| 265 | + $_output = "<?php "; |
|
| 266 | + if ($update_compile_id) { |
|
| 267 | + $_output .= "\$_compile_id_save[] = \$_smarty_tpl->compile_id;\n\$_smarty_tpl->compile_id = {$_compile_id};\n"; |
|
| 268 | + } |
|
| 269 | + // was there an assign attribute |
|
| 270 | + if (isset($_assign)) { |
|
| 271 | + $_output .= "ob_start();\n"; |
|
| 272 | + } |
|
| 273 | + $_output .= "\$_smarty_tpl->_subTemplateRender({$fullResourceName}, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_scope, {$_cache_tpl});\n"; |
|
| 274 | + if (isset($_assign)) { |
|
| 275 | + $_output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n"; |
|
| 276 | + } |
|
| 277 | + if ($update_compile_id) { |
|
| 278 | + $_output .= "\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n"; |
|
| 279 | + } |
|
| 280 | + $_output .= "?>\n"; |
|
| 281 | + return $_output; |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | - /** |
|
| 285 | - * Compile inline sub template |
|
| 286 | - * |
|
| 287 | - * @param \Smarty_Internal_SmartyTemplateCompiler $compiler |
|
| 288 | - * @param \Smarty_Internal_Template $tpl |
|
| 289 | - * @param string $t_hash |
|
| 290 | - * |
|
| 291 | - * @return bool |
|
| 292 | - */ |
|
| 293 | - public function compileInlineTemplate(Smarty_Internal_SmartyTemplateCompiler $compiler, |
|
| 294 | - Smarty_Internal_Template $tpl, $t_hash) |
|
| 295 | - { |
|
| 296 | - $uid = $tpl->source->type . $tpl->source->uid; |
|
| 297 | - if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) { |
|
| 298 | - $compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'uid' ] = |
|
| 299 | - $tpl->source->uid; |
|
| 300 | - if (isset($compiler->template->inheritance)) { |
|
| 301 | - $tpl->inheritance = clone $compiler->template->inheritance; |
|
| 302 | - } |
|
| 303 | - $tpl->compiled = new Smarty_Template_Compiled(); |
|
| 304 | - $tpl->compiled->nocache_hash = $compiler->parent_compiler->template->compiled->nocache_hash; |
|
| 305 | - $tpl->loadCompiler(); |
|
| 306 | - // save unique function name |
|
| 307 | - $compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'func' ] = |
|
| 308 | - $tpl->compiled->unifunc = 'content_' . str_replace(array('.', ','), '_', uniqid('', true)); |
|
| 309 | - // make sure whole chain gets compiled |
|
| 310 | - $tpl->mustCompile = true; |
|
| 311 | - $compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'nocache_hash' ] = |
|
| 312 | - $tpl->compiled->nocache_hash; |
|
| 313 | - if ($compiler->template->source->type == 'file') { |
|
| 314 | - $sourceInfo = $compiler->template->source->filepath; |
|
| 315 | - } else { |
|
| 316 | - $basename = $compiler->template->source->handler->getBasename($compiler->template->source); |
|
| 317 | - $sourceInfo = $compiler->template->source->type . ':' . |
|
| 318 | - ($basename ? $basename : $compiler->template->source->name); |
|
| 319 | - } |
|
| 320 | - // get compiled code |
|
| 321 | - $compiled_code = "<?php\n\n"; |
|
| 322 | - $compiled_code .= "/* Start inline template \"{$sourceInfo}\" =============================*/\n"; |
|
| 323 | - $compiled_code .= "function {$tpl->compiled->unifunc} (\$_smarty_tpl) {\n"; |
|
| 324 | - $compiled_code .= "?>\n" . $tpl->compiler->compileTemplateSource($tpl, null, $compiler->parent_compiler); |
|
| 325 | - $compiled_code .= "<?php\n"; |
|
| 326 | - $compiled_code .= "}\n?>\n"; |
|
| 327 | - $compiled_code .= $tpl->compiler->postFilter($tpl->compiler->blockOrFunctionCode); |
|
| 328 | - $compiled_code .= "<?php\n\n"; |
|
| 329 | - $compiled_code .= "/* End inline template \"{$sourceInfo}\" =============================*/\n"; |
|
| 330 | - $compiled_code .= "?>"; |
|
| 331 | - unset($tpl->compiler); |
|
| 332 | - if ($tpl->compiled->has_nocache_code) { |
|
| 333 | - // replace nocache_hash |
|
| 334 | - $compiled_code = |
|
| 335 | - str_replace("{$tpl->compiled->nocache_hash}", $compiler->template->compiled->nocache_hash, |
|
| 336 | - $compiled_code); |
|
| 337 | - $compiler->template->compiled->has_nocache_code = true; |
|
| 338 | - } |
|
| 339 | - $compiler->parent_compiler->mergedSubTemplatesCode[ $tpl->compiled->unifunc ] = $compiled_code; |
|
| 340 | - return true; |
|
| 341 | - } else { |
|
| 342 | - return false; |
|
| 343 | - } |
|
| 344 | - } |
|
| 284 | + /** |
|
| 285 | + * Compile inline sub template |
|
| 286 | + * |
|
| 287 | + * @param \Smarty_Internal_SmartyTemplateCompiler $compiler |
|
| 288 | + * @param \Smarty_Internal_Template $tpl |
|
| 289 | + * @param string $t_hash |
|
| 290 | + * |
|
| 291 | + * @return bool |
|
| 292 | + */ |
|
| 293 | + public function compileInlineTemplate(Smarty_Internal_SmartyTemplateCompiler $compiler, |
|
| 294 | + Smarty_Internal_Template $tpl, $t_hash) |
|
| 295 | + { |
|
| 296 | + $uid = $tpl->source->type . $tpl->source->uid; |
|
| 297 | + if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) { |
|
| 298 | + $compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'uid' ] = |
|
| 299 | + $tpl->source->uid; |
|
| 300 | + if (isset($compiler->template->inheritance)) { |
|
| 301 | + $tpl->inheritance = clone $compiler->template->inheritance; |
|
| 302 | + } |
|
| 303 | + $tpl->compiled = new Smarty_Template_Compiled(); |
|
| 304 | + $tpl->compiled->nocache_hash = $compiler->parent_compiler->template->compiled->nocache_hash; |
|
| 305 | + $tpl->loadCompiler(); |
|
| 306 | + // save unique function name |
|
| 307 | + $compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'func' ] = |
|
| 308 | + $tpl->compiled->unifunc = 'content_' . str_replace(array('.', ','), '_', uniqid('', true)); |
|
| 309 | + // make sure whole chain gets compiled |
|
| 310 | + $tpl->mustCompile = true; |
|
| 311 | + $compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'nocache_hash' ] = |
|
| 312 | + $tpl->compiled->nocache_hash; |
|
| 313 | + if ($compiler->template->source->type == 'file') { |
|
| 314 | + $sourceInfo = $compiler->template->source->filepath; |
|
| 315 | + } else { |
|
| 316 | + $basename = $compiler->template->source->handler->getBasename($compiler->template->source); |
|
| 317 | + $sourceInfo = $compiler->template->source->type . ':' . |
|
| 318 | + ($basename ? $basename : $compiler->template->source->name); |
|
| 319 | + } |
|
| 320 | + // get compiled code |
|
| 321 | + $compiled_code = "<?php\n\n"; |
|
| 322 | + $compiled_code .= "/* Start inline template \"{$sourceInfo}\" =============================*/\n"; |
|
| 323 | + $compiled_code .= "function {$tpl->compiled->unifunc} (\$_smarty_tpl) {\n"; |
|
| 324 | + $compiled_code .= "?>\n" . $tpl->compiler->compileTemplateSource($tpl, null, $compiler->parent_compiler); |
|
| 325 | + $compiled_code .= "<?php\n"; |
|
| 326 | + $compiled_code .= "}\n?>\n"; |
|
| 327 | + $compiled_code .= $tpl->compiler->postFilter($tpl->compiler->blockOrFunctionCode); |
|
| 328 | + $compiled_code .= "<?php\n\n"; |
|
| 329 | + $compiled_code .= "/* End inline template \"{$sourceInfo}\" =============================*/\n"; |
|
| 330 | + $compiled_code .= "?>"; |
|
| 331 | + unset($tpl->compiler); |
|
| 332 | + if ($tpl->compiled->has_nocache_code) { |
|
| 333 | + // replace nocache_hash |
|
| 334 | + $compiled_code = |
|
| 335 | + str_replace("{$tpl->compiled->nocache_hash}", $compiler->template->compiled->nocache_hash, |
|
| 336 | + $compiled_code); |
|
| 337 | + $compiler->template->compiled->has_nocache_code = true; |
|
| 338 | + } |
|
| 339 | + $compiler->parent_compiler->mergedSubTemplatesCode[ $tpl->compiled->unifunc ] = $compiled_code; |
|
| 340 | + return true; |
|
| 341 | + } else { |
|
| 342 | + return false; |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | 345 | } |
@@ -78,13 +78,13 @@ discard block |
||
| 78 | 78 | // check and get attributes |
| 79 | 79 | $_attr = $this->getAttributes($compiler, $args); |
| 80 | 80 | |
| 81 | - $fullResourceName = $source_resource = $_attr[ 'file' ]; |
|
| 81 | + $fullResourceName = $source_resource = $_attr['file']; |
|
| 82 | 82 | $variable_template = false; |
| 83 | 83 | $cache_tpl = false; |
| 84 | 84 | // parse resource_name |
| 85 | 85 | if (preg_match('/^([\'"])(([A-Za-z0-9_\-]{2,})[:])?(([^$()]+)|(.+))\1$/', $source_resource, $match)) { |
| 86 | - $type = !empty($match[ 3 ]) ? $match[ 3 ] : $compiler->template->smarty->default_resource_type; |
|
| 87 | - $name = !empty($match[ 5 ]) ? $match[ 5 ] : $match[ 6 ]; |
|
| 86 | + $type = !empty($match[3]) ? $match[3] : $compiler->template->smarty->default_resource_type; |
|
| 87 | + $name = !empty($match[5]) ? $match[5] : $match[6]; |
|
| 88 | 88 | $handler = Smarty_Resource::load($compiler->smarty, $type); |
| 89 | 89 | if ($handler->recompiled || $handler->uncompiled) { |
| 90 | 90 | $variable_template = true; |
@@ -93,24 +93,24 @@ discard block |
||
| 93 | 93 | if ($type != 'string') { |
| 94 | 94 | $fullResourceName = "{$type}:{$name}"; |
| 95 | 95 | $compiled = $compiler->parent_compiler->template->compiled; |
| 96 | - if (isset($compiled->includes[ $fullResourceName ])) { |
|
| 97 | - $compiled->includes[ $fullResourceName ] ++; |
|
| 96 | + if (isset($compiled->includes[$fullResourceName])) { |
|
| 97 | + $compiled->includes[$fullResourceName]++; |
|
| 98 | 98 | $cache_tpl = true; |
| 99 | 99 | } else { |
| 100 | 100 | if ("{$compiler->template->source->type}:{$compiler->template->source->name}" == |
| 101 | 101 | $fullResourceName |
| 102 | 102 | ) { |
| 103 | 103 | // recursive call of current template |
| 104 | - $compiled->includes[ $fullResourceName ] = 2; |
|
| 104 | + $compiled->includes[$fullResourceName] = 2; |
|
| 105 | 105 | $cache_tpl = true; |
| 106 | 106 | } else { |
| 107 | - $compiled->includes[ $fullResourceName ] = 1; |
|
| 107 | + $compiled->includes[$fullResourceName] = 1; |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | $fullResourceName = '"' . $fullResourceName . '"'; |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | - if (empty($match[ 5 ])) { |
|
| 113 | + if (empty($match[5])) { |
|
| 114 | 114 | $variable_template = true; |
| 115 | 115 | } |
| 116 | 116 | } else { |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // flag if included template code should be merged into caller |
| 140 | - $merge_compiled_includes = ($compiler->smarty->merge_compiled_includes || $_attr[ 'inline' ] === true) && |
|
| 140 | + $merge_compiled_includes = ($compiler->smarty->merge_compiled_includes || $_attr['inline'] === true) && |
|
| 141 | 141 | !$compiler->template->source->handler->recompiled; |
| 142 | 142 | |
| 143 | 143 | if ($merge_compiled_includes) { |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $merge_compiled_includes = false; |
| 147 | 147 | } |
| 148 | 148 | // variable compile_id? |
| 149 | - if (isset($_attr[ 'compile_id' ]) && $compiler->isVariable($_attr[ 'compile_id' ])) { |
|
| 149 | + if (isset($_attr['compile_id']) && $compiler->isVariable($_attr['compile_id'])) { |
|
| 150 | 150 | $merge_compiled_includes = false; |
| 151 | 151 | } |
| 152 | 152 | } |
@@ -157,28 +157,28 @@ discard block |
||
| 157 | 157 | * a call in nocache mode. |
| 158 | 158 | * |
| 159 | 159 | */ |
| 160 | - if ($_attr[ 'nocache' ] !== true && $_attr[ 'caching' ]) { |
|
| 161 | - $_caching = $_new_caching = (int) $_attr[ 'caching' ]; |
|
| 160 | + if ($_attr['nocache'] !== true && $_attr['caching']) { |
|
| 161 | + $_caching = $_new_caching = (int) $_attr['caching']; |
|
| 162 | 162 | $call_nocache = true; |
| 163 | 163 | } else { |
| 164 | 164 | $_new_caching = Smarty::CACHING_LIFETIME_CURRENT; |
| 165 | 165 | } |
| 166 | - if (isset($_attr[ 'cache_lifetime' ])) { |
|
| 167 | - $_cache_lifetime = $_attr[ 'cache_lifetime' ]; |
|
| 166 | + if (isset($_attr['cache_lifetime'])) { |
|
| 167 | + $_cache_lifetime = $_attr['cache_lifetime']; |
|
| 168 | 168 | $call_nocache = true; |
| 169 | 169 | $_caching = $_new_caching; |
| 170 | 170 | } else { |
| 171 | 171 | $_cache_lifetime = '$_smarty_tpl->cache_lifetime'; |
| 172 | 172 | } |
| 173 | - if (isset($_attr[ 'cache_id' ])) { |
|
| 174 | - $_cache_id = $_attr[ 'cache_id' ]; |
|
| 173 | + if (isset($_attr['cache_id'])) { |
|
| 174 | + $_cache_id = $_attr['cache_id']; |
|
| 175 | 175 | $call_nocache = true; |
| 176 | 176 | $_caching = $_new_caching; |
| 177 | 177 | } else { |
| 178 | 178 | $_cache_id = '$_smarty_tpl->cache_id'; |
| 179 | 179 | } |
| 180 | - if (isset($_attr[ 'compile_id' ])) { |
|
| 181 | - $_compile_id = $_attr[ 'compile_id' ]; |
|
| 180 | + if (isset($_attr['compile_id'])) { |
|
| 181 | + $_compile_id = $_attr['compile_id']; |
|
| 182 | 182 | } else { |
| 183 | 183 | $_compile_id = '$_smarty_tpl->compile_id'; |
| 184 | 184 | } |
@@ -188,31 +188,31 @@ discard block |
||
| 188 | 188 | $merge_compiled_includes = false; |
| 189 | 189 | } |
| 190 | 190 | // assign attribute |
| 191 | - if (isset($_attr[ 'assign' ])) { |
|
| 191 | + if (isset($_attr['assign'])) { |
|
| 192 | 192 | // output will be stored in a smarty variable instead of being displayed |
| 193 | - if ($_assign = $compiler->getId($_attr[ 'assign' ])) { |
|
| 193 | + if ($_assign = $compiler->getId($_attr['assign'])) { |
|
| 194 | 194 | $_assign = "'{$_assign}'"; |
| 195 | 195 | if ($compiler->tag_nocache || $compiler->nocache || $call_nocache) { |
| 196 | 196 | // create nocache var to make it know for further compiling |
| 197 | - $compiler->setNocacheInVariable($_attr[ 'assign' ]); |
|
| 197 | + $compiler->setNocacheInVariable($_attr['assign']); |
|
| 198 | 198 | } |
| 199 | 199 | } else { |
| 200 | - $_assign = $_attr[ 'assign' ]; |
|
| 200 | + $_assign = $_attr['assign']; |
|
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | $has_compiled_template = false; |
| 205 | 205 | if ($merge_compiled_includes) { |
| 206 | - $c_id = isset($_attr[ 'compile_id' ]) ? $_attr[ 'compile_id' ] : $compiler->template->compile_id; |
|
| 206 | + $c_id = isset($_attr['compile_id']) ? $_attr['compile_id'] : $compiler->template->compile_id; |
|
| 207 | 207 | // we must observe different compile_id and caching |
| 208 | 208 | $t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching')); |
| 209 | 209 | $compiler->smarty->allow_ambiguous_resources = true; |
| 210 | 210 | /* @var Smarty_Internal_Template $tpl */ |
| 211 | - $tpl = new $compiler->smarty->template_class (trim($fullResourceName, '"\''), $compiler->smarty, |
|
| 211 | + $tpl = new $compiler->smarty->template_class(trim($fullResourceName, '"\''), $compiler->smarty, |
|
| 212 | 212 | $compiler->template, $compiler->template->cache_id, $c_id, |
| 213 | 213 | $_caching); |
| 214 | 214 | $uid = $tpl->source->type . $tpl->source->uid; |
| 215 | - if (!isset($compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ])) { |
|
| 215 | + if (!isset($compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash])) { |
|
| 216 | 216 | $has_compiled_template = $this->compileInlineTemplate($compiler, $tpl, $t_hash); |
| 217 | 217 | } else { |
| 218 | 218 | $has_compiled_template = true; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | unset($tpl); |
| 221 | 221 | } |
| 222 | 222 | // delete {include} standard attributes |
| 223 | - unset($_attr[ 'file' ], $_attr[ 'assign' ], $_attr[ 'cache_id' ], $_attr[ 'compile_id' ], $_attr[ 'cache_lifetime' ], $_attr[ 'nocache' ], $_attr[ 'caching' ], $_attr[ 'scope' ], $_attr[ 'inline' ]); |
|
| 223 | + unset($_attr['file'], $_attr['assign'], $_attr['cache_id'], $_attr['compile_id'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope'], $_attr['inline']); |
|
| 224 | 224 | // remaining attributes must be assigned as smarty variable |
| 225 | 225 | $_vars = 'array()'; |
| 226 | 226 | if (!empty($_attr)) { |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | { |
| 296 | 296 | $uid = $tpl->source->type . $tpl->source->uid; |
| 297 | 297 | if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) { |
| 298 | - $compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'uid' ] = |
|
| 298 | + $compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['uid'] = |
|
| 299 | 299 | $tpl->source->uid; |
| 300 | 300 | if (isset($compiler->template->inheritance)) { |
| 301 | 301 | $tpl->inheritance = clone $compiler->template->inheritance; |
@@ -304,11 +304,11 @@ discard block |
||
| 304 | 304 | $tpl->compiled->nocache_hash = $compiler->parent_compiler->template->compiled->nocache_hash; |
| 305 | 305 | $tpl->loadCompiler(); |
| 306 | 306 | // save unique function name |
| 307 | - $compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'func' ] = |
|
| 307 | + $compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['func'] = |
|
| 308 | 308 | $tpl->compiled->unifunc = 'content_' . str_replace(array('.', ','), '_', uniqid('', true)); |
| 309 | 309 | // make sure whole chain gets compiled |
| 310 | 310 | $tpl->mustCompile = true; |
| 311 | - $compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'nocache_hash' ] = |
|
| 311 | + $compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['nocache_hash'] = |
|
| 312 | 312 | $tpl->compiled->nocache_hash; |
| 313 | 313 | if ($compiler->template->source->type == 'file') { |
| 314 | 314 | $sourceInfo = $compiler->template->source->filepath; |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | $compiled_code); |
| 337 | 337 | $compiler->template->compiled->has_nocache_code = true; |
| 338 | 338 | } |
| 339 | - $compiler->parent_compiler->mergedSubTemplatesCode[ $tpl->compiled->unifunc ] = $compiled_code; |
|
| 339 | + $compiler->parent_compiler->mergedSubTemplatesCode[$tpl->compiled->unifunc] = $compiled_code; |
|
| 340 | 340 | return true; |
| 341 | 341 | } else { |
| 342 | 342 | return false; |
@@ -11,193 +11,193 @@ |
||
| 11 | 11 | class Smarty_Internal_Runtime_SubTemplate |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Subtemplate template object cache |
|
| 16 | - * |
|
| 17 | - * @var Smarty_Internal_Template[] |
|
| 18 | - */ |
|
| 19 | - public $tplObjects = array(); |
|
| 14 | + /** |
|
| 15 | + * Subtemplate template object cache |
|
| 16 | + * |
|
| 17 | + * @var Smarty_Internal_Template[] |
|
| 18 | + */ |
|
| 19 | + public $tplObjects = array(); |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Subtemplate call count |
|
| 23 | - * |
|
| 24 | - * @var int[] |
|
| 25 | - */ |
|
| 26 | - public $subTplInfo = array(); |
|
| 21 | + /** |
|
| 22 | + * Subtemplate call count |
|
| 23 | + * |
|
| 24 | + * @var int[] |
|
| 25 | + */ |
|
| 26 | + public $subTplInfo = array(); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Runtime function to render subtemplate |
|
| 30 | - * |
|
| 31 | - * @param \Smarty_Internal_Template $parent |
|
| 32 | - * @param string $template template name |
|
| 33 | - * @param mixed $cache_id cache id |
|
| 34 | - * @param mixed $compile_id compile id |
|
| 35 | - * @param integer $caching cache mode |
|
| 36 | - * @param integer $cache_lifetime life time of cache data |
|
| 37 | - * @param array $data passed parameter template variables |
|
| 38 | - * @param int $scope scope in which {include} should execute |
|
| 39 | - * @param bool $forceTplCache cache template object |
|
| 40 | - * @param string $uid file dependency uid |
|
| 41 | - * @param string $content_func function name |
|
| 42 | - * |
|
| 43 | - */ |
|
| 44 | - public function render(Smarty_Internal_Template $parent, $template, $cache_id, $compile_id, $caching, |
|
| 45 | - $cache_lifetime, $data, $scope, $forceTplCache, $uid = null, $content_func = null) |
|
| 46 | - { |
|
| 47 | - // if there are cached template objects calculate $templateID |
|
| 48 | - $_templateId = |
|
| 49 | - !empty($this->tplObjects) ? $parent->smarty->_getTemplateId($template, $cache_id, $compile_id, $caching) : |
|
| 50 | - null; |
|
| 51 | - // already in template cache? |
|
| 52 | - /* @var Smarty_Internal_Template $tpl */ |
|
| 53 | - if (isset($_templateId) && isset($this->tplObjects[$_templateId])) { |
|
| 54 | - // clone cached template object because of possible recursive call |
|
| 55 | - $tpl = clone $this->tplObjects[$_templateId]; |
|
| 56 | - $tpl->parent = $parent; |
|
| 57 | - // if $caching mode changed the compiled resource is invalid |
|
| 58 | - if ((bool) $tpl->caching !== (bool) $caching) { |
|
| 59 | - unset($tpl->compiled); |
|
| 60 | - } |
|
| 61 | - // get variables from calling scope |
|
| 62 | - $tpl->tpl_vars = $parent->tpl_vars; |
|
| 63 | - $tpl->config_vars = $parent->config_vars; |
|
| 64 | - // get template functions |
|
| 65 | - $tpl->tpl_function = $parent->tpl_function; |
|
| 66 | - // copy inheritance object? |
|
| 67 | - if (isset($parent->ext->_inheritance)) { |
|
| 68 | - $tpl->ext->_inheritance = $parent->ext->_inheritance; |
|
| 69 | - } else { |
|
| 70 | - unset($tpl->ext->_inheritance); |
|
| 71 | - } |
|
| 72 | - } else { |
|
| 73 | - $tpl = clone $parent; |
|
| 74 | - $tpl->parent = $parent; |
|
| 75 | - if (!isset($tpl->templateId) || $tpl->templateId !== $_templateId) { |
|
| 76 | - $tpl->templateId = $_templateId; |
|
| 77 | - $tpl->template_resource = $template; |
|
| 78 | - $tpl->cache_id = $cache_id; |
|
| 79 | - $tpl->compile_id = $compile_id; |
|
| 80 | - if (isset($uid)) { |
|
| 81 | - // for inline templates we can get all resource information from file dependency |
|
| 82 | - if (isset($tpl->compiled->file_dependency[$uid])) { |
|
| 83 | - list($filepath, $timestamp, $resource) = $tpl->compiled->file_dependency[$uid]; |
|
| 84 | - $tpl->source = |
|
| 85 | - new Smarty_Template_Source(isset($tpl->smarty->_cache['resource_handlers'][$resource]) ? |
|
| 86 | - $tpl->smarty->_cache['resource_handlers'][$resource] : |
|
| 87 | - Smarty_Resource::load($tpl->smarty, $resource), $tpl->smarty, |
|
| 88 | - $filepath, $resource, $filepath); |
|
| 89 | - $tpl->source->filepath = $filepath; |
|
| 90 | - $tpl->source->timestamp = $timestamp; |
|
| 91 | - $tpl->source->exists = true; |
|
| 92 | - $tpl->source->uid = $uid; |
|
| 93 | - } else { |
|
| 94 | - $tpl->source = null; |
|
| 95 | - } |
|
| 96 | - } else { |
|
| 97 | - $tpl->source = null; |
|
| 98 | - } |
|
| 99 | - if (!isset($tpl->source)) { |
|
| 100 | - $tpl->source = Smarty_Template_Source::load($tpl); |
|
| 101 | - unset($tpl->compiled); |
|
| 102 | - } |
|
| 103 | - unset($tpl->cached); |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - $tpl->caching = $caching; |
|
| 107 | - $tpl->cache_lifetime = $cache_lifetime; |
|
| 108 | - if ($caching == 9999) { |
|
| 109 | - $tpl->cached = $parent->cached; |
|
| 110 | - } |
|
| 111 | - // set template scope |
|
| 112 | - $tpl->scope = $scope; |
|
| 113 | - $scopePtr = false; |
|
| 114 | - if ($scope & ~Smarty::SCOPE_BUBBLE_UP) { |
|
| 115 | - if ($scope == Smarty::SCOPE_GLOBAL) { |
|
| 116 | - $tpl->tpl_vars = Smarty::$global_tpl_vars; |
|
| 117 | - $tpl->config_vars = $tpl->smarty->config_vars; |
|
| 118 | - $scopePtr = true; |
|
| 119 | - } else { |
|
| 120 | - if ($scope == Smarty::SCOPE_PARENT) { |
|
| 121 | - $scopePtr = $parent; |
|
| 122 | - } elseif ($scope == Smarty::SCOPE_SMARTY) { |
|
| 123 | - $scopePtr = $tpl->smarty; |
|
| 124 | - } else { |
|
| 125 | - $scopePtr = $tpl; |
|
| 126 | - while (isset($scopePtr->parent)) { |
|
| 127 | - if ($scopePtr->parent->_objType != 2 && $scope & Smarty::SCOPE_TPL_ROOT) { |
|
| 128 | - break; |
|
| 129 | - } |
|
| 130 | - $scopePtr = $scopePtr->parent; |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - $tpl->tpl_vars = $scopePtr->tpl_vars; |
|
| 134 | - $tpl->config_vars = $scopePtr->config_vars; |
|
| 135 | - } |
|
| 136 | - } |
|
| 28 | + /** |
|
| 29 | + * Runtime function to render subtemplate |
|
| 30 | + * |
|
| 31 | + * @param \Smarty_Internal_Template $parent |
|
| 32 | + * @param string $template template name |
|
| 33 | + * @param mixed $cache_id cache id |
|
| 34 | + * @param mixed $compile_id compile id |
|
| 35 | + * @param integer $caching cache mode |
|
| 36 | + * @param integer $cache_lifetime life time of cache data |
|
| 37 | + * @param array $data passed parameter template variables |
|
| 38 | + * @param int $scope scope in which {include} should execute |
|
| 39 | + * @param bool $forceTplCache cache template object |
|
| 40 | + * @param string $uid file dependency uid |
|
| 41 | + * @param string $content_func function name |
|
| 42 | + * |
|
| 43 | + */ |
|
| 44 | + public function render(Smarty_Internal_Template $parent, $template, $cache_id, $compile_id, $caching, |
|
| 45 | + $cache_lifetime, $data, $scope, $forceTplCache, $uid = null, $content_func = null) |
|
| 46 | + { |
|
| 47 | + // if there are cached template objects calculate $templateID |
|
| 48 | + $_templateId = |
|
| 49 | + !empty($this->tplObjects) ? $parent->smarty->_getTemplateId($template, $cache_id, $compile_id, $caching) : |
|
| 50 | + null; |
|
| 51 | + // already in template cache? |
|
| 52 | + /* @var Smarty_Internal_Template $tpl */ |
|
| 53 | + if (isset($_templateId) && isset($this->tplObjects[$_templateId])) { |
|
| 54 | + // clone cached template object because of possible recursive call |
|
| 55 | + $tpl = clone $this->tplObjects[$_templateId]; |
|
| 56 | + $tpl->parent = $parent; |
|
| 57 | + // if $caching mode changed the compiled resource is invalid |
|
| 58 | + if ((bool) $tpl->caching !== (bool) $caching) { |
|
| 59 | + unset($tpl->compiled); |
|
| 60 | + } |
|
| 61 | + // get variables from calling scope |
|
| 62 | + $tpl->tpl_vars = $parent->tpl_vars; |
|
| 63 | + $tpl->config_vars = $parent->config_vars; |
|
| 64 | + // get template functions |
|
| 65 | + $tpl->tpl_function = $parent->tpl_function; |
|
| 66 | + // copy inheritance object? |
|
| 67 | + if (isset($parent->ext->_inheritance)) { |
|
| 68 | + $tpl->ext->_inheritance = $parent->ext->_inheritance; |
|
| 69 | + } else { |
|
| 70 | + unset($tpl->ext->_inheritance); |
|
| 71 | + } |
|
| 72 | + } else { |
|
| 73 | + $tpl = clone $parent; |
|
| 74 | + $tpl->parent = $parent; |
|
| 75 | + if (!isset($tpl->templateId) || $tpl->templateId !== $_templateId) { |
|
| 76 | + $tpl->templateId = $_templateId; |
|
| 77 | + $tpl->template_resource = $template; |
|
| 78 | + $tpl->cache_id = $cache_id; |
|
| 79 | + $tpl->compile_id = $compile_id; |
|
| 80 | + if (isset($uid)) { |
|
| 81 | + // for inline templates we can get all resource information from file dependency |
|
| 82 | + if (isset($tpl->compiled->file_dependency[$uid])) { |
|
| 83 | + list($filepath, $timestamp, $resource) = $tpl->compiled->file_dependency[$uid]; |
|
| 84 | + $tpl->source = |
|
| 85 | + new Smarty_Template_Source(isset($tpl->smarty->_cache['resource_handlers'][$resource]) ? |
|
| 86 | + $tpl->smarty->_cache['resource_handlers'][$resource] : |
|
| 87 | + Smarty_Resource::load($tpl->smarty, $resource), $tpl->smarty, |
|
| 88 | + $filepath, $resource, $filepath); |
|
| 89 | + $tpl->source->filepath = $filepath; |
|
| 90 | + $tpl->source->timestamp = $timestamp; |
|
| 91 | + $tpl->source->exists = true; |
|
| 92 | + $tpl->source->uid = $uid; |
|
| 93 | + } else { |
|
| 94 | + $tpl->source = null; |
|
| 95 | + } |
|
| 96 | + } else { |
|
| 97 | + $tpl->source = null; |
|
| 98 | + } |
|
| 99 | + if (!isset($tpl->source)) { |
|
| 100 | + $tpl->source = Smarty_Template_Source::load($tpl); |
|
| 101 | + unset($tpl->compiled); |
|
| 102 | + } |
|
| 103 | + unset($tpl->cached); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + $tpl->caching = $caching; |
|
| 107 | + $tpl->cache_lifetime = $cache_lifetime; |
|
| 108 | + if ($caching == 9999) { |
|
| 109 | + $tpl->cached = $parent->cached; |
|
| 110 | + } |
|
| 111 | + // set template scope |
|
| 112 | + $tpl->scope = $scope; |
|
| 113 | + $scopePtr = false; |
|
| 114 | + if ($scope & ~Smarty::SCOPE_BUBBLE_UP) { |
|
| 115 | + if ($scope == Smarty::SCOPE_GLOBAL) { |
|
| 116 | + $tpl->tpl_vars = Smarty::$global_tpl_vars; |
|
| 117 | + $tpl->config_vars = $tpl->smarty->config_vars; |
|
| 118 | + $scopePtr = true; |
|
| 119 | + } else { |
|
| 120 | + if ($scope == Smarty::SCOPE_PARENT) { |
|
| 121 | + $scopePtr = $parent; |
|
| 122 | + } elseif ($scope == Smarty::SCOPE_SMARTY) { |
|
| 123 | + $scopePtr = $tpl->smarty; |
|
| 124 | + } else { |
|
| 125 | + $scopePtr = $tpl; |
|
| 126 | + while (isset($scopePtr->parent)) { |
|
| 127 | + if ($scopePtr->parent->_objType != 2 && $scope & Smarty::SCOPE_TPL_ROOT) { |
|
| 128 | + break; |
|
| 129 | + } |
|
| 130 | + $scopePtr = $scopePtr->parent; |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + $tpl->tpl_vars = $scopePtr->tpl_vars; |
|
| 134 | + $tpl->config_vars = $scopePtr->config_vars; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - if (!isset($this->tplObjects[$tpl->_getTemplateId()]) && !$tpl->source->handler->recompiled) { |
|
| 139 | - // if template is called multiple times set flag to to cache template objects |
|
| 140 | - $forceTplCache = $forceTplCache || |
|
| 141 | - (isset($this->subTplInfo[$tpl->template_resource]) && $this->subTplInfo[$tpl->template_resource] > 1); |
|
| 142 | - // check if template object should be cached |
|
| 143 | - if ($tpl->parent->_objType == 2 && isset($this->tplObjects[$tpl->parent->templateId]) || |
|
| 144 | - ($forceTplCache && $tpl->smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_AUTOMATIC) || |
|
| 145 | - ($tpl->smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_ON) |
|
| 146 | - ) { |
|
| 147 | - $this->tplObjects[$tpl->_getTemplateId()] = $tpl; |
|
| 148 | - } |
|
| 149 | - } |
|
| 138 | + if (!isset($this->tplObjects[$tpl->_getTemplateId()]) && !$tpl->source->handler->recompiled) { |
|
| 139 | + // if template is called multiple times set flag to to cache template objects |
|
| 140 | + $forceTplCache = $forceTplCache || |
|
| 141 | + (isset($this->subTplInfo[$tpl->template_resource]) && $this->subTplInfo[$tpl->template_resource] > 1); |
|
| 142 | + // check if template object should be cached |
|
| 143 | + if ($tpl->parent->_objType == 2 && isset($this->tplObjects[$tpl->parent->templateId]) || |
|
| 144 | + ($forceTplCache && $tpl->smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_AUTOMATIC) || |
|
| 145 | + ($tpl->smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_ON) |
|
| 146 | + ) { |
|
| 147 | + $this->tplObjects[$tpl->_getTemplateId()] = $tpl; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - if (!empty($data)) { |
|
| 152 | - // set up variable values |
|
| 153 | - foreach ($data as $_key => $_val) { |
|
| 154 | - $tpl->tpl_vars[$_key] = new Smarty_Variable($_val); |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - if (isset($uid)) { |
|
| 158 | - if ($parent->smarty->debugging) { |
|
| 159 | - $parent->smarty->_debug->start_template($tpl); |
|
| 160 | - $parent->smarty->_debug->start_render($tpl); |
|
| 161 | - } |
|
| 162 | - $tpl->compiled->getRenderedTemplateCode($tpl, $content_func); |
|
| 163 | - if ($parent->smarty->debugging) { |
|
| 164 | - $parent->smarty->_debug->end_template($tpl); |
|
| 165 | - $parent->smarty->_debug->end_render($tpl); |
|
| 166 | - } |
|
| 167 | - if ($tpl->caching == 9999 && $tpl->compiled->has_nocache_code) { |
|
| 168 | - $parent->cached->hashes[$tpl->compiled->nocache_hash] = true; |
|
| 169 | - } |
|
| 170 | - } else { |
|
| 171 | - if (isset($tpl->compiled)) { |
|
| 172 | - $tpl->compiled->render($tpl); |
|
| 173 | - } else { |
|
| 174 | - $tpl->render(); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - if ($scopePtr) { |
|
| 178 | - if ($scope == Smarty::SCOPE_GLOBAL) { |
|
| 179 | - Smarty::$global_tpl_vars = $tpl->tpl_vars; |
|
| 180 | - $tpl->smarty->config_vars = $tpl->config_vars; |
|
| 181 | - } else { |
|
| 182 | - $scopePtr->tpl_vars = $tpl->tpl_vars; |
|
| 183 | - $scopePtr->config_vars = $tpl->config_vars; |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - } |
|
| 151 | + if (!empty($data)) { |
|
| 152 | + // set up variable values |
|
| 153 | + foreach ($data as $_key => $_val) { |
|
| 154 | + $tpl->tpl_vars[$_key] = new Smarty_Variable($_val); |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + if (isset($uid)) { |
|
| 158 | + if ($parent->smarty->debugging) { |
|
| 159 | + $parent->smarty->_debug->start_template($tpl); |
|
| 160 | + $parent->smarty->_debug->start_render($tpl); |
|
| 161 | + } |
|
| 162 | + $tpl->compiled->getRenderedTemplateCode($tpl, $content_func); |
|
| 163 | + if ($parent->smarty->debugging) { |
|
| 164 | + $parent->smarty->_debug->end_template($tpl); |
|
| 165 | + $parent->smarty->_debug->end_render($tpl); |
|
| 166 | + } |
|
| 167 | + if ($tpl->caching == 9999 && $tpl->compiled->has_nocache_code) { |
|
| 168 | + $parent->cached->hashes[$tpl->compiled->nocache_hash] = true; |
|
| 169 | + } |
|
| 170 | + } else { |
|
| 171 | + if (isset($tpl->compiled)) { |
|
| 172 | + $tpl->compiled->render($tpl); |
|
| 173 | + } else { |
|
| 174 | + $tpl->render(); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + if ($scopePtr) { |
|
| 178 | + if ($scope == Smarty::SCOPE_GLOBAL) { |
|
| 179 | + Smarty::$global_tpl_vars = $tpl->tpl_vars; |
|
| 180 | + $tpl->smarty->config_vars = $tpl->config_vars; |
|
| 181 | + } else { |
|
| 182 | + $scopePtr->tpl_vars = $tpl->tpl_vars; |
|
| 183 | + $scopePtr->config_vars = $tpl->config_vars; |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - /** |
|
| 189 | - * Get called subtemplates from compiled template and save call count |
|
| 190 | - * |
|
| 191 | - * @param \Smarty_Internal_Template $tpl |
|
| 192 | - */ |
|
| 193 | - public function registerSubTemplates(Smarty_Internal_Template $tpl) |
|
| 194 | - { |
|
| 195 | - foreach ($tpl->compiled->includes as $name => $count) { |
|
| 196 | - if (isset($this->subTplInfo[$name])) { |
|
| 197 | - $this->subTplInfo[$name] += $count; |
|
| 198 | - } else { |
|
| 199 | - $this->subTplInfo[$name] = $count; |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - } |
|
| 188 | + /** |
|
| 189 | + * Get called subtemplates from compiled template and save call count |
|
| 190 | + * |
|
| 191 | + * @param \Smarty_Internal_Template $tpl |
|
| 192 | + */ |
|
| 193 | + public function registerSubTemplates(Smarty_Internal_Template $tpl) |
|
| 194 | + { |
|
| 195 | + foreach ($tpl->compiled->includes as $name => $count) { |
|
| 196 | + if (isset($this->subTplInfo[$name])) { |
|
| 197 | + $this->subTplInfo[$name] += $count; |
|
| 198 | + } else { |
|
| 199 | + $this->subTplInfo[$name] = $count; |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | 203 | } |
@@ -46,8 +46,7 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | // if there are cached template objects calculate $templateID |
| 48 | 48 | $_templateId = |
| 49 | - !empty($this->tplObjects) ? $parent->smarty->_getTemplateId($template, $cache_id, $compile_id, $caching) : |
|
| 50 | - null; |
|
| 49 | + !empty($this->tplObjects) ? $parent->smarty->_getTemplateId($template, $cache_id, $compile_id, $caching) : null; |
|
| 51 | 50 | // already in template cache? |
| 52 | 51 | /* @var Smarty_Internal_Template $tpl */ |
| 53 | 52 | if (isset($_templateId) && isset($this->tplObjects[$_templateId])) { |
@@ -83,8 +82,7 @@ discard block |
||
| 83 | 82 | list($filepath, $timestamp, $resource) = $tpl->compiled->file_dependency[$uid]; |
| 84 | 83 | $tpl->source = |
| 85 | 84 | new Smarty_Template_Source(isset($tpl->smarty->_cache['resource_handlers'][$resource]) ? |
| 86 | - $tpl->smarty->_cache['resource_handlers'][$resource] : |
|
| 87 | - Smarty_Resource::load($tpl->smarty, $resource), $tpl->smarty, |
|
| 85 | + $tpl->smarty->_cache['resource_handlers'][$resource] : Smarty_Resource::load($tpl->smarty, $resource), $tpl->smarty, |
|
| 88 | 86 | $filepath, $resource, $filepath); |
| 89 | 87 | $tpl->source->filepath = $filepath; |
| 90 | 88 | $tpl->source->timestamp = $timestamp; |
@@ -16,80 +16,80 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | abstract class Smarty_Resource_Custom extends Smarty_Resource |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * fetch template and its modification time from data source |
|
| 21 | - * |
|
| 22 | - * @param string $name template name |
|
| 23 | - * @param string &$source template source |
|
| 24 | - * @param integer &$mtime template modification timestamp (epoch) |
|
| 25 | - */ |
|
| 26 | - abstract protected function fetch($name, &$source, &$mtime); |
|
| 19 | + /** |
|
| 20 | + * fetch template and its modification time from data source |
|
| 21 | + * |
|
| 22 | + * @param string $name template name |
|
| 23 | + * @param string &$source template source |
|
| 24 | + * @param integer &$mtime template modification timestamp (epoch) |
|
| 25 | + */ |
|
| 26 | + abstract protected function fetch($name, &$source, &$mtime); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Fetch template's modification timestamp from data source |
|
| 30 | - * {@internal implementing this method is optional. |
|
| 31 | - * Only implement it if modification times can be accessed faster than loading the complete template source.}} |
|
| 32 | - * |
|
| 33 | - * @param string $name template name |
|
| 34 | - * |
|
| 35 | - * @return integer|boolean timestamp (epoch) the template was modified, or false if not found |
|
| 36 | - */ |
|
| 37 | - protected function fetchTimestamp($name) |
|
| 38 | - { |
|
| 39 | - return null; |
|
| 40 | - } |
|
| 28 | + /** |
|
| 29 | + * Fetch template's modification timestamp from data source |
|
| 30 | + * {@internal implementing this method is optional. |
|
| 31 | + * Only implement it if modification times can be accessed faster than loading the complete template source.}} |
|
| 32 | + * |
|
| 33 | + * @param string $name template name |
|
| 34 | + * |
|
| 35 | + * @return integer|boolean timestamp (epoch) the template was modified, or false if not found |
|
| 36 | + */ |
|
| 37 | + protected function fetchTimestamp($name) |
|
| 38 | + { |
|
| 39 | + return null; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * populate Source Object with meta data from Resource |
|
| 44 | - * |
|
| 45 | - * @param Smarty_Template_Source $source source object |
|
| 46 | - * @param Smarty_Internal_Template $_template template object |
|
| 47 | - */ |
|
| 48 | - public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) |
|
| 49 | - { |
|
| 50 | - $source->filepath = $source->type . ':' . $source->name; |
|
| 51 | - $source->uid = sha1($source->type . ':' . $source->name); |
|
| 42 | + /** |
|
| 43 | + * populate Source Object with meta data from Resource |
|
| 44 | + * |
|
| 45 | + * @param Smarty_Template_Source $source source object |
|
| 46 | + * @param Smarty_Internal_Template $_template template object |
|
| 47 | + */ |
|
| 48 | + public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) |
|
| 49 | + { |
|
| 50 | + $source->filepath = $source->type . ':' . $source->name; |
|
| 51 | + $source->uid = sha1($source->type . ':' . $source->name); |
|
| 52 | 52 | |
| 53 | - $mtime = $this->fetchTimestamp($source->name); |
|
| 54 | - if ($mtime !== null) { |
|
| 55 | - $source->timestamp = $mtime; |
|
| 56 | - } else { |
|
| 57 | - $this->fetch($source->name, $content, $timestamp); |
|
| 58 | - $source->timestamp = isset($timestamp) ? $timestamp : false; |
|
| 59 | - if (isset($content)) { |
|
| 60 | - $source->content = $content; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - $source->exists = !!$source->timestamp; |
|
| 64 | - } |
|
| 53 | + $mtime = $this->fetchTimestamp($source->name); |
|
| 54 | + if ($mtime !== null) { |
|
| 55 | + $source->timestamp = $mtime; |
|
| 56 | + } else { |
|
| 57 | + $this->fetch($source->name, $content, $timestamp); |
|
| 58 | + $source->timestamp = isset($timestamp) ? $timestamp : false; |
|
| 59 | + if (isset($content)) { |
|
| 60 | + $source->content = $content; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + $source->exists = !!$source->timestamp; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Load template's source into current template object |
|
| 68 | - * |
|
| 69 | - * @param Smarty_Template_Source $source source object |
|
| 70 | - * |
|
| 71 | - * @return string template source |
|
| 72 | - * @throws SmartyException if source cannot be loaded |
|
| 73 | - */ |
|
| 74 | - public function getContent(Smarty_Template_Source $source) |
|
| 75 | - { |
|
| 76 | - $this->fetch($source->name, $content, $timestamp); |
|
| 77 | - if (isset($content)) { |
|
| 78 | - return $content; |
|
| 79 | - } |
|
| 66 | + /** |
|
| 67 | + * Load template's source into current template object |
|
| 68 | + * |
|
| 69 | + * @param Smarty_Template_Source $source source object |
|
| 70 | + * |
|
| 71 | + * @return string template source |
|
| 72 | + * @throws SmartyException if source cannot be loaded |
|
| 73 | + */ |
|
| 74 | + public function getContent(Smarty_Template_Source $source) |
|
| 75 | + { |
|
| 76 | + $this->fetch($source->name, $content, $timestamp); |
|
| 77 | + if (isset($content)) { |
|
| 78 | + return $content; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - throw new SmartyException("Unable to read template {$source->type} '{$source->name}'"); |
|
| 82 | - } |
|
| 81 | + throw new SmartyException("Unable to read template {$source->type} '{$source->name}'"); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Determine basename for compiled filename |
|
| 86 | - * |
|
| 87 | - * @param Smarty_Template_Source $source source object |
|
| 88 | - * |
|
| 89 | - * @return string resource's basename |
|
| 90 | - */ |
|
| 91 | - public function getBasename(Smarty_Template_Source $source) |
|
| 92 | - { |
|
| 93 | - return basename($source->name); |
|
| 94 | - } |
|
| 84 | + /** |
|
| 85 | + * Determine basename for compiled filename |
|
| 86 | + * |
|
| 87 | + * @param Smarty_Template_Source $source source object |
|
| 88 | + * |
|
| 89 | + * @return string resource's basename |
|
| 90 | + */ |
|
| 91 | + public function getBasename(Smarty_Template_Source $source) |
|
| 92 | + { |
|
| 93 | + return basename($source->name); |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -11,31 +11,31 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_ClearConfig |
| 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 a single or all config variables |
|
| 23 | - * |
|
| 24 | - * @api Smarty::clearConfig() |
|
| 25 | - * @link http://www.smarty.net/docs/en/api.clear.config.tpl |
|
| 26 | - * |
|
| 27 | - * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data |
|
| 28 | - * @param string|null $name variable name or null |
|
| 29 | - * |
|
| 30 | - * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty |
|
| 31 | - */ |
|
| 32 | - public function clearConfig(Smarty_Internal_Data $data, $name = null) |
|
| 33 | - { |
|
| 34 | - if (isset($name)) { |
|
| 35 | - unset($data->config_vars[ $name ]); |
|
| 36 | - } else { |
|
| 37 | - $data->config_vars = array(); |
|
| 38 | - } |
|
| 39 | - return $data; |
|
| 40 | - } |
|
| 21 | + /** |
|
| 22 | + * clear a single or all config variables |
|
| 23 | + * |
|
| 24 | + * @api Smarty::clearConfig() |
|
| 25 | + * @link http://www.smarty.net/docs/en/api.clear.config.tpl |
|
| 26 | + * |
|
| 27 | + * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data |
|
| 28 | + * @param string|null $name variable name or null |
|
| 29 | + * |
|
| 30 | + * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty |
|
| 31 | + */ |
|
| 32 | + public function clearConfig(Smarty_Internal_Data $data, $name = null) |
|
| 33 | + { |
|
| 34 | + if (isset($name)) { |
|
| 35 | + unset($data->config_vars[ $name ]); |
|
| 36 | + } else { |
|
| 37 | + $data->config_vars = array(); |
|
| 38 | + } |
|
| 39 | + return $data; |
|
| 40 | + } |
|
| 41 | 41 | } |
| 42 | 42 | \ No newline at end of file |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | public function clearConfig(Smarty_Internal_Data $data, $name = null) |
| 33 | 33 | { |
| 34 | 34 | if (isset($name)) { |
| 35 | - unset($data->config_vars[ $name ]); |
|
| 35 | + unset($data->config_vars[$name]); |
|
| 36 | 36 | } else { |
| 37 | 37 | $data->config_vars = array(); |
| 38 | 38 | } |
@@ -16,31 +16,31 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_CompileBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Register post compile callback to compile inheritance initialization code |
|
| 21 | - * |
|
| 22 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 23 | - * @param bool|false $initChildSequence if true force child template |
|
| 24 | - */ |
|
| 25 | - public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false) |
|
| 26 | - { |
|
| 27 | - if ($initChildSequence || !isset($compiler->_cache[ 'inheritanceInit' ])) { |
|
| 28 | - $compiler->registerPostCompileCallback(array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'), |
|
| 29 | - array($initChildSequence), 'inheritanceInit', $initChildSequence); |
|
| 19 | + /** |
|
| 20 | + * Register post compile callback to compile inheritance initialization code |
|
| 21 | + * |
|
| 22 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 23 | + * @param bool|false $initChildSequence if true force child template |
|
| 24 | + */ |
|
| 25 | + public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false) |
|
| 26 | + { |
|
| 27 | + if ($initChildSequence || !isset($compiler->_cache[ 'inheritanceInit' ])) { |
|
| 28 | + $compiler->registerPostCompileCallback(array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'), |
|
| 29 | + array($initChildSequence), 'inheritanceInit', $initChildSequence); |
|
| 30 | 30 | |
| 31 | - $compiler->_cache[ 'inheritanceInit' ] = true; |
|
| 32 | - } |
|
| 33 | - } |
|
| 31 | + $compiler->_cache[ 'inheritanceInit' ] = true; |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Compile inheritance initialization code as prefix |
|
| 37 | - * |
|
| 38 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 39 | - * @param bool|false $initChildSequence if true force child template |
|
| 40 | - */ |
|
| 41 | - static function postCompile(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false) |
|
| 42 | - { |
|
| 43 | - $compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->_loadInheritance();\n\$_smarty_tpl->inheritance->init(\$_smarty_tpl, " . |
|
| 44 | - var_export($initChildSequence, true) . ");\n?>\n"; |
|
| 45 | - } |
|
| 35 | + /** |
|
| 36 | + * Compile inheritance initialization code as prefix |
|
| 37 | + * |
|
| 38 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 39 | + * @param bool|false $initChildSequence if true force child template |
|
| 40 | + */ |
|
| 41 | + static function postCompile(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false) |
|
| 42 | + { |
|
| 43 | + $compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->_loadInheritance();\n\$_smarty_tpl->inheritance->init(\$_smarty_tpl, " . |
|
| 44 | + var_export($initChildSequence, true) . ");\n?>\n"; |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | \ No newline at end of file |
@@ -24,11 +24,11 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false) |
| 26 | 26 | { |
| 27 | - if ($initChildSequence || !isset($compiler->_cache[ 'inheritanceInit' ])) { |
|
| 27 | + if ($initChildSequence || !isset($compiler->_cache['inheritanceInit'])) { |
|
| 28 | 28 | $compiler->registerPostCompileCallback(array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'), |
| 29 | 29 | array($initChildSequence), 'inheritanceInit', $initChildSequence); |
| 30 | 30 | |
| 31 | - $compiler->_cache[ 'inheritanceInit' ] = true; |
|
| 31 | + $compiler->_cache['inheritanceInit'] = true; |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
@@ -18,90 +18,90 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Smarty_Internal_Resource_String extends Smarty_Resource |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * populate Source Object with meta data from Resource |
|
| 23 | - * |
|
| 24 | - * @param Smarty_Template_Source $source source object |
|
| 25 | - * @param Smarty_Internal_Template $_template template object |
|
| 26 | - * |
|
| 27 | - * @return void |
|
| 28 | - */ |
|
| 29 | - public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) |
|
| 30 | - { |
|
| 31 | - $source->uid = $source->filepath = sha1($source->name . $source->smarty->_joined_template_dir); |
|
| 32 | - $source->timestamp = $source->exists = true; |
|
| 33 | - } |
|
| 21 | + /** |
|
| 22 | + * populate Source Object with meta data from Resource |
|
| 23 | + * |
|
| 24 | + * @param Smarty_Template_Source $source source object |
|
| 25 | + * @param Smarty_Internal_Template $_template template object |
|
| 26 | + * |
|
| 27 | + * @return void |
|
| 28 | + */ |
|
| 29 | + public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) |
|
| 30 | + { |
|
| 31 | + $source->uid = $source->filepath = sha1($source->name . $source->smarty->_joined_template_dir); |
|
| 32 | + $source->timestamp = $source->exists = true; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Load template's source from $resource_name into current template object |
|
| 37 | - * |
|
| 38 | - * @uses decode() to decode base64 and urlencoded template_resources |
|
| 39 | - * |
|
| 40 | - * @param Smarty_Template_Source $source source object |
|
| 41 | - * |
|
| 42 | - * @return string template source |
|
| 43 | - */ |
|
| 44 | - public function getContent(Smarty_Template_Source $source) |
|
| 45 | - { |
|
| 46 | - return $this->decode($source->name); |
|
| 47 | - } |
|
| 35 | + /** |
|
| 36 | + * Load template's source from $resource_name into current template object |
|
| 37 | + * |
|
| 38 | + * @uses decode() to decode base64 and urlencoded template_resources |
|
| 39 | + * |
|
| 40 | + * @param Smarty_Template_Source $source source object |
|
| 41 | + * |
|
| 42 | + * @return string template source |
|
| 43 | + */ |
|
| 44 | + public function getContent(Smarty_Template_Source $source) |
|
| 45 | + { |
|
| 46 | + return $this->decode($source->name); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * decode base64 and urlencode |
|
| 51 | - * |
|
| 52 | - * @param string $string template_resource to decode |
|
| 53 | - * |
|
| 54 | - * @return string decoded template_resource |
|
| 55 | - */ |
|
| 56 | - protected function decode($string) |
|
| 57 | - { |
|
| 58 | - // decode if specified |
|
| 59 | - if (($pos = strpos($string, ':')) !== false) { |
|
| 60 | - if (!strncmp($string, 'base64', 6)) { |
|
| 61 | - return base64_decode(substr($string, 7)); |
|
| 62 | - } elseif (!strncmp($string, 'urlencode', 9)) { |
|
| 63 | - return urldecode(substr($string, 10)); |
|
| 64 | - } |
|
| 65 | - } |
|
| 49 | + /** |
|
| 50 | + * decode base64 and urlencode |
|
| 51 | + * |
|
| 52 | + * @param string $string template_resource to decode |
|
| 53 | + * |
|
| 54 | + * @return string decoded template_resource |
|
| 55 | + */ |
|
| 56 | + protected function decode($string) |
|
| 57 | + { |
|
| 58 | + // decode if specified |
|
| 59 | + if (($pos = strpos($string, ':')) !== false) { |
|
| 60 | + if (!strncmp($string, 'base64', 6)) { |
|
| 61 | + return base64_decode(substr($string, 7)); |
|
| 62 | + } elseif (!strncmp($string, 'urlencode', 9)) { |
|
| 63 | + return urldecode(substr($string, 10)); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - return $string; |
|
| 68 | - } |
|
| 67 | + return $string; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * modify resource_name according to resource handlers specifications |
|
| 72 | - * |
|
| 73 | - * @param Smarty $smarty Smarty instance |
|
| 74 | - * @param string $resource_name resource_name to make unique |
|
| 75 | - * @param boolean $isConfig flag for config resource |
|
| 76 | - * |
|
| 77 | - * @return string unique resource name |
|
| 78 | - */ |
|
| 79 | - public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) |
|
| 80 | - { |
|
| 81 | - return get_class($this) . '#' . $this->decode($resource_name); |
|
| 82 | - } |
|
| 70 | + /** |
|
| 71 | + * modify resource_name according to resource handlers specifications |
|
| 72 | + * |
|
| 73 | + * @param Smarty $smarty Smarty instance |
|
| 74 | + * @param string $resource_name resource_name to make unique |
|
| 75 | + * @param boolean $isConfig flag for config resource |
|
| 76 | + * |
|
| 77 | + * @return string unique resource name |
|
| 78 | + */ |
|
| 79 | + public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) |
|
| 80 | + { |
|
| 81 | + return get_class($this) . '#' . $this->decode($resource_name); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Determine basename for compiled filename |
|
| 86 | - * Always returns an empty string. |
|
| 87 | - * |
|
| 88 | - * @param Smarty_Template_Source $source source object |
|
| 89 | - * |
|
| 90 | - * @return string resource's basename |
|
| 91 | - */ |
|
| 92 | - public function getBasename(Smarty_Template_Source $source) |
|
| 93 | - { |
|
| 94 | - return ''; |
|
| 95 | - } |
|
| 84 | + /** |
|
| 85 | + * Determine basename for compiled filename |
|
| 86 | + * Always returns an empty string. |
|
| 87 | + * |
|
| 88 | + * @param Smarty_Template_Source $source source object |
|
| 89 | + * |
|
| 90 | + * @return string resource's basename |
|
| 91 | + */ |
|
| 92 | + public function getBasename(Smarty_Template_Source $source) |
|
| 93 | + { |
|
| 94 | + return ''; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - /* |
|
| 97 | + /* |
|
| 98 | 98 | * Disable timestamp checks for string resource. |
| 99 | 99 | * |
| 100 | 100 | * @return bool |
| 101 | 101 | */ |
| 102 | - public function checkTimestamps() |
|
| 103 | - { |
|
| 104 | - return false; |
|
| 105 | - } |
|
| 102 | + public function checkTimestamps() |
|
| 103 | + { |
|
| 104 | + return false; |
|
| 105 | + } |
|
| 106 | 106 | } |
| 107 | 107 | |
@@ -16,25 +16,25 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_CompileBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Compiles code for the {rdelim} tag |
|
| 21 | - * This tag does output the right delimiter. |
|
| 22 | - * |
|
| 23 | - * @param array $args array with attributes from parser |
|
| 24 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 25 | - * |
|
| 26 | - * @return string compiled code |
|
| 27 | - * @throws \SmartyCompilerException |
|
| 28 | - */ |
|
| 29 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 30 | - { |
|
| 31 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 32 | - if ($_attr[ 'nocache' ] === true) { |
|
| 33 | - $compiler->trigger_template_error('nocache option not allowed', null, true); |
|
| 34 | - } |
|
| 35 | - // this tag does not return compiled code |
|
| 36 | - $compiler->has_code = true; |
|
| 19 | + /** |
|
| 20 | + * Compiles code for the {rdelim} tag |
|
| 21 | + * This tag does output the right delimiter. |
|
| 22 | + * |
|
| 23 | + * @param array $args array with attributes from parser |
|
| 24 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 25 | + * |
|
| 26 | + * @return string compiled code |
|
| 27 | + * @throws \SmartyCompilerException |
|
| 28 | + */ |
|
| 29 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 30 | + { |
|
| 31 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 32 | + if ($_attr[ 'nocache' ] === true) { |
|
| 33 | + $compiler->trigger_template_error('nocache option not allowed', null, true); |
|
| 34 | + } |
|
| 35 | + // this tag does not return compiled code |
|
| 36 | + $compiler->has_code = true; |
|
| 37 | 37 | |
| 38 | - return $compiler->smarty->right_delimiter; |
|
| 39 | - } |
|
| 38 | + return $compiler->smarty->right_delimiter; |
|
| 39 | + } |
|
| 40 | 40 | } |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
| 30 | 30 | { |
| 31 | 31 | $_attr = $this->getAttributes($compiler, $args); |
| 32 | - if ($_attr[ 'nocache' ] === true) { |
|
| 32 | + if ($_attr['nocache'] === true) { |
|
| 33 | 33 | $compiler->trigger_template_error('nocache option not allowed', null, true); |
| 34 | 34 | } |
| 35 | 35 | // this tag does not return compiled code |
@@ -15,182 +15,182 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | abstract class Smarty_Internal_CompileBase |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Array of names of required attribute required by tag |
|
| 20 | - * |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - public $required_attributes = array(); |
|
| 18 | + /** |
|
| 19 | + * Array of names of required attribute required by tag |
|
| 20 | + * |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + public $required_attributes = array(); |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Array of names of optional attribute required by tag |
|
| 27 | - * use array('_any') if there is no restriction of attributes names |
|
| 28 | - * |
|
| 29 | - * @var array |
|
| 30 | - */ |
|
| 31 | - public $optional_attributes = array(); |
|
| 25 | + /** |
|
| 26 | + * Array of names of optional attribute required by tag |
|
| 27 | + * use array('_any') if there is no restriction of attributes names |
|
| 28 | + * |
|
| 29 | + * @var array |
|
| 30 | + */ |
|
| 31 | + public $optional_attributes = array(); |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Shorttag attribute order defined by its names |
|
| 35 | - * |
|
| 36 | - * @var array |
|
| 37 | - */ |
|
| 38 | - public $shorttag_order = array(); |
|
| 33 | + /** |
|
| 34 | + * Shorttag attribute order defined by its names |
|
| 35 | + * |
|
| 36 | + * @var array |
|
| 37 | + */ |
|
| 38 | + public $shorttag_order = array(); |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Array of names of valid option flags |
|
| 42 | - * |
|
| 43 | - * @var array |
|
| 44 | - */ |
|
| 45 | - public $option_flags = array('nocache'); |
|
| 40 | + /** |
|
| 41 | + * Array of names of valid option flags |
|
| 42 | + * |
|
| 43 | + * @var array |
|
| 44 | + */ |
|
| 45 | + public $option_flags = array('nocache'); |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Mapping array for boolqn option value |
|
| 49 | - * |
|
| 50 | - * @var array |
|
| 51 | - */ |
|
| 52 | - public $optionMap = array(1 => true, 0 => false, 'true' => true, 'false' => false); |
|
| 47 | + /** |
|
| 48 | + * Mapping array for boolqn option value |
|
| 49 | + * |
|
| 50 | + * @var array |
|
| 51 | + */ |
|
| 52 | + public $optionMap = array(1 => true, 0 => false, 'true' => true, 'false' => false); |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Mapping array with attributes as key |
|
| 56 | - * |
|
| 57 | - * @var array |
|
| 58 | - */ |
|
| 59 | - public $mapCache = array(); |
|
| 54 | + /** |
|
| 55 | + * Mapping array with attributes as key |
|
| 56 | + * |
|
| 57 | + * @var array |
|
| 58 | + */ |
|
| 59 | + public $mapCache = array(); |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * This function checks if the attributes passed are valid |
|
| 63 | - * The attributes passed for the tag to compile are checked against the list of required and |
|
| 64 | - * optional attributes. Required attributes must be present. Optional attributes are check against |
|
| 65 | - * the corresponding list. The keyword '_any' specifies that any attribute will be accepted |
|
| 66 | - * as valid |
|
| 67 | - * |
|
| 68 | - * @param object $compiler compiler object |
|
| 69 | - * @param array $attributes attributes applied to the tag |
|
| 70 | - * |
|
| 71 | - * @return array of mapped attributes for further processing |
|
| 72 | - */ |
|
| 73 | - public function getAttributes($compiler, $attributes) |
|
| 74 | - { |
|
| 75 | - $_indexed_attr = array(); |
|
| 76 | - if (!isset($this->mapCache[ 'option' ])) { |
|
| 77 | - $this->mapCache[ 'option' ] = array_fill_keys($this->option_flags, true); |
|
| 78 | - } |
|
| 79 | - foreach ($attributes as $key => $mixed) { |
|
| 80 | - // shorthand ? |
|
| 81 | - if (!is_array($mixed)) { |
|
| 82 | - // option flag ? |
|
| 83 | - if (isset($this->mapCache[ 'option' ][ trim($mixed, '\'"') ])) { |
|
| 84 | - $_indexed_attr[ trim($mixed, '\'"') ] = true; |
|
| 85 | - // shorthand attribute ? |
|
| 86 | - } elseif (isset($this->shorttag_order[ $key ])) { |
|
| 87 | - $_indexed_attr[ $this->shorttag_order[ $key ] ] = $mixed; |
|
| 88 | - } else { |
|
| 89 | - // too many shorthands |
|
| 90 | - $compiler->trigger_template_error('too many shorthand attributes', null, true); |
|
| 91 | - } |
|
| 92 | - // named attribute |
|
| 93 | - } else { |
|
| 94 | - foreach ($mixed as $k => $v) { |
|
| 95 | - // option flag? |
|
| 96 | - if (isset($this->mapCache[ 'option' ][ $k ])) { |
|
| 97 | - if (is_bool($v)) { |
|
| 98 | - $_indexed_attr[ $k ] = $v; |
|
| 99 | - } else { |
|
| 100 | - if (is_string($v)) { |
|
| 101 | - $v = trim($v, '\'" '); |
|
| 102 | - } |
|
| 103 | - if (isset($this->optionMap[ $v ])) { |
|
| 104 | - $_indexed_attr[ $k ] = $this->optionMap[ $v ]; |
|
| 105 | - } else { |
|
| 106 | - $compiler->trigger_template_error("illegal value '" . var_export($v, true) . |
|
| 107 | - "' for option flag '{$k}'", null, true); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - // must be named attribute |
|
| 111 | - } else { |
|
| 112 | - $_indexed_attr[ $k ] = $v; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - // check if all required attributes present |
|
| 118 | - foreach ($this->required_attributes as $attr) { |
|
| 119 | - if (!isset($_indexed_attr[ $attr ])) { |
|
| 120 | - $compiler->trigger_template_error("missing \"" . $attr . "\" attribute", null, true); |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - // check for not allowed attributes |
|
| 124 | - if ($this->optional_attributes != array('_any')) { |
|
| 125 | - if (!isset($this->mapCache[ 'all' ])) { |
|
| 126 | - $this->mapCache[ 'all' ] = |
|
| 127 | - array_fill_keys(array_merge($this->required_attributes, $this->optional_attributes, |
|
| 128 | - $this->option_flags), true); |
|
| 129 | - } |
|
| 130 | - foreach ($_indexed_attr as $key => $dummy) { |
|
| 131 | - if (!isset($this->mapCache[ 'all' ][ $key ]) && $key !== 0) { |
|
| 132 | - $compiler->trigger_template_error("unexpected \"" . $key . "\" attribute", null, true); |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - // default 'false' for all option flags not set |
|
| 137 | - foreach ($this->option_flags as $flag) { |
|
| 138 | - if (!isset($_indexed_attr[ $flag ])) { |
|
| 139 | - $_indexed_attr[ $flag ] = false; |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - if (isset($_indexed_attr[ 'nocache' ]) && $_indexed_attr[ 'nocache' ]) { |
|
| 143 | - $compiler->tag_nocache = true; |
|
| 144 | - } |
|
| 145 | - return $_indexed_attr; |
|
| 146 | - } |
|
| 61 | + /** |
|
| 62 | + * This function checks if the attributes passed are valid |
|
| 63 | + * The attributes passed for the tag to compile are checked against the list of required and |
|
| 64 | + * optional attributes. Required attributes must be present. Optional attributes are check against |
|
| 65 | + * the corresponding list. The keyword '_any' specifies that any attribute will be accepted |
|
| 66 | + * as valid |
|
| 67 | + * |
|
| 68 | + * @param object $compiler compiler object |
|
| 69 | + * @param array $attributes attributes applied to the tag |
|
| 70 | + * |
|
| 71 | + * @return array of mapped attributes for further processing |
|
| 72 | + */ |
|
| 73 | + public function getAttributes($compiler, $attributes) |
|
| 74 | + { |
|
| 75 | + $_indexed_attr = array(); |
|
| 76 | + if (!isset($this->mapCache[ 'option' ])) { |
|
| 77 | + $this->mapCache[ 'option' ] = array_fill_keys($this->option_flags, true); |
|
| 78 | + } |
|
| 79 | + foreach ($attributes as $key => $mixed) { |
|
| 80 | + // shorthand ? |
|
| 81 | + if (!is_array($mixed)) { |
|
| 82 | + // option flag ? |
|
| 83 | + if (isset($this->mapCache[ 'option' ][ trim($mixed, '\'"') ])) { |
|
| 84 | + $_indexed_attr[ trim($mixed, '\'"') ] = true; |
|
| 85 | + // shorthand attribute ? |
|
| 86 | + } elseif (isset($this->shorttag_order[ $key ])) { |
|
| 87 | + $_indexed_attr[ $this->shorttag_order[ $key ] ] = $mixed; |
|
| 88 | + } else { |
|
| 89 | + // too many shorthands |
|
| 90 | + $compiler->trigger_template_error('too many shorthand attributes', null, true); |
|
| 91 | + } |
|
| 92 | + // named attribute |
|
| 93 | + } else { |
|
| 94 | + foreach ($mixed as $k => $v) { |
|
| 95 | + // option flag? |
|
| 96 | + if (isset($this->mapCache[ 'option' ][ $k ])) { |
|
| 97 | + if (is_bool($v)) { |
|
| 98 | + $_indexed_attr[ $k ] = $v; |
|
| 99 | + } else { |
|
| 100 | + if (is_string($v)) { |
|
| 101 | + $v = trim($v, '\'" '); |
|
| 102 | + } |
|
| 103 | + if (isset($this->optionMap[ $v ])) { |
|
| 104 | + $_indexed_attr[ $k ] = $this->optionMap[ $v ]; |
|
| 105 | + } else { |
|
| 106 | + $compiler->trigger_template_error("illegal value '" . var_export($v, true) . |
|
| 107 | + "' for option flag '{$k}'", null, true); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + // must be named attribute |
|
| 111 | + } else { |
|
| 112 | + $_indexed_attr[ $k ] = $v; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + // check if all required attributes present |
|
| 118 | + foreach ($this->required_attributes as $attr) { |
|
| 119 | + if (!isset($_indexed_attr[ $attr ])) { |
|
| 120 | + $compiler->trigger_template_error("missing \"" . $attr . "\" attribute", null, true); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + // check for not allowed attributes |
|
| 124 | + if ($this->optional_attributes != array('_any')) { |
|
| 125 | + if (!isset($this->mapCache[ 'all' ])) { |
|
| 126 | + $this->mapCache[ 'all' ] = |
|
| 127 | + array_fill_keys(array_merge($this->required_attributes, $this->optional_attributes, |
|
| 128 | + $this->option_flags), true); |
|
| 129 | + } |
|
| 130 | + foreach ($_indexed_attr as $key => $dummy) { |
|
| 131 | + if (!isset($this->mapCache[ 'all' ][ $key ]) && $key !== 0) { |
|
| 132 | + $compiler->trigger_template_error("unexpected \"" . $key . "\" attribute", null, true); |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + // default 'false' for all option flags not set |
|
| 137 | + foreach ($this->option_flags as $flag) { |
|
| 138 | + if (!isset($_indexed_attr[ $flag ])) { |
|
| 139 | + $_indexed_attr[ $flag ] = false; |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + if (isset($_indexed_attr[ 'nocache' ]) && $_indexed_attr[ 'nocache' ]) { |
|
| 143 | + $compiler->tag_nocache = true; |
|
| 144 | + } |
|
| 145 | + return $_indexed_attr; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Push opening tag name on stack |
|
| 150 | - * Optionally additional data can be saved on stack |
|
| 151 | - * |
|
| 152 | - * @param object $compiler compiler object |
|
| 153 | - * @param string $openTag the opening tag's name |
|
| 154 | - * @param mixed $data optional data saved |
|
| 155 | - */ |
|
| 156 | - public function openTag($compiler, $openTag, $data = null) |
|
| 157 | - { |
|
| 158 | - array_push($compiler->_tag_stack, array($openTag, $data)); |
|
| 159 | - } |
|
| 148 | + /** |
|
| 149 | + * Push opening tag name on stack |
|
| 150 | + * Optionally additional data can be saved on stack |
|
| 151 | + * |
|
| 152 | + * @param object $compiler compiler object |
|
| 153 | + * @param string $openTag the opening tag's name |
|
| 154 | + * @param mixed $data optional data saved |
|
| 155 | + */ |
|
| 156 | + public function openTag($compiler, $openTag, $data = null) |
|
| 157 | + { |
|
| 158 | + array_push($compiler->_tag_stack, array($openTag, $data)); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * Pop closing tag |
|
| 163 | - * Raise an error if this stack-top doesn't match with expected opening tags |
|
| 164 | - * |
|
| 165 | - * @param object $compiler compiler object |
|
| 166 | - * @param array|string $expectedTag the expected opening tag names |
|
| 167 | - * |
|
| 168 | - * @return mixed any type the opening tag's name or saved data |
|
| 169 | - */ |
|
| 170 | - public function closeTag($compiler, $expectedTag) |
|
| 171 | - { |
|
| 172 | - if (count($compiler->_tag_stack) > 0) { |
|
| 173 | - // get stacked info |
|
| 174 | - list($_openTag, $_data) = array_pop($compiler->_tag_stack); |
|
| 175 | - // open tag must match with the expected ones |
|
| 176 | - if (in_array($_openTag, (array) $expectedTag)) { |
|
| 177 | - if (is_null($_data)) { |
|
| 178 | - // return opening tag |
|
| 179 | - return $_openTag; |
|
| 180 | - } else { |
|
| 181 | - // return restored data |
|
| 182 | - return $_data; |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - // wrong nesting of tags |
|
| 186 | - $compiler->trigger_template_error("unclosed {$compiler->smarty->left_delimiter}" . $_openTag . |
|
| 187 | - "{$compiler->smarty->right_delimiter} tag"); |
|
| 161 | + /** |
|
| 162 | + * Pop closing tag |
|
| 163 | + * Raise an error if this stack-top doesn't match with expected opening tags |
|
| 164 | + * |
|
| 165 | + * @param object $compiler compiler object |
|
| 166 | + * @param array|string $expectedTag the expected opening tag names |
|
| 167 | + * |
|
| 168 | + * @return mixed any type the opening tag's name or saved data |
|
| 169 | + */ |
|
| 170 | + public function closeTag($compiler, $expectedTag) |
|
| 171 | + { |
|
| 172 | + if (count($compiler->_tag_stack) > 0) { |
|
| 173 | + // get stacked info |
|
| 174 | + list($_openTag, $_data) = array_pop($compiler->_tag_stack); |
|
| 175 | + // open tag must match with the expected ones |
|
| 176 | + if (in_array($_openTag, (array) $expectedTag)) { |
|
| 177 | + if (is_null($_data)) { |
|
| 178 | + // return opening tag |
|
| 179 | + return $_openTag; |
|
| 180 | + } else { |
|
| 181 | + // return restored data |
|
| 182 | + return $_data; |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + // wrong nesting of tags |
|
| 186 | + $compiler->trigger_template_error("unclosed {$compiler->smarty->left_delimiter}" . $_openTag . |
|
| 187 | + "{$compiler->smarty->right_delimiter} tag"); |
|
| 188 | 188 | |
| 189 | - return; |
|
| 190 | - } |
|
| 191 | - // wrong nesting of tags |
|
| 192 | - $compiler->trigger_template_error("unexpected closing tag", null, true); |
|
| 189 | + return; |
|
| 190 | + } |
|
| 191 | + // wrong nesting of tags |
|
| 192 | + $compiler->trigger_template_error("unexpected closing tag", null, true); |
|
| 193 | 193 | |
| 194 | - return; |
|
| 195 | - } |
|
| 194 | + return; |
|
| 195 | + } |
|
| 196 | 196 | } |
@@ -73,18 +73,18 @@ discard block |
||
| 73 | 73 | public function getAttributes($compiler, $attributes) |
| 74 | 74 | { |
| 75 | 75 | $_indexed_attr = array(); |
| 76 | - if (!isset($this->mapCache[ 'option' ])) { |
|
| 77 | - $this->mapCache[ 'option' ] = array_fill_keys($this->option_flags, true); |
|
| 76 | + if (!isset($this->mapCache['option'])) { |
|
| 77 | + $this->mapCache['option'] = array_fill_keys($this->option_flags, true); |
|
| 78 | 78 | } |
| 79 | 79 | foreach ($attributes as $key => $mixed) { |
| 80 | 80 | // shorthand ? |
| 81 | 81 | if (!is_array($mixed)) { |
| 82 | 82 | // option flag ? |
| 83 | - if (isset($this->mapCache[ 'option' ][ trim($mixed, '\'"') ])) { |
|
| 84 | - $_indexed_attr[ trim($mixed, '\'"') ] = true; |
|
| 83 | + if (isset($this->mapCache['option'][trim($mixed, '\'"')])) { |
|
| 84 | + $_indexed_attr[trim($mixed, '\'"')] = true; |
|
| 85 | 85 | // shorthand attribute ? |
| 86 | - } elseif (isset($this->shorttag_order[ $key ])) { |
|
| 87 | - $_indexed_attr[ $this->shorttag_order[ $key ] ] = $mixed; |
|
| 86 | + } elseif (isset($this->shorttag_order[$key])) { |
|
| 87 | + $_indexed_attr[$this->shorttag_order[$key]] = $mixed; |
|
| 88 | 88 | } else { |
| 89 | 89 | // too many shorthands |
| 90 | 90 | $compiler->trigger_template_error('too many shorthand attributes', null, true); |
@@ -93,15 +93,15 @@ discard block |
||
| 93 | 93 | } else { |
| 94 | 94 | foreach ($mixed as $k => $v) { |
| 95 | 95 | // option flag? |
| 96 | - if (isset($this->mapCache[ 'option' ][ $k ])) { |
|
| 96 | + if (isset($this->mapCache['option'][$k])) { |
|
| 97 | 97 | if (is_bool($v)) { |
| 98 | - $_indexed_attr[ $k ] = $v; |
|
| 98 | + $_indexed_attr[$k] = $v; |
|
| 99 | 99 | } else { |
| 100 | 100 | if (is_string($v)) { |
| 101 | 101 | $v = trim($v, '\'" '); |
| 102 | 102 | } |
| 103 | - if (isset($this->optionMap[ $v ])) { |
|
| 104 | - $_indexed_attr[ $k ] = $this->optionMap[ $v ]; |
|
| 103 | + if (isset($this->optionMap[$v])) { |
|
| 104 | + $_indexed_attr[$k] = $this->optionMap[$v]; |
|
| 105 | 105 | } else { |
| 106 | 106 | $compiler->trigger_template_error("illegal value '" . var_export($v, true) . |
| 107 | 107 | "' for option flag '{$k}'", null, true); |
@@ -109,37 +109,37 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | // must be named attribute |
| 111 | 111 | } else { |
| 112 | - $_indexed_attr[ $k ] = $v; |
|
| 112 | + $_indexed_attr[$k] = $v; |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | // check if all required attributes present |
| 118 | 118 | foreach ($this->required_attributes as $attr) { |
| 119 | - if (!isset($_indexed_attr[ $attr ])) { |
|
| 119 | + if (!isset($_indexed_attr[$attr])) { |
|
| 120 | 120 | $compiler->trigger_template_error("missing \"" . $attr . "\" attribute", null, true); |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | // check for not allowed attributes |
| 124 | 124 | if ($this->optional_attributes != array('_any')) { |
| 125 | - if (!isset($this->mapCache[ 'all' ])) { |
|
| 126 | - $this->mapCache[ 'all' ] = |
|
| 125 | + if (!isset($this->mapCache['all'])) { |
|
| 126 | + $this->mapCache['all'] = |
|
| 127 | 127 | array_fill_keys(array_merge($this->required_attributes, $this->optional_attributes, |
| 128 | 128 | $this->option_flags), true); |
| 129 | 129 | } |
| 130 | 130 | foreach ($_indexed_attr as $key => $dummy) { |
| 131 | - if (!isset($this->mapCache[ 'all' ][ $key ]) && $key !== 0) { |
|
| 131 | + if (!isset($this->mapCache['all'][$key]) && $key !== 0) { |
|
| 132 | 132 | $compiler->trigger_template_error("unexpected \"" . $key . "\" attribute", null, true); |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | // default 'false' for all option flags not set |
| 137 | 137 | foreach ($this->option_flags as $flag) { |
| 138 | - if (!isset($_indexed_attr[ $flag ])) { |
|
| 139 | - $_indexed_attr[ $flag ] = false; |
|
| 138 | + if (!isset($_indexed_attr[$flag])) { |
|
| 139 | + $_indexed_attr[$flag] = false; |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | - if (isset($_indexed_attr[ 'nocache' ]) && $_indexed_attr[ 'nocache' ]) { |
|
| 142 | + if (isset($_indexed_attr['nocache']) && $_indexed_attr['nocache']) { |
|
| 143 | 143 | $compiler->tag_nocache = true; |
| 144 | 144 | } |
| 145 | 145 | return $_indexed_attr; |
@@ -11,30 +11,30 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_UnregisterObject |
| 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 plugin to be used in templates |
|
| 23 | - * |
|
| 24 | - * @api Smarty::unregisterObject() |
|
| 25 | - * @link http://www.smarty.net/docs/en/api.unregister.object.tpl |
|
| 26 | - * |
|
| 27 | - * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 28 | - * @param string $object_name name of object |
|
| 29 | - * |
|
| 30 | - * @return \Smarty|\Smarty_Internal_Template |
|
| 31 | - */ |
|
| 32 | - public function unregisterObject(Smarty_Internal_TemplateBase $obj, $object_name) |
|
| 33 | - { |
|
| 34 | - $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 35 | - if (isset($smarty->registered_objects[ $object_name ])) { |
|
| 36 | - unset($smarty->registered_objects[ $object_name ]); |
|
| 37 | - } |
|
| 38 | - return $obj; |
|
| 39 | - } |
|
| 21 | + /** |
|
| 22 | + * Registers plugin to be used in templates |
|
| 23 | + * |
|
| 24 | + * @api Smarty::unregisterObject() |
|
| 25 | + * @link http://www.smarty.net/docs/en/api.unregister.object.tpl |
|
| 26 | + * |
|
| 27 | + * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 28 | + * @param string $object_name name of object |
|
| 29 | + * |
|
| 30 | + * @return \Smarty|\Smarty_Internal_Template |
|
| 31 | + */ |
|
| 32 | + public function unregisterObject(Smarty_Internal_TemplateBase $obj, $object_name) |
|
| 33 | + { |
|
| 34 | + $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 35 | + if (isset($smarty->registered_objects[ $object_name ])) { |
|
| 36 | + unset($smarty->registered_objects[ $object_name ]); |
|
| 37 | + } |
|
| 38 | + return $obj; |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | \ No newline at end of file |
@@ -32,8 +32,8 @@ |
||
| 32 | 32 | public function unregisterObject(Smarty_Internal_TemplateBase $obj, $object_name) |
| 33 | 33 | { |
| 34 | 34 | $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
| 35 | - if (isset($smarty->registered_objects[ $object_name ])) { |
|
| 36 | - unset($smarty->registered_objects[ $object_name ]); |
|
| 35 | + if (isset($smarty->registered_objects[$object_name])) { |
|
| 36 | + unset($smarty->registered_objects[$object_name]); |
|
| 37 | 37 | } |
| 38 | 38 | return $obj; |
| 39 | 39 | } |