]> git.mxchange.org Git - friendica.git/blob - vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_private_function_plugin.php
Add Smarty to Composer
[friendica.git] / vendor / smarty / smarty / libs / sysplugins / smarty_internal_compile_private_function_plugin.php
1 <?php
2 /**
3  * Smarty Internal Plugin Compile Function Plugin
4  * Compiles code for the execution of function plugin
5  *
6  * @package    Smarty
7  * @subpackage Compiler
8  * @author     Uwe Tews
9  */
10
11 /**
12  * Smarty Internal Plugin Compile Function Plugin Class
13  *
14  * @package    Smarty
15  * @subpackage Compiler
16  */
17 class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_CompileBase
18 {
19     /**
20      * Attribute definition: Overwrites base class.
21      *
22      * @var array
23      * @see Smarty_Internal_CompileBase
24      */
25     public $required_attributes = array();
26
27     /**
28      * Attribute definition: Overwrites base class.
29      *
30      * @var array
31      * @see Smarty_Internal_CompileBase
32      */
33     public $optional_attributes = array('_any');
34
35     /**
36      * Compiles code for the execution of function plugin
37      *
38      * @param  array                                $args      array with attributes from parser
39      * @param \Smarty_Internal_TemplateCompilerBase $compiler  compiler object
40      * @param  array                                $parameter array with compilation parameter
41      * @param  string                               $tag       name of function plugin
42      * @param  string                               $function  PHP function name
43      *
44      * @return string compiled code
45      */
46     public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $function)
47     {
48         // check and get attributes
49         $_attr = $this->getAttributes($compiler, $args);
50
51         unset($_attr[ 'nocache' ]);
52         // convert attributes into parameter array string
53         $_paramsArray = array();
54         foreach ($_attr as $_key => $_value) {
55             if (is_int($_key)) {
56                 $_paramsArray[] = "$_key=>$_value";
57             } else {
58                 $_paramsArray[] = "'$_key'=>$_value";
59             }
60         }
61         $_params = 'array(' . implode(",", $_paramsArray) . ')';
62         // compile code
63         $output = "{$function}({$_params},\$_smarty_tpl)";
64         if (!empty($parameter[ 'modifierlist' ])) {
65             $output = $compiler->compileTag('private_modifier', array(),
66                                             array('modifierlist' => $parameter[ 'modifierlist' ],
67                                                   'value' => $output));
68         }
69         //Does tag create output
70         $compiler->has_output = true;
71         $output = "<?php echo {$output};?>\n";
72         return $output;
73     }
74 }