X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/1c7da4318298a790e63c5648de57b3b804426731..3cdfe066336ad19772d300a85d6c1feaadc074ea:/lib/lib.php diff --git a/lib/lib.php b/lib/lib.php index c4fbca30..7760f695 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -1,5 +1,46 @@ $b['importance']?-1:1); - return ($a['foundorder'] < $b['foundorder']?-1:1); + return $a['foundorder'] <=> $b['foundorder']; } @@ -89,6 +130,24 @@ function addQuotes($s) return "'".$s."'"; } +function fwriteConstDef($rFile, $sConstName, $value) +{ + $sEscapedValue; + + if (is_bool($value)) { + $sEscapedValue = $value ? 'true' : 'false'; + } elseif (is_numeric($value)) { + $sEscapedValue = strval($value); + } elseif (!$value) { + $sEscapedValue = 'false'; + } else { + $sEscapedValue = addQuotes(str_replace("'", "\\'", (string)$value)); + } + + fwrite($rFile, "@define('CONST_$sConstName', $sEscapedValue);\n"); +} + + function parseLatLon($sQuery) { $sFound = null;