Add LStemplate :: registerFunction() method

This commit is contained in:
Benjamin Renard 2014-04-09 17:15:52 +02:00
parent c989346360
commit d4ac29dd04
3 changed files with 39 additions and 13 deletions

View file

@ -118,6 +118,11 @@ class LStemplate {
die(_("LStemplate : Smarty version not recognized."));
}
self :: registerFunction("getFData", "LStemplate_smarty_getFData");
self :: registerFunction("tr", "LStemplate_smarty_tr");
self :: registerFunction("img", "LStemplate_smarty_img");
self :: registerFunction("css", "LStemplate_smarty_css");
return True;
}
else {
@ -258,6 +263,18 @@ class LStemplate {
return self :: $_smarty -> fetch("ls:$template");
}
/**
* Register a template function
*
* @param[in] string $name The function name in template
* @param[in] string $function_name The function name in PHP
*
* @retval void
*/
public static function registerFunction($name,$function_name) {
LStemplate_register_function($name,$function_name);
}
}
function LStemplate_smarty_getFData($params) {

View file

@ -101,10 +101,14 @@ LStemplate :: $_smarty -> register_resource('ls', array(
'LStemplate_smarty_get_trusted'
)
);
// Register special template functions
LStemplate :: $_smarty -> register_function('getFData','LStemplate_smarty_getFData');
LStemplate :: $_smarty -> register_function('tr','LStemplate_smarty_tr');
LStemplate :: $_smarty -> register_function('img','LStemplate_smarty_img');
LStemplate :: $_smarty -> register_function('css','LStemplate_smarty_css');
/**
* Register a template function
*
* @param[in] string $name The function name in template
* @param[in] string $function_name The function name in PHP
*
* @retval void
*/
function LStemplate_register_function($name,$function_name) {
LStemplate :: $_smarty -> register_function($name,$function_name);
}

View file

@ -60,9 +60,14 @@ class Smarty_Resource_LdapSaisie extends Smarty_Resource_Custom {
// Register 'ls' template ressource
LStemplate :: $_smarty -> registerResource('ls', new Smarty_Resource_LdapSaisie());
// Register special template functions
LStemplate :: $_smarty -> registerPlugin("function","getFData", "LStemplate_smarty_getFData");
LStemplate :: $_smarty -> registerPlugin("function","tr", "LStemplate_smarty_tr");
LStemplate :: $_smarty -> registerPlugin("function","img", "LStemplate_smarty_img");
LStemplate :: $_smarty -> registerPlugin("function","css", "LStemplate_smarty_css");
/**
* Register a template function
*
* @param[in] string $name The function name in template
* @param[in] string $function_name The function name in PHP
*
* @retval void
*/
function LStemplate_register_function($name,$function_name) {
LStemplate :: $_smarty -> registerPlugin("function",$name,$function_name);
}