fix more syntax issues

This commit is contained in:
Sarah Hoffmann 2017-10-08 16:42:04 +02:00
parent fd08d41962
commit 795153b213
2 changed files with 17 additions and 14 deletions

View File

@ -741,12 +741,15 @@ class Geocode
// If the token is valid // If the token is valid
if (isset($aValidTokens[' '.$sToken])) { if (isset($aValidTokens[' '.$sToken])) {
// Recheck if the original word shows up in the query.
$bWordInQuery = false;
if (isset($aSearchTerm['word']) && $aSearchTerm['word']) {
$bWordInQuery = $this->normTerm($aSearchTerm['word']) !== false;
}
foreach ($aValidTokens[' '.$sToken] as $aSearchTerm) { foreach ($aValidTokens[' '.$sToken] as $aSearchTerm) {
// Recheck if the original word shows up in the query.
$bWordInQuery = false;
if (isset($aSearchTerm['word']) && $aSearchTerm['word']) {
$bWordInQuery = strpos(
$sNormQuery,
$this->normTerm($aSearchTerm['word'])
) !== false;
}
$aNewSearches = $oCurrentSearch->extendWithFullTerm( $aNewSearches = $oCurrentSearch->extendWithFullTerm(
$aSearchTerm, $aSearchTerm,
$bWordInQuery, $bWordInQuery,
@ -1180,7 +1183,7 @@ class Geocode
); );
} elseif ($oSearch->isOperator(Operator::POSTCODE)) { } elseif ($oSearch->isOperator(Operator::POSTCODE)) {
$aPlaceIDs = $oSearch->queryPostcode( $aPlaceIDs = $oSearch->queryPostcode(
$oDB, $this->oDB,
$sCountryCodesSQL, $sCountryCodesSQL,
$this->iLimit $this->iLimit
); );

View File

@ -20,7 +20,7 @@ abstract class Operator
/// Search for postcodes. /// Search for postcodes.
const POSTCODE = 5; const POSTCODE = 5;
private $aConstantNames = null; private static $aConstantNames = null;
public static function toString($iOperator) public static function toString($iOperator)
{ {
@ -28,17 +28,17 @@ abstract class Operator
return ''; return '';
} }
if ($aConstantNames === null) { if (Operator::$aConstantNames === null) {
$oReflector = new \ReflectionClass ('Nominatim\Operator'); $oReflector = new \ReflectionClass ('Nominatim\Operator');
$aConstants = $oReflector->getConstants(); $aConstants = $oReflector->getConstants();
$aConstantNames = array(); Operator::$aConstantNames = array();
foreach ($aConstants as $sName => $iValue) { foreach ($aConstants as $sName => $iValue) {
$aConstantNames[$iValue] = $sName; Operator::$aConstantNames[$iValue] = $sName;
} }
} }
return $aConstantNames[$iOperator]; return Operator::$aConstantNames[$iOperator];
} }
} }
@ -322,7 +322,7 @@ class SearchDescription
} }
$oSearch->setPoiSearch($iOp, $aSearchTerm['class'], $aSearchTerm['type']); $oSearch->setPoiSearch($iOp, $aSearchTerm['class'], $aSearchTerm['type']);
$aNewWordsetSearches[] = $oSearch; $aNewSearches[] = $oSearch;
} }
} elseif (isset($aSearchTerm['word_id']) && $aSearchTerm['word_id']) { } elseif (isset($aSearchTerm['word_id']) && $aSearchTerm['word_id']) {
$iWordID = $aSearchTerm['word_id']; $iWordID = $aSearchTerm['word_id'];
@ -501,10 +501,10 @@ class SearchDescription
$sSQL .= 'WHERE '; $sSQL .= 'WHERE ';
} }
$sSQL .= "p.postcode = '".pg_escape_string(reset($this->$aName))."'"; $sSQL .= "p.postcode = '".pg_escape_string(reset($this->aName))."'";
$sCountryTerm = $this->countryCodeSQL('p.country_code', $sCountryList); $sCountryTerm = $this->countryCodeSQL('p.country_code', $sCountryList);
if ($sCountryTerm) { if ($sCountryTerm) {
$sSQL .= ' AND '.$sCountyTerm; $sSQL .= ' AND '.$sCountryTerm;
} }
$sSQL .= " LIMIT $iLimit"; $sSQL .= " LIMIT $iLimit";