Files
smarty/libs/sysplugins/smarty_internal_compile_extends.php

64 lines
1.8 KiB
PHP
Raw Normal View History

<?php
/**
* Smarty Internal Plugin Compile extend
* Compiles the {extends} tag
*
* @package Smarty
* @subpackage Compiler
* @author Uwe Tews
*/
2010-08-17 15:39:51 +00:00
/**
* Smarty Internal Plugin Compile extend Class
*
* @package Smarty
* @subpackage Compiler
*/
class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase
{
2011-09-16 14:19:56 +00:00
/**
* Attribute definition: Overwrites base class.
*
* @var array
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('file');
2015-07-12 01:11:22 +02:00
2011-09-16 14:19:56 +00:00
/**
* 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 \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return string compiled code
* @throws \SmartyCompilerException
* @throws \SmartyException
*/
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
// check and get attributes
2011-09-16 14:19:56 +00:00
$_attr = $this->getAttributes($compiler, $args);
if ($_attr['nocache'] === true) {
$compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->line - 1);
}
2011-09-16 14:19:56 +00:00
if (strpos($_attr['file'], '$_tmp') !== false) {
$compiler->trigger_template_error('illegal value for file attribute', $compiler->parser->lex->line - 1);
}
// save template name
$compiler->extendsFileName = $_attr['file'];
// process {block} in child template mode
$compiler->inheritanceChild = true;
$compiler->has_code = false;
return '';
}
}