From a974d2509257cb2c4967631cea30eb483c37c837 Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Thu, 12 Sep 2013 16:16:00 +0100 Subject: [PATCH] fix structured and batch mode. Add constant to disable batch mode by default --- lib/Geocode.php | 28 +++++++++++++++++++++------- lib/lib.php | 15 --------------- lib/template/search-batch-json.php | 1 + settings/settings.php | 2 ++ website/search.php | 2 +- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/lib/Geocode.php b/lib/Geocode.php index 0e1d7c1f..4b5b4e3d 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -190,6 +190,20 @@ return $this->sQuery; } + function loadStructuredAddressElement(&$aStructuredQuery, &$iMinAddressRank, &$iMaxAddressRank, &$aAddressRankList, $sValue, $sKey, $iNewMinAddressRank, $iNewMaxAddressRank, $aItemListValues) + { + $sValue = trim($sValue); + if (!$sValue) return false; + $aStructuredQuery[$sKey] = $sValue; + if ($iMinAddressRank == 0 && $iMaxAddressRank == 30) + { + $iMinAddressRank = $iNewMinAddressRank; + $iMaxAddressRank = $iNewMaxAddressRank; + } + if ($aItemListValues) $aAddressRankList = array_merge($aAddressRankList, $aItemListValues); + return true; + } + function setStructuredQuery($sAmentiy = false, $sStreet = false, $sCity = false, $sCounty = false, $sState = false, $sCountry = false, $sPostalCode = false) { $this->sQuery = false; @@ -197,13 +211,13 @@ $this->aStructuredQuery = array(); $this->sAllowedTypesSQLList = ''; - loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sAmentiy, 'amenity', 26, 30, false); - loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sStreet, 'street', 26, 30, false); - loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sCity, 'city', 14, 24, false); - loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sCounty, 'county', 9, 13, false); - loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sState, 'state', 8, 8, false); - loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sCountry, 'country', 4, 4, false); - loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sPostalCode, 'postalcode' , 5, 11, array(5, 11)); + $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sAmentiy, 'amenity', 26, 30, false); + $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sStreet, 'street', 26, 30, false); + $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sCity, 'city', 14, 24, false); + $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sCounty, 'county', 9, 13, false); + $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sState, 'state', 8, 8, false); + $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sCountry, 'country', 4, 4, false); + $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sPostalCode, 'postalcode' , 5, 11, array(5, 11)); if (sizeof($this->aStructuredQuery) > 0) { diff --git a/lib/lib.php b/lib/lib.php index 3417c95b..a75c3af7 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -884,21 +884,6 @@ return $iPlaceID; } - function loadStructuredAddressElement(&$aStructuredQuery, &$iMinAddressRank, &$iMaxAddressRank, &$aAddressRankList, $aParams, $sKey, $iNewMinAddressRank, $iNewMaxAddressRank, $aItemListValues) - { - if (!isset($_GET[$sKey])) return false; - $sValue = trim($_GET[$sKey]); - if (!$sValue) return false; - $aStructuredQuery[$sKey] = $sValue; - if ($iMinAddressRank == 0 && $iMaxAddressRank == 30) - { - $iMinAddressRank = $iNewMinAddressRank; - $iMaxAddressRank = $iNewMaxAddressRank; - } - if ($aItemListValues) $aAddressRankList = array_merge($aAddressRankList, $aItemListValues); - return true; - } - function addQuotes($s) { return "'".$s."'"; diff --git a/lib/template/search-batch-json.php b/lib/template/search-batch-json.php index 13c61952..ef2c143a 100644 --- a/lib/template/search-batch-json.php +++ b/lib/template/search-batch-json.php @@ -6,6 +6,7 @@ foreach($aBatchResults as $aSearchResults) { + if (!$aSearchResults) $aSearchResults = array(); $aFilteredPlaces = array(); foreach($aSearchResults as $iResNum => $aPointDetails) { diff --git a/settings/settings.php b/settings/settings.php index fc6ee8de..0ce34ad2 100644 --- a/settings/settings.php +++ b/settings/settings.php @@ -67,6 +67,8 @@ @define('CONST_Search_AreaPolygons_Enabled', true); @define('CONST_Search_AreaPolygons', true); + @define('CONST_Search_BatchMode', false); + @define('CONST_Search_TryDroppedAddressTerms', false); @define('CONST_Search_NameOnlySearchFrequencyThreshold', false); diff --git a/website/search.php b/website/search.php index 8e0bb6f6..b87f60e0 100755 --- a/website/search.php +++ b/website/search.php @@ -160,7 +160,7 @@ loadParamsToGeocode($oGeocode, $_GET, false); - if (isset($_GET['batch'])) + if (CONST_Search_BatchMode && isset($_GET['batch'])) { $aBatch = json_decode($_GET['batch'], true); $aBatchResults = array(); -- 2.39.5