2009-03-22 16:09:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Smarty method Register_Function
|
|
|
|
|
*
|
|
|
|
|
* Registers a PHP function as Smarty function plugin
|
|
|
|
|
*
|
|
|
|
|
* @package Smarty
|
|
|
|
|
* @subpackage SmartyMethod
|
|
|
|
|
* @author Uwe Tews
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2009-08-08 17:28:23 +00:00
|
|
|
* Registers custom function to be used in templates
|
2009-03-22 16:09:05 +00:00
|
|
|
*
|
2009-08-08 17:28:23 +00:00
|
|
|
* @param object $smarty
|
|
|
|
|
* @param string $function_tag the name of the template function
|
|
|
|
|
* @param string $function_impl the name of the PHP function to register
|
|
|
|
|
* @param boolean $cacheable if true (default) this fuction is cachable
|
2009-03-22 16:09:05 +00:00
|
|
|
*/
|
2009-11-03 20:38:38 +00:00
|
|
|
function Smarty_Method_Register_Function($smarty, $function_tag, $function_impl, $cacheable = true, $cache_attr = array())
|
2009-08-08 17:28:23 +00:00
|
|
|
{
|
|
|
|
|
if (isset($smarty->registered_plugins[$function_tag])) {
|
|
|
|
|
throw new Exception("Plugin tag \"{$function_tag}\" already registered");
|
|
|
|
|
} elseif (!is_callable($function_impl)) {
|
|
|
|
|
throw new Exception("Plugin \"{$function_tag}\" not callable");
|
|
|
|
|
} else {
|
|
|
|
|
$smarty->registered_plugins[$function_tag] =
|
2009-09-19 13:22:32 +00:00
|
|
|
array('function', $function_impl, $cacheable, $cache_attr);
|
2009-03-22 16:09:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-08-08 17:28:23 +00:00
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
?>
|