Add compatibility to Smarty 3

This commit is contained in:
Benjamin Renard 2012-09-02 20:12:26 +02:00
parent 1477f1378b
commit 702d53839d
6 changed files with 21 additions and 21 deletions

View file

@ -149,7 +149,19 @@ class LSsession {
} }
} }
if (method_exists($GLOBALS['Smarty'],'register_function')) {
define('SMARTY3',False);
$GLOBALS['Smarty'] -> register_function('getFData','smarty_getFData'); $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_CSS_DIR',LS_CSS_DIR);
$GLOBALS['Smarty'] -> assign('LS_IMAGES_DIR',LS_IMAGES_DIR); $GLOBALS['Smarty'] -> assign('LS_IMAGES_DIR',LS_IMAGES_DIR);

View file

@ -456,21 +456,9 @@ function LSdebugDefined() {
return _($msg); return _($msg);
} }
function tr($msg,$key=null) { function smarty_tr($params) {
if (is_array($msg)) { extract($params);
echo __($msg[$key]); echo __($msg);
}
else {
$val = $GLOBALS['Smarty']->get_template_vars($msg);
if (!$val)
$val=$msg;
if (is_array($val)) {
echo __($val[$key]);
}
else {
echo __($val);
}
}
} }
/** /**

View file

@ -4,7 +4,7 @@
<!-- Tabs - Start Title --> <!-- Tabs - Start Title -->
<ul class='LSform_layout'> <ul class='LSform_layout'>
{foreach from=$LSform_layout item=tab key=tab_key} {foreach from=$LSform_layout item=tab key=tab_key}
<li class='LSform_layout' id='LSform_layout_btn_{$tab_key}'><a href="#{$tab_key}">{php}tr('tab','label'){/php}</a></li> <li class='LSform_layout' id='LSform_layout_btn_{$tab_key}'><a href="#{$tab_key}">{tr msg=$tab.label}</a></li>
{/foreach} {/foreach}
</ul> </ul>
<!-- Tabs - End Title --> <!-- Tabs - End Title -->
@ -12,7 +12,7 @@
<!-- Tabs - Start Content --> <!-- Tabs - Start Content -->
{foreach from=$LSform_layout item=tab key=tab_key} {foreach from=$LSform_layout item=tab key=tab_key}
<a name='{$tab_key}'></a> <a name='{$tab_key}'></a>
<h2 class='LSform_layout'>{php}tr('tab','label'){/php}</h2> <h2 class='LSform_layout'>{tr msg=$tab.label}</h2>
<div class='LSform LSform_layout' id='LSform_layout_div_{$tab_key}'> <div class='LSform LSform_layout' id='LSform_layout_div_{$tab_key}'>
{if $LSformElement_image!='' && $tab.img==1} {if $LSformElement_image!='' && $tab.img==1}
<div class='LSformElement_image{if $LSformElement_image_errors} LSformElement_image_errors{/if}'> <div class='LSformElement_image{if $LSformElement_image_errors} LSformElement_image_errors{/if}'>

View file

@ -4,7 +4,7 @@
<!-- Tabs - Start Title --> <!-- Tabs - Start Title -->
<ul class='LSform_layout'> <ul class='LSform_layout'>
{foreach from=$LSform_layout item=tab key=tab_key} {foreach from=$LSform_layout item=tab key=tab_key}
<li class='LSform_layout' id='LSform_layout_btn_{$tab_key}'><a href="#{$tab_key}">{php}tr('tab','label'){/php}</a></li> <li class='LSform_layout' id='LSform_layout_btn_{$tab_key}'><a href="#{$tab_key}">{tr msg=$tab.label}</a></li>
{/foreach} {/foreach}
</ul> </ul>
<!-- Tabs - End Title --> <!-- Tabs - End Title -->

View file

@ -31,7 +31,7 @@
{/if} {/if}
<ul class='menu'> <ul class='menu'>
{foreach from=$LSaccess item=label key=LSobject_type} {foreach from=$LSaccess item=label key=LSobject_type}
<li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{php}tr('label'){/php}</a></li> <li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{tr msg=$label}</a></li>
{/foreach} {/foreach}
</ul> </ul>
</td> </td>

View file

@ -22,7 +22,7 @@
<ul class='LSview-actions'> <ul class='LSview-actions'>
{foreach from=$LSview_actions item=item} {foreach from=$LSview_actions item=item}
{if is_array($item)} {if is_array($item)}
<li class='LSview-actions'><a href='{$item.url}' class='LSview-actions'><img src='{$LS_IMAGES_DIR}/{$item.action}.png' alt='{php}tr('label');{/php}' title='{php}tr('label');{/php}' /> {php}tr('item','label');{/php}</a></li> <li class='LSview-actions'><a href='{$item.url}' class='LSview-actions'><img src='{$LS_IMAGES_DIR}/{$item.action}.png' alt='{tr msg=$label}' title='{tr msg=$label}' /> {tr msg=$item.label}</a></li>
{/if} {/if}
{/foreach} {/foreach}
</ul> </ul>