mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-17 14:35:19 +02:00
64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?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 \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
|
|
$_attr = $this->getAttributes($compiler, $args);
|
|
if ($_attr['nocache'] === true) {
|
|
$compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->line - 1);
|
|
}
|
|
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 '';
|
|
}
|
|
}
|