2009-04-24 19:59:51 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2010-05-25 19:33:55 +00:00
|
|
|
* Smarty Internal Plugin Compile Function_Call
|
|
|
|
* Compiles the calls of user defined tags defined by {function}
|
2011-09-16 14:19:56 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2010-05-25 19:33:55 +00:00
|
|
|
* @subpackage Compiler
|
2014-06-06 02:40:04 +00:00
|
|
|
* @author Uwe Tews
|
2010-05-25 19:33:55 +00:00
|
|
|
*/
|
2010-08-17 15:39:51 +00:00
|
|
|
|
2009-04-24 19:59:51 +00:00
|
|
|
/**
|
2010-05-25 19:33:55 +00:00
|
|
|
* Smarty Internal Plugin Compile Function_Call 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-05-25 19:33:55 +00:00
|
|
|
*/
|
2013-07-14 22:15:45 +00:00
|
|
|
class Smarty_Internal_Compile_Call 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('name');
|
2015-09-14 23:50:20 +02:00
|
|
|
|
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 $shorttag_order = array('name');
|
2015-09-14 23:50:20 +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-04-24 19:59:51 +00:00
|
|
|
/**
|
2010-05-25 19:33:55 +00:00
|
|
|
* Compiles the calls of user defined tags defined by {function}
|
2011-09-16 14:19:56 +00:00
|
|
|
*
|
2018-06-12 09:58:15 +02:00
|
|
|
* @param array $args array with attributes from parser
|
|
|
|
* @param object $compiler compiler object
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2010-05-25 19:33:55 +00:00
|
|
|
* @return string compiled code
|
|
|
|
*/
|
2009-04-24 19:59:51 +00:00
|
|
|
public function compile($args, $compiler)
|
|
|
|
{
|
|
|
|
// check and get attributes
|
2011-09-16 14:19:56 +00:00
|
|
|
$_attr = $this->getAttributes($compiler, $args);
|
2010-11-11 21:34:36 +00:00
|
|
|
// save possible attributes
|
2016-02-09 01:27:15 +01:00
|
|
|
if (isset($_attr[ 'assign' ])) {
|
2014-06-06 02:40:04 +00:00
|
|
|
// output will be stored in a smarty variable instead of being displayed
|
2016-02-09 01:27:15 +01:00
|
|
|
$_assign = $_attr[ 'assign' ];
|
2011-09-16 14:19:56 +00:00
|
|
|
}
|
2017-11-06 01:02:56 +01:00
|
|
|
//$_name = trim($_attr['name'], "''");
|
2016-02-09 01:27:15 +01:00
|
|
|
$_name = $_attr[ 'name' ];
|
|
|
|
unset($_attr[ 'name' ], $_attr[ 'assign' ], $_attr[ 'nocache' ]);
|
2009-12-29 20:12:11 +00:00
|
|
|
// set flag (compiled code of {function} must be included in cache file
|
2014-11-01 22:42:34 +01:00
|
|
|
if (!$compiler->template->caching || $compiler->nocache || $compiler->tag_nocache) {
|
2010-05-25 19:33:55 +00:00
|
|
|
$_nocache = 'true';
|
2009-12-31 16:38:12 +00:00
|
|
|
} else {
|
2010-05-25 19:33:55 +00:00
|
|
|
$_nocache = 'false';
|
2011-09-16 14:19:56 +00:00
|
|
|
}
|
2010-05-25 19:33:55 +00:00
|
|
|
$_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
|
|
|
}
|
2010-11-11 21:34:36 +00:00
|
|
|
}
|
2017-11-06 01:02:56 +01:00
|
|
|
$_params = 'array(' . implode(',', $_paramsArray) . ')';
|
2014-11-01 22:42:34 +01:00
|
|
|
//$compiler->suppressNocacheProcessing = true;
|
2009-04-24 19:59:51 +00:00
|
|
|
// was there an assign attribute
|
|
|
|
if (isset($_assign)) {
|
2015-09-14 23:50:20 +02:00
|
|
|
$_output =
|
2016-10-08 06:07:14 +02:00
|
|
|
"<?php ob_start();\n\$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
2009-04-24 19:59:51 +00:00
|
|
|
} else {
|
2015-09-14 23:50:20 +02:00
|
|
|
$_output =
|
2016-10-08 06:07:14 +02:00
|
|
|
"<?php \$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n";
|
2011-09-16 14:19:56 +00:00
|
|
|
}
|
2009-04-24 19:59:51 +00:00
|
|
|
return $_output;
|
2011-09-16 14:19:56 +00:00
|
|
|
}
|
|
|
|
}
|