mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-23 00:43:48 +01:00
withoutAccents(): use unidecode lib if available
This commit is contained in:
parent
afb67b02e9
commit
b936decf89
2 changed files with 28 additions and 57 deletions
2
debian/control
vendored
2
debian/control
vendored
|
@ -7,7 +7,7 @@ Maintainer: Benjamin Renard <brenard@easter-eggs.com>
|
|||
Package: ldapsaisie
|
||||
Architecture: all
|
||||
Depends: apache2 | httpd, php-ldap | php5-ldap, php-fpm | libapache2-mod-php5 | libapache2-mod-php | php5-cli | php-cli, smarty | smarty3, php-net-ldap2, php-net-ftp, php-mail, php-mail-mime, php-console-table
|
||||
Recommends: php-mbstring, php-phpseclib
|
||||
Recommends: php-mbstring, php-phpseclib, php-unidecode
|
||||
Description: web based interface for managing LDAP servers content
|
||||
LdapSaisie is a Web application developed to manage LDAP directory.
|
||||
It has been written in PHP / JavaScript and is published under the
|
||||
|
|
|
@ -531,6 +531,14 @@ function LSdebugDefined() {
|
|||
return $msg;
|
||||
}
|
||||
|
||||
// Try to load unidecode library
|
||||
if (!function_exists('unidecode')) {
|
||||
if (file_exists(LS_LIB_DIR."/unidecode/unidecode.php"))
|
||||
@include(LS_LIB_DIR."/unidecode/unidecode.php");
|
||||
if (!function_exists('unidecode') && stream_resolve_include_path("unidecode/unidecode.php"))
|
||||
@include("unidecode/unidecode.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprime les accents d'une chaine
|
||||
*
|
||||
|
@ -538,62 +546,25 @@ function LSdebugDefined() {
|
|||
*
|
||||
* @retval string La chaine sans les accents
|
||||
*/
|
||||
function withoutAccents($string){
|
||||
$replaceAccent = Array(
|
||||
"à" => "a",
|
||||
"á" => "a",
|
||||
"â" => "a",
|
||||
"ã" => "a",
|
||||
"ä" => "a",
|
||||
"ç" => "c",
|
||||
"è" => "e",
|
||||
"é" => "e",
|
||||
"ê" => "e",
|
||||
"ë" => "e",
|
||||
"ì" => "i",
|
||||
"í" => "i",
|
||||
"î" => "i",
|
||||
"ï" => "i",
|
||||
"ñ" => "n",
|
||||
"ò" => "o",
|
||||
"ó" => "o",
|
||||
"ô" => "o",
|
||||
"õ" => "o",
|
||||
"ö" => "o",
|
||||
"ù" => "u",
|
||||
"ú" => "u",
|
||||
"û" => "u",
|
||||
"ü" => "u",
|
||||
"ý" => "y",
|
||||
"ÿ" => "y",
|
||||
"À" => "A",
|
||||
"Á" => "A",
|
||||
"Â" => "A",
|
||||
"Ã" => "A",
|
||||
"Ä" => "A",
|
||||
"Ç" => "C",
|
||||
"È" => "E",
|
||||
"É" => "E",
|
||||
"Ê" => "E",
|
||||
"Ë" => "E",
|
||||
"Ì" => "I",
|
||||
"Í" => "I",
|
||||
"Î" => "I",
|
||||
"Ï" => "I",
|
||||
"Ñ" => "N",
|
||||
"Ò" => "O",
|
||||
"Ó" => "O",
|
||||
"Ô" => "O",
|
||||
"Õ" => "O",
|
||||
"Ö" => "O",
|
||||
"Ù" => "U",
|
||||
"Ú" => "U",
|
||||
"Û" => "U",
|
||||
"Ü" => "U",
|
||||
"Ý" => "Y"
|
||||
);
|
||||
return strtr($string, $replaceAccent);
|
||||
}
|
||||
function withoutAccents($string){
|
||||
// Use unidecode lib if available
|
||||
if (function_exists('unidecode'))
|
||||
return unidecode($string);
|
||||
|
||||
// Otherwise, use historical method
|
||||
$replaceAccent = array(
|
||||
"à" => "a", "á" => "a", "â" => "a", "ã" => "a", "ä" => "a", "ç" => "c",
|
||||
"è" => "e", "é" => "e", "ê" => "e", "ë" => "e", "ì" => "i", "í" => "i",
|
||||
"î" => "i", "ï" => "i", "ñ" => "n", "ò" => "o", "ó" => "o", "ô" => "o",
|
||||
"õ" => "o", "ö" => "o", "ù" => "u", "ú" => "u", "û" => "u", "ü" => "u",
|
||||
"ý" => "y", "ÿ" => "y", "À" => "A", "Á" => "A", "Â" => "A", "Ã" => "A",
|
||||
"Ä" => "A", "Ç" => "C", "È" => "E", "É" => "E", "Ê" => "E", "Ë" => "E",
|
||||
"Ì" => "I", "Í" => "I", "Î" => "I", "Ï" => "I", "Ñ" => "N", "Ò" => "O",
|
||||
"Ó" => "O", "Ô" => "O", "Õ" => "O", "Ö" => "O", "Ù" => "U", "Ú" => "U",
|
||||
"Û" => "U", "Ü" => "U", "Ý" => "Y"
|
||||
);
|
||||
return strtr($string, $replaceAccent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue