68 $include_file = $_attr[
'file'];
70 if (isset($_attr[
'assign'])) {
72 $_assign = $_attr[
'assign'];
76 if (isset($_attr[
'scope'])) {
77 $_attr[
'scope'] = trim($_attr[
'scope'],
"'\"");
78 if ($_attr[
'scope'] ==
'parent') {
80 } elseif ($_attr[
'scope'] ==
'root') {
82 } elseif ($_attr[
'scope'] ==
'global') {
90 if ($_attr[
'nocache'] ===
true) {
91 $compiler->tag_nocache =
true;
94 $call_nocache = $compiler->tag_nocache || $compiler->nocache;
97 if ($compiler->template->caching && !$compiler->nocache && !$compiler->tag_nocache) {
98 $_caching = self::CACHING_NOCACHE_CODE;
102 $merge_compiled_includes = ($compiler->smarty->merge_compiled_includes || ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes) || $_attr[
'inline'] ===
true) && !$compiler->template->source->recompiled;
104 if ($merge_compiled_includes && $_attr[
'inline'] !==
true) {
106 if ($compiler->has_variable_string || !((substr_count($include_file,
'"') == 2 || substr_count($include_file,
"'") == 2)) || substr_count($include_file,
'(') != 0 || substr_count($include_file,
'$_smarty_tpl->') != 0) {
107 $merge_compiled_includes =
false;
108 if ($compiler->template->caching) {
112 if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes && $_attr[
'inline'] !==
true) {
117 if (isset($_attr[
'compile_id'])) {
118 if (!((substr_count($_attr[
'compile_id'],
'"') == 2 || substr_count($_attr[
'compile_id'],
"'") == 2 || is_numeric($_attr[
'compile_id']))) || substr_count($_attr[
'compile_id'],
'(') != 0 || substr_count($_attr[
'compile_id'],
'$_smarty_tpl->') != 0) {
119 $merge_compiled_includes =
false;
120 if ($compiler->template->caching) {
124 if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes && $_attr[
'inline'] !==
true) {
137 if ($_attr[
'nocache'] !==
true && $_attr[
'caching']) {
138 $_caching = $_new_caching = (int) $_attr[
'caching'];
139 $call_nocache =
true;
143 if (isset($_attr[
'cache_lifetime'])) {
144 $_cache_lifetime = $_attr[
'cache_lifetime'];
145 $call_nocache =
true;
146 $_caching = $_new_caching;
148 $_cache_lifetime =
'$_smarty_tpl->cache_lifetime';
150 if (isset($_attr[
'cache_id'])) {
151 $_cache_id = $_attr[
'cache_id'];
152 $call_nocache =
true;
153 $_caching = $_new_caching;
155 $_cache_id =
'$_smarty_tpl->cache_id';
157 if (isset($_attr[
'compile_id'])) {
158 $_compile_id = $_attr[
'compile_id'];
160 $_compile_id =
'$_smarty_tpl->compile_id';
164 if ($compiler->template->caching && $call_nocache) {
165 $merge_compiled_includes =
false;
168 $has_compiled_template =
false;
169 if ($merge_compiled_includes) {
170 if ($compiler->template->caching && ($compiler->tag_nocache || $compiler->nocache) && $_caching != self::CACHING_NOCACHE_CODE) {
172 if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes) {
176 $c_id = isset($_attr[
'compile_id']) ? $_attr[
'compile_id'] : $compiler->template->compile_id;
178 $uid = sha1($c_id . ($_caching ?
'--caching' :
'--nocaching'));
184 $_smarty_tpl = $compiler->template;
185 eval(
"\$tpl_name = $include_file;");
186 if (!isset($compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid])) {
187 $compiler->smarty->allow_ambiguous_resources =
true;
188 $tpl =
new $compiler->smarty->template_class ($tpl_name, $compiler->smarty, $compiler->template, $compiler->template->cache_id, $c_id, $_caching);
190 $compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid][
'func'] = $tpl->properties[
'unifunc'] =
'content_' . str_replace(array(
'.',
','),
'_', uniqid(
'',
true));
191 if ($compiler->inheritance) {
192 $tpl->compiler->inheritance =
true;
195 $tpl->mustCompile =
true;
196 if (!($tpl->source->uncompiled) && $tpl->source->exists) {
197 $tpl->compiler->suppressTemplatePropertyHeader =
true;
198 $compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid][
'nocache_hash'] = $tpl->properties[
'nocache_hash'] = str_replace(array(
'.',
','),
'_', uniqid(rand(),
true));
201 unset($tpl->compiler);
204 $compiled_code = preg_replace(
"/(<\?php \/\*%%SmartyHeaderCode:{$tpl->properties['nocache_hash']}%%\*\/(.+?)\/\*\/%%SmartyHeaderCode%%\*\/\?>\n)/s",
'', $compiled_code);
205 if ($tpl->has_nocache_code) {
207 $compiled_code = str_replace(
"{$tpl->properties['nocache_hash']}", $compiler->template->properties[
'nocache_hash'], $compiled_code);
208 $compiler->template->has_nocache_code =
true;
210 $compiler->parent_compiler->mergedSubTemplatesCode[$tpl->properties[
'unifunc']] = $compiled_code;
211 $has_compiled_template =
true;
212 if (!empty($tpl->required_plugins[
'compiled'])) {
213 foreach ($tpl->required_plugins[
'compiled'] as $name => $callBack) {
214 if (!isset($compiler->template->required_plugins[
'compiled'][$name])) {
215 $compiler->template->required_plugins[
'compiled'][$name] = $callBack;
219 if (!empty($tpl->required_plugins[
'nocache'])) {
220 foreach ($tpl->required_plugins[
'nocache'] as $name => $callBack) {
221 if (!isset($compiler->template->required_plugins[
'nocache'][$name])) {
222 $compiler->template->required_plugins[
'nocache'][$name] = $callBack;
229 $has_compiled_template =
true;
233 unset($_attr[
'file'], $_attr[
'assign'], $_attr[
'cache_id'], $_attr[
'compile_id'], $_attr[
'cache_lifetime'], $_attr[
'nocache'], $_attr[
'caching'], $_attr[
'scope'], $_attr[
'inline']);
236 if (!empty($_attr)) {
240 foreach ($_attr as $key => $value) {
241 $_pairs[] =
"'$key'=>$value";
242 $_vars_nc .=
"\$_smarty_tpl->tpl_vars['$key'] = new Smarty_Variable($value);\n";
244 $_vars =
'array(' . join(
',', $_pairs) .
')';
246 $compiler->
trigger_template_error(
'variable passing not allowed in parent/global scope', $compiler->lex->taglineno);
251 $update_compile_id = $compiler->template->caching && !$compiler->tag_nocache && !$compiler->nocache && $_compile_id !=
'$_smarty_tpl->compile_id';
252 if ($has_compiled_template && !$call_nocache) {
256 $_hash = $compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid][
'nocache_hash'];
257 $_output =
"<?php /* Call merged included template \"" . $tpl_name .
"\" */\n";
258 if ($update_compile_id) {
259 $_output .= $compiler->
makeNocacheCode(
"\$_compile_id_save[] = \$_smarty_tpl->compile_id;\n\$_smarty_tpl->compile_id = {$_compile_id};\n");
261 if (!empty($_vars_nc) && $_caching == 9999 && $_smarty_tpl->caching) {
263 $_output .= substr($compiler->
processNocacheCode(
'<?php ' . $_vars_nc .
"?>\n",
true), 6, - 3);
266 if (isset($_assign)) {
267 $_output .=
" \$_smarty_tpl->tpl_vars[$_assign] = new Smarty_Variable(\$_smarty_tpl->getInlineSubTemplate({$include_file}, {$_cache_id}, {$_compile_id}, {$_caching}, {$_cache_lifetime}, {$_vars}, {$_parent_scope}, '{$_hash}', '{$compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid]['func']}'));\n";
269 $_output .=
"echo \$_smarty_tpl->getInlineSubTemplate({$include_file}, {$_cache_id}, {$_compile_id}, {$_caching}, {$_cache_lifetime}, {$_vars}, {$_parent_scope}, '{$_hash}', '{$compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid]['func']}');\n";
271 if ($update_compile_id) {
272 $_output .= $compiler->
makeNocacheCode(
"\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n");
274 $_output .=
"/* End of included template \"" . $tpl_name .
"\" */?>\n";
280 $compiler->tag_nocache =
true;
283 if ($update_compile_id) {
284 $_output .=
"\$_compile_id_save[] = \$_smarty_tpl->compile_id;\n\$_smarty_tpl->compile_id = {$_compile_id};\n";
287 if (isset($_assign)) {
288 $_output .=
"\$_smarty_tpl->tpl_vars[$_assign] = new Smarty_Variable(\$_smarty_tpl->getSubTemplate ($include_file, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_parent_scope));\n";
290 $_output .=
"echo \$_smarty_tpl->getSubTemplate ($include_file, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_parent_scope);\n";
292 if ($update_compile_id) {
293 $_output .=
"\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n";