mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-28 00:39:19 +01:00
changed search order and added some caching, to minimize db-accesses in country_code
This commit is contained in:
parent
a0ff70602a
commit
0d3caf95a8
@ -384,12 +384,8 @@ class country
|
|||||||
*/
|
*/
|
||||||
function country_code($name)
|
function country_code($name)
|
||||||
{
|
{
|
||||||
// search case-insensitive all translations for the english phrase of given country $name
|
if (!$name) return ''; // nothing to do
|
||||||
// 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 (($code = array_search(strtoupper($name),$this->country_array)) !== false)
|
if (($code = array_search(strtoupper($name),$this->country_array)) !== false)
|
||||||
{
|
{
|
||||||
return $code;
|
return $code;
|
||||||
@ -401,6 +397,21 @@ class country
|
|||||||
{
|
{
|
||||||
return $code;
|
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;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user