diff --git a/public_html/conf/config.inc.php b/public_html/conf/config.inc.php index 2bbb5626..6ec825dd 100644 --- a/public_html/conf/config.inc.php +++ b/public_html/conf/config.inc.php @@ -178,7 +178,7 @@ $GLOBALS['LSconfig'] = array( // Theme Default define('LS_THEME','default'); define('LS_TEMPLATES_DIR', 'templates'); -define('LS_IMAGES_DIR', 'images/'.LS_THEME); +define('LS_IMAGES_DIR', 'images'); define('LS_CSS_DIR', 'css/'.LS_THEME); //Debug diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php index 9d9b415e..4ad5c514 100644 --- a/public_html/includes/class/class.LSsession.php +++ b/public_html/includes/class/class.LSsession.php @@ -133,16 +133,18 @@ class LSsession { */ private static function startLStemplate() { if ( self :: loadLSclass('LStemplate') ) { - self :: addJSconfigParam('LS_IMAGES_DIR',LS_IMAGES_DIR); - return LStemplate :: start( + $res = LStemplate :: start( array( 'smarty_path' => LSconfig :: get('Smarty'), 'template_dir' => LS_TEMPLATES_DIR, + 'image_dir' => LS_IMAGES_DIR, 'compile_dir' => LS_TMP_DIR, 'debug' => LSdebug, 'debug_smarty' => (isset($_REQUEST['LStemplate_debug'])), ) ); + self :: addJSconfigParam('LS_IMAGES_DIR',LStemplate :: getDefaultImageDirPath()); + return $res; } return False; } diff --git a/public_html/includes/class/class.LStemplate.php b/public_html/includes/class/class.LStemplate.php index 24e757a4..2feeae60 100644 --- a/public_html/includes/class/class.LStemplate.php +++ b/public_html/includes/class/class.LStemplate.php @@ -35,13 +35,21 @@ class LStemplate { * array( * 'smarty_path' => '/path/to/Smarty.php', * 'template_dir' => '/path/to/template/directory', + * 'image_dir' => '/path/to/image/directory', * 'compile_dir' => '/path/to/compile/directory', * 'debug' => True, * 'debug_smarty' => True * ) * **/ - private static $config = NULL; + private static $config = array ( + 'smarty_path' => 'smarty/libs/Smarty.class.php', + 'template_dir' => 'templates', + 'image_dir' => 'images', + 'compile_dir' => 'tmp', + 'debug' => False, + 'debug_smarty' => False + ); // Smarty object public static $_smarty = NULL; @@ -66,24 +74,26 @@ class LStemplate { * @retval boolean True on success, False instead **/ public static function start($config) { - self :: $config = $config; + foreach ($config as $key => $value) { + self :: $config[$key] = $value; + } - if (LSsession :: includeFile($config['smarty_path'])) { + if (LSsession :: includeFile(self :: $config['smarty_path'])) { self :: $_smarty = new Smarty(); - self :: $_smarty -> template_dir = $config['template_dir']; + self :: $_smarty -> template_dir = self :: $config['template_dir']; - if ( ! is_writable($config['compile_dir']) ) { - die(_('LStemplate : compile directory is not writable (dir : '.$config['compile_dir'].')')); + if ( ! is_writable(self :: $config['compile_dir']) ) { + die(_('LStemplate : compile directory is not writable (dir : '.self :: $config['compile_dir'].')')); } - self :: $_smarty -> compile_dir = $config['compile_dir']; + self :: $_smarty -> compile_dir = self :: $config['compile_dir']; - if ($config['debug']) { + if (self :: $config['debug']) { self :: $_smarty -> caching = 0; // cache files are always regenerated self :: $_smarty -> force_compile = TRUE; // recompile template if it is changed self :: $_smarty -> compile_check = TRUE; - if ($config['debug_smarty']) { + if (self :: $config['debug_smarty']) { // debug smarty self :: $_smarty -> debugging = true; } @@ -107,7 +117,7 @@ class LStemplate { } self :: $_smarty -> assign('LS_CSS_DIR',LS_CSS_DIR); - self :: $_smarty -> assign('LS_IMAGES_DIR',LS_IMAGES_DIR); + self :: $_smarty -> assign('LS_IMAGES_DIR',self :: getDefaultImageDirPath()); return True; } @@ -138,6 +148,36 @@ class LStemplate { return $root_dir.'/'.$default_dir.'/'.$file; } + /** + * Return the default path of images directory + * + * @retval string The path of the file + **/ + public static function getDefaultImageDirPath() { + if (is_dir(self :: $config['image_dir'].'/'.LS_THEME)) { + return self :: $config['image_dir'].'/'.LS_THEME; + } + return self :: $config['image_dir'].'/default'; + } + + + /** + * Return the path of the image file to use + * + * @param[in] string $image The image name (eg: mail) + * + * @retval string The path of the image file + **/ + public static function getImagePath($image) { + $exts=array('png','gif','jpg'); + foreach($exts as $ext) { + $path=self :: getFilePath("$image.$ext",self :: $config['image_dir'],False); + if ($path) return $path; + } + return self :: $config['image_dir']."/default/$image.png"; + } + + /** * Return the path of the Smarty template file to use * @@ -229,6 +269,11 @@ function LStemplate_smarty_tr($params) { echo __($msg); } +function LStemplate_smarty_img($params) { + extract($params); + echo LStemplate :: getImagePath($name); +} + // Errors LSerror :: defineError('LStemplate_01', _("LStemplate : Template %{file} not found.") diff --git a/public_html/includes/class/class.LStemplate_smarty2_support.php b/public_html/includes/class/class.LStemplate_smarty2_support.php index 50b802eb..d28da83f 100644 --- a/public_html/includes/class/class.LStemplate_smarty2_support.php +++ b/public_html/includes/class/class.LStemplate_smarty2_support.php @@ -105,4 +105,5 @@ LStemplate :: $_smarty -> register_resource('ls', array( // 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'); diff --git a/public_html/includes/class/class.LStemplate_smarty3_support.php b/public_html/includes/class/class.LStemplate_smarty3_support.php index ed264563..4ed45a0f 100644 --- a/public_html/includes/class/class.LStemplate_smarty3_support.php +++ b/public_html/includes/class/class.LStemplate_smarty3_support.php @@ -63,4 +63,5 @@ 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"); diff --git a/public_html/templates/default/LSdefault.tpl b/public_html/templates/default/LSdefault.tpl index e060537f..881ee909 100644 --- a/public_html/templates/default/LSdefault.tpl +++ b/public_html/templates/default/LSdefault.tpl @@ -12,6 +12,6 @@
{foreach from=$LSlanguages item=lang} - {$lang} + {$lang} {/foreach}
diff --git a/public_html/templates/default/LSform.tpl b/public_html/templates/default/LSform.tpl index 805ff15b..9d943e7f 100644 --- a/public_html/templates/default/LSform.tpl +++ b/public_html/templates/default/LSform.tpl @@ -18,9 +18,9 @@
{if $LSformElement_image_actions!='' && !$LSformElement_image_errors} {/if} @@ -31,7 +31,7 @@
{foreach from=$tab.args item=arg} {if $LSform_fields[$arg]} -
{$LSform_fields[$arg].label}{if $LSform_fields[$arg].required} *{/if}{if $LSform_fields[$arg].help_info!=""} ?{/if}
+
{$LSform_fields[$arg].label}{if $LSform_fields[$arg].required} *{/if}{if $LSform_fields[$arg].help_info!=""} ?{/if}
{$LSform_fields[$arg].html}{if $LSform_fields[$arg].add != ''} + Ajouter un champ{/if}
{if $LSform_fields[$arg].errors != ''} {foreach from=$LSform_fields[$arg].errors item=error} @@ -51,9 +51,9 @@
{if $LSformElement_image_actions!='' && !$LSformElement_image_errors}
    -
  • +
  • {foreach from=$LSformElement_image_actions item=item} -
  • +
  • {/foreach}
{/if} @@ -64,7 +64,7 @@
{foreach from=$LSform_fields item=field} -
{$field.label}{if $field.required} *{/if}{if $field.help_info!=""} ?{/if}
+
{$field.label}{if $field.required} *{/if}{if $field.help_info!=""} ?{/if}
{$field.html}{if $field.add != ''} + Ajouter un champ{/if}
{if $field.errors != ''} {foreach from=$field.errors item=error} diff --git a/public_html/templates/default/LSformElement_supannLabeledValue_field.tpl b/public_html/templates/default/LSformElement_supannLabeledValue_field.tpl index c7d2ebf9..ade4df4d 100644 --- a/public_html/templates/default/LSformElement_supannLabeledValue_field.tpl +++ b/public_html/templates/default/LSformElement_supannLabeledValue_field.tpl @@ -1,7 +1,7 @@ {if $freeze} {if $value or $parseValue} {if $parseValue} - {if $label}[{$label}] {/if}{$value} + {if $label}[{$label}] {/if}{$value} {else} {$value} {/if} diff --git a/public_html/templates/default/LSformElement_supannRoleEntite_field.tpl b/public_html/templates/default/LSformElement_supannRoleEntite_field.tpl index 5c3866e7..1f0a5f1d 100644 --- a/public_html/templates/default/LSformElement_supannRoleEntite_field.tpl +++ b/public_html/templates/default/LSformElement_supannRoleEntite_field.tpl @@ -1,7 +1,7 @@ {if $freeze} {if $value or $parseValue} {if $parseValue} - {if $label_role}[{$label_role}] {/if}{$role} : {if $label_code}[{$label_code}] {/if}{$code} ({if $label_type}[{$label_type}] {/if}{$type}) + {if $label_role}[{$label_role}] {/if}{$role} : {if $label_code}[{$label_code}] {/if}{$code} ({if $label_type}[{$label_type}] {/if}{$type}) {else} {$value} {/if} diff --git a/public_html/templates/default/LSrelations.tpl b/public_html/templates/default/LSrelations.tpl index bb1d68b9..8f8628bf 100644 --- a/public_html/templates/default/LSrelations.tpl +++ b/public_html/templates/default/LSrelations.tpl @@ -2,7 +2,7 @@ {if $item.actions!=''} {/if} diff --git a/public_html/templates/default/login.tpl b/public_html/templates/default/login.tpl index 88b3c7cc..ad6f4a64 100644 --- a/public_html/templates/default/login.tpl +++ b/public_html/templates/default/login.tpl @@ -14,7 +14,7 @@ {include file='ls:LSdefault.tpl'}
- +
@@ -39,7 +39,7 @@
-{$lang_label} : {$LSlang} +{$lang_label} : {$LSlang} {$loginform_label_recoverPassword}
diff --git a/public_html/templates/default/modify.tpl b/public_html/templates/default/modify.tpl index 712cbd70..e422ea42 100644 --- a/public_html/templates/default/modify.tpl +++ b/public_html/templates/default/modify.tpl @@ -3,7 +3,7 @@ {if $LSview_actions != ''} {/if} diff --git a/public_html/templates/default/question.tpl b/public_html/templates/default/question.tpl index 48a2a6a3..7177b721 100644 --- a/public_html/templates/default/question.tpl +++ b/public_html/templates/default/question.tpl @@ -3,7 +3,7 @@ {if $LSview_actions != ''}

{foreach from=$LSview_actions item=item} - {$item.label} + {$item.label} {/foreach}

{/if} diff --git a/public_html/templates/default/recoverpassword.tpl b/public_html/templates/default/recoverpassword.tpl index 2040c8bc..0ca9c9c4 100644 --- a/public_html/templates/default/recoverpassword.tpl +++ b/public_html/templates/default/recoverpassword.tpl @@ -13,7 +13,7 @@ {include file='ls:LSdefault.tpl'}
- +
@@ -28,7 +28,7 @@

{$recoverpassword_msg}

-{$lang_label} : {$LSlang} +{$lang_label} : {$LSlang} {$recoverpasswordform_label_back}
diff --git a/public_html/templates/default/select.tpl b/public_html/templates/default/select.tpl index b380e272..71ff7e9c 100644 --- a/public_html/templates/default/select.tpl +++ b/public_html/templates/default/select.tpl @@ -18,7 +18,7 @@