Browse Source

Ticket #3556 - Point №1: Auto Location field (Timeline)

AntonLV 5 years ago
parent
commit
b20d22cfed

+ 10 - 9
inc/classes/BxDolLocationFieldGoogle.php

@@ -36,7 +36,7 @@ class BxDolLocationFieldGoogle extends BxDolLocationField
                 'condition' => !$isManualInput,
                 'content' => array(
                     'id_status' => $sIdStatus,
-                    'location_string' => _t('_sys_location_undefined'),
+                    'location_string' => _t('_sys_location_field_label'),
                 ),
             ),
             'api_field_name_short' => 'short_name',
@@ -48,17 +48,11 @@ class BxDolLocationFieldGoogle extends BxDolLocationField
         foreach ($aLocationIndexes as $sKey)
             $aVars[$sKey] = $this->getLocationVal($aInput, $sKey, $oForm);
 
-        if ($aVars['country']) {
-            $aCountries = BxDolFormQuery::getDataItems('Country');
-            $s = ($aVars['street_number'] ? $aVars['street_number'] . ', ' : '') . ($aVars['street'] ? $aVars['street'] . ', ' : '') . ($aVars['city'] ? $aVars['city'] . ', ' : '') . ($aVars['state'] ? $aVars['state'] . ', ' : '') . $aCountries[$aVars['country']];
-            $aVars['bx_if:auto_input']['content']['location_string'] = $s;
-        }
-
         if ($isManualInput) {
             $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
-			$aInput['type'] = 'text';
+            $aInput['type'] = 'text';
             $aInput['attrs']['id'] = $sIdInput;
-			$aInput['attrs'] = array_merge($aAttrs, $aInput['attrs']);
+            $aInput['attrs'] = array_merge($aAttrs, $aInput['attrs']);
             $aVars['input'] = $oForm->genInputStandard($aInput);
         } 
         else {
@@ -67,6 +61,13 @@ class BxDolLocationFieldGoogle extends BxDolLocationField
             else
                 $aInput['checked'] = $oForm->getCleanValue($aInput['name'] . '_lat') && $oForm->getCleanValue($aInput['name'] . '_lng') ? 1 : 0;
             $aVars['input'] = $oForm->genInputSwitcher($aInput);
+
+            $sLocationString = _t($aInput['checked'] ? '_sys_location_undefined' : '_sys_location_field_label');
+            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']];
+            }
+            $aVars['bx_if:auto_input']['content']['location_string'] = $sLocationString;
         }
 
         return $aVars;

+ 2 - 2
inc/classes/BxDolLocationFieldNominatim.php

@@ -23,14 +23,14 @@ class BxDolLocationFieldNominatim extends BxDolLocationField
             foreach ($aLocationIndexes as $sKey)
                 $aVars[$sKey] = $this->getLocationVal($aInput, $sKey, $oForm);
 
-            $aInputField['caption'] = _t('_sys_location_undefined');
+            $aInputField['caption'] = _t('_sys_location_field_label');
 
             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');
+            $sLocationString = _t($aInputField['checked'] ? '_sys_location_undefined' : '_sys_location_field_label');
             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']];

+ 2 - 1
modules/boonex/english/data/langs/system/en.xml

@@ -2651,11 +2651,12 @@ If it is not enabled then please consider implement this optimization, since it
     <string name="_sys_location_country_city_street"><![CDATA[<i class="sys-icon location-arrow"></i> {4} {3}, {2}, {1}, {0} ]]></string>
 	<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_undefined"><![CDATA[Location undefined]]></string>
 	<string name="_sys_location_map_google_static"><![CDATA[Google Maps (Static)]]></string>
 	<string name="_sys_location_map_leaflet"><![CDATA[Leaflet (various free map providers)]]></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_field_label"><![CDATA[Show location]]></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>

+ 10 - 9
modules/boonex/russian/data/langs/system/ru.xml

@@ -2633,13 +2633,14 @@ _sys_layout_1_column<?xml version="1.0" encoding="utf-8"?>
 	<string name="_sys_location_country"><![CDATA[<i class="sys-icon location-arrow"></i> {0}]]></string>
 	<string name="_sys_location_country_city"><![CDATA[<i class="sys-icon location-arrow"></i> {2}, {1}, {0}]]></string>
     <string name="_sys_location_country_city_street"><![CDATA[<i class="sys-icon location-arrow"></i> {4} {3}, {2}, {1}, {0} ]]></string>
-	<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_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_map_leaflet"><![CDATA[Leaflet (разные бесплатные поставщики карт)]]></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_field_google"><![CDATA[Google автозаполнение адресов]]></string>
+    <string name="_sys_location_field_plain"><![CDATA[Простые поля c Nominatim OSM геокодированием]]></string>
+    <string name="_sys_location_field_label"><![CDATA[Показывать местоположение]]></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>
@@ -2648,11 +2649,11 @@ _sys_layout_1_column<?xml version="1.0" encoding="utf-8"?>
     <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_debug"><![CDATA[Система: отладка]]></string>
     <string name="_sys_log_twilio"><![CDATA[Система: Twilio]]></string>
     <string name="_sys_log_push"><![CDATA[Система: PUSH]]></string>
-	<string name="_sys_log_payments"><![CDATA[Система: Платежи]]></string>
-	<string name="_sys_log_cron_jobs"><![CDATA[System: Задания Cron]]></string>
+    <string name="_sys_log_payments"><![CDATA[Система: Платежи]]></string>
+    <string name="_sys_log_cron_jobs"><![CDATA[System: Задания Cron]]></string>
     <string name="_sys_log_transcoder"><![CDATA[System: Транскодер]]></string>
     <string name="_sys_macros_malformed"><![CDATA[Ошибка: некорректный макрос]]></string>
     <string name="_sys_macros_unsafe"><![CDATA[Ошибка: небезопасный макрос]]></string>

+ 1 - 1
template/location_field_google.html

@@ -109,7 +109,7 @@
             for(var sKey in oBxLocationHashMap) 
                 $('[name="' + oBxLocationHashMap[sKey].html + '"]').val('');
 
-            $('#__id_status__').html("<bx_text_js:_sys_location_undefined />");
+            $('#__id_status__').html("<bx_text_js:_sys_location_field_label />");
 
             $(_self).prop("checked", false);
             $(_self).parents('.bx-switcher-cont').removeClass('on').addClass('off');

+ 1 - 1
template/location_field_plain_auto.html

@@ -22,7 +22,7 @@
         var callbackOnLocationReset = function (error) {
             $('[name="__name___lat"]').val('');
             $('[name="__name___lng"]').val('');
-            $('#__id_status__ span').html("<bx_text_js:_sys_location_undefined />");
+            $('#__id_status__ span').html("<bx_text_js:_sys_location_field_label />");
             $(_self).prop("checked", false);
             $(_self).parents('.bx-switcher-cont').removeClass('on').addClass('off');
         }