mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 22:43:47 +01:00
LStemplate : rename special smarty functions and added method getFilePath()
This commit is contained in:
parent
dcdb484134
commit
f4e97c8133
4 changed files with 48 additions and 30 deletions
|
@ -49,6 +49,12 @@ class LStemplate {
|
|||
// Smarty version
|
||||
private static $_smarty_version = NULL;
|
||||
|
||||
// Array of directories
|
||||
private static $directories = array(
|
||||
'local',
|
||||
LS_THEME
|
||||
);
|
||||
|
||||
/**
|
||||
* Start LStemplate
|
||||
*
|
||||
|
@ -111,6 +117,27 @@ class LStemplate {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path of the file to use
|
||||
*
|
||||
* @param[in] string $name The file name (eg: mail.png)
|
||||
* @param[in] string $root_dir The root directory (eg: images)
|
||||
* @param[in] string $default_dir The default directory (eg: default)
|
||||
*
|
||||
* @retval string The path of the file
|
||||
**/
|
||||
public static function getFilePath($file,$root_dir,$default_dir='default') {
|
||||
foreach(self :: $directories as $dir) {
|
||||
if (file_exists($root_dir.'/'.$dir.'/'.$file)) {
|
||||
return $root_dir.'/'.$dir.'/'.$file;
|
||||
}
|
||||
}
|
||||
if (!$default_dir) {
|
||||
return;
|
||||
}
|
||||
return $root_dir.'/'.$default_dir.'/'.$file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path of the Smarty template file to use
|
||||
*
|
||||
|
@ -119,16 +146,7 @@ class LStemplate {
|
|||
* @retval string The path of the Smarty template file
|
||||
**/
|
||||
public static function getTemplatePath($template) {
|
||||
$directories=array(
|
||||
'local',
|
||||
LS_THEME
|
||||
);
|
||||
foreach($directories as $dir) {
|
||||
if (file_exists(self :: $config['template_dir'].'/'.$dir.'/'.$template)) {
|
||||
return self :: $config['template_dir'].'/'.$dir.'/'.$template;
|
||||
}
|
||||
}
|
||||
return $config['template_dir'].'/default/'.$template;
|
||||
return self :: getFilePath($template,self :: $config['template_dir']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,6 +219,16 @@ class LStemplate {
|
|||
|
||||
}
|
||||
|
||||
function LStemplate_smarty_getFData($params) {
|
||||
extract($params);
|
||||
echo getFData($format,$data,$meth=NULL);
|
||||
}
|
||||
|
||||
function LStemplate_smarty_tr($params) {
|
||||
extract($params);
|
||||
echo __($msg);
|
||||
}
|
||||
|
||||
// Errors
|
||||
LSerror :: defineError('LStemplate_01',
|
||||
_("LStemplate : Template %{file} not found.")
|
||||
|
|
|
@ -103,6 +103,6 @@ LStemplate :: $_smarty -> register_resource('ls', array(
|
|||
);
|
||||
|
||||
// Register special template functions
|
||||
LStemplate :: $_smarty -> register_function('getFData','smarty_getFData');
|
||||
LStemplate :: $_smarty -> register_function('tr','smarty_tr');
|
||||
LStemplate :: $_smarty -> register_function('getFData','LStemplate_smarty_getFData');
|
||||
LStemplate :: $_smarty -> register_function('tr','LStemplate_smarty_tr');
|
||||
|
||||
|
|
|
@ -61,6 +61,6 @@ class Smarty_Resource_LdapSaisie extends Smarty_Resource_Custom {
|
|||
LStemplate :: $_smarty -> registerResource('ls', new Smarty_Resource_LdapSaisie());
|
||||
|
||||
// Register special template functions
|
||||
LStemplate :: $_smarty -> registerPlugin("function","getFData", "smarty_getFData");
|
||||
LStemplate :: $_smarty -> registerPlugin("function","tr", "smarty_tr");
|
||||
LStemplate :: $_smarty -> registerPlugin("function","getFData", "LStemplate_smarty_getFData");
|
||||
LStemplate :: $_smarty -> registerPlugin("function","tr", "LStemplate_smarty_tr");
|
||||
|
||||
|
|
|
@ -164,11 +164,6 @@ function _getFData_extractAndModify($data,$ch) {
|
|||
return $val;
|
||||
}
|
||||
|
||||
function smarty_getFData($params) {
|
||||
extract($params);
|
||||
echo getFData($format,$data,$meth=NULL);
|
||||
}
|
||||
|
||||
function getFieldInFormat($format) {
|
||||
$fields=array();
|
||||
$expr="%[{(]([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9]+))?(-)?(\!|\_)?(~)?[})]";
|
||||
|
@ -456,11 +451,6 @@ function LSdebugDefined() {
|
|||
return _($msg);
|
||||
}
|
||||
|
||||
function smarty_tr($params) {
|
||||
extract($params);
|
||||
echo __($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprime les accents d'une chaine
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue