1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17:
18: class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase
19: {
20: 21: 22: 23: 24: 25:
26: public $required_attributes = array('file');
27: 28: 29: 30: 31: 32:
33: public $shorttag_order = array('file');
34:
35: 36: 37: 38: 39: 40: 41: 42:
43: public function compile($args, $compiler)
44: {
45:
46: $_attr = $this->getAttributes($compiler, $args);
47: if ($_attr['nocache'] === true) {
48: $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
49: }
50: if (strpos($_attr['file'], '$_tmp') !== false) {
51: $compiler->trigger_template_error('illegal value for file attribute', $compiler->lex->taglineno);
52: }
53:
54: $name = $_attr['file'];
55: 56: 57:
58: $_smarty_tpl = $compiler->template;
59: eval("\$tpl_name = $name;");
60:
61: $_template = new $compiler->smarty->template_class($tpl_name, $compiler->smarty, $compiler->template);
62:
63: $uid = $_template->source->uid;
64: if (isset($compiler->extends_uid[$uid])) {
65: $compiler->trigger_template_error("illegal recursive call of \"$include_file\"", $compiler->lex->line - 1);
66: }
67: $compiler->extends_uid[$uid] = true;
68: if (empty($_template->source->components)) {
69: array_unshift($compiler->sources, $_template->source);
70: } else {
71: foreach ($_template->source->components as $source) {
72: array_unshift($compiler->sources, $source);
73: $uid = $source->uid;
74: if (isset($compiler->extends_uid[$uid])) {
75: $compiler->trigger_template_error("illegal recursive call of \"{$source->filepath}\"", $compiler->lex->line - 1);
76: }
77: $compiler->extends_uid[$uid] = true;
78: }
79: }
80: unset ($_template);
81: $compiler->inheritance_child = true;
82: $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBODY);
83: return '';
84: }
85: }
86: