51 static $_is_stringy = array(
'string' =>
true,
'eval' =>
true);
52 $this->_rdl = preg_quote($compiler->smarty->right_delimiter);
53 $this->_ldl = preg_quote($compiler->smarty->left_delimiter);
54 if (!$compiler->smarty->auto_literal) {
59 $filepath = $compiler->template->source->filepath;
60 $this->mbstring_overload = ini_get(
'mbstring.func_overload') & 2;
63 if ($_attr[
'nocache'] ===
true) {
64 $compiler->trigger_template_error(
'nocache option not allowed', $compiler->lex->taglineno);
67 $_smarty_tpl = $compiler->template;
69 if (strpos($_attr[
'file'],
'$_tmp') !==
false) {
70 $compiler->trigger_template_error(
'illegal value for file attribute', $compiler->lex->taglineno);
72 eval(
'$include_file = ' . $_attr[
'file'] .
';');
74 $_template =
new $compiler->smarty->template_class($include_file, $compiler->smarty, $compiler->template);
76 if (isset($_is_stringy[$_template->source->type])) {
77 $template_sha1 = sha1($include_file);
79 $template_sha1 = sha1($_template->source->filepath);
81 if (isset($compiler->template->properties[
'file_dependency'][$template_sha1])) {
82 $compiler->trigger_template_error(
"illegal recursive call of \"{$include_file}\"", $compiler->lex->line - 1);
84 $compiler->template->properties[
'file_dependency'][$template_sha1] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type);
85 $_content = ($this->mbstring_overload ? mb_substr($compiler->lex->data, $compiler->lex->counter - 1, 20000000,
'latin1') : substr($compiler->lex->data, $compiler->lex->counter - 1));
86 if (preg_match_all(
"!({$this->_ldl}{$al}block\s(.+?)\s*{$this->_rdl})!", $_content, $s) !=
87 preg_match_all(
"!({$this->_ldl}{$al}/block\s*{$this->_rdl})!", $_content, $c)) {
88 $compiler->trigger_template_error(
'unmatched {block} {/block} pairs');
90 preg_match_all(
"!{$this->_ldl}{$al}block\s(.+?)\s*{$this->_rdl}|{$this->_ldl}{$al}/block\s*{$this->_rdl}|{$this->_ldl}\*([\S\s]*?)\*{$this->_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
91 $_result_count = count($_result[0]);
93 while ($_start+1 < $_result_count) {
96 if (($this->mbstring_overload ? mb_substr($_result[0][$_start][0],0,mb_strlen($compiler->smarty->left_delimiter,
'latin1')+1,
'latin1') : substr($_result[0][$_start][0],0,strlen($compiler->smarty->left_delimiter)+1)) == $compiler->smarty->left_delimiter.
'*') {
100 while ($_level != 0) {
102 if (($this->mbstring_overload ? mb_substr($_result[0][$_start + $_end][0],0,mb_strlen($compiler->smarty->left_delimiter,
'latin1')+1,
'latin1') : substr($_result[0][$_start + $_end][0],0,strlen($compiler->smarty->left_delimiter)+1)) == $compiler->smarty->left_delimiter.
'*') {
105 if (!strpos($_result[0][$_start + $_end][0],
'/')) {
111 $_block_content = str_replace($compiler->smarty->left_delimiter .
'$smarty.block.parent' . $compiler->smarty->right_delimiter,
'%%%%SMARTY_PARENT%%%%',
112 ($this->mbstring_overload ? mb_substr($_content, $_result[0][$_start][1] + mb_strlen($_result[0][$_start][0],
'latin1'), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + mb_strlen($_result[0][$_start][0],
'latin1'),
'latin1') : substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + strlen($_result[0][$_start][0]))));
114 $_start = $_start + $_end + 1;
116 if ($_template->source->type ==
'extends') {
117 $_template->block_data = $compiler->template->block_data;
119 $compiler->template->source->content = $_template->source->content;
120 if ($_template->source->type ==
'extends') {
121 $compiler->template->block_data = $_template->block_data;
122 foreach ($_template->source->components as $key => $component) {
123 $compiler->template->properties[
'file_dependency'][$key] = array($component->filepath, $component->timestamp, $component->type);
126 $compiler->template->source->filepath = $_template->source->filepath;
127 $compiler->abort_and_recompile =
true;
static saveBlockData($block_content, $block_tag, $template, $filepath)
Save or replace child block source by block name during parsing.
getAttributes($compiler, $attributes)
This function checks if the attributes passed are valid.
compile($args, $compiler)
Compiles code for the {extends} tag.