fusionpbx/resources/templates/engine/smarty/sysplugins/smarty_internal_compile_app...

53 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2013-11-09 21:02:56 +01:00
<?php
/**
* Smarty Internal Plugin Compile Append
* Compiles the {append} tag
*
2018-11-07 08:18:14 +01:00
* @package Smarty
2013-11-09 21:02:56 +01:00
* @subpackage Compiler
2018-11-07 08:18:14 +01:00
* @author Uwe Tews
2013-11-09 21:02:56 +01:00
*/
/**
* Smarty Internal Plugin Compile Append Class
*
2018-11-07 08:18:14 +01:00
* @package Smarty
2013-11-09 21:02:56 +01:00
* @subpackage Compiler
*/
class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign
{
/**
* Compiles code for the {append} tag
*
2018-11-07 08:18:14 +01:00
* @param array $args array with attributes from parser
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
* @param array $parameter array with compilation parameter
*
2013-11-09 21:02:56 +01:00
* @return string compiled code
2018-11-07 08:18:14 +01:00
* @throws \SmartyCompilerException
2013-11-09 21:02:56 +01:00
*/
2018-11-07 08:18:14 +01:00
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
2013-11-09 21:02:56 +01:00
{
// the following must be assigned at runtime because it will be overwritten in parent class
$this->required_attributes = array('var', 'value');
$this->shorttag_order = array('var', 'value');
$this->optional_attributes = array('scope', 'index');
2018-11-07 08:18:14 +01:00
$this->mapCache = array();
2013-11-09 21:02:56 +01:00
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
// map to compile assign attributes
2018-11-07 08:18:14 +01:00
if (isset($_attr[ 'index' ])) {
$_params[ 'smarty_internal_index' ] = '[' . $_attr[ 'index' ] . ']';
unset($_attr[ 'index' ]);
2013-11-09 21:02:56 +01:00
} else {
2018-11-07 08:18:14 +01:00
$_params[ 'smarty_internal_index' ] = '[]';
2013-11-09 21:02:56 +01:00
}
$_new_attr = array();
foreach ($_attr as $key => $value) {
$_new_attr[] = array($key => $value);
}
// call compile assign
return parent::compile($_new_attr, $compiler, $_params);
}
}