gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

commit 921492ba52243eed3e6c4615a67d8b43a72b14ff
parent dd0a62907cbc11f898b49c4586e782fc576bbd8d
Author: Marcel <MTRNord@users.noreply.github.com>
Date:   Sat, 31 Oct 2015 17:28:33 +0100

Create smarty_internal_compile_extends.php
Diffstat:
Alibs/smarty/sysplugins/smarty_internal_compile_extends.php | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+), 0 deletions(-)

diff --git a/libs/smarty/sysplugins/smarty_internal_compile_extends.php b/libs/smarty/sysplugins/smarty_internal_compile_extends.php @@ -0,0 +1,85 @@ +<?php + +/** + * Smarty Internal Plugin Compile extend + * Compiles the {extends} tag + * + * @package Smarty + * @subpackage Compiler + * @author Uwe Tews + */ + +/** + * Smarty Internal Plugin Compile extend Class + * + * @package Smarty + * @subpackage Compiler + */ +class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase +{ + /** + * Attribute definition: Overwrites base class. + * + * @var array + * @see Smarty_Internal_CompileBase + */ + public $required_attributes = array('file'); + /** + * Attribute definition: Overwrites base class. + * + * @var array + * @see Smarty_Internal_CompileBase + */ + public $shorttag_order = array('file'); + + /** + * Compiles code for the {extends} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * + * @return string compiled code + */ + public function compile($args, $compiler) + { + // check and get attributes + $_attr = $this->getAttributes($compiler, $args); + if ($_attr['nocache'] === true) { + $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno); + } + if (strpos($_attr['file'], '$_tmp') !== false) { + $compiler->trigger_template_error('illegal value for file attribute', $compiler->lex->taglineno); + } + + $name = $_attr['file']; + /** @var Smarty_Internal_Template $_smarty_tpl + * used in evaluated code + */ + $_smarty_tpl = $compiler->template; + eval("\$tpl_name = $name;"); + // create template object + $_template = new $compiler->smarty->template_class($tpl_name, $compiler->smarty, $compiler->template); + // check for recursion + $uid = $_template->source->uid; + if (isset($compiler->extends_uid[$uid])) { + $compiler->trigger_template_error("illegal recursive call of \"$include_file\"", $compiler->lex->line - 1); + } + $compiler->extends_uid[$uid] = true; + if (empty($_template->source->components)) { + array_unshift($compiler->sources, $_template->source); + } else { + foreach ($_template->source->components as $source) { + array_unshift($compiler->sources, $source); + $uid = $source->uid; + if (isset($compiler->extends_uid[$uid])) { + $compiler->trigger_template_error("illegal recursive call of \"{$source->filepath}\"", $compiler->lex->line - 1); + } + $compiler->extends_uid[$uid] = true; + } + } + unset ($_template); + $compiler->inheritance_child = true; + $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBODY); + return ''; + } +}