61 public function compile($args, $compiler, $parameter)
66 $include_file = $_attr[
'file'];
68 if (isset($_attr[
'assign'])) {
70 $_assign = $_attr[
'assign'];
74 if (isset($_attr[
'scope'])) {
75 $_attr[
'scope'] = trim($_attr[
'scope'],
"'\"");
76 if ($_attr[
'scope'] ==
'parent') {
78 }
elseif ($_attr[
'scope'] ==
'root') {
80 }
elseif ($_attr[
'scope'] ==
'global') {
85 if ($compiler->nocache || $compiler->tag_nocache) {
89 if ($compiler->template->caching && !$compiler->nocache && !$compiler->tag_nocache) {
90 $_caching = self::CACHING_NOCACHE_CODE;
97 if (isset($_attr[
'cache_lifetime'])) {
98 $_cache_lifetime = $_attr[
'cache_lifetime'];
99 $compiler->tag_nocache =
true;
102 $_cache_lifetime =
'null';
104 if (isset($_attr[
'cache_id'])) {
105 $_cache_id = $_attr[
'cache_id'];
106 $compiler->tag_nocache =
true;
109 $_cache_id =
'$_smarty_tpl->cache_id';
111 if (isset($_attr[
'compile_id'])) {
112 $_compile_id = $_attr[
'compile_id'];
114 $_compile_id =
'$_smarty_tpl->compile_id';
116 if ($_attr[
'caching'] ===
true) {
119 if ($_attr[
'nocache'] ===
true) {
120 $compiler->tag_nocache =
true;
124 $has_compiled_template =
false;
125 if (($compiler->smarty->merge_compiled_includes || $_attr[
'inline'] ===
true) && !$compiler->template->source->recompiled
128 if (!$compiler->has_variable_string && (substr_count($include_file,
'"') == 2 or substr_count($include_file,
"'") == 2)
129 and substr_count($include_file,
'(') == 0 and substr_count($include_file,
'$_smarty_tpl->') == 0) {
131 eval(
"\$tpl_name = $include_file;");
132 if (!isset($compiler->smarty->merged_templates_func[$tpl_name]) || $compiler->inheritance) {
133 $tpl =
new $compiler->smarty->template_class ($tpl_name, $compiler->smarty, $compiler->template, $compiler->template->cache_id, $compiler->template->compile_id);
135 $compiler->smarty->merged_templates_func[$tpl_name][
'func'] =
$tpl->properties[
'unifunc'] =
'content_'. str_replace(
'.',
'_', uniqid(
'',
true));
137 $compiler->smarty->merged_templates_func[$tpl_name][
'nocache_hash'] =
$tpl->properties[
'nocache_hash'] = $compiler->template->properties[
'nocache_hash'];
138 if ($compiler->template->caching) {
140 $tpl->caching = self::CACHING_NOCACHE_CODE;
143 $tpl->mustCompile =
true;
144 if (!(
$tpl->source->uncompiled) &&
$tpl->source->exists) {
146 $compiled_code =
$tpl->compiler->compileTemplate(
$tpl);
148 unset(
$tpl->compiler);
150 $compiler->template->properties[
'function'] = array_merge($compiler->template->properties[
'function'],
$tpl->properties[
'function']);
152 $tpl->properties[
'file_dependency'][
$tpl->source->uid] = array(
$tpl->source->filepath,
$tpl->source->timestamp,
$tpl->source->type);
153 $compiler->template->properties[
'file_dependency'] = array_merge($compiler->template->properties[
'file_dependency'],
$tpl->properties[
'file_dependency']);
155 $compiled_code = preg_replace(
"/(<\?php \/\*%%SmartyHeaderCode:{$tpl->properties['nocache_hash']}%%\*\/(.+?)\/\*\/%%SmartyHeaderCode%%\*\/\?>\n)/s",
'', $compiled_code);
156 if (
$tpl->has_nocache_code) {
158 $compiled_code = str_replace(
"{$tpl->properties['nocache_hash']}", $compiler->template->properties[
'nocache_hash'], $compiled_code);
159 $compiler->template->has_nocache_code =
true;
161 $compiler->merged_templates[
$tpl->properties[
'unifunc']] = $compiled_code;
162 $has_compiled_template =
true;
165 $has_compiled_template =
true;
170 unset($_attr[
'file'], $_attr[
'assign'], $_attr[
'cache_id'], $_attr[
'compile_id'], $_attr[
'cache_lifetime'], $_attr[
'nocache'], $_attr[
'caching'], $_attr[
'scope'], $_attr[
'inline']);
172 if (!empty($_attr)) {
175 foreach ($_attr as $key => $value) {
176 $_pairs[] =
"'$key'=>$value";
178 $_vars =
'array('.join(
',',$_pairs).
')';
181 $compiler->trigger_template_error(
'variable passing not allowed in parent/global scope', $compiler->lex->taglineno);
187 if ($has_compiled_template) {
188 $_hash = $compiler->smarty->merged_templates_func[$tpl_name][
'nocache_hash'];
189 $_output =
"<?php /* Call merged included template \"" . $tpl_name .
"\" */\n";
190 $_output .=
"\$_tpl_stack[] = \$_smarty_tpl;\n";
191 $_output .=
" \$_smarty_tpl = \$_smarty_tpl->setupInlineSubTemplate($include_file, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_parent_scope, '$_hash');\n";
192 if (isset($_assign)) {
193 $_output .=
'ob_start(); ';
195 $_output .= $compiler->smarty->merged_templates_func[$tpl_name][
'func'].
"(\$_smarty_tpl);\n";
196 $_output .=
"\$_smarty_tpl = array_pop(\$_tpl_stack); ";
197 if (isset($_assign)) {
198 $_output .=
" \$_smarty_tpl->tpl_vars[$_assign] = new Smarty_variable(ob_get_clean());";
200 $_output .=
"/* End of included template \"" . $tpl_name .
"\" */?>";
205 if (isset($_assign)) {
206 $_output =
"<?php \$_smarty_tpl->tpl_vars[$_assign] = new Smarty_variable(\$_smarty_tpl->getSubTemplate ($include_file, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_parent_scope));?>\n";;
208 $_output =
"<?php echo \$_smarty_tpl->getSubTemplate ($include_file, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_parent_scope);?>\n";
const CACHING_OFF
define caching modes
if(!empty($_GET['id'])) if(isset($_POST['form_name'], $_POST['form_subject'], $_POST['form_text'], $_POST['form_lang'])&&empty($_GET['id'])) if(empty($_GET['id'])) $tpl
getAttributes($compiler, $attributes)
This function checks if the attributes passed are valid.
compile($args, $compiler, $parameter)
Compiles code for the {include} tag.
const CACHING_LIFETIME_CURRENT
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
const CACHING_NOCACHE_CODE
caching mode to create nocache code but no cache file
const SCOPE_LOCAL
define variable scopes