Files
smarty/libs/sysplugins/smarty_internal_compile_private_function_plugin.php

73 lines
2.0 KiB
PHP
Raw Normal View History

<?php
/**
* Smarty Internal Plugin Compile Function Plugin
2011-09-16 14:19:56 +00:00
*
* Compiles code for the execution of function plugin
2011-09-16 14:19:56 +00:00
*
* @package Smarty
* @subpackage Compiler
2011-09-16 14:19:56 +00:00
* @author Uwe Tews
*/
2010-08-17 15:39:51 +00:00
/**
* Smarty Internal Plugin Compile Function Plugin Class
2011-09-16 14:19:56 +00:00
*
* @package Smarty
* @subpackage Compiler
*/
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
*/
public $required_attributes = array();
2011-09-16 14:19:56 +00:00
/**
* Attribute definition: Overwrites base class.
*
* @var array
* @see Smarty_Internal_CompileBase
*/
public $optional_attributes = array('_any');
/**
* Compiles code for the execution of function plugin
2011-09-16 14:19:56 +00:00
*
* @param array $args array with attributes from parser
* @param object $compiler compiler object
* @param array $parameter array with compilation parameter
* @param string $tag name of function plugin
* @param string $function PHP function name
* @return string compiled code
*/
public function compile($args, $compiler, $parameter, $tag, $function)
{
// This tag does create output
2011-09-16 14:19:56 +00:00
$compiler->has_output = true;
// check and get attributes
2011-09-16 14:19:56 +00:00
$_attr = $this->getAttributes($compiler, $args);
if ($_attr['nocache'] === true) {
2011-09-16 14:19:56 +00:00
$compiler->tag_nocache = true;
}
unset($_attr['nocache']);
// convert attributes into parameter array string
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} else {
$_paramsArray[] = "'$_key'=>$_value";
2011-09-16 14:19:56 +00:00
}
}
$_params = 'array(' . implode(",", $_paramsArray) . ')';
// compile code
$output = "<?php echo {$function}({$_params},\$_smarty_tpl);?>\n";
return $output;
2011-09-16 14:19:56 +00:00
}
}
2010-02-28 12:50:33 +00:00
?>