Просмотр исходного кода

Merge branch 'master' of https://github.com/unaio/una

AntonLV 5 лет назад
Родитель
Сommit
c4d0679bc4

+ 2 - 3
inc/classes/BxDolCacheMemcache.php

@@ -83,13 +83,12 @@ class BxDolCacheMemcache extends BxDolCache
     }
 
     /**
-     * remove all data from cache by key prefix
+     * It always removes all data, regardless the prefix param
      * @return true on success
      */
     function removeAllByPrefix ($s)
     {
-        // not implemented for current cache
-        return false;
+        return $this->oMemcache->flush();
     }
 }
 

+ 2 - 41
inc/classes/BxDolEmbed.php

@@ -36,23 +36,8 @@
  * @endcode
  *
  */
-class BxDolEmbed extends BxDolFactory implements iBxDolFactoryObject
+class BxDolEmbed extends BxDolFactoryObject
 {
-    protected $_sObject;
-    protected $_aObject;
-
-    /**
-     * Constructor
-     * @param $aObject array of editor options
-     */
-    protected function __construct($aObject)
-    {
-        parent::__construct();
-
-        $this->_sObject = $aObject['object'];
-        $this->_aObject = $aObject;
-    }
-
     /**
      * Get editor object instance by object name
      * @param $sObject object name
@@ -63,31 +48,7 @@ class BxDolEmbed extends BxDolFactory implements iBxDolFactoryObject
         if (!$sObject)
             $sObject = getParam('sys_embed_default');
 
-        if (isset($GLOBALS['bxDolClasses']['BxDolEmbed!'.$sObject]))
-            return $GLOBALS['bxDolClasses']['BxDolEmbed!'.$sObject];
-
-        $aObject = BxDolEmbedQuery::getObject($sObject);
-        if (!$aObject || !is_array($aObject))
-            return false;
-
-        if (empty($aObject['override_class_name']))
-            return false;
-
-        $sClass = $aObject['override_class_name'];
-        if (!empty($aObject['override_class_file']))
-            require_once(BX_DIRECTORY_PATH_ROOT . $aObject['override_class_file']);
-
-        $o = new $sClass($aObject, $oTemplate);
-
-        return ($GLOBALS['bxDolClasses']['BxDolEmbed!'.$sObject] = $o);
-    }
-
-    /**
-     * Get object name
-     */
-    public function getObjectName ()
-    {
-        return $this->_sObject;
+        return parent::getObjectInstanceByClassNames($sObject, $oTemplate, 'BxDolEmbed', 'BxDolEmbedQuery');
     }
 
     /**

+ 4 - 22
inc/classes/BxDolEmbedQuery.php

@@ -11,34 +11,16 @@
  * Database queries for embed objects.
  * @see BxDolEmbed
  */
-class BxDolEmbedQuery extends BxDolDb
+class BxDolEmbedQuery extends BxDolFactoryObjectQuery
 {
-    protected $_aObject;
-
-    public function __construct($aObject)
-    {
-        parent::__construct();
-        $this->_aObject = $aObject;
-    }
-
-    static public function getObject ($sObject)
+    static public function getObject($sObject)
     {
-        $oDb = BxDolDb::getInstance();
-        $sQuery = $oDb->prepare("SELECT * FROM `sys_objects_embeds` WHERE `object` = ?", $sObject);
-        $aObject = $oDb->getRow($sQuery);
-        if (!$aObject || !is_array($aObject))
-            return false;
-
-        return $aObject;
+        return parent::getObjectFromTable($sObject, 'sys_objects_embeds');
     }
 
     static public function getObjects ()
     {
-        $aObjects = BxDolDb::getInstance()->getAll("SELECT * FROM `sys_objects_embeds` WHERE 1");
-        if(empty($aObjects) || !is_array($aObjects))
-            return array();
-
-        return $aObjects;
+        return parent::getObjectsFromTable('sys_objects_embeds');
     }
 }
 

+ 65 - 0
inc/classes/BxDolFactoryObject.php

@@ -0,0 +1,65 @@
+<?php defined('BX_DOL') or defined('BX_DOL_INSTALL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+/**
+ * Base class for classes with implement object instance 
+ */
+abstract class BxDolFactoryObject extends BxDolFactory implements iBxDolFactoryObject
+{
+	protected $_oDb;
+    protected $_oTemplate;
+	protected $_sObject;
+    protected $_aObject;
+
+    protected function __construct($aObject, $oTemplate = null, $sDbClassName = '')
+    {
+        parent::__construct();
+
+        $this->_aObject = $aObject;
+        $this->_sObject = $aObject['object'];
+        $this->_oTemplate = $oTemplate ? $oTemplate : BxDolTemplate::getInstance();
+        if ($sDbClassName)
+            $this->_oDb = new $sDbClassName($this->_aObject);
+    }
+
+   /**
+     * Get object instance by object name
+     * @param $sObject object name
+     * @return object instance or false on error
+     */
+    public static function getObjectInstanceByClassNames($sObject, $oTemplate, $sClassName, $sDbClassName)
+    {
+        if(isset($GLOBALS['bxDolClasses'][$sClassName . '!' . $sObject]))
+            return $GLOBALS['bxDolClasses'][$sClassName . '!' . $sObject];
+
+        $aObject = $sDbClassName::getObject($sObject);
+        if (!$aObject || !is_array($aObject))
+            return false;
+
+        $sClass = $sClassName;
+        if(!empty($aObject['class_name'])) {
+            $sClass = $aObject['class_name'];
+            if(!empty($aObject['class_file']))
+                require_once(BX_DIRECTORY_PATH_ROOT . $aObject['class_file']);
+        }        
+
+        $o = new $sClass($aObject, $oTemplate);
+        return ($GLOBALS['bxDolClasses'][$sClassName . '!' . $sObject] = $o);
+    }
+
+    /**
+     * Get current object name
+     */
+    public function getObjectName()
+    {
+        return $this->_aObject['object'];
+    }
+}
+
+/** @} */

+ 46 - 0
inc/classes/BxDolFactoryObjectQuery.php

@@ -0,0 +1,46 @@
+<?php defined('BX_DOL') or defined('BX_DOL_INSTALL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+/**
+ * Base class for DB classes associated with object instance 
+ */
+class BxDolFactoryObjectQuery extends BxDolDb
+{
+    protected $_aObject;
+
+    public function __construct($aObject = array())
+    {
+        parent::__construct();
+        $this->_aObject = $aObject;
+    }
+
+    static public function getObjectFromTable($sObject, $sTable)
+    {
+        $oDb = BxDolDb::getInstance();
+
+        $sQuery = $oDb->prepare("SELECT * FROM `$sTable` WHERE `object` = ?", $sObject);
+
+        $aObject = $oDb->getRow($sQuery);
+        if(!$aObject || !is_array($aObject))
+            return false;
+
+        return $aObject;
+    }
+
+    static public function getObjectsFromTable ($sTable)
+    {
+        $aObjects = BxDolDb::getInstance()->getAll("SELECT * FROM `$sTable`");
+        if(empty($aObjects) || !is_array($aObjects))
+            return array();
+
+        return $aObjects;
+    }
+}
+
+/** @} */

+ 5 - 106
inc/classes/BxDolLocationField.php

@@ -17,23 +17,11 @@
  * - class_name: user defined class name which is derived from BxDolLocationField.
  * - class_file: the location of the user defined class, leave it empty if class is located in system folders.
  */
-class BxDolLocationField extends BxDolFactory implements iBxDolFactoryObject
+class BxDolLocationField extends BxDolFactoryObject
 {
-	protected $_oDb;
-	protected $_sObject;
-    protected $_aObject;
-
-    /**
-     * Constructor
-     */
     protected function __construct($aObject)
     {
-        parent::__construct();
-
-        $this->_aObject = $aObject;
-        $this->_sObject = $aObject['object'];
-
-        $this->_oDb = new BxDolLocationFieldQuery($this->_aObject);
+        parent::__construct($aObject, null, 'BxDolLocationFieldQuery');
     }
 
    /**
@@ -43,102 +31,13 @@ class BxDolLocationField extends BxDolFactory implements iBxDolFactoryObject
      */
     public static function getObjectInstance($sObject)
     {
-        if(isset($GLOBALS['bxDolClasses']['BxDolLocationField!' . $sObject]))
-            return $GLOBALS['bxDolClasses']['BxDolLocationField!' . $sObject];
-
-        $aObject = BxDolLocationFieldQuery::getLocationFieldObject($sObject);
-        if (!$aObject || !is_array($aObject))
-            return false;
-
-        $sClass = 'BxDolLocationField';
-        if(!empty($aObject['class_name'])) {
-            $sClass = $aObject['class_name'];
-            if(!empty($aObject['class_file']))
-                require_once(BX_DIRECTORY_PATH_ROOT . $aObject['class_file']);
-        }        
-
-        $o = new $sClass($aObject);
-        return ($GLOBALS['bxDolClasses']['BxDolLocationField!' . $sObject] = $o);
-    }
-
-    /**
-     * Get current object name
-     */
-    public function getObjectName()
-    {
-        return $this->_aObject['object'];
+        return parent::getObjectInstanceByClassNames($sObject, null, 'BxDolLocationField', 'BxDolLocationFieldQuery');
     }
 
     public function genInputLocation (&$aInput, $oForm)
     {        
-        $isManualInput = (int)(isset($aInput['manual_input']) && $aInput['manual_input']);
-        if (!$isManualInput) {
-            $aVars = array();
-            $aInputField = $aInput;
-
-            $aLocationIndexes = BxDolForm::$LOCATION_INDEXES;
-            foreach ($aLocationIndexes as $sKey)
-                $aVars[$sKey] = $this->getLocationVal($aInput, $sKey, $oForm);
-
-            $aInputField['caption'] = _t('_sys_location_undefined');
-
-            if ($this->getLocationVal($aInput, 'lat', $oForm) && $this->getLocationVal($aInput, 'lng', $oForm))
-                $aInputField['checked'] = true;
-            else
-                $aInputField['checked'] = $oForm->getCleanValue($aInput['name'] . '_lat') && $oForm->getCleanValue($aInput['name'] . '_lng') ? 1 : 0;
-
-            $sLocationString = _t('_sys_location_undefined');
-            if ($aVars['country']) {
-                $aCountries = BxDolFormQuery::getDataItems('Country');
-                $sLocationString = ($aVars['street_number'] ? $aVars['street_number'] . ', ' : '') . ($aVars['street'] ? $aVars['street'] . ', ' : '') . ($aVars['city'] ? $aVars['city'] . ', ' : '') . ($aVars['state'] ? $aVars['state'] . ', ' : '') . $aCountries[$aVars['country']];
-            }
-            elseif ($aVars['lat'] || $aVars['lng']) {
-                $sLocationString = $aVars['lat'] . ', ' . $aVars['lng'];
-            }
-
-            $aVars = array (
-                'name' => $aInput['name'],
-                'input' => $oForm->genInputSwitcher($aInputField),
-                'id_status' => $oForm->getInputId($aInput) . '_status',
-                'location_string' => $sLocationString,
-            );
-
-            $sRet = $oForm->getTemplate()->parseHtmlByName('form_field_location_plain_auto.html', $aVars);
-        }
-        else {
-            // TODO: translations for placeholders
-            $aFields = array(
-                'lat' => array('type' => 'hidden'),
-                'lng' => array('type' => 'hidden'),
-                'street_number' => array('type' => 'text', 'ph' => 'Number'),
-                'street' => array('type' => 'text', 'ph' => 'Street'),
-                'city' => array('type' => 'text', 'ph' => 'City / Disctrict'),
-                'state' => array('type' => 'text', 'ph' => 'State / Province'),
-                'zip' => array('type' => 'text', 'ph' => 'Postal Code'),
-                'country' => array('type' => 'select'),
-            );
-
-            $sRet = '';
-            foreach ($aFields as $sKey => $a) {
-                $aInputField = $aInput;
-                $aInputField['name'] = $aInput['name'] . '_' . $sKey;
-                $aInputField['type'] = $a['type'];
-                $aInputField['value'] = $this->getLocationVal($aInput, $sKey, $oForm);            
-                $aInputField['attrs']['placeholder'] = empty($a['ph']) ? '' : _t($a['ph']);
-                if (isset($aInputField['attrs']['class']))
-                    $aInputField['attrs']['class'] .= ' bx-form-input-location-' . $sKey;
-                else
-                    $aInputField['attrs']['class'] = 'bx-form-input-location-' . $sKey;
-                if ('country' == $sKey) {
-                    $aInputField['values'] = BxDolFormQuery::getDataItems('Country');
-                    $sRet .= $oForm->genInputSelect($aInputField);
-                }
-                else {
-                    $sRet .= $oForm->genInputStandard($aInputField);
-                }
-            }
-        }
-        return $sRet;
+        // override this
+        return 'not implemented';
     }
 
     protected function getLocationVal ($aInput, $sIndex, $oForm) 

+ 1 - 1
inc/classes/BxDolLocationFieldGoogle.php

@@ -12,7 +12,7 @@ class BxDolLocationFieldGoogle extends BxDolLocationField
     public function genInputLocation (&$aInput, $oForm)
     {
         $aVars = $this->_getInputLocationVars($aInput, $oForm);
-        return $oForm->getTemplate()->parseHtmlByName('form_field_location_google.html', $aVars);
+        return $oForm->getTemplate()->parseHtmlByName('location_field_google.html', $aVars);
     }
 
     protected function _getInputLocationVars(&$aInput, $oForm)

+ 105 - 0
inc/classes/BxDolLocationFieldNominatim.php

@@ -0,0 +1,105 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+/**
+ * Plain fields with Nomination service geocoding
+ */
+class BxDolLocationFieldNominatim extends BxDolLocationField
+{
+    public function genInputLocation (&$aInput, $oForm)
+    {        
+        $isManualInput = (int)(isset($aInput['manual_input']) && $aInput['manual_input']);
+        if (!$isManualInput) {
+            $aVars = array();
+            $aInputField = $aInput;
+
+            $aLocationIndexes = BxDolForm::$LOCATION_INDEXES;
+            foreach ($aLocationIndexes as $sKey)
+                $aVars[$sKey] = $this->getLocationVal($aInput, $sKey, $oForm);
+
+            $aInputField['caption'] = _t('_sys_location_undefined');
+
+            if ($this->getLocationVal($aInput, 'lat', $oForm) && $this->getLocationVal($aInput, 'lng', $oForm))
+                $aInputField['checked'] = true;
+            else
+                $aInputField['checked'] = $oForm->getCleanValue($aInput['name'] . '_lat') && $oForm->getCleanValue($aInput['name'] . '_lng') ? 1 : 0;
+
+            $sLocationString = _t('_sys_location_undefined');
+            if ($aVars['country']) {
+                $aCountries = BxDolFormQuery::getDataItems('Country');
+                $sLocationString = ($aVars['street_number'] ? $aVars['street_number'] . ', ' : '') . ($aVars['street'] ? $aVars['street'] . ', ' : '') . ($aVars['city'] ? $aVars['city'] . ', ' : '') . ($aVars['state'] ? $aVars['state'] . ', ' : '') . $aCountries[$aVars['country']];
+            }
+            elseif ($aVars['lat'] || $aVars['lng']) {
+                $sLocationString = $aVars['lat'] . ', ' . $aVars['lng'];
+            }
+
+            $aVars['name'] = $aInput['name'];
+            $aVars['input'] = $oForm->genInputSwitcher($aInputField);
+            $aVars['id_status'] = $oForm->getInputId($aInput) . '_status';
+            $aVars['location_string'] = $sLocationString;
+            $aVars['nominatim_server'] = $this->getNominatimServer();
+            $aVars['nominatim_email'] = $this->getNominatimEmail();
+
+            $sRet = $oForm->getTemplate()->parseHtmlByName('location_field_plain_auto.html', $aVars);
+        }
+        else {
+            $aFields = array(
+                'lat' => array('type' => 'hidden'),
+                'lng' => array('type' => 'hidden'),
+                'street_number' => array('type' => 'text', 'ph' => _t('_sys_location_ph_number')),
+                'street' => array('type' => 'text', 'ph' => _t('_sys_location_ph_street')),
+                'city' => array('type' => 'text', 'ph' => _t('_sys_location_ph_city')),
+                'state' => array('type' => 'text', 'ph' => _t('_sys_location_ph_state')),
+                'zip' => array('type' => 'text', 'ph' => _t('_sys_location_ph_zip')),
+                'country' => array('type' => 'select'),
+            );
+
+            $sInputs = '';
+            foreach ($aFields as $sKey => $a) {
+                $aInputField = $aInput;
+                $aInputField['name'] = $aInput['name'] . '_' . $sKey;
+                $aInputField['type'] = $a['type'];
+                $aInputField['value'] = $this->getLocationVal($aInput, $sKey, $oForm);            
+                $aInputField['attrs']['placeholder'] = empty($a['ph']) ? '' : _t($a['ph']);
+                if (isset($aInputField['attrs']['class']))
+                    $aInputField['attrs']['class'] .= ' bx-form-input-location-' . $sKey;
+                else
+                    $aInputField['attrs']['class'] = 'bx-form-input-location-' . $sKey;
+                if ('country' == $sKey) {
+                    $aCountries = BxDolFormQuery::getDataItems('Country');
+                    array_unshift($aCountries, array('key' => '', 'value' => _t('_None')));
+                    $aInputField['values'] = $aCountries;
+                    $sInputs .= $oForm->genInputSelect($aInputField);
+                }
+                else {
+                    $sInputs .= $oForm->genInputStandard($aInputField);
+                }
+            }
+            $sRet = $oForm->getTemplate()->parseHtmlByName('location_field_plain.html', array(
+                'name' => $aInput['name'],
+                'nominatim_server' => $this->getNominatimServer(),
+                'nominatim_email' => $this->getNominatimEmail(),
+                'inputs' => $sInputs,
+            ));
+        }
+        return $sRet;
+    }
+
+    protected function getNominatimServer ()
+    {
+        return trim(trim(getParam('sys_nominatim_server')), '/');
+    }
+
+    protected function getNominatimEmail ()
+    {
+        return trim(getParam('sys_nominatim_email'));
+    }
+}
+
+/** @} */

+ 5 - 15
inc/classes/BxDolLocationFieldQuery.php

@@ -7,26 +7,16 @@
  * @{
  */
 
-class BxDolLocationFieldQuery extends BxDolDb
+class BxDolLocationFieldQuery extends BxDolFactoryObjectQuery
 {
-
-    public function __construct($aObject = array())
+    static public function getObject($sObject)
     {
-        parent::__construct();
-        $this->_aObject = $aObject;
+        return parent::getObjectFromTable($sObject, 'sys_objects_location_field');
     }
 
-    static public function getLocationFieldObject($sObject)
+    static public function getObjects ()
     {
-        $oDb = BxDolDb::getInstance();
-
-        $sQuery = $oDb->prepare("SELECT * FROM `sys_objects_location_field` WHERE `object` = ?", $sObject);
-
-        $aObject = $oDb->getRow($sQuery);
-        if(!$aObject || !is_array($aObject))
-            return false;
-
-        return $aObject;
+        return parent::getObjectsFromTable('sys_objects_location_field');
     }
 }
 

+ 3 - 39
inc/classes/BxDolLocationMap.php

@@ -17,24 +17,11 @@
  * - class_name: user defined class name which is derived from BxDolLocationField.
  * - class_file: the location of the user defined class, leave it empty if class is located in system folders.
  */
-class BxDolLocationMap extends BxDolFactory implements iBxDolFactoryObject
+class BxDolLocationMap extends BxDolFactoryObject
 {
-	protected $_oDb;
-	protected $_sObject;
-    protected $_aObject;
-    protected $_oTemplate;
-
-    /**
-     * Constructor
-     */
     protected function __construct($aObject, $oTemplate = null)
     {
-        parent::__construct();
-
-        $this->_aObject = $aObject;
-        $this->_sObject = $aObject['object'];
-        $this->_oTemplate = $oTemplate ? $oTemplate : BxDolTemplate::getInstance();
-        $this->_oDb = new BxDolLocationMapQuery($this->_aObject);
+        parent::__construct($aObject, $oTemplate, 'BxDolLocationFieldQuery');
     }
 
    /**
@@ -44,30 +31,7 @@ class BxDolLocationMap extends BxDolFactory implements iBxDolFactoryObject
      */
     public static function getObjectInstance($sObject, $oTemplate = null)
     {
-        if(isset($GLOBALS['bxDolClasses']['BxDolLocationMap!' . $sObject]))
-            return $GLOBALS['bxDolClasses']['BxDolLocationMap!' . $sObject];
-
-        $aObject = BxDolLocationMapQuery::getLocationMapObject($sObject);
-        if (!$aObject || !is_array($aObject))
-            return false;
-
-        $sClass = 'BxDolLocationMap';
-        if(!empty($aObject['class_name'])) {
-            $sClass = $aObject['class_name'];
-            if(!empty($aObject['class_file']))
-                require_once(BX_DIRECTORY_PATH_ROOT . $aObject['class_file']);
-        }        
-
-        $o = new $sClass($aObject, $oTemplate);
-        return ($GLOBALS['bxDolClasses']['BxDolLocationMap!' . $sObject] = $o);
-    }
-
-    /**
-     * Get current object name
-     */
-    public function getObjectName()
-    {
-        return $this->_aObject['object'];
+        return parent::getObjectInstanceByClassNames($sObject, $oTemplate, 'BxDolLocationMap', 'BxDolLocationMapQuery');
     }
 
     /**

+ 5 - 15
inc/classes/BxDolLocationMapQuery.php

@@ -7,26 +7,16 @@
  * @{
  */
 
-class BxDolLocationMapQuery extends BxDolDb
+class BxDolLocationMapQuery extends BxDolFactoryObjectQuery
 {
-
-    public function __construct($aObject = array())
+    static public function getObject($sObject)
     {
-        parent::__construct();
-        $this->_aObject = $aObject;
+        return parent::getObjectFromTable($sObject, 'sys_objects_location_map');
     }
 
-    static public function getLocationMapObject($sObject)
+    static public function getObjects ()
     {
-        $oDb = BxDolDb::getInstance();
-
-        $sQuery = $oDb->prepare("SELECT * FROM `sys_objects_location_map` WHERE `object` = ?", $sObject);
-
-        $aObject = $oDb->getRow($sQuery);
-        if(!$aObject || !is_array($aObject))
-            return false;
-
-        return $aObject;
+        return parent::getObjectsFromTable('sys_objects_location_map');
     }
 }
 

+ 15 - 2
inc/classes/BxDolMetatags.php

@@ -571,6 +571,8 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
      */
     public function locationsAdd($iId, $sLatitude, $sLongitude, $sCountryCode, $sState, $sCity, $sZip = '', $sStreet = '', $sStreetNumber = '') 
     {
+        // TODO: if lat & lng aren't defined then perform geocoding automatically, or maybe leverage this on client side ?
+
         return $this->_oQuery->locationsAdd($iId, $sLatitude, $sLongitude, $sCountryCode, $sState, $sCity, $sZip, $sStreet, $sStreetNumber);
     }
 
@@ -692,11 +694,22 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
      * @return string with links to country and city
      */
     public function locationsString($iId, $bHTML = true, $aParams = array())
+    {
+        bx_import('BxDolForm');        
+        $aLocation = $this->locationGet($iId);
+        return $this->locationsStringFromArray($aLocation, $bHTML, $aParams);
+    }
+
+    /**
+     * Get locations string with links
+     * @param $aLocation location array
+     * @return string with links to country and city
+     */
+    public function locationsStringFromArray($aLocation, $bHTML = true, $aParams = array())
     {
         $s = '';
-        bx_import('BxDolForm');
         $aCountries = BxDolFormQuery::getDataItems('Country');
-        $aLocation = $this->locationGet($iId);
+
         if(!$aLocation || !$aLocation['country'] || !isset($aCountries[$aLocation['country']])) {
             if (!empty($aLocation['lat']) || !empty($aLocation['lng']))
                 $s = _t('_sys_location_country', $aLocation['lat'] . ', ' . $aLocation['lng']);

+ 1 - 1
inc/classes/BxDolMetatagsQuery.php

@@ -89,7 +89,7 @@ class BxDolMetatagsQuery extends BxDolDb
     public function locationsAdd($mixedContentId, $fLat, $fLng, $sCountryCode, $sState, $sCity, $sZip, $sStreet, $sStreetNumber)
     {
         $this->locationsDelete($mixedContentId);
-        if (!$fLat && !$fLng && !$sCountryCode)
+        if (!$fLat && !$fLng) // locations without latitude and longitude aren't allowed
             return true;
 
         $sQuery = $this->prepare("INSERT INTO `{$this->_aObject['table_locations']}` SET `object_id` = ?, `lat` = ?, `lng` = ?, `country` = ?, `state` = ?, `city` = ?, `zip` = ?, `street` = ?, `street_number` = ?", $mixedContentId, $fLat, $fLng, $sCountryCode, $sState, $sCity, $sZip, $sStreet, $sStreetNumber);

+ 14 - 3
install/sql/system.sql

@@ -434,8 +434,6 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 
 (@iCategoryId, 'sys_default_payment', '_adm_stg_cpt_option_sys_default_payment', '', 'select', 'a:3:{s:6:"module";s:6:"system";s:6:"method";s:12:"get_payments";s:5:"class";s:21:"TemplPaymentsServices";}', '', '', 60),
 
-(@iCategoryId, 'sys_maps_api_key', '_adm_stg_cpt_option_sys_maps_api_key', '', 'digit', '', '', '', 70),
-
 (@iCategoryId, 'sys_embed_default', '_adm_stg_cpt_option_sys_embed_default', 'sys_embedly', 'select', 'a:3:{s:6:"module";s:6:"system";s:6:"method";s:25:"get_options_embed_default";s:5:"class";s:13:"TemplServices";}', '', '', 79),
 (@iCategoryId, 'sys_embedly_api_key', '_adm_stg_cpt_option_sys_embedly_api_key', '', 'digit', '', '', '', 80),
 
@@ -591,6 +589,19 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 (@iCategoryId, 'sys_twilio_gate_from_number', '_adm_stg_cpt_option_sys_twilio_gate_from_number', '', 'digit', '', '', '', 3);
 
 
+--
+-- CATEGORY: Location
+--
+INSERT INTO `sys_options_categories`(`type_id`, `name`, `caption`, `hidden`, `order`) VALUES (@iTypeId, 'location', '_adm_stg_cpt_category_location', 0, 20);
+SET @iCategoryId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `extra`, `check`, `check_error`, `order`) VALUES
+(@iCategoryId, 'sys_location_field_default', '_adm_stg_cpt_option_sys_location_field_default', 'sys_plain', 'select', 'a:3:{s:6:"module";s:6:"system";s:6:"method";s:34:"get_options_location_field_default";s:5:"class";s:13:"TemplServices";}', '', '', 10),
+(@iCategoryId, 'sys_location_map_default', '_adm_stg_cpt_option_sys_location_map_default', 'sys_google_static', 'select', 'a:3:{s:6:"module";s:6:"system";s:6:"method";s:32:"get_options_location_map_default";s:5:"class";s:13:"TemplServices";}', '', '', 12),
+(@iCategoryId, 'sys_maps_api_key', '_adm_stg_cpt_option_sys_maps_api_key', '', 'digit', '', '', '', 20),
+(@iCategoryId, 'sys_nominatim_server', '_adm_stg_cpt_option_sys_nominatim_server', 'https://nominatim.openstreetmap.org', 'digit', '', '', '', 30),
+(@iCategoryId, 'sys_nominatim_email', '_adm_stg_cpt_option_sys_nominatim_email', '', 'digit', '', '', '', 32);
+
 --
 -- CATEGORY (HIDDEN): Audit
 --
@@ -5243,7 +5254,7 @@ CREATE TABLE `sys_objects_location_field` (
 
 INSERT INTO `sys_objects_location_field` (`object`, `module`, `title`, `class_name`, `class_file`) VALUES
 ('sys_google', 'system', '_sys_location_field_google', 'BxDolLocationFieldGoogle', ''),
-('sys_plain', 'system', '_sys_location_field_plain', 'BxDolLocationField', '');
+('sys_plain', 'system', '_sys_location_field_plain', 'BxDolLocationFieldNominatim', '');
 
 -- --------------------------------------------------------
 

+ 0 - 9
modules/base/general/template/css/forms.css

@@ -24,12 +24,3 @@
 .bx-base-general-use-as-thumb label {
     vertical-align:middle;
 }
-
-/* location input */
-
-.bx-form-input-location-cont > div {
-    float:left;
-    line-height:1.5rem;
-}
-
-

+ 16 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -1424,6 +1424,7 @@
 	<string name="_adm_stg_cpt_category_system"><![CDATA[System]]></string>
 	<string name="_adm_stg_cpt_category_templates"><![CDATA[Templates]]></string>
     <string name="_adm_stg_cpt_category_twilio_gate"><![CDATA[Twilio]]></string>
+    <string name="_adm_stg_cpt_category_location"><![CDATA[Location]]></string>
     <string name="_adm_stg_cpt_option_client_image_resize_width"><![CDATA[Image width to resize before upload (0 - disable)]]></string>
     <string name="_adm_stg_cpt_option_client_image_resize_height"><![CDATA[Image height to resize before upload (0 - disable)]]></string>
 	<string name="_adm_stg_cpt_option_currency_code"><![CDATA[Currency code (for checkout system)]]></string>
@@ -1502,6 +1503,8 @@
 	<string name="_adm_stg_cpt_option_sys_install_time"><![CDATA[Installation date]]></string>
 	<string name="_adm_stg_cpt_option_sys_upgrade_channel"><![CDATA[Update channel]]></string>
 	<string name="_adm_stg_cpt_option_sys_live_updates_interval"><![CDATA[Live updates interval (in milliseconds)]]></string>
+    <string name="_adm_stg_cpt_option_sys_location_field_default"><![CDATA[Location field provider]]></string>
+    <string name="_adm_stg_cpt_option_sys_location_map_default"><![CDATA[Location map provider]]></string>
 	<string name="_adm_stg_cpt_option_sys_maps_api_key"><![CDATA[Google Maps API key]]></string>
 	<string name="_adm_stg_cpt_option_sys_embed_default"><![CDATA[Embeds provider]]></string>
 	<string name="_adm_stg_cpt_option_sys_embedly_api_key"><![CDATA[Embed.ly API key (fill in to use instead of Iframely)]]></string>
@@ -1528,6 +1531,8 @@
 	<string name="_adm_stg_cpt_option_sys_twilio_gate_sid"><![CDATA[Account SID]]></string>
 	<string name="_adm_stg_cpt_option_sys_twilio_gate_token"><![CDATA[Auth token]]></string>
 	<string name="_adm_stg_cpt_option_sys_twilio_gate_from_number"><![CDATA[Default 'From' number for SMS]]></string>    
+	<string name="_adm_stg_cpt_option_sys_nominatim_server"><![CDATA[Nominatim server URL]]></string>    
+	<string name="_adm_stg_cpt_option_sys_nominatim_email"><![CDATA[Nominatim email to identify requests]]></string>
 	<string name="_adm_stg_cpt_option_sys_recaptcha_key_private"><![CDATA[reCAPTCHA private key]]></string>
 	<string name="_adm_stg_cpt_option_sys_recaptcha_key_public"><![CDATA[reCAPTCHA public key]]></string>
 	<string name="_adm_stg_cpt_option_sys_redirect_after_account_added"><![CDATA[Redirect after account creation to]]></string>
@@ -2572,6 +2577,17 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_location_determining"><![CDATA[Determining location...]]></string>
 	<string name="_sys_location_geolocation_not_supported_by_browser"><![CDATA[Geolocation is not supported by this browser]]></string>
 	<string name="_sys_location_undefined"><![CDATA[Location off]]></string>
+	<string name="_sys_location_map_google_static"><![CDATA[Google Maps (Static)]]></string>
+	<string name="_sys_location_field_google"><![CDATA[Google autocomplete for addresses]]></string>
+	<string name="_sys_location_field_plain"><![CDATA[Plain address fields with Nominatim OSM geocoding]]></string>
+    <string name="_sys_location_ph_number"><![CDATA[Number]]></string>
+    <string name="_sys_location_ph_street"><![CDATA[Street]]></string>
+    <string name="_sys_location_ph_city"><![CDATA[City / District]]></string>
+    <string name="_sys_location_ph_state"><![CDATA[State / Province]]></string>
+    <string name="_sys_location_ph_zip"><![CDATA[Postal Code]]></string>
+    <string name="_sys_location_status_undef"><![CDATA[Undefined]]></string>
+    <string name="_sys_location_status_ok"><![CDATA[Address found]]></string>
+    <string name="_sys_location_status_fail"><![CDATA[Address not found]]></string>
 	<string name="_sys_log_debug"><![CDATA[System: debug]]></string>
     <string name="_sys_log_twilio"><![CDATA[System: Twilio]]></string>
     <string name="_sys_log_push"><![CDATA[System: PUSH]]></string>

+ 14 - 1
modules/boonex/russian/data/langs/system/ru.xml

@@ -1485,6 +1485,8 @@
     <string name="_adm_stg_cpt_option_sys_install_time"><![CDATA[Дата установки]]></string>
     <string name="_adm_stg_cpt_option_sys_upgrade_channel"><![CDATA[Канал обновлений]]></string>
     <string name="_adm_stg_cpt_option_sys_live_updates_interval"><![CDATA[Интервал обновлений (в миллисекундах)]]></string>
+    <string name="_adm_stg_cpt_option_sys_location_field_default"><![CDATA[Поставщик для поля ввода адреса]]></string>
+    <string name="_adm_stg_cpt_option_sys_location_map_default"><![CDATA[Поставщик для отображения карт]]></string>
     <string name="_adm_stg_cpt_option_sys_maps_api_key"><![CDATA[Ключ Google Maps API]]></string>
     <string name="_adm_stg_cpt_option_sys_embed_default"><![CDATA[Поставщик встраиваемого кода]]></string>
     <string name="_adm_stg_cpt_option_sys_embedly_api_key"><![CDATA[Ключ Embed.ly API (заполните, чтобы использовать вместо Iframely)]]></string>
@@ -2301,7 +2303,7 @@
 	<string name="_sys_form_forgot_password_input_submit"><![CDATA[Выполнить]]></string>
 	<string name="_sys_form_input_age"><![CDATA[Возраст]]></string>
 	<string name="_sys_form_input_sys_location"><![CDATA[Расположение]]></string>
-        <string name="_sys_form_input_location"><![CDATA[Расположение по радиусу]]></string>
+        <string name="_sys_form_input_location"><![CDATA[Местоположение]]></string>
         <string name="_sys_form_input_location_radius_label"><![CDATA[Радиус (в км)]]></string>
         <string name="_sys_form_input_sys_anonymous"><![CDATA[Анонимная публикация]]></string>
         <string name="_sys_form_input_anonymous"><![CDATA[Анонимная публикация]]></string>
@@ -2529,6 +2531,17 @@
 	<string name="_sys_location_determining"><![CDATA[Определение местоположения...]]></string>
 	<string name="_sys_location_geolocation_not_supported_by_browser"><![CDATA[Геолокация не поддерживается этим браузером]]></string>
 	<string name="_sys_location_undefined"><![CDATA[Отключить местоположение]]></string>
+	<string name="_sys_location_map_google_static"><![CDATA[Google Maps (статическое изображение)]]></string>
+	<string name="_sys_location_field_google"><![CDATA[Google автозаполнение адресов]]></string>
+	<string name="_sys_location_field_plain"><![CDATA[Простые поля c Nominatim OSM геокодированием]]></string>
+    <string name="_sys_location_ph_number"><![CDATA[Номер]]></string>
+    <string name="_sys_location_ph_street"><![CDATA[Улица]]></string>
+    <string name="_sys_location_ph_city"><![CDATA[Город]]></string>
+    <string name="_sys_location_ph_state"><![CDATA[Область]]></string>
+    <string name="_sys_location_ph_zip"><![CDATA[Почтовый код]]></string>
+    <string name="_sys_location_status_undef"><![CDATA[Не определено]]></string>
+    <string name="_sys_location_status_ok"><![CDATA[Адрес найден]]></string>
+    <string name="_sys_location_status_fail"><![CDATA[Адрес не найден]]></string>
 	<string name="_sys_log_debug"><![CDATA[Система: отладка]]></string>
     <string name="_sys_log_twilio"><![CDATA[Система: Twilio]]></string>
     <string name="_sys_log_push"><![CDATA[Система: PUSH]]></string>

+ 20 - 0
template/css/forms.css

@@ -697,3 +697,23 @@
 .bx-form-input-location-city {
     margin-bottom:0.25rem;
 }
+
+.bx-form-input-location-cont .bx-form-input-location-status-cont {
+    float:none;
+    width:98%;
+    line-height:normal;
+}
+.bx-form-input-location-status {
+    float:left;
+}
+.bx-form-input-location-copyright {
+    float:right;
+}
+
+.bx-form-input-location-auto-cont {
+    display:table;
+}
+.bx-form-input-location-auto-cont > div {
+    display:table-cell;
+    vertical-align:middle;
+}

+ 0 - 38
template/form_field_location_plain_auto.html

@@ -1,38 +0,0 @@
-
-<div class="bx-form-input-location-cont bx-clearfix">
-    __input__
-    <div id="__id_status__" class="bx-def-margin-sec-left">__location_string__</div>
-</div>
-
-<input type="hidden" name="__name___lat" value="__lat__" />
-<input type="hidden" name="__name___lng" value="__lng__" />
-
-<script>
-    $('input[name=__name__][type=checkbox]').on('change', function () {
-        var _self = this;
-        var callbackOnLocationReset = function (error) {
-            $('[name="__name___lat"]').val('');
-            $('[name="__name___lng"]').val('');
-            $('#__id_status__').html("<bx_text_js:_sys_location_undefined />");
-            $(_self).prop("checked", false);
-            $(_self).parents('.bx-switcher-cont').removeClass('on').addClass('off');
-        }
-
-        var callbackOnLocationSucess = function (position) {
-            $('[name="__name___lat"]').val(position.coords.latitude);
-            $('[name="__name___lng"]').val(position.coords.longitude);
-            $('#__id_status__').html(position.coords.latitude + ', ' + position.coords.longitude);
-        }
-
-        if ($(this).is(':checked')) {
-            $('#__id_status__').html('<bx_text_js:_sys_location_determining />');
-            if (navigator.geolocation)
-                navigator.geolocation.getCurrentPosition(callbackOnLocationSucess, callbackOnLocationReset);
-            else
-                $('#__id_status__').html('<bx_text_js:_sys_location_geolocation_not_supported_by_browser />');
-        }
-        else {
-            callbackOnLocationReset();
-        }
-    });
-</script>

+ 0 - 0
template/form_field_location_google.html → template/location_field_google.html


+ 89 - 0
template/location_field_plain.html

@@ -0,0 +1,89 @@
+
+<div class="bx-form-input-location-__name__ bx-form-input-location-cont bx-clearfix">
+    __inputs__
+    <div class="bx-form-input-location-status-cont bx-def-font-small bx-def-font-grayed bx-def-margin-thd-top bx-clearfix">
+        <div class="bx-form-input-location-status ok"><i class="sys-icon sys-colored col-green1-dark check-circle"></i> <bx_text:_sys_location_status_ok /></div>
+        <div class="bx-form-input-location-status fail"><i class="sys-icon sys-colored col-red1-dark times-circle"></i> <bx_text:_sys_location_status_fail /></div>
+        <div class="bx-form-input-location-status undef"><i class="sys-icon sys-colored question-circle"></i> <bx_text:_sys_location_status_undef /></div>
+        <div class="bx-form-input-location-status loading"><i class="sys-icon sys-colored sync-alt"></i> <bx_text:_sys_loading /></div>
+        <div class="bx-form-input-location-copyright"></div>
+    </div>
+</div>
+
+<script>
+(function () {
+    var getLocationString = function () {
+        var sCountry = $('select[name="__name___country"]').val();
+        var sZip = $('input[name="__name___zip"]').val();
+        var sState = $('input[name="__name___state"]').val();
+        var sCity = $('input[name="__name___city"]').val();
+        var sStreet = $('input[name="__name___street"]').val();
+        var sNum = $('input[name="__name___street_number"]').val();
+
+        if (!sCountry || !sCountry.length)
+            return '';
+
+        sRet = (sZip.length ? sZip + ', ' : '') + sCountry;
+
+        sRet = (sCity.length ? sCity + ', ': '') + (sState.length ? sState + ', ': '') + sRet;
+        
+        if (sCity.length)
+            sRet = (sStreet.length && sNum.length ? sNum + ' ' : '') + (sStreet.length ? sStreet + ', ' : '') + sRet;
+
+        return sRet;
+    }
+
+    var setLocationStatus = function (s) {
+        $('.bx-form-input-location-__name__ .bx-form-input-location-status').hide();
+        $('.bx-form-input-location-__name__ .bx-form-input-location-status.' + s).show();
+    }
+
+    setLocationStatus('undef');
+
+    $(document).ready(function () {
+        $('input[name^="__name__"],select[name^="__name__"]').on('change', function () {
+            if ('undefined' !== typeof(glBxLocationFieldPlainGeocodingRequest) && glBxLocationFieldPlainGeocodingRequest) { // cancel previous request
+                clearTimeout(glBxLocationFieldPlainGeocodingRequest);
+                glBxLocationFieldPlainGeocodingRequest = null;
+            }
+
+            if ('hidden' == this.type)
+                return;
+            
+            var s = getLocationString();
+            if (!s) {
+                setLocationStatus('undef');
+                return;
+            }
+
+            glBxLocationFieldPlainGeocodingRequest = setTimeout(function () {
+                setLocationStatus('loading');
+                $.getJSON('__nominatim_server__/search/' + encodeURIComponent(s) + '?format=json&limit=1&email=__nominatim_email__', function (oResult) {
+                    glBxLocationFieldPlainGeocodingRequest = false;
+                    if (('object' === typeof oResult) && oResult.length && ('undefined' !== typeof oResult[0].lat) && ('undefined' !== typeof oResult[0].lon)) {
+                        $('input[name="__name___lat"]').val(oResult[0].lat);
+                        $('input[name="__name___lng"]').val(oResult[0].lon);
+                        if ('undefined' !== typeof(oResult[0].licence))
+                            $('.bx-form-input-location-__name__ .bx-form-input-location-copyright').html(oResult[0].licence);
+                        setLocationStatus('ok');
+                    } else {
+                        $('input[name="__name___lat"]').val(0);
+                        $('input[name="__name___lng"]').val(0);
+                        setLocationStatus('fail');
+                    }
+                });
+            }, 1500);
+        });
+
+        if (getLocationString()) {
+            if (parseFloat($('input[name="__name___lat"]').val()) && parseFloat($('input[name="__name___lng"]').val()))
+                setLocationStatus('ok');
+            else
+                setLocationStatus('fail');
+        } 
+        else {
+            setLocationStatus('undef');
+        }
+    });
+})();
+</script>

+ 93 - 0
template/location_field_plain_auto.html

@@ -0,0 +1,93 @@
+
+<div class="bx-form-input-location-auto-cont bx-clearfix">
+    <div>__input__</div>
+    <div id="__id_status__" class="bx-def-padding-sec-left">
+        <span>__location_string__</span>
+        <div id="__id_status__copyright" class="bx-def-margin-thd-top bx-def-font-small bx-def-font-grayed"></div>
+    </div>    
+</div>
+
+<input type="hidden" name="__name___lat" value="__lat__" />
+<input type="hidden" name="__name___lng" value="__lng__" />
+<input type="hidden" name="__name___country" value="__country__" />
+<input type="hidden" name="__name___state" value="__state__" />
+<input type="hidden" name="__name___city" value="__city__" />
+<input type="hidden" name="__name___zip" value="__zip__" />
+<input type="hidden" name="__name___street" value="__street__" />
+<input type="hidden" name="__name___street_number" value="__street_number__" />
+
+<script>
+    $('input[name=__name__][type=checkbox]').on('change', function () {
+        var _self = this;
+        var callbackOnLocationReset = function (error) {
+            $('[name="__name___lat"]').val('');
+            $('[name="__name___lng"]').val('');
+            $('#__id_status__ span').html("<bx_text_js:_sys_location_undefined />");
+            $(_self).prop("checked", false);
+            $(_self).parents('.bx-switcher-cont').removeClass('on').addClass('off');
+        }
+
+        var callbackOnLocationSucess = function (position) {
+
+            var iTimeout = 200;
+            if ('undefined' !== typeof(glBxLocationFieldPlainAutoGeocodingRequest) && glBxLocationFieldPlainAutoGeocodingRequest) { // cancel previous request
+                clearTimeout(glBxLocationFieldPlainAutoGeocodingRequest);
+                glBxLocationFieldPlainAutoGeocodingRequest = null;
+                iTimeout = 1000;
+            }
+
+            glBxLocationFieldPlainAutoGeocodingRequest = setTimeout(function () {
+                $.getJSON('__nominatim_server__/reverse?lat=' + encodeURIComponent(position.coords.latitude) + '&lon=' + encodeURIComponent(position.coords.longitude) + '&format=json&addressdetails=1&email=__nominatim_email__', function (oResult) {
+
+                    glBxLocationFieldPlainAutoGeocodingRequest = false;
+
+                    if (('object' === typeof oResult) && ('undefined' !== typeof oResult.display_name) && ('undefined' !== typeof oResult.address) && ('undefined' !== typeof oResult.address.country_code)) {
+                        $('[name="__name___lat"]').val(position.coords.latitude);
+                        $('[name="__name___lng"]').val(position.coords.longitude);
+
+                        $('[name="__name___country"]').val(oResult.address.country_code.toUpperCase());
+
+                        if ('undefined' !== typeof oResult.address.suburb)
+                            $('[name="__name___city"]').val(oResult.address.suburb);
+                        else if ('undefined' !== typeof oResult.address.town)
+                            $('[name="__name___city"]').val(oResult.address.town);
+                        else if ('undefined' !== typeof oResult.address.city)
+                            $('[name="__name___city"]').val(oResult.address.city);
+
+                        var oMap = {
+                            'postcode': '__name___zip',
+                            'state': '__name___state',
+                            'road': '__name___street',
+                            'house_number': '__name___street_number',
+                        }
+                        $.each(oMap, function (i) {
+                            if ('undefined' !== typeof oResult.address[i])
+                                $('[name="' + this + '"]').val(oResult.address[i]);
+                        });
+
+                        $('#__id_status__ span').html(oResult.display_name);
+                        if  ('undefined' !== typeof oResult.licence)
+                            $('#__id_status__copyright').html(oResult.licence);
+
+                    } 
+                    else {
+                        $('#__id_status__ span').html(position.coords.latitude + ', ' + position.coords.longitude);
+                    }
+                });
+            }, iTimeout);
+
+
+        }
+
+        if ($(this).is(':checked')) {
+            $('#__id_status__ span').html('<bx_text_js:_sys_location_determining />');
+            if (navigator.geolocation)
+                navigator.geolocation.getCurrentPosition(callbackOnLocationSucess, callbackOnLocationReset);
+            else
+                $('#__id_status__ span').html('<bx_text_js:_sys_location_geolocation_not_supported_by_browser />');
+        }
+        else {
+            callbackOnLocationReset();
+        }
+    });
+</script>

+ 0 - 3
template/metatags_locations_map.html

@@ -1,3 +0,0 @@
-<div class="bx-metatags-locations-map bx-def-round-corners bx-def-color-bg-box" style="background-image:url(__map_img__);">
-    <div class="bx-metatags-locations-map-string bx-def-font-grayed bx-def-padding-sec bx-def-round-corners">__location_string__</div>
-</div>

+ 1 - 1
template/scripts/BxBaseFormView.php

@@ -1709,7 +1709,7 @@ BLAH;
 
     function genInputLocation(&$aInput)
     {
-        $o = BxDolLocationField::getObjectInstance('sys_plain');
+        $o = BxDolLocationField::getObjectInstance(getParam('sys_location_field_default'));
         if (!$o)
             return _t('_sys_txt_error_occured');
 

+ 1 - 2
template/scripts/BxBaseMetatags.php

@@ -109,8 +109,7 @@ class BxBaseMetatags extends BxDolMetatags
         if(!$sLocationHtml)
 			return '';
 
-        // TODO: add param for map object
-        $o = BxDolLocationMap::getObjectInstance('sys_google_static',  $this->_oTemplate);
+        $o = BxDolLocationMap::getObjectInstance(getParam('sys_location_map_default'),  $this->_oTemplate);
         if(!$o)
 			return '';
 

+ 22 - 0
template/scripts/BxBaseServices.php

@@ -483,6 +483,28 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
         return $aResults;
     }
 
+    public function serviceGetOptionsLocationFieldDefault()
+    {
+        $aResults = array();
+
+        $aObjects = BxDolLocationFieldQuery::getObjects();
+        foreach($aObjects as $aObject)
+            $aResults[$aObject['object']] = _t($aObject['title']);
+
+        return $aResults;
+    }
+
+    public function serviceGetOptionsLocationMapDefault()
+    {
+        $aResults = array();
+
+        $aObjects = BxDolLocationMapQuery::getObjects();
+        foreach($aObjects as $aObject)
+            $aResults[$aObject['object']] = _t($aObject['title']);
+
+        return $aResults;
+    }
+
     public function serviceGetOptionsRelations()
     {
         $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));