Code

Updated smarty
[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_method_register_function.php
1 <?php
3 /**
4 * Smarty method Register_Function
5
6 * Registers a PHP function as Smarty function plugin
7
8 * @package Smarty
9 * @subpackage SmartyMethod
10 * @author Uwe Tews 
11 */
13 /**
14 * Registers custom function to be used in templates
15
16 * @param object $smarty 
17 * @param string $function_tag the name of the template function
18 * @param string $function_impl the name of the PHP function to register
19 * @param boolean $cacheable if true (default) this fuction is cachable
20 */
21 function  Smarty_Method_Register_Function($smarty, $function_tag, $function_impl, $cacheable = true, $cache_attr = array())
22 {
23     if (isset($smarty->registered_plugins['function'][$function_tag])) {
24         throw new Exception("Plugin tag \"{$function_tag}\" already registered");
25     } elseif (!is_callable($function_impl)) {
26         throw new Exception("Plugin \"{$function_tag}\" not callable");
27     } else {
28         $smarty->registered_plugins['function'][$function_tag] =
29         array($function_impl, $cacheable, $cache_attr);
30     } 
31
33 ?>