3 * Smarty Internal Plugin Compile Function_Call
4 * Compiles the calls of user defined tags defined by {function}
12 * Smarty Internal Plugin Compile Function_Call Class
15 * @subpackage Compiler
17 class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
20 * Attribute definition: Overwrites base class.
23 * @see Smarty_Internal_CompileBase
25 public $required_attributes = array('name');
28 * Attribute definition: Overwrites base class.
31 * @see Smarty_Internal_CompileBase
33 public $shorttag_order = array('name');
36 * Attribute definition: Overwrites base class.
39 * @see Smarty_Internal_CompileBase
41 public $optional_attributes = array('_any');
44 * Compiles the calls of user defined tags defined by {function}
46 * @param array $args array with attributes from parser
47 * @param object $compiler compiler object
49 * @return string compiled code
51 public function compile($args, $compiler)
53 // check and get attributes
54 $_attr = $this->getAttributes($compiler, $args);
55 // save possible attributes
56 if (isset($_attr[ 'assign' ])) {
57 // output will be stored in a smarty variable instead of being displayed
58 $_assign = $_attr[ 'assign' ];
60 //$_name = trim($_attr['name'], "'\"");
61 $_name = $_attr[ 'name' ];
62 unset($_attr[ 'name' ], $_attr[ 'assign' ], $_attr[ 'nocache' ]);
63 // set flag (compiled code of {function} must be included in cache file
64 if (!$compiler->template->caching || $compiler->nocache || $compiler->tag_nocache) {
69 $_paramsArray = array();
70 foreach ($_attr as $_key => $_value) {
72 $_paramsArray[] = "$_key=>$_value";
74 $_paramsArray[] = "'$_key'=>$_value";
77 $_params = 'array(' . implode(",", $_paramsArray) . ')';
78 //$compiler->suppressNocacheProcessing = true;
79 // was there an assign attribute
80 if (isset($_assign)) {
82 "<?php ob_start();\n\$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
85 "<?php \$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n";