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.")); 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; return True;
} }
else { else {
@ -258,6 +263,18 @@ class LStemplate {
return self :: $_smarty -> fetch("ls:$template"); 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) { function LStemplate_smarty_getFData($params) {

View file

@ -101,10 +101,14 @@ LStemplate :: $_smarty -> register_resource('ls', array(
'LStemplate_smarty_get_trusted' 'LStemplate_smarty_get_trusted'
) )
); );
/**
// Register special template functions * Register a template function
LStemplate :: $_smarty -> register_function('getFData','LStemplate_smarty_getFData'); *
LStemplate :: $_smarty -> register_function('tr','LStemplate_smarty_tr'); * @param[in] string $name The function name in template
LStemplate :: $_smarty -> register_function('img','LStemplate_smarty_img'); * @param[in] string $function_name The function name in PHP
LStemplate :: $_smarty -> register_function('css','LStemplate_smarty_css'); *
* @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 // Register 'ls' template ressource
LStemplate :: $_smarty -> registerResource('ls', new Smarty_Resource_LdapSaisie()); LStemplate :: $_smarty -> registerResource('ls', new Smarty_Resource_LdapSaisie());
// Register special template functions /**
LStemplate :: $_smarty -> registerPlugin("function","getFData", "LStemplate_smarty_getFData"); * Register a template function
LStemplate :: $_smarty -> registerPlugin("function","tr", "LStemplate_smarty_tr"); *
LStemplate :: $_smarty -> registerPlugin("function","img", "LStemplate_smarty_img"); * @param[in] string $name The function name in template
LStemplate :: $_smarty -> registerPlugin("function","css", "LStemplate_smarty_css"); * @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);
}