AntonLV 7 лет назад
Родитель
Сommit
6dce4d4301

+ 19 - 0
inc/classes/BxDolMetatags.php

@@ -590,6 +590,25 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
         );
     }
 
+    /**
+     * Parse address components into associative array with the following indexes:
+     * lat, lng, country, state, city, zip, street, street_number
+     */ 
+    public static function locationsParseComponents($aAdress, $sPrefix = '')
+    {
+        $aKeys = array('lat', 'lng', 'country', 'state', 'city', 'zip', 'street', 'street_number');
+
+        if($sPrefix)
+            $sPrefix .= '_';
+
+        $aRet = array();
+        $iAdress = count($aAdress);
+        for($i = 0; $i < $iAdress; $i++)
+            $aRet[$sPrefix . $aKeys[$i]] = $aAdress[$i];
+
+        return $aRet;
+    }
+
     /**
      * Parse google's formatted address components into array with the following indexes:
      * lat, lng, country, state, city, zip, street, street_number

+ 1 - 1
modules/base/general/classes/BxBaseModGeneralDb.php

@@ -163,7 +163,7 @@ class BxBaseModGeneralDb extends BxDolModuleDb
                     if(!isset($CNF['OBJECT_METATAGS']))
                         break;
 
-                    list($fLatitude, $fLongitude, $sCountry, $sState, $sCity, $sZip) = $aSearchParam['value'];
+                    list($fLatitude, $fLongitude, $sCountry, $sState, $sCity, $sZip) = $aSearchParam['value']['array'];
 
                     $aSql = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS'])->locationsGetAsSQLPart($CNF['TABLE_ENTRIES'], $CNF['FIELD_ID'], $sCountry, $sState, $sCity, $sZip);
 

+ 22 - 6
template/scripts/BxBaseSearchExtended.php

@@ -97,18 +97,30 @@ class BxBaseSearchExtended extends BxDolSearchExtended
 
         $aParamsSearch = array();
         foreach($this->_aObject['fields'] as $aField) {
-            $sValue = $oForm->getCleanValue($aField['name']);
-            if(empty($sValue) || (is_array($sValue) && bx_is_empty_array($sValue)))
+            $mixedValue = $oForm->getCleanValue($aField['name']);
+            if(empty($mixedValue) || (is_array($mixedValue) && bx_is_empty_array($mixedValue)))
                 continue;
 
             $aParamsSearch[$aField['name']] = array(
                 'type' => $aField['search_type'],
-                'value' => $sValue,
+                'value' => $mixedValue,
                 'operator' => $aField['search_operator']
             );
 
-            if(!$bCondition)
-                $aParams['cond'][$aField['name']] = $sValue;
+            if(!$bCondition) {
+                if(!isset($aParams['cond']))
+                    $aParams['cond'] = array();
+
+                switch($oForm->aInputs[$aField['name']]['type']) {
+                    case 'location':
+                        $aParams['cond'][$aField['name']] = $mixedValue['string'];
+                        $aParams['cond'] = array_merge($aParams['cond'], BxDolMetatags::locationsParseComponents($mixedValue['array'], $aField['name']));
+                        break;
+
+                    default:
+                        $aParams['cond'][$aField['name']] = $mixedValue;
+                }
+            }
         }
 
         if(empty($aParamsSearch) || !is_array($aParamsSearch))
@@ -224,6 +236,9 @@ class BxBaseSearchExtended extends BxDolSearchExtended
                     'pass' => !empty($aField['pass']) ? $aField['pass'] : 'Xss'
                 )
             );
+
+            if(in_array($aField['search_type'], array('location')))
+                $aForm['inputs'][$aField['name']]['manual_input'] = true;
         }
 
         $aForm['inputs']['search'] = array(
@@ -241,9 +256,10 @@ class BxBaseSearchExtended extends BxDolSearchExtended
 
         $bJsMode = isset($aParams['js_mode']) ? (bool)$aParams['js_mode'] : $this->_bJsMode;
         $bCondition = !empty($aParams['cond']) && is_array($aParams['cond']);
+        $aValues = !$bJsMode && $bCondition ? $aParams['cond'] : array();
 
         $this->_oForm = new $sClass($aForm, $this->_oTemplate);
-        $this->_oForm->initChecker(!$bJsMode && $bCondition ? $aParams['cond'] : array());
+        $this->_oForm->initChecker($aValues, $aValues);
 
         return $this->_oForm;
     }

+ 4 - 1
template/scripts/BxBaseSearchExtendedForm.php

@@ -31,7 +31,10 @@ class BxBaseSearchExtendedForm extends BxTemplFormView
 
         //--- Process field with 'Location' type. 
         if($bType && $this->aInputs[$sName]['type'] == 'location')
-            return BxDolMetatags::locationsRetrieveFromForm($sName, $this);
+            return array(
+                'string' => parent::getCleanValue($sName), 
+                'array' => BxDolMetatags::locationsRetrieveFromForm($sName, $this)
+            );
 
         //--- Process field with 'Date Range Age' and 'Date-Time Range Age' type.
         if($bType && in_array($this->aInputs[$sName]['type'], array('datepicker_range_age', 'datetime_range_age'))) {