From d4ac29dd04ca0b6fbced373d93b9305b1e562640 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 9 Apr 2014 17:15:52 +0200 Subject: [PATCH] Add LStemplate :: registerFunction() method --- .../includes/class/class.LStemplate.php | 17 +++++++++++++++++ .../class/class.LStemplate_smarty2_support.php | 18 +++++++++++------- .../class/class.LStemplate_smarty3_support.php | 17 +++++++++++------ 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/public_html/includes/class/class.LStemplate.php b/public_html/includes/class/class.LStemplate.php index 2bedd3c4..9f816f38 100644 --- a/public_html/includes/class/class.LStemplate.php +++ b/public_html/includes/class/class.LStemplate.php @@ -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) { diff --git a/public_html/includes/class/class.LStemplate_smarty2_support.php b/public_html/includes/class/class.LStemplate_smarty2_support.php index 57d598d9..5c3b12da 100644 --- a/public_html/includes/class/class.LStemplate_smarty2_support.php +++ b/public_html/includes/class/class.LStemplate_smarty2_support.php @@ -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); +} diff --git a/public_html/includes/class/class.LStemplate_smarty3_support.php b/public_html/includes/class/class.LStemplate_smarty3_support.php index 36d43a36..4c781142 100644 --- a/public_html/includes/class/class.LStemplate_smarty3_support.php +++ b/public_html/includes/class/class.LStemplate_smarty3_support.php @@ -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); +}