2009-03-22 16:09:05 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2010-07-01 19:57:56 +00:00
|
|
|
* Smarty Internal Plugin Compile Function Plugin
|
|
|
|
* Compiles code for the execution of function plugin
|
2011-09-16 14:19:56 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2010-07-01 19:57:56 +00:00
|
|
|
* @subpackage Compiler
|
2014-06-06 02:40:04 +00:00
|
|
|
* @author Uwe Tews
|
2010-07-01 19:57:56 +00:00
|
|
|
*/
|
2010-08-17 15:39:51 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-07-01 19:57:56 +00:00
|
|
|
* Smarty Internal Plugin Compile Function Plugin Class
|
2011-09-16 14:19:56 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2011-09-16 14:19:56 +00:00
|
|
|
* @subpackage Compiler
|
2010-07-01 19:57:56 +00:00
|
|
|
*/
|
2013-07-14 22:15:45 +00:00
|
|
|
class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_CompileBase
|
|
|
|
{
|
2011-09-16 14:19:56 +00:00
|
|
|
/**
|
|
|
|
* Attribute definition: Overwrites base class.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @see Smarty_Internal_CompileBase
|
|
|
|
*/
|
2010-11-11 21:34:36 +00:00
|
|
|
public $required_attributes = array();
|
2015-08-06 01:19:11 +02:00
|
|
|
|
2011-09-16 14:19:56 +00:00
|
|
|
/**
|
|
|
|
* Attribute definition: Overwrites base class.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @see Smarty_Internal_CompileBase
|
|
|
|
*/
|
|
|
|
public $optional_attributes = array('_any');
|
2010-11-11 21:34:36 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-07-01 19:57:56 +00:00
|
|
|
* Compiles code for the execution of function plugin
|
2011-09-16 14:19:56 +00:00
|
|
|
*
|
2018-06-12 09:58:15 +02:00
|
|
|
* @param array $args array with attributes from parser
|
2016-02-09 01:27:15 +01:00
|
|
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
2018-06-12 09:58:15 +02:00
|
|
|
* @param array $parameter array with compilation parameter
|
|
|
|
* @param string $tag name of function plugin
|
|
|
|
* @param string $function PHP function name
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2010-07-01 19:57:56 +00:00
|
|
|
* @return string compiled code
|
2017-10-26 10:25:41 +02:00
|
|
|
* @throws \SmartyCompilerException
|
|
|
|
* @throws \SmartyException
|
2010-07-01 19:57:56 +00:00
|
|
|
*/
|
2016-02-09 01:27:15 +01:00
|
|
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $function)
|
2009-03-22 16:09:05 +00:00
|
|
|
{
|
|
|
|
// check and get attributes
|
2011-09-16 14:19:56 +00:00
|
|
|
$_attr = $this->getAttributes($compiler, $args);
|
2016-02-09 01:27:15 +01:00
|
|
|
unset($_attr[ 'nocache' ]);
|
2009-03-22 16:09:05 +00:00
|
|
|
// convert attributes into parameter array string
|
|
|
|
$_paramsArray = array();
|
|
|
|
foreach ($_attr as $_key => $_value) {
|
2009-11-18 21:51:20 +00:00
|
|
|
if (is_int($_key)) {
|
|
|
|
$_paramsArray[] = "$_key=>$_value";
|
|
|
|
} else {
|
|
|
|
$_paramsArray[] = "'$_key'=>$_value";
|
2011-09-16 14:19:56 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-06 01:02:56 +01:00
|
|
|
$_params = 'array(' . implode(',', $_paramsArray) . ')';
|
2009-03-22 16:09:05 +00:00
|
|
|
// compile code
|
2016-07-18 17:57:50 +02:00
|
|
|
$output = "{$function}({$_params},\$_smarty_tpl)";
|
|
|
|
if (!empty($parameter[ 'modifierlist' ])) {
|
2018-06-12 09:58:15 +02:00
|
|
|
$output = $compiler->compileTag(
|
2018-08-31 16:45:09 +02:00
|
|
|
'private_modifier',
|
|
|
|
array(),
|
|
|
|
array(
|
|
|
|
'modifierlist' => $parameter[ 'modifierlist' ],
|
|
|
|
'value' => $output
|
|
|
|
)
|
2018-06-12 09:58:15 +02:00
|
|
|
);
|
2016-07-18 17:57:50 +02:00
|
|
|
}
|
2016-09-15 03:23:04 +02:00
|
|
|
$output = "<?php echo {$output};?>\n";
|
2009-03-22 16:09:05 +00:00
|
|
|
return $output;
|
2011-09-16 14:19:56 +00:00
|
|
|
}
|
|
|
|
}
|