mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:50 +01:00
changed search order and added some caching, to minimize db-accesses in country_code
This commit is contained in:
parent
be03b8e71d
commit
9909652b9b
@ -384,12 +384,8 @@ class country
|
||||
*/
|
||||
function country_code($name)
|
||||
{
|
||||
// search case-insensitive all translations for the english phrase of given country $name
|
||||
// we do that to catch all possible cases of translations
|
||||
if (($name_en = $GLOBALS['egw']->translation->get_message_id($name,'common')))
|
||||
{
|
||||
$name = strtoupper($name_en);
|
||||
}
|
||||
if (!$name) return ''; // nothing to do
|
||||
|
||||
if (($code = array_search(strtoupper($name),$this->country_array)) !== false)
|
||||
{
|
||||
return $code;
|
||||
@ -401,6 +397,21 @@ class country
|
||||
{
|
||||
return $code;
|
||||
}
|
||||
// search case-insensitive all translations for the english phrase of given country $name
|
||||
// we do that to catch all possible cases of translations
|
||||
static $en_names = array(); // we do some caching to minimize db-accesses
|
||||
if (isset($en_names[$name]))
|
||||
{
|
||||
$name = $en_names[$name];
|
||||
}
|
||||
elseif (($name_en = $GLOBALS['egw']->translation->get_message_id($name,'common')))
|
||||
{
|
||||
$name = $en_names[$name] = strtoupper($name_en);
|
||||
}
|
||||
if (($code = array_search(strtoupper($name),$this->country_array)) !== false)
|
||||
{
|
||||
return $code;
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user