mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-16 15:33:02 +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
|
// Smarty version
|
||||||
private static $_smarty_version = NULL;
|
private static $_smarty_version = NULL;
|
||||||
|
|
||||||
|
// Array of directories
|
||||||
|
private static $directories = array(
|
||||||
|
'local',
|
||||||
|
LS_THEME
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start LStemplate
|
* 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
|
* 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
|
* @retval string The path of the Smarty template file
|
||||||
**/
|
**/
|
||||||
public static function getTemplatePath($template) {
|
public static function getTemplatePath($template) {
|
||||||
$directories=array(
|
return self :: getFilePath($template,self :: $config['template_dir']);
|
||||||
'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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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
|
// Errors
|
||||||
LSerror :: defineError('LStemplate_01',
|
LSerror :: defineError('LStemplate_01',
|
||||||
_("LStemplate : Template %{file} not found.")
|
_("LStemplate : Template %{file} not found.")
|
||||||
|
|
|
@ -103,6 +103,6 @@ LStemplate :: $_smarty -> register_resource('ls', array(
|
||||||
);
|
);
|
||||||
|
|
||||||
// Register special template functions
|
// Register special template functions
|
||||||
LStemplate :: $_smarty -> register_function('getFData','smarty_getFData');
|
LStemplate :: $_smarty -> register_function('getFData','LStemplate_smarty_getFData');
|
||||||
LStemplate :: $_smarty -> register_function('tr','smarty_tr');
|
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());
|
LStemplate :: $_smarty -> registerResource('ls', new Smarty_Resource_LdapSaisie());
|
||||||
|
|
||||||
// Register special template functions
|
// Register special template functions
|
||||||
LStemplate :: $_smarty -> registerPlugin("function","getFData", "smarty_getFData");
|
LStemplate :: $_smarty -> registerPlugin("function","getFData", "LStemplate_smarty_getFData");
|
||||||
LStemplate :: $_smarty -> registerPlugin("function","tr", "smarty_tr");
|
LStemplate :: $_smarty -> registerPlugin("function","tr", "LStemplate_smarty_tr");
|
||||||
|
|
||||||
|
|
|
@ -164,11 +164,6 @@ function _getFData_extractAndModify($data,$ch) {
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function smarty_getFData($params) {
|
|
||||||
extract($params);
|
|
||||||
echo getFData($format,$data,$meth=NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFieldInFormat($format) {
|
function getFieldInFormat($format) {
|
||||||
$fields=array();
|
$fields=array();
|
||||||
$expr="%[{(]([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9]+))?(-)?(\!|\_)?(~)?[})]";
|
$expr="%[{(]([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9]+))?(-)?(\!|\_)?(~)?[})]";
|
||||||
|
@ -456,11 +451,6 @@ function LSdebugDefined() {
|
||||||
return _($msg);
|
return _($msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function smarty_tr($params) {
|
|
||||||
extract($params);
|
|
||||||
echo __($msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supprime les accents d'une chaine
|
* Supprime les accents d'une chaine
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue