X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/b944e8b1720552f02bea3363225e9625f099911f..095dbe671880a9457960295425300e054feb6a1a:/lib/lib.php diff --git a/lib/lib.php b/lib/lib.php index e569aa8b..12f7e57e 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -94,7 +94,8 @@ function bySearchRank($a, $b) { - if ($a['iSearchRank'] == $b['iSearchRank']) return 0; + if ($a['iSearchRank'] == $b['iSearchRank']) + return strlen($a['sOperator']) + strlen($a['sHouseNumber']) - strlen($b['sOperator']) - strlen($b['sHouseNumber']); return ($a['iSearchRank'] < $b['iSearchRank']?-1:1); } @@ -117,18 +118,26 @@ } - function getPreferredLanguages() + function getPreferredLanguages($sLangString=false) { - // If we have been provided the value in $_GET it overrides browser value - if (isset($_GET['accept-language']) && $_GET['accept-language']) + if (!$sLangString) { - $_SERVER["HTTP_ACCEPT_LANGUAGE"] = $_GET['accept-language']; + // If we have been provided the value in $_GET it overrides browser value + if (isset($_GET['accept-language']) && $_GET['accept-language']) + { + $_SERVER["HTTP_ACCEPT_LANGUAGE"] = $_GET['accept-language']; + $sLangString = $_GET['accept-language']; + } + else if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) + { + $sLangString = $_SERVER["HTTP_ACCEPT_LANGUAGE"]; + } } $aLanguages = array(); - if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) + if ($sLangString) { - if (preg_match_all('/(([a-z]{1,8})(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $aLanguagesParse, PREG_SET_ORDER)) + if (preg_match_all('/(([a-z]{1,8})(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $sLangString, $aLanguagesParse, PREG_SET_ORDER)) { foreach($aLanguagesParse as $iLang => $aLanguage) { @@ -852,12 +861,12 @@ $sSQL .= ' ORDER BY ST_distance('.$sPointSQL.', geometry) ASC limit 1'; //var_dump($sSQL); $aPlace = $oDB->getRow($sSQL); - $iPlaceID = $aPlace['place_id']; - if (PEAR::IsError($iPlaceID)) + if (PEAR::IsError($aPlace)) { - var_Dump($sSQL, $iPlaceID); + var_Dump($sSQL, $aPlace); exit; } + $iPlaceID = $aPlace['place_id']; } // The point we found might be too small - use the address to find what it is a child of