From 702d53839d208691ad64af4565414dba14cb3d84 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sun, 2 Sep 2012 20:12:26 +0200 Subject: [PATCH] Add compatibility to Smarty 3 --- public_html/includes/class/class.LSsession.php | 14 +++++++++++++- public_html/includes/functions.php | 18 +++--------------- public_html/templates/default/LSform.tpl | 4 ++-- public_html/templates/default/LSform_view.tpl | 2 +- public_html/templates/default/top.tpl | 2 +- public_html/templates/default/viewSearch.tpl | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php index d7580493..525a8374 100644 --- a/public_html/includes/class/class.LSsession.php +++ b/public_html/includes/class/class.LSsession.php @@ -149,7 +149,19 @@ class LSsession { } } - $GLOBALS['Smarty'] -> register_function('getFData','smarty_getFData'); + if (method_exists($GLOBALS['Smarty'],'register_function')) { + define('SMARTY3',False); + $GLOBALS['Smarty'] -> register_function('getFData','smarty_getFData'); + $GLOBALS['Smarty'] -> register_function('tr','smarty_tr'); + } + elseif (method_exists($GLOBALS['Smarty'],'registerPlugin')) { + define('SMARTY3',True); + $GLOBALS['Smarty'] -> registerPlugin("function","getFData", "smarty_getFData"); + $GLOBALS['Smarty'] -> registerPlugin("function","tr", "smarty_tr"); + } + else { + die("Smarty : Can't register getFData fonction"); + } $GLOBALS['Smarty'] -> assign('LS_CSS_DIR',LS_CSS_DIR); $GLOBALS['Smarty'] -> assign('LS_IMAGES_DIR',LS_IMAGES_DIR); diff --git a/public_html/includes/functions.php b/public_html/includes/functions.php index af34595a..0e2e7b74 100644 --- a/public_html/includes/functions.php +++ b/public_html/includes/functions.php @@ -456,21 +456,9 @@ function LSdebugDefined() { return _($msg); } - function tr($msg,$key=null) { - if (is_array($msg)) { - echo __($msg[$key]); - } - else { - $val = $GLOBALS['Smarty']->get_template_vars($msg); - if (!$val) - $val=$msg; - if (is_array($val)) { - echo __($val[$key]); - } - else { - echo __($val); - } - } + function smarty_tr($params) { + extract($params); + echo __($msg); } /** diff --git a/public_html/templates/default/LSform.tpl b/public_html/templates/default/LSform.tpl index cafdad40..805ff15b 100644 --- a/public_html/templates/default/LSform.tpl +++ b/public_html/templates/default/LSform.tpl @@ -4,7 +4,7 @@ @@ -12,7 +12,7 @@ {foreach from=$LSform_layout item=tab key=tab_key} -

{php}tr('tab','label'){/php}

+

{tr msg=$tab.label}

{if $LSformElement_image!='' && $tab.img==1}
diff --git a/public_html/templates/default/LSform_view.tpl b/public_html/templates/default/LSform_view.tpl index 2d84943a..d24a588a 100644 --- a/public_html/templates/default/LSform_view.tpl +++ b/public_html/templates/default/LSform_view.tpl @@ -4,7 +4,7 @@ diff --git a/public_html/templates/default/top.tpl b/public_html/templates/default/top.tpl index 887d27a9..ae5af80f 100644 --- a/public_html/templates/default/top.tpl +++ b/public_html/templates/default/top.tpl @@ -31,7 +31,7 @@ {/if} diff --git a/public_html/templates/default/viewSearch.tpl b/public_html/templates/default/viewSearch.tpl index b8d7b9fe..eb6b539d 100644 --- a/public_html/templates/default/viewSearch.tpl +++ b/public_html/templates/default/viewSearch.tpl @@ -22,7 +22,7 @@