PEEL Shopping
Open source ecommerce : PEEL Shopping
smarty_internal_compile_extends.php
Go to the documentation of this file.
1 <?php
2 
20 
27  public $required_attributes = array('file');
34  public $shorttag_order = array('file');
40  public $mbstring_overload = 0;
41 
49  public function compile($args, $compiler)
50  {
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) {
55  $al = '\s*';
56  } else {
57  $al = '';
58  }
59  $filepath = $compiler->template->source->filepath;
60  $this->mbstring_overload = ini_get('mbstring.func_overload') & 2;
61  // check and get attributes
62  $_attr = $this->getAttributes($compiler, $args);
63  if ($_attr['nocache'] === true) {
64  $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
65  }
66 
67  $_smarty_tpl = $compiler->template;
68  $include_file = null;
69  if (strpos($_attr['file'], '$_tmp') !== false) {
70  $compiler->trigger_template_error('illegal value for file attribute', $compiler->lex->taglineno);
71  }
72  eval('$include_file = ' . $_attr['file'] . ';');
73  // create template object
74  $_template = new $compiler->smarty->template_class($include_file, $compiler->smarty, $compiler->template);
75  // save file dependency
76  if (isset($_is_stringy[$_template->source->type])) {
77  $template_sha1 = sha1($include_file);
78  } else {
79  $template_sha1 = sha1($_template->source->filepath);
80  }
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);
83  }
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');
89  }
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]);
92  $_start = 0;
93  while ($_start+1 < $_result_count) {
94  $_end = 0;
95  $_level = 1;
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.'*') {
97  $_start++;
98  continue;
99  }
100  while ($_level != 0) {
101  $_end++;
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.'*') {
103  continue;
104  }
105  if (!strpos($_result[0][$_start + $_end][0], '/')) {
106  $_level++;
107  } else {
108  $_level--;
109  }
110  }
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]))));
113  Smarty_Internal_Compile_Block::saveBlockData($_block_content, $_result[0][$_start][0], $compiler->template, $filepath);
114  $_start = $_start + $_end + 1;
115  }
116  if ($_template->source->type == 'extends') {
117  $_template->block_data = $compiler->template->block_data;
118  }
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);
124  }
125  }
126  $compiler->template->source->filepath = $_template->source->filepath;
127  $compiler->abort_and_recompile = true;
128  return '';
129  }
130 
131 }
132 
133 ?>
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.

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:17 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.