diff --git a/.gitignore b/.gitignore index 8e100cc6..258fc7c5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ vendor/ j4/pkg_agosms/sik j4/pkg_agosms/dist/ j4/pkg_agosms/vendor/ +.vscode \ No newline at end of file diff --git a/j4/pkg_agosms/src/administrator/components/com_agosms/forms/agosm.xml b/j4/pkg_agosms/src/administrator/components/com_agosms/forms/agosm.xml index 0af93145..7cb3d331 100644 --- a/j4/pkg_agosms/src/administrator/components/com_agosms/forms/agosm.xml +++ b/j4/pkg_agosms/src/administrator/components/com_agosms/forms/agosm.xml @@ -31,6 +31,33 @@ hint="JFIELD_ALIAS_PLACEHOLDER" /> + + + + + + element['clear'] != 'false'); - $allowSelect = ((string) $this->element['select'] != 'false'); - - // The active agosm id field. - $value = (int) $this->value > 0 ? (int) $this->value : ''; - - // Create the modal id. - $modalId = 'Agosm_' . $this->id; - - // Add the modal field script to the document head. - HTMLHelper::_( - 'script', - 'system/fields/modal-fields.min.js', - ['version' => 'auto', 'relative' => true] - ); - - // Script to proxy the select modal function to the modal-fields.js file. - if ($allowSelect) { - static $scriptSelect = null; - - if (is_null($scriptSelect)) { - $scriptSelect = []; - } - - if (!isset($scriptSelect[$this->id])) { - Factory::getDocument()->addScriptDeclaration(" - function jSelectAgosm_" - . $this->id - . "(id, title, object) { window.processModalSelect('Agosm', '" - . $this->id . "', id, title, '', object);}"); - - $scriptSelect[$this->id] = true; - } - } - - // Setup variables for display. - $linkAgosms = 'index.php?option=com_agosms&view=agosms&layout=modal&tmpl=component&' - . Session::getFormToken() . '=1'; - $modalTitle = Text::_('COM_AGOSMS_CHANGE_AGOSM'); - - if (isset($this->element['language'])) { - $linkAgosms .= '&forcedLanguage=' . $this->element['language']; - $modalTitle .= ' — ' . $this->element['label']; - } - - $urlSelect = $linkAgosms . '&function=jSelectAgosm_' . $this->id; - - if ($value) { - $db = Factory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('name')) - ->from($db->quoteName('#__agosms_details')) - ->where($db->quoteName('id') . ' = ' . (int) $value); - $db->setQuery($query); - - try { - $title = $db->loadResult(); - } catch (\RuntimeException $e) { - Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); - } - } - - $title = empty($title) ? Text::_('COM_AGOSMS_SELECT_A_AGOSM') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); - - // The current agosm display field. - $html = ''; - - if ($allowSelect || $allowNew || $allowEdit || $allowClear) { - $html .= ''; - } - - $html .= ''; - - // Select agosm button - if ($allowSelect) { - $html .= '' - . ' ' . Text::_('JSELECT') - . ''; - } - - // Clear agosm button - if ($allowClear) { - $html .= '' - . '' . Text::_('JCLEAR') - . ''; - } - - if ($allowSelect || $allowNew || $allowEdit || $allowClear) { - $html .= ''; - } - - // Select agosm modal - if ($allowSelect) { - $html .= HTMLHelper::_( - 'bootstrap.renderModal', - 'ModalSelect' . $modalId, - [ - 'title' => $modalTitle, - 'url' => $urlSelect, - 'height' => '400px', - 'width' => '800px', - 'bodyHeight' => 70, - 'modalWidth' => 80, - 'agosmter' => '', - ] - ); - } - - // Note: class='required' for client side validation. - $class = $this->required ? ' class="required modal-value"' : ''; - - $html .= ''; - - return $html; - } - - /** - * Method to get the field label markup. - * - * @return string The field label markup. - * - * @since __DEPLOY_VERSION__ - */ - protected function getLabel() - { - return str_replace($this->id, $this->id . '_name', parent::getLabel()); - } -} diff --git a/j4/pkg_agosms/src/administrator/components/com_agosms/src/Rule/CoordinatesRule.php b/j4/pkg_agosms/src/administrator/components/com_agosms/src/Rule/CoordinatesRule.php new file mode 100644 index 00000000..14e4d1f8 --- /dev/null +++ b/j4/pkg_agosms/src/administrator/components/com_agosms/src/Rule/CoordinatesRule.php @@ -0,0 +1,37 @@ +activeFilters = $this->get('ActiveFilters'); $this->state = $this->get('State'); - if (!count($this->items) && $this->get('IsEmptyState')) - { + if (!count($this->items) && $this->get('IsEmptyState')) { $this->setLayout('emptystate'); } diff --git a/j4/pkg_agosms/src/administrator/components/com_agosms/tmpl/agosm/edit.php b/j4/pkg_agosms/src/administrator/components/com_agosms/tmpl/agosm/edit.php index 1a096d69..f6d475b5 100644 --- a/j4/pkg_agosms/src/administrator/components/com_agosms/tmpl/agosm/edit.php +++ b/j4/pkg_agosms/src/administrator/components/com_agosms/tmpl/agosm/edit.php @@ -43,7 +43,11 @@
- + + getForm()->renderField('description'); ?> + + getForm()->renderField('popuptext'); ?> + getForm()->renderField('coordinates'); ?>
diff --git a/j4/pkg_agosms/src/administrator/components/com_agosms/tmpl/agosms/emptystate.php b/j4/pkg_agosms/src/administrator/components/com_agosms/tmpl/agosms/emptystate.php index 8f9ad63c..0f647611 100644 --- a/j4/pkg_agosms/src/administrator/components/com_agosms/tmpl/agosms/emptystate.php +++ b/j4/pkg_agosms/src/administrator/components/com_agosms/tmpl/agosms/emptystate.php @@ -21,8 +21,7 @@ $user = Factory::getApplication()->getIdentity(); -if ($user->authorise('core.create', 'com_agosms') || count($user->getAuthorisedCategories('com_agosms', 'core.create')) > 0) -{ +if ($user->authorise('core.create', 'com_agosms') || count($user->getAuthorisedCategories('com_agosms', 'core.create')) > 0) { $displayData['createURL'] = 'index.php?option=com_agosms&task=agosm.add'; } diff --git a/j4/pkg_agosms/src/components/com_agosms/src/Model/AgosmModel.php b/j4/pkg_agosms/src/components/com_agosms/src/Model/AgosmModel.php index 3ac203bf..fee2b5c0 100644 --- a/j4/pkg_agosms/src/components/com_agosms/src/Model/AgosmModel.php +++ b/j4/pkg_agosms/src/components/com_agosms/src/Model/AgosmModel.php @@ -40,7 +40,10 @@ class AgosmModel extends BaseDatabaseModel public function getItem($pk = null) { $app = Factory::getApplication(); - $pk = $app->input->getInt('id'); + + if ($app->input->getInt('id') !== null) { + $pk = $app->input->getInt('id'); + } if ($this->_item === null) { $this->_item = []; diff --git a/j4/pkg_agosms/src/components/com_agosms/src/Model/AgosmsModel.php b/j4/pkg_agosms/src/components/com_agosms/src/Model/AgosmsModel.php new file mode 100644 index 00000000..3939f1b1 --- /dev/null +++ b/j4/pkg_agosms/src/components/com_agosms/src/Model/AgosmsModel.php @@ -0,0 +1,142 @@ +getDbo(); + $query = $db->getQuery(true); + + // Select the required fields from the table. + $query->select( + $db->quoteName( + explode( + ', ', + $this->getState( + 'list.select', + 'a.id, a.name, a.catid' . + ', a.popuptext' . + ', a.description' . + ', a.coordinates' . + ', a.access' . + ', a.checked_out' . + ', a.checked_out_time' . + ', a.language' . + ', a.ordering' . + ', a.featured' . + ', a.state' . + ', a.published' . + ', a.publish_up, a.publish_down' + ) + ) + ) + ); + + $query->from($db->quoteName('#__agosms_details', 'a')); + + return $query; + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + * @since __BUMP_VERSION__ + */ + protected function populateState($ordering = 'a.name', $direction = 'asc') + { + $app = Factory::getApplication(); + $forcedLanguage = $app->input->get('forcedLanguage', '', 'cmd'); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) { + $this->context .= '.' . $layout; + } + + // Adjust the context to support forced languages. + if ($forcedLanguage) { + $this->context .= '.' . $forcedLanguage; + } + + // List state information. + parent::populateState($ordering, $direction); + + // Force a language. + if (!empty($forcedLanguage)) { + $this->setState('filter.language', $forcedLanguage); + } + } +} diff --git a/j4/pkg_agosms/src/components/com_agosms/src/Model/FooModel.php b/j4/pkg_agosms/src/components/com_agosms/src/Model/FooModel.php deleted file mode 100644 index 3ac203bf..00000000 --- a/j4/pkg_agosms/src/components/com_agosms/src/Model/FooModel.php +++ /dev/null @@ -1,91 +0,0 @@ -input->getInt('id'); - - if ($this->_item === null) { - $this->_item = []; - } - - if (!isset($this->_item[$pk])) { - try { - $db = $this->getDbo(); - $query = $db->getQuery(true); - - $query->select('*') - ->from($db->quoteName('#__agosms_details', 'a')) - ->where('a.id = ' . (int) $pk); - - $db->setQuery($query); - $data = $db->loadObject(); - - if (empty($data)) { - throw new \Exception(Text::_('COM_AGOSMS_ERROR_AGOSM_NOT_FOUND'), 404); - } - - $this->_item[$pk] = $data; - } catch (\Exception $e) { - $this->setError($e); - $this->_item[$pk] = false; - } - } - - return $this->_item[$pk]; - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @return void - * - * @since __BUMP_VERSION__ - */ - protected function populateState() - { - $app = Factory::getApplication(); - - $this->setState('agosm.id', $app->input->getInt('id')); - $this->setState('params', $app->getParams()); - } -} diff --git a/j4/pkg_agosms/src/components/com_agosms/src/Model/FormModel.php b/j4/pkg_agosms/src/components/com_agosms/src/Model/FormModel.php deleted file mode 100644 index 67c85f4d..00000000 --- a/j4/pkg_agosms/src/components/com_agosms/src/Model/FormModel.php +++ /dev/null @@ -1,215 +0,0 @@ -getState('agosm.id') && Associations::isEnabled()) { - $associations = Associations::getAssociations('com_agosms', '#__agosms_details', 'com_agosms.item', $id); - - // Make fields read only - if (!empty($associations)) { - $form->setFieldAttribute('language', 'readonly', 'true'); - $form->setFieldAttribute('language', 'filter', 'unset'); - } - } - - return $form; - } - - /** - * Method to get agosm data. - * - * @param integer $itemId The id of the agosm. - * - * @return mixed Agosm item data object on success, false on failure. - * - * @throws Exception - * - * @since __DEPLOY_VERSION__ - */ - public function getItem($itemId = null) - { - $itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('agosm.id'); - - // Get a row instance. - $table = $this->getTable(); - - // Attempt to load the row. - try { - if (!$table->load($itemId)) { - return false; - } - } catch (Exception $e) { - Factory::getApplication()->enqueueMessage($e->getMessage()); - - return false; - } - - $properties = $table->getProperties(); - $value = ArrayHelper::toObject($properties, 'JObject'); - - // Convert field to Registry. - $value->params = new Registry($value->params); - - return $value; - } - - /** - * Get the return URL. - * - * @return string The return URL. - * - * @since __DEPLOY_VERSION__ - */ - public function getReturnPage() - { - return base64_encode($this->getState('return_page')); - } - - /** - * Method to save the form data. - * - * @param array $data The form data. - * - * @return boolean True on success. - * - * @throws Exception - * @since __DEPLOY_VERSION__ - */ - public function save($data) - { - // Associations are not edited in frontend ATM so we have to inherit them - if (Associations::isEnabled() && !empty($data['id']) - && $associations = Associations::getAssociations('com_agosms', '#__agosms_details', 'com_agosms.item', $data['id'])) { - foreach ($associations as $tag => $associated) { - $associations[$tag] = (int) $associated->id; - } - - $data['associations'] = $associations; - } - - return parent::save($data); - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @return void - * - * @throws Exception - * - * @since __DEPLOY_VERSION__ - */ - protected function populateState() - { - $app = Factory::getApplication(); - - // Load state from the request. - $pk = $app->input->getInt('id'); - $this->setState('agosm.id', $pk); - - $this->setState('agosm.catid', $app->input->getInt('catid')); - - $return = $app->input->get('return', null, 'base64'); - $this->setState('return_page', base64_decode($return)); - - // Load the parameters. - $params = $app->getParams(); - $this->setState('params', $params); - - $this->setState('layout', $app->input->getString('layout')); - } - - /** - * Allows preprocessing of the JForm object. - * - * @param Form $form The form object - * @param array $data The data to be merged into the form object - * @param string $group The plugin group to be executed - * - * @return Form - * - * @since __DEPLOY_VERSION__ - */ - protected function preprocessForm(Form $form, $data, $group = 'agosm') - { - if (!Multilanguage::isEnabled()) { - $form->setFieldAttribute('language', 'type', 'hidden'); - $form->setFieldAttribute('language', 'default', '*'); - } - - return parent::preprocessForm($form, $data, $group); - } - - /** - * Method to get a table object, load it if necessary. - * - * @param string $name The table name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $options Configuration array for model. Optional. - * - * @return Table A Table object - * - * @since __DEPLOY_VERSION__ - * @throws \Exception - */ - public function getTable($name = 'Agosm', $prefix = 'Administrator', $options = []) - { - return parent::getTable($name, $prefix, $options); - } -} diff --git a/j4/pkg_agosms/src/media/mod_agosm/joomla.asset.json b/j4/pkg_agosms/src/media/mod_agosm/joomla.asset.json new file mode 100644 index 00000000..301d4f3b --- /dev/null +++ b/j4/pkg_agosms/src/media/mod_agosm/joomla.asset.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json", + "name": "mod_agosms", + "version": "4.0.0", + "description": "Mod Agsosm", + "license": "GPL-2.0-or-later", + "assets": [ + ] +} \ No newline at end of file diff --git a/j4/pkg_agosms/src/media/mod_agosm/js/agosm.js b/j4/pkg_agosms/src/media/mod_agosm/js/agosm.js index a2d55756..f44be3c1 100644 --- a/j4/pkg_agosms/src/media/mod_agosm/js/agosm.js +++ b/j4/pkg_agosms/src/media/mod_agosm/js/agosm.js @@ -229,7 +229,7 @@ document.addEventListener('DOMContentLoaded', function () { zoomOffset: -1, id: mapboxmaptype, accessToken: mapboxkey - }); + }); } if (baselayer === 'mapnikde') { tileLayer = L.tileLayer('https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', { @@ -515,34 +515,32 @@ document.addEventListener('DOMContentLoaded', function () { tempMarker.openPopup(); }); } - window['mymap' + moduleId].on("moveend", function (event) { - var bounds = event.target.getBounds(); + window['mymap' + moduleId].on("moveend", function (event) { + var bounds = event.target.getBounds(); var indexhidemove = 0; for (var specialpin in specialpins) { indexhidemove++; - var hidemove = document.querySelector('.agmarkerlistli_specialpin' + indexhidemove); - if(hidemove){ + if (document.querySelector('.agmarkerlistli_specialpin' + indexhidemove)) { var cords = L.latLng(specialpins[specialpin].latlonpin.split(",", 3)); if (!bounds.contains(cords)) { - hidemove.hidden = true; + document.querySelector('.agmarkerlistli_specialpin' + indexhidemove).hidden = true; } else { - hidemove.hidden = false; + document.querySelector('.agmarkerlistli_specialpin' + indexhidemove).hidden = false; } } } }); - window['mymap' + moduleId].on("zoomend", function (event) { - var bounds = event.target.getBounds(); + window['mymap' + moduleId].on("zoomend", function (event) { + var bounds = event.target.getBounds(); var indexhidezoom = 0; for (var specialpin in specialpins) { indexhidezoom++; - var hidezoom = document.querySelector('.agmarkerlistli_specialpin' + indexhidezoom); - if(hidezoom){ + if (document.querySelector('.agmarkerlistli_specialpin' + indexhidezoom)) { var cords = L.latLng(specialpins[specialpin].latlonpin.split(",", 3)); if (!bounds.contains(cords)) { - hidezoom.hidden = true; + document.querySelector('.agmarkerlistli_specialpin' + indexhidezoom).hidden = true; } else { - hidezoom.hidden = false; + document.querySelector('.agmarkerlistli_specialpin' + indexhidezoom).hidden = false; } } } @@ -554,47 +552,46 @@ document.addEventListener('DOMContentLoaded', function () { // Show Pins from component if (showcomponentpin === '1') { - var clustermarkers = L.markerClusterGroup({ - maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center - iconCreateFunction: null, - clusterPane: L.Marker.prototype.options.pane, - - spiderfyOnMaxZoom: true, - showCoverageOnHover: true, - zoomToBoundsOnClick: true, - singleMarkerMode: false, - - disableClusteringAtZoom: disableClusteringAtZoom, - - // Setting this to false prevents the removal of any clusters outside of the viewpoint, which - // is the default behaviour for performance reasons. - removeOutsideVisibleBounds: true, - - // Set to false to disable all animations (zoom and spiderfy). - // If false, option animateAddingMarkers below has no effect. - // If L.DomUtil.TRANSITION is falsy, this option has no effect. - animate: true, - - //Whether to animate adding markers after adding the MarkerClusterGroup to the map - // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains. - animateAddingMarkers: false, - - //Increase to increase the distance away that spiderfied markers appear from the center - spiderfyDistanceMultiplier: 1, - - // Make it possible to specify a polyline options on a spider leg - spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, - - // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts - chunkedLoading: false, - chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback) - chunkDelay: 50, // at the end of each interval, give n milliseconds back to system/browser - chunkProgress: null, // progress callback: function(processed, total, elapsed) (e.g. for a progress indicator) - - //Options to pass to the L.Polygon constructor - polygonOptions: {} - }); + maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center + iconCreateFunction: null, + clusterPane: L.Marker.prototype.options.pane, + + spiderfyOnMaxZoom: true, + showCoverageOnHover: true, + zoomToBoundsOnClick: true, + singleMarkerMode: false, + + disableClusteringAtZoom: disableClusteringAtZoom, + + // Setting this to false prevents the removal of any clusters outside of the viewpoint, which + // is the default behaviour for performance reasons. + removeOutsideVisibleBounds: true, + + // Set to false to disable all animations (zoom and spiderfy). + // If false, option animateAddingMarkers below has no effect. + // If L.DomUtil.TRANSITION is falsy, this option has no effect. + animate: true, + + //Whether to animate adding markers after adding the MarkerClusterGroup to the map + // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains. + animateAddingMarkers: false, + + //Increase to increase the distance away that spiderfied markers appear from the center + spiderfyDistanceMultiplier: 1, + + // Make it possible to specify a polyline options on a spider leg + spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, + + // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts + chunkedLoading: false, + chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback) + chunkDelay: 50, // at the end of each interval, give n milliseconds back to system/browser + chunkProgress: null, // progress callback: function(processed, total, elapsed) (e.g. for a progress indicator) + + //Options to pass to the L.Polygon constructor + polygonOptions: {} + }); for (var specialcomponentpin in specialcomponentpins) { // skip loop if the property is from prototype @@ -685,33 +682,37 @@ document.addEventListener('DOMContentLoaded', function () { tempMarker.openPopup(); }); } - window['mymap' + moduleId].on("moveend", function (event) { - var bounds = event.target.getBounds(); + window['mymap' + moduleId].on("moveend", function (event) { + var bounds = event.target.getBounds(); for (var specialcomponentpin in specialcomponentpins) { - if(specialcomponentpins[specialcomponentpin].id){ + if (specialcomponentpins[specialcomponentpin].id) { var cords = L.latLng(specialcomponentpins[specialcomponentpin].coordinates.split(",", 3)); - if (!bounds.contains(cords)) { - document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = true; - } else { - document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = false; + if (document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id)) { + if (!bounds.contains(cords)) { + document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = true; + } else { + document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = false; + } } } } }); - window['mymap' + moduleId].on("zoomend", function (event) { - var bounds = event.target.getBounds(); + window['mymap' + moduleId].on("zoomend", function (event) { + var bounds = event.target.getBounds(); for (var specialcomponentpin in specialcomponentpins) { - if(specialcomponentpins[specialcomponentpin].id){ + if (specialcomponentpins[specialcomponentpin].id) { var cords = L.latLng(specialcomponentpins[specialcomponentpin].coordinates.split(",", 3)); - if (!bounds.contains(cords)) { - document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = true; - } else { - document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = false; + if (document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id)) { + if (!bounds.contains(cords)) { + document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = true; + } else { + document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = false; + } } } } }); - + } if (JSON.parse(sessionStorage.getItem('mapState')) && savestate === "1") { @@ -725,47 +726,46 @@ document.addEventListener('DOMContentLoaded', function () { // One Pin from component if (showcomponentpinone === '1') { - var clustermarkers = L.markerClusterGroup({ - maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center - iconCreateFunction: null, - clusterPane: L.Marker.prototype.options.pane, - - spiderfyOnMaxZoom: true, - showCoverageOnHover: true, - zoomToBoundsOnClick: true, - singleMarkerMode: false, - - disableClusteringAtZoom: disableClusteringAtZoom, - - // Setting this to false prevents the removal of any clusters outside of the viewpoint, which - // is the default behaviour for performance reasons. - removeOutsideVisibleBounds: true, - - // Set to false to disable all animations (zoom and spiderfy). - // If false, option animateAddingMarkers below has no effect. - // If L.DomUtil.TRANSITION is falsy, this option has no effect. - animate: true, - - //Whether to animate adding markers after adding the MarkerClusterGroup to the map - // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains. - animateAddingMarkers: false, - - //Increase to increase the distance away that spiderfied markers appear from the center - spiderfyDistanceMultiplier: 1, - - // Make it possible to specify a polyline options on a spider leg - spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, - - // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts - chunkedLoading: false, - chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback) - chunkDelay: 50, // at the end of each interval, give n milliseconds back to system/browser - chunkProgress: null, // progress callback: function(processed, total, elapsed) (e.g. for a progress indicator) - - //Options to pass to the L.Polygon constructor - polygonOptions: {} - }); + maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center + iconCreateFunction: null, + clusterPane: L.Marker.prototype.options.pane, + + spiderfyOnMaxZoom: true, + showCoverageOnHover: true, + zoomToBoundsOnClick: true, + singleMarkerMode: false, + + disableClusteringAtZoom: disableClusteringAtZoom, + + // Setting this to false prevents the removal of any clusters outside of the viewpoint, which + // is the default behaviour for performance reasons. + removeOutsideVisibleBounds: true, + + // Set to false to disable all animations (zoom and spiderfy). + // If false, option animateAddingMarkers below has no effect. + // If L.DomUtil.TRANSITION is falsy, this option has no effect. + animate: true, + + //Whether to animate adding markers after adding the MarkerClusterGroup to the map + // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains. + animateAddingMarkers: false, + + //Increase to increase the distance away that spiderfied markers appear from the center + spiderfyDistanceMultiplier: 1, + + // Make it possible to specify a polyline options on a spider leg + spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, + + // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts + chunkedLoading: false, + chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback) + chunkDelay: 50, // at the end of each interval, give n milliseconds back to system/browser + chunkProgress: null, // progress callback: function(processed, total, elapsed) (e.g. for a progress indicator) + + //Options to pass to the L.Polygon constructor + polygonOptions: {} + }); var obj = specialcomponentpinone; let tempMarker = L.marker(obj.coordinates.split(",", 3)); @@ -861,45 +861,45 @@ document.addEventListener('DOMContentLoaded', function () { // Show Pins from customfield if (showcustomfieldpin === '1') { var clustermarkers = L.markerClusterGroup({ - maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center - iconCreateFunction: null, - clusterPane: L.Marker.prototype.options.pane, - - spiderfyOnMaxZoom: true, - showCoverageOnHover: true, - zoomToBoundsOnClick: true, - singleMarkerMode: false, - - disableClusteringAtZoom: disableClusteringAtZoom, - - // Setting this to false prevents the removal of any clusters outside of the viewpoint, which - // is the default behaviour for performance reasons. - removeOutsideVisibleBounds: true, - - // Set to false to disable all animations (zoom and spiderfy). - // If false, option animateAddingMarkers below has no effect. - // If L.DomUtil.TRANSITION is falsy, this option has no effect. - animate: true, - - //Whether to animate adding markers after adding the MarkerClusterGroup to the map - // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains. - animateAddingMarkers: false, - - //Increase to increase the distance away that spiderfied markers appear from the center - spiderfyDistanceMultiplier: 1, - - // Make it possible to specify a polyline options on a spider leg - spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, - - // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts - chunkedLoading: false, - chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback) - chunkDelay: 50, // at the end of each interval, give n milliseconds back to system/browser - chunkProgress: null, // progress callback: function(processed, total, elapsed) (e.g. for a progress indicator) - - //Options to pass to the L.Polygon constructor - polygonOptions: {} - }); + maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center + iconCreateFunction: null, + clusterPane: L.Marker.prototype.options.pane, + + spiderfyOnMaxZoom: true, + showCoverageOnHover: true, + zoomToBoundsOnClick: true, + singleMarkerMode: false, + + disableClusteringAtZoom: disableClusteringAtZoom, + + // Setting this to false prevents the removal of any clusters outside of the viewpoint, which + // is the default behaviour for performance reasons. + removeOutsideVisibleBounds: true, + + // Set to false to disable all animations (zoom and spiderfy). + // If false, option animateAddingMarkers below has no effect. + // If L.DomUtil.TRANSITION is falsy, this option has no effect. + animate: true, + + //Whether to animate adding markers after adding the MarkerClusterGroup to the map + // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains. + animateAddingMarkers: false, + + //Increase to increase the distance away that spiderfied markers appear from the center + spiderfyDistanceMultiplier: 1, + + // Make it possible to specify a polyline options on a spider leg + spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, + + // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts + chunkedLoading: false, + chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback) + chunkDelay: 50, // at the end of each interval, give n milliseconds back to system/browser + chunkProgress: null, // progress callback: function(processed, total, elapsed) (e.g. for a progress indicator) + + //Options to pass to the L.Polygon constructor + polygonOptions: {} + }); for (var specialcustomfieldpin in specialcustomfieldpins) { // skip loop if the property is from prototype @@ -963,34 +963,38 @@ document.addEventListener('DOMContentLoaded', function () { tempMarkercf.openPopup(); }); } - window['mymap' + moduleId].on("moveend", function (event) { - var bounds = event.target.getBounds(); + window['mymap' + moduleId].on("moveend", function (event) { + var bounds = event.target.getBounds(); for (var specialcustomfieldpin in specialcustomfieldpins) { - if(specialcustomfieldpins[specialcustomfieldpin].id){ + if (specialcustomfieldpins[specialcustomfieldpin].id) { var cords = L.latLng(specialcustomfieldpins[specialcustomfieldpin].cords.split(",").slice(0, 2)); - if (!bounds.contains(cords)) { - document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = true; - } else { - document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = false; + if (document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id)) { + if (!bounds.contains(cords)) { + document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = true; + } else { + document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = false; + } } } } }); - - window['mymap' + moduleId].on("zoomend", function (event) { - var bounds = event.target.getBounds(); + + window['mymap' + moduleId].on("zoomend", function (event) { + var bounds = event.target.getBounds(); for (var specialcustomfieldpin in specialcustomfieldpins) { - if(specialcustomfieldpins[specialcustomfieldpin].id){ + if (specialcustomfieldpins[specialcustomfieldpin].id) { var cords = L.latLng(specialcustomfieldpins[specialcustomfieldpin].cords.split(",").slice(0, 2)); - if (!bounds.contains(cords)) { - document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = true; - } else { - document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = false; + if (document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id)) { + if (!bounds.contains(cords)) { + document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = true; + } else { + document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = false; + } } } } }); - + tempMarkercf.addTo(clustermarkers); } } @@ -1027,44 +1031,44 @@ document.addEventListener('DOMContentLoaded', function () { if (geojson === '1') { // Get Style Start - function areaStyle(feature){ + function areaStyle(feature) { return { fillColor: getAreaFill(feature), color: getAreaStroke(feature), weight: getAreaStrokeWidth(feature), opacity: getAreaStrokeOpacity(feature), fillOpacity: getAreaFillOpacity(feature) - } - }; - function getAreaFill(feature){ + } + }; + function getAreaFill(feature) { if (feature.properties.fill) { return feature.properties.fill; } else { return 'blue'; } }; - function getAreaStroke(feature){ + function getAreaStroke(feature) { if (feature.properties.stroke) { return feature.properties.stroke; } else { return 'blue'; } }; - function getAreaStrokeWidth(feature){ + function getAreaStrokeWidth(feature) { if (feature.properties["stroke-width"]) { return feature.properties["stroke-width"]; } else { return 2; } }; - function getAreaStrokeOpacity(feature){ + function getAreaStrokeOpacity(feature) { if (feature.properties["stroke-opacity"]) { return feature.properties["stroke-opacity"]; } else { return 1; } }; - function getAreaFillOpacity(feature){ + function getAreaFillOpacity(feature) { if (feature.properties["fill-opacity"]) { return feature.properties["fill-opacity"]; } else { @@ -1078,7 +1082,7 @@ document.addEventListener('DOMContentLoaded', function () { if (geojsonTextRaw === '{}') { console.log('No GeoJson Object'); } else { - L.geoJSON(geojsonText, {style: areaStyle}).addTo(window['mymap' + moduleId]); + L.geoJSON(geojsonText, { style: areaStyle }).addTo(window['mymap' + moduleId]); } } catch (e) { @@ -1102,7 +1106,7 @@ document.addEventListener('DOMContentLoaded', function () { if (geojsonTextRaw === '{}') { console.log('No GeoJson Object'); } else { - L.geoJSON(geojsonTextRaw, {style: areaStyle}).addTo(window['mymap' + moduleId]); + L.geoJSON(geojsonTextRaw, { style: areaStyle }).addTo(window['mymap' + moduleId]); } } catch (e) { diff --git a/j4/pkg_agosms/src/modules/mod_agosm/Helper/EasyFileUploaderHelper.php b/j4/pkg_agosms/src/modules/mod_agosm/Helper/EasyFileUploaderHelper.php index 41a4988a..31e0c0db 100644 --- a/j4/pkg_agosms/src/modules/mod_agosm/Helper/EasyFileUploaderHelper.php +++ b/j4/pkg_agosms/src/modules/mod_agosm/Helper/EasyFileUploaderHelper.php @@ -1,4 +1,4 @@ -get('ag_parent'); - $parent = trim($parent, "/\\ \t\n\r\0\x0B"); - - // Get the folder location and trim whitespace and slashes from both ends - $folder = $params->get('ag_folder'); - $folder = trim($folder, "/\\ \t\n\r\0\x0B"); - $folder = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $folder); - - // Compile the full absolute path - $path = $jpath . DIRECTORY_SEPARATOR . $parent . DIRECTORY_SEPARATOR . $folder; - $path = rtrim($path, "/\\ \t\n\r\0\x0B"); - - // Compile the full relative path - $relativepath = $parent . DIRECTORY_SEPARATOR . $folder; - $relativepath = rtrim($relativepath, "/\\ \t\n\r\0\x0B"); - - if ($params->get('ag_user') == true) - { - // Get the user data - $user = Factory::getUser(); - - if ($user->guest == false) - { - $path .= DIRECTORY_SEPARATOR . $user->username; - $relativepath .= DIRECTORY_SEPARATOR . $user->username; - } - else - { - // Todo - } - } - - // Check to see if the upload process has started - if (isset($_FILES[$params->get('ag_variable')])) - { - // Now, we're going to check each of the uploaded files - $total = intval($params->get('ag_multiple')); - - for ($i = 0; $i < $total; $i++) - { - $result[$i]['show'] = true; - $result[$i]['rpath'] = $relativepath; - $result[$i]['path'] = $path; - - // So, now, check for any other errors - if ($_FILES[$params->get('ag_variable')]["error"][$i] > 0) - { - // Error was found. Show the return code. - $error_text = Text::_('MOD_AG_RETURN_CODE') . ": " . $_FILES[$params->get('ag_variable')]["error"][$i] . "
"; - $error_text .= self::fileUploadErrorMessage($_FILES[$params->get('ag_variable')]["error"][$i]); - - $result[$i]['type'] = 'error'; - $result[$i]['text'] = $error_text; - - // Note that UPLOAD_ERR_NO_FILE = 4 - if ($_FILES[$params->get('ag_variable')]["error"][$i] == UPLOAD_ERR_NO_FILE) - { - // Set the result type to warning instead of error - $result[$i]['type'] = 'warning'; - - // Get the value for 'ag_shownofile', the default is 1 - $shownofile = $params->get('ag_shownofile', 1); - - if ($shownofile == false) - { - $result[$i]['show'] = false; - } - } - } - else - { - /* - No errors found. - Check to see if the file type is correct - But first, we have to store the file types in a variable. I was getting an issue with empty() */ - if (self::isValidFileType($params, $i)) - { - // The file type is permitted - // So, check for the right size - if ($_FILES[$params->get('ag_variable')]["size"][$i] < $params->get('ag_maxsize')) - { - // File is an acceptable size - // Check to see if file already exists in the destination folder - if (file_exists($path . DIRECTORY_SEPARATOR . $_FILES[$params->get('ag_variable')]["name"][$i])) - { - // File already exists - // Check whether the user wants to replace the file or not. - if ($params->get('ag_default_replace') == true - || ($params->get('ag_replace') == true && $_POST["answer"] == true)) - { - // Yep, the user wants to replace the file, so just delete the existing file - File::delete($path . DIRECTORY_SEPARATOR . $_FILES[$params->get('ag_variable')]["name"][$i]); - self::storeUploadedFile($path, $params, $result, $i, true); - } - else - { - $result[$i]['type'] = 'info'; - $result[$i]['text'] = $_FILES[$params->get('ag_variable')]["name"][$i] . " " . Text::_('MOD_AG_ALREADY_EXISTS'); - } - } - else - { - // Check to see if the file meets the safety standards - $is_safe = self::checkFileSafety($params, $result, $i); - - if ($is_safe) - { - self::storeUploadedFile($path, $params, $result, $i); - } - } - } - else - { - // File is too large - $result[$i]['type'] = 'warning'; - $result[$i]['text'] = Text::_('MOD_AG_TOO_LARGE_ERROR') . self::sizeToText($params->get('ag_maxsize')) . "."; - } - } - else - { - // The file type is not permitted - $fakeMIME = $_FILES[$params->get('ag_variable')]["type"][$i]; - $trueMIME = self::actualMIME($_FILES[$params->get('ag_variable')]["tmp_name"][$i]); - $result[$i]['type'] = 'error'; - $result[$i]['text'] = Text::_('MOD_AG_INVALID_ERROR') - . "
" - . Text::_('MOD_AG_PHP_MIME_ERROR') - . ($trueMIME !== false ? "(" - . $trueMIME . ")" : "") - . "
" . Text::_('MOD_AG_BROWSER_MIME_ERROR') - . $fakeMIME; - } - } - } - } - - return $result; - } - - /** - * Method to get file uplaod. - * - * @param boolean &$params If true, the view output will be cached - * @param boolean &$i If true, the view output will be cached - * - * @return array This object to support chaining. - * - * @since 1.0.40 - */ - private static function isValidFileType(&$params, &$i) - { - $valid = false; - - $filetypes = $params->get('ag_filetypes'); - $actualMIME = self::actualMIME($_FILES[$params->get('ag_variable')]["tmp_name"][$i]); - - if ($filetypes == "*" - || (stripos($filetypes, $_FILES[$params->get('ag_variable')]["type"][$i]) !== false - && $actualMIME !== false - && stripos($filetypes, $actualMIME) !== false)) - { - $valid = true; - } - - return $valid; - } - - /** - * Method to get file mime. - * - * @param boolean $file If file - * - * @return boolean This object - * - * @since 1.0.40 - */ - private static function actualMIME($file) - { - if (!file_exists($file)) - { - return false; - } - - $mime = false; - - // Try to use recommended functions - if (defined('FILEINFO_MIME_TYPE') - && function_exists('finfo_open') - && is_callable('finfo_open') - && function_exists('finfo_file') - && is_callable('finfo_file') - && function_exists('finfo_close') - && is_callable('finfo_close')) - { - $finfo = finfo_open(FILEINFO_MIME_TYPE); - $mime = finfo_file($finfo, $file); - - if ($mime === '') - { - $mime = false; - } - - finfo_close($finfo); - } - elseif (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') - { - $f = "'" . $file . "'"; - - if (function_exists('escapeshellarg') && is_callable('escapeshellarg')) - { - // Prefer to use escapeshellarg if it is available - $f = escapeshellarg($file); - } - - if (function_exists('exec') && is_callable('exec')) - { - /* - Didn't like how 'system' flushes output to browser. replaced with 'exec' - Note: You can change this to: shell_exec("file -b --mime-type $f"); if you get - "Regular file" as the mime type */ - $mime = exec("file -bi $f"); - - // This removes the charset value if it was returned with the mime type. mime is first. - $mime = strtok($mime, '; '); - - // Remove any remaining whitespace - $mime = trim($mime); - } - elseif (function_exists('shell_exec') && is_callable('shell_exec')) - { - // Note: You can change this to: shell_exec("file -b --mime-type $f"); if you get - // "Regular file" as the mime type - $mime = shell_exec("file -bi $f"); - - // This removes the charset value if it was returned with the mime type. - // Mime is first. - $mime = strtok($mime, '; '); - - // Remove any remaining whitespace - $mime = trim($mime); - } - } - elseif (function_exists('mime_content_type') && is_callable('mime_content_type')) - { - // Test using mime_content_type last, since it sometimes detects the mime incorrectly - $mime = mime_content_type($file); - } - - return $mime; - } - - /** - * Method to get file uplaod. - * - * @param boolean $filepath If true, the view output will be cached - * @param boolean &$params If true, the view output will be cached - * @param boolean &$result If true, the view output will be cached - * @param boolean &$i If true, the view output will be cached - * @param boolean $replaced If true, the view output will be cached - * - * @return void - * - * @since 1.0.40 - */ - private static function storeUploadedFile($filepath, &$params, &$result, &$i, $replaced = false) - { - $result_text = ''; - $success = false; - - // Move the file to the destination folder - if (file_exists($filepath)) - { - $success = move_uploaded_file( - $_FILES[$params->get('ag_variable')]["tmp_name"][$i], $filepath . DIRECTORY_SEPARATOR . $_FILES[$params->get('ag_variable')]["name"][$i] - ); - } - else - { - $result_text .= Text::_('MOD_AG_FOLDER_NOT_EXISTS') . " "; - } - - if ($replaced) - { - $result_text .= Text::_('MOD_AG_REPLACEMENT_APPROVED') . " "; - } - - if ($success) - { - // Upload was successful. - $result_text .= Text::_('MOD_AG_UPLOAD_SUCCESSFUL') . "
"; - $result_text .= Text::_('MOD_AG_NAME') . ": " . $_FILES[$params->get('ag_variable')]["name"][$i] . "
"; - $result_text .= Text::_('MOD_AG_TYPE') . ": " . $_FILES[$params->get('ag_variable')]["type"][$i] . "
"; - $result_text .= Text::_('MOD_AG_SIZE') . ": " . self::sizeToText($_FILES[$params->get('ag_variable')]["size"][$i]) . "
"; - - $result[$i]['type'] = 'success'; - $result[$i]['text'] = $result_text; - } - else - { - $result_text .= Text::_('MOD_AG_UPLOAD_UNSUCCESSFUL'); - - $result[$i]['type'] = 'error'; - $result[$i]['text'] = $result_text; - } - } - - /** - * Method to get the error code. - * - * @param string $error_code If true, the view output will be cached - * - * @return string The message - * - * @since 1.0.40 - */ - protected static function fileUploadErrorMessage($error_code) - { - switch ($error_code) - { - case UPLOAD_ERR_INI_SIZE: - $message = Text::_('MOD_AG_INI_SIZE_ERROR'); - break; - case UPLOAD_ERR_FORM_SIZE: - $message = Text::_('MOD_AG_FORM_SIZE_ERROR'); - break; - case UPLOAD_ERR_PARTIAL: - $message = Text::_('MOD_AG_PARTIAL_ERROR'); - break; - case UPLOAD_ERR_NO_FILE: - $message = Text::_('MOD_AG_NO_FILE_ERROR'); - break; - case UPLOAD_ERR_NO_TMP_DIR: - $message = Text::_('MOD_AG_NO_TMP_DIR_ERROR'); - break; - case UPLOAD_ERR_CANT_WRITE: - $message = Text::_('MOD_AG_CANT_WRITE_ERROR'); - break; - case UPLOAD_ERR_EXTENSION: - $message = Text::_('MOD_AG_EXTENSION_ERROR'); - break; - default: - $message = Text::_('MOD_AG_UNKNOWN_ERROR'); - break; - } - - return $message; - } - - /** - * Method to get file uplaod. - * - * @param string $size If true, the view output will be cached - * - * @return string - * - * @since 1.0.40 - */ - protected static function sizeToText($size) - { - $text = ""; - $kb = 1024; - $mb = $kb * $kb; - $gb = $mb * $kb; - - if ($size >= $gb) - { - $size = round($size / $gb, 2); - $text = $size . "GB"; - } - elseif ($size >= $mb) - { - $size = round($size / $mb, 2); - $text = $size . "MB"; - } - elseif ($size >= $kb) - { - $size = round($size / $kb, 2); - $text = $size . "KB"; - } - else - { - $text = $size . Text::_('MOD_AG_BYTES'); - } - - return $text; - } - - /** - * Checks an uploaded for suspicious naming and potential PHP contents which could indicate a hacking attempt. - * - * @param boolean &$params If true, the view output will be cached - * @param boolean &$result If true, the view output will be cached - * @param boolean &$i If true, the view output will be cached - * @param boolean $forbidden If true, the view output will be cached - * - * @return boolean True of the file is safe - */ - public static function checkFileSafety( - &$params, - &$result, - &$i, - $forbidden = array('php', 'phps', 'php5', 'php3', 'php4', 'inc', 'pl', 'cgi', 'fcgi', 'java', 'jar', 'py') - ) - { - $safe = true; - - /** - * 1. Prevent buffer overflow attack by checking for null byte in the file name - */ - $null_byte = "\x00"; - - if (stripos($_FILES[$params->get('ag_variable')]["name"][$i], $null_byte) !== false) - { - $result[$i]['type'] = 'error'; - $result[$i]['text'] = Text::_('MOD_AG_NULL_BYTE_FOUND'); - - return false; - } - - /** - * 2. Prevent uploading forbidden script files (based on file extension) - */ - $filename = $_FILES[$params->get('ag_variable')]["name"][$i]; - $split = explode('.', $filename); - array_shift($split); - $only_extensions = array_map('strtolower', $split); - - foreach ($forbidden as $script) - { - if (in_array($script, $only_extensions)) - { - $result[$i]['type'] = 'error'; - $result[$i]['text'] = Text::_('MOD_AG_FORBIDDEN_SCRIPT_FOUND'); - - return false; - } - } - - /** - * 3. Check the contents of the uploaded file for the following: - * a. Presence of the PHP tag, get('ag_variable')]["tmp_name"][$i], 'r'); - - if ($fp !== false) - { - $data = ''; - - while (!feof($fp) && $safe === true) - { - $data .= @fread($fp, $buffer); - - /** - * a. Check for the presence of the PHP tag, get('ag_scriptsinarchives'); - - if (!$allow_scripts_in_archive) - { - $archive_exts = array('zip', '7z', 'jar', 'rar', 'tar', 'gz', 'tgz', 'bz2', 'tbz', 'jpa'); - $is_archive = false; - - foreach ($archive_exts as $archive) - { - // Check to see if uploaded file is an archive file - if (in_array($archive, $only_extensions)) - { - $is_archive = true; - } - } - - if ($is_archive) - { - foreach ($forbidden as $ext) - { - // Search for the short tag - if (stripos($data, '.' . $ext) !== false) - { - $result[$i]['type'] = 'error'; - $result[$i]['text'] = Text::_('MOD_AG_FORBIDDEN_IN_ARCHIVE_FOUND'); - - $safe = false; - continue; - } - } - } - } - - // Start the next loop with the last 10 bytes just in case the PHP tag was split up - $data = substr($data, -10); - } - - // Close the file handle - fclose($fp); - } - - return $safe; - } -} +namespace AG\Module\Agosms\Site\Helper; + +defined('_JEXEC') or die; + +// No direct access +defined('_JEXEC') or die; + +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Factory; + +// Import joomla file helper class +\JLoader::import('joomla.filesystem.file'); + +/** + * Help uploading files + * + * @since 1.0.40 + */ +class EasyFileUploaderHelper +{ + + /** + * Method to get file uplaod. + * + * @param boolean &$params If true, the view output will be cached + * + * @return array This object to support chaining. + * + * @since 1.0.40 + */ + public static function getFileToUpload(&$params) + { + $result = []; + + // Get the Joomla Path and trim whitespace and slashes from the end + $jpath = JPATH_SITE; + $jpath = rtrim($jpath, "/\\ \t\n\r\0\x0B"); + + // Get the parent folder and trim whitespace and slashes from both ends + $parent = $params->get('ag_parent'); + $parent = trim($parent, "/\\ \t\n\r\0\x0B"); + + // Get the folder location and trim whitespace and slashes from both ends + $folder = $params->get('ag_folder'); + $folder = trim($folder, "/\\ \t\n\r\0\x0B"); + $folder = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $folder); + + // Compile the full absolute path + $path = $jpath . DIRECTORY_SEPARATOR . $parent . DIRECTORY_SEPARATOR . $folder; + $path = rtrim($path, "/\\ \t\n\r\0\x0B"); + + // Compile the full relative path + $relativepath = $parent . DIRECTORY_SEPARATOR . $folder; + $relativepath = rtrim($relativepath, "/\\ \t\n\r\0\x0B"); + + if ($params->get('ag_user') == true) { + // Get the user data + $user = Factory::getUser(); + + if ($user->guest == false) { + $path .= DIRECTORY_SEPARATOR . $user->username; + $relativepath .= DIRECTORY_SEPARATOR . $user->username; + } else { + // Todo + } + } + + // Check to see if the upload process has started + if (isset($_FILES[$params->get('ag_variable')])) { + // Now, we're going to check each of the uploaded files + $total = intval($params->get('ag_multiple')); + + for ($i = 0; $i < $total; $i++) { + $result[$i]['show'] = true; + $result[$i]['rpath'] = $relativepath; + $result[$i]['path'] = $path; + + // So, now, check for any other errors + if ($_FILES[$params->get('ag_variable')]["error"][$i] > 0) { + // Error was found. Show the return code. + $error_text = Text::_('MOD_AG_RETURN_CODE') . ": " . $_FILES[$params->get('ag_variable')]["error"][$i] . "
"; + $error_text .= self::fileUploadErrorMessage($_FILES[$params->get('ag_variable')]["error"][$i]); + + $result[$i]['type'] = 'error'; + $result[$i]['text'] = $error_text; + + // Note that UPLOAD_ERR_NO_FILE = 4 + if ($_FILES[$params->get('ag_variable')]["error"][$i] == UPLOAD_ERR_NO_FILE) { + // Set the result type to warning instead of error + $result[$i]['type'] = 'warning'; + + // Get the value for 'ag_shownofile', the default is 1 + $shownofile = $params->get('ag_shownofile', 1); + + if ($shownofile == false) { + $result[$i]['show'] = false; + } + } + } else { + /* + No errors found. + Check to see if the file type is correct + But first, we have to store the file types in a variable. I was getting an issue with empty() */ + if (self::isValidFileType($params, $i)) { + // The file type is permitted + // So, check for the right size + if ($_FILES[$params->get('ag_variable')]["size"][$i] < $params->get('ag_maxsize')) { + // File is an acceptable size + // Check to see if file already exists in the destination folder + if (file_exists($path . DIRECTORY_SEPARATOR . $_FILES[$params->get('ag_variable')]["name"][$i])) { + // File already exists + // Check whether the user wants to replace the file or not. + if ($params->get('ag_default_replace') == true + || ($params->get('ag_replace') == true && $_POST["answer"] == true)) { + // Yep, the user wants to replace the file, so just delete the existing file + File::delete($path . DIRECTORY_SEPARATOR . $_FILES[$params->get('ag_variable')]["name"][$i]); + self::storeUploadedFile($path, $params, $result, $i, true); + } else { + $result[$i]['type'] = 'info'; + $result[$i]['text'] = $_FILES[$params->get('ag_variable')]["name"][$i] . " " . Text::_('MOD_AG_ALREADY_EXISTS'); + } + } else { + // Check to see if the file meets the safety standards + $is_safe = self::checkFileSafety($params, $result, $i); + + if ($is_safe) { + self::storeUploadedFile($path, $params, $result, $i); + } + } + } else { + // File is too large + $result[$i]['type'] = 'warning'; + $result[$i]['text'] = Text::_('MOD_AG_TOO_LARGE_ERROR') . self::sizeToText($params->get('ag_maxsize')) . "."; + } + } else { + // The file type is not permitted + $fakeMIME = $_FILES[$params->get('ag_variable')]["type"][$i]; + $trueMIME = self::actualMIME($_FILES[$params->get('ag_variable')]["tmp_name"][$i]); + $result[$i]['type'] = 'error'; + $result[$i]['text'] = Text::_('MOD_AG_INVALID_ERROR') + . "
" + . Text::_('MOD_AG_PHP_MIME_ERROR') + . ($trueMIME !== false ? "(" + . $trueMIME . ")" : "") + . "
" . Text::_('MOD_AG_BROWSER_MIME_ERROR') + . $fakeMIME; + } + } + } + } + + return $result; + } + + /** + * Method to get file uplaod. + * + * @param boolean &$params If true, the view output will be cached + * @param boolean &$i If true, the view output will be cached + * + * @return array This object to support chaining. + * + * @since 1.0.40 + */ + private static function isValidFileType(&$params, &$i) + { + $valid = false; + + $filetypes = $params->get('ag_filetypes'); + $actualMIME = self::actualMIME($_FILES[$params->get('ag_variable')]["tmp_name"][$i]); + + if ($filetypes == "*" + || (stripos($filetypes, $_FILES[$params->get('ag_variable')]["type"][$i]) !== false + && $actualMIME !== false + && stripos($filetypes, $actualMIME) !== false)) { + $valid = true; + } + + return $valid; + } + + /** + * Method to get file mime. + * + * @param boolean $file If file + * + * @return boolean This object + * + * @since 1.0.40 + */ + private static function actualMIME($file) + { + if (!file_exists($file)) { + return false; + } + + $mime = false; + + // Try to use recommended functions + if (defined('FILEINFO_MIME_TYPE') + && function_exists('finfo_open') + && is_callable('finfo_open') + && function_exists('finfo_file') + && is_callable('finfo_file') + && function_exists('finfo_close') + && is_callable('finfo_close')) { + $finfo = finfo_open(FILEINFO_MIME_TYPE); + $mime = finfo_file($finfo, $file); + + if ($mime === '') { + $mime = false; + } + + finfo_close($finfo); + } else if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { + $f = "'" . $file . "'"; + + if (function_exists('escapeshellarg') && is_callable('escapeshellarg')) { + // Prefer to use escapeshellarg if it is available + $f = escapeshellarg($file); + } + + if (function_exists('exec') && is_callable('exec')) { + /* + Didn't like how 'system' flushes output to browser. replaced with 'exec' + Note: You can change this to: shell_exec("file -b --mime-type $f"); if you get + "Regular file" as the mime type */ + $mime = exec("file -bi $f"); + + // This removes the charset value if it was returned with the mime type. mime is first. + $mime = strtok($mime, '; '); + + // Remove any remaining whitespace + $mime = trim($mime); + } else if (function_exists('shell_exec') && is_callable('shell_exec')) { + // Note: You can change this to: shell_exec("file -b --mime-type $f"); if you get + // "Regular file" as the mime type + $mime = shell_exec("file -bi $f"); + + // This removes the charset value if it was returned with the mime type. + // Mime is first. + $mime = strtok($mime, '; '); + + // Remove any remaining whitespace + $mime = trim($mime); + } + } else if (function_exists('mime_content_type') && is_callable('mime_content_type')) { + // Test using mime_content_type last, since it sometimes detects the mime incorrectly + $mime = mime_content_type($file); + } + + return $mime; + } + + /** + * Method to get file uplaod. + * + * @param boolean $filepath If true, the view output will be cached + * @param boolean &$params If true, the view output will be cached + * @param boolean &$result If true, the view output will be cached + * @param boolean &$i If true, the view output will be cached + * @param boolean $replaced If true, the view output will be cached + * + * @return void + * + * @since 1.0.40 + */ + private static function storeUploadedFile($filepath, &$params, &$result, &$i, $replaced = false) + { + $result_text = ''; + $success = false; + + // Move the file to the destination folder + if (file_exists($filepath)) { + $success = move_uploaded_file( + $_FILES[$params->get('ag_variable')]["tmp_name"][$i], + $filepath . DIRECTORY_SEPARATOR . $_FILES[$params->get('ag_variable')]["name"][$i] + ); + } else { + $result_text .= Text::_('MOD_AG_FOLDER_NOT_EXISTS') . " "; + } + + if ($replaced) { + $result_text .= Text::_('MOD_AG_REPLACEMENT_APPROVED') . " "; + } + + if ($success) { + // Upload was successful. + $result_text .= Text::_('MOD_AG_UPLOAD_SUCCESSFUL') . "
"; + $result_text .= Text::_('MOD_AG_NAME') . ": " . $_FILES[$params->get('ag_variable')]["name"][$i] . "
"; + $result_text .= Text::_('MOD_AG_TYPE') . ": " . $_FILES[$params->get('ag_variable')]["type"][$i] . "
"; + $result_text .= Text::_('MOD_AG_SIZE') . ": " . self::sizeToText($_FILES[$params->get('ag_variable')]["size"][$i]) . "
"; + + $result[$i]['type'] = 'success'; + $result[$i]['text'] = $result_text; + } else { + $result_text .= Text::_('MOD_AG_UPLOAD_UNSUCCESSFUL'); + + $result[$i]['type'] = 'error'; + $result[$i]['text'] = $result_text; + } + } + + /** + * Method to get the error code. + * + * @param string $error_code If true, the view output will be cached + * + * @return string The message + * + * @since 1.0.40 + */ + protected static function fileUploadErrorMessage($error_code) + { + switch ($error_code) { + case UPLOAD_ERR_INI_SIZE: + $message = Text::_('MOD_AG_INI_SIZE_ERROR'); + break; + case UPLOAD_ERR_FORM_SIZE: + $message = Text::_('MOD_AG_FORM_SIZE_ERROR'); + break; + case UPLOAD_ERR_PARTIAL: + $message = Text::_('MOD_AG_PARTIAL_ERROR'); + break; + case UPLOAD_ERR_NO_FILE: + $message = Text::_('MOD_AG_NO_FILE_ERROR'); + break; + case UPLOAD_ERR_NO_TMP_DIR: + $message = Text::_('MOD_AG_NO_TMP_DIR_ERROR'); + break; + case UPLOAD_ERR_CANT_WRITE: + $message = Text::_('MOD_AG_CANT_WRITE_ERROR'); + break; + case UPLOAD_ERR_EXTENSION: + $message = Text::_('MOD_AG_EXTENSION_ERROR'); + break; + default: + $message = Text::_('MOD_AG_UNKNOWN_ERROR'); + break; + } + + return $message; + } + + /** + * Method to get file uplaod. + * + * @param string $size If true, the view output will be cached + * + * @return string + * + * @since 1.0.40 + */ + protected static function sizeToText($size) + { + $text = ""; + $kb = 1024; + $mb = $kb * $kb; + $gb = $mb * $kb; + + if ($size >= $gb) { + $size = round($size / $gb, 2); + $text = $size . "GB"; + } else if ($size >= $mb) { + $size = round($size / $mb, 2); + $text = $size . "MB"; + } else if ($size >= $kb) { + $size = round($size / $kb, 2); + $text = $size . "KB"; + } else { + $text = $size . Text::_('MOD_AG_BYTES'); + } + + return $text; + } + + /** + * Checks an uploaded for suspicious naming and potential PHP contents which could indicate a hacking attempt. + * + * @param boolean &$params If true, the view output will be cached + * @param boolean &$result If true, the view output will be cached + * @param boolean &$i If true, the view output will be cached + * @param boolean $forbidden If true, the view output will be cached + * + * @return boolean True of the file is safe + */ + public static function checkFileSafety( + &$params, + &$result, + &$i, + $forbidden = ['php', 'phps', 'php5', 'php3', 'php4', 'inc', 'pl', 'cgi', 'fcgi', 'java', 'jar', 'py'] + ) { + $safe = true; + + /** + * 1. Prevent buffer overflow attack by checking for null byte in the file name + */ + $null_byte = "\x00"; + + if (stripos($_FILES[$params->get('ag_variable')]["name"][$i], $null_byte) !== false) { + $result[$i]['type'] = 'error'; + $result[$i]['text'] = Text::_('MOD_AG_NULL_BYTE_FOUND'); + + return false; + } + + /** + * 2. Prevent uploading forbidden script files (based on file extension) + */ + $filename = $_FILES[$params->get('ag_variable')]["name"][$i]; + $split = explode('.', $filename); + array_shift($split); + $only_extensions = array_map('strtolower', $split); + + foreach ($forbidden as $script) { + if (in_array($script, $only_extensions)) { + $result[$i]['type'] = 'error'; + $result[$i]['text'] = Text::_('MOD_AG_FORBIDDEN_SCRIPT_FOUND'); + + return false; + } + } + + /** + * 3. Check the contents of the uploaded file for the following: + * a. Presence of the PHP tag, get('ag_variable')]["tmp_name"][$i], 'r'); + + if ($fp !== false) { + $data = ''; + + while (!feof($fp) && $safe === true) { + $data .= @fread($fp, $buffer); + + /** + * a. Check for the presence of the PHP tag, get('ag_scriptsinarchives'); + + if (!$allow_scripts_in_archive) { + $archive_exts = ['zip', '7z', 'jar', 'rar', 'tar', 'gz', 'tgz', 'bz2', 'tbz', 'jpa']; + $is_archive = false; + + foreach ($archive_exts as $archive) { + // Check to see if uploaded file is an archive file + if (in_array($archive, $only_extensions)) { + $is_archive = true; + } + } + + if ($is_archive) { + foreach ($forbidden as $ext) { + // Search for the short tag + if (stripos($data, '.' . $ext) !== false) { + $result[$i]['type'] = 'error'; + $result[$i]['text'] = Text::_('MOD_AG_FORBIDDEN_IN_ARCHIVE_FOUND'); + + $safe = false; + continue; + } + } + } + } + + // Start the next loop with the last 10 bytes just in case the PHP tag was split up + $data = substr($data, -10); + } + + // Close the file handle + fclose($fp); + } + + return $safe; + } +} diff --git a/j4/pkg_agosms/src/modules/mod_agosm/helper.php b/j4/pkg_agosms/src/modules/mod_agosm/helper.php deleted file mode 100644 index 71995526..00000000 --- a/j4/pkg_agosms/src/modules/mod_agosm/helper.php +++ /dev/null @@ -1,360 +0,0 @@ - true)); - - // Set application parameters in model - $app = JFactory::getApplication(); - $appParams = $app->getParams(); - $model->setState('params', $appParams); - - // Set the filters based on the module params - $model->setState('list.start', 0); - $model->setState('list.limit', (int) $params->get('count', 5)); - - $model->setState('filter.state', 1); - $model->setState('filter.publish_date', true); - - // Access filter - $access = !JComponentHelper::getParams('com_agosms')->get('show_noauth'); - $model->setState('filter.access', $access); - - $ordering = $params->get('ordering', 'ordering'); - $model->setState('list.ordering', $ordering == 'order' ? 'ordering' : $ordering); - $model->setState('list.direction', $params->get('direction', 'asc')); - - $catid = (int) $params->get('catid', 0); - $model->setState('category.id', $catid); - $model->setState('category.group', $params->get('groupby', 0)); - $model->setState('category.ordering', $params->get('groupby_ordering', 'c.lft')); - $model->setState('category.direction', $params->get('groupby_direction', 'ASC')); - - // Create query object - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - - $case_when1 = ' CASE WHEN '; - $case_when1 .= $query->charLength('a.alias', '!=', '0'); - $case_when1 .= ' THEN '; - $a_id = $query->castAsChar('a.id'); - $case_when1 .= $query->concatenate(array($a_id, 'a.alias'), ':'); - $case_when1 .= ' ELSE '; - $case_when1 .= $a_id . ' END as slug'; - - $case_when2 = ' CASE WHEN '; - $case_when2 .= $query->charLength('c.alias', '!=', '0'); - $case_when2 .= ' THEN '; - $c_id = $query->castAsChar('c.id'); - $case_when2 .= $query->concatenate(array($c_id, 'c.alias'), ':'); - $case_when2 .= ' ELSE '; - $case_when2 .= $c_id . ' END as catslug'; - - $model->setState( - 'list.select', 'a.*, c.published AS c_published,' . $case_when1 . ',' . $case_when2 . ',' . 'DATE_FORMAT(a.created, "%Y-%m-%d") AS created' - ); - - $model->setState('filter.c.published', 1); - - // Filter by language - $model->setState('filter.language', $app->getLanguageFilter()); - - $items = $model->getItems(); - - if ($items) - { - foreach ($items as $item) - { - $category = $model->getCategory($item->id); - break; - } - - return $category; - } - - return; - } - - /** - * Show online member names - * - * @param mixed &$params The parameters set in the administrator backend - * - * @return mixed Null if no agosms based on input parameters else an array containing all the agosms. - * - * @since 1.0.40 - * */ - public static function getList(&$params) - { - // Get an instance of the generic articles model - $model = JModelLegacy::getInstance('Category', 'AgosmsModel', array('ignore_request' => true)); - - // Set application parameters in model - $app = JFactory::getApplication(); - $appParams = $app->getParams(); - $model->setState('params', $appParams); - - // Set the filters based on the module params - $model->setState('list.start', 0); - $model->setState('filter.state', 1); - $model->setState('filter.publish_date', true); - - // Access filter - $access = !JComponentHelper::getParams('com_agosms')->get('show_noauth'); - $model->setState('filter.access', $access); - - $ordering = $params->get('ordering', 'ordering'); - $model->setState('list.ordering', $ordering == 'order' ? 'ordering' : $ordering); - $model->setState('list.direction', $params->get('direction', 'asc')); - - $catid = $params->get('catid', null); - $model->setState('category.id', $catid[0]); - $model->setState('category.group', $params->get('groupby', 0)); - $model->setState('category.ordering', $params->get('groupby_ordering', 'c.lft')); - $model->setState('category.direction', $params->get('groupby_direction', 'ASC')); - - // Create query object - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $items = $model->getItems(); - - if ($items) - { - return $items; - } - - return; - } - - /** - * Show online member names - * - * @param mixed &$params The parameters set in the administrator backend - * - * @return mixed Null if no agosms based on input parameters else an array containing all the agosms. - * - * @since 1.0.72 - * */ - public static function getListone(&$params) - { - // Get an instance of the generic articles model - $model = JModelLegacy::getInstance('Agosm', 'AgosmsModel', array('ignore_request' => true)); - - $id = $params->get('showcomponentpinoneid', null); - $item = $model->getItem((int)$id); - - if ($item) - { - return $item; - } - - return; - } - - /** - * Show online member names - * - * @param mixed &$params The parameters set in the administrator backend - * - * @return mixed Null if no agosms based on input parameters else an array containing all the agosms. - * - * @since 1.0.40 - * */ - public static function getListCustomField(&$params) - { - // Get an instance of the generic articles model - $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true)); - - // Todo check if other compontent than com_content - if ($model) - { - // Set application parameters in model - $app = JFactory::getApplication(); - $appParams = $app->getParams(); - $model->setState('params', $appParams); - - // Set the filters based on the module params - $model->setState('list.start', 0); - $model->setState('filter.state', 1); - $model->setState('filter.publish_date', true); - - // Access filter - $access = !JComponentHelper::getParams('com_agosms')->get('show_noauth'); - $model->setState('filter.access', $access); - - $cat = $params->get('catidcf', 0); - $catid = (int) $params->get('catid', 0); - $model->setState('category.id', $catid); - $model->setState('category.group', $params->get('groupby', 0)); - $model->setState('category.ordering', $params->get('groupby_ordering', 'c.lft')); - $model->setState('category.direction', $params->get('groupby_direction', 'ASC')); - - // Create query object - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $items = $model->getItems(); - $itemsfiltered = array(); - - if ($items) - { - foreach ($items as $key => $item) - { - if ($cat[0] != 0 && $item->catid != $cat[0]) - { - continue; - } - - if ($item->state !== "1") - { - continue; - } - - // Get item's fields, also preparing their value property for manual display - // (calling plugins events and loading layouts to get their HTML display) - $fields = FieldsHelper::getFields('com_content.article', $item, true); - - foreach ($fields as $key => $field) - { - $itemfiltered = new stdClass; - - if ($field->title == 'lat, lon') - { - $itemfiltered->cords = $field->value; - $test = explode(",", $itemfiltered->cords); - - if (is_numeric($test[0]) && is_numeric($test[1])) - { - $itemfiltered->title = $item->title; - $itemfiltered->id = $item->id; - $itemfiltered->type = $field->type; - } - } - - if ($field->type == 'agosmsmarker') - { - $itemfiltered->cords = $field->value; - $test = explode(",", $itemfiltered->cords); - - if (is_numeric($test[0]) && is_numeric($test[1])) - { - $itemfiltered->title = $item->title; - $itemfiltered->id = $item->id; - $itemfiltered->type = $field->type; - } - } - - if ($field->type == 'agosmsaddressmarker') - { - // Get plugin parameters - $popup = $field->fieldparams->get('popup', '0'); - $specialicon = $field->fieldparams->get('specialicon', '0'); - - $itemfiltered->cords = $field->rawvalue; - $test = explode(",", $itemfiltered->cords); - - if (sizeof($test) > 5 && is_numeric($test[0]) && is_numeric($test[1])) - { - $itemfiltered->title = $item->title; - $itemfiltered->id = $item->id; - $itemfiltered->type = $field->type; - $itemfiltered->lat = $test[0]; - $itemfiltered->lon = $test[1]; - - if ($specialicon) - { - $itemfiltered->iconcolor = $test[2]; - $itemfiltered->markercolor = $test[3]; - $itemfiltered->icon = $test[4]; - } - - if ($popup) - { - $itemfiltered->popuptext = $test[5]; - } - } - } - - $itemsfiltered[] = $itemfiltered; - } - } - } - - if ($itemsfiltered) - { - return $itemsfiltered; - } - } - - return array(); - } - - /** - * Show external database - * - * @param mixed &$params The parameters set in the administrator backend - * - * @return mixed Null if no agosms based on input parameters else an array containing all the agosms. - * - * @since 1.0.43 - * */ - public static function getListExternaldb(&$params) - { - $options = array( - 'driver' => 'mysqli', - 'host' => 'localhost', - 'user' => 'root', - 'password' => 'Schweden1!', - 'database' => 'joomla_db' - ); - - $externalDb = JDatabaseDriver::getInstance($options); - $query = $externalDb->getQuery(true); - - $query->select($externalDb->quoteName(array('*'))); - $query->from($externalDb->quoteName('j3_agosms')); - - // Reset the query using our newly populated query object. - $externalDb->setQuery($query); - - // Load the results as a list of stdClass objects (see later for more options on retrieving data). - $results = $externalDb->loadObjectList(); - - return $results; - } - -} diff --git a/j4/pkg_agosms/src/modules/mod_agosm/language/de-DE/de-DE.mod_agosm.ini b/j4/pkg_agosms/src/modules/mod_agosm/language/de-DE/de-DE.mod_agosm.ini index f399befb..5ce34794 100644 --- a/j4/pkg_agosms/src/modules/mod_agosm/language/de-DE/de-DE.mod_agosm.ini +++ b/j4/pkg_agosms/src/modules/mod_agosm/language/de-DE/de-DE.mod_agosm.ini @@ -1,5 +1,7 @@ MOD_AGOSM="AGOSM Modul" -MOD_AGOSM_XML_DESCRIPTION="Zeigt OpenStreetMap mit Markern und Controllern an." +MOD_AGOSM_XML_DESCRIPTION="Zeigt OpenStreetMap mit Markern und Controllern an. Öffne bei Problemen gerne ein Issue unter https://github.com/astridx/pkg_agosms/issues." +MOD_AGOSMS="AGOSM Modul" +MOD_AGOSMS_XML_DESCRIPTION="Zeigt OpenStreetMap mit Markern und Controllern an. Öffne bei Problemen gerne ein Issue unter https://github.com/astridx/pkg_agosms/issues." ;Routing MOD_AGOSM_ROUTING_SIMPLE_TEXT_STUNDEN=" Stunden. " MOD_AGOSM_ROUTING_SIMPLE_TEXT_KILOMETER=" Kilometer. " diff --git a/j4/pkg_agosms/src/modules/mod_agosm/language/en-GB/en-GB.mod_agosm.ini b/j4/pkg_agosms/src/modules/mod_agosm/language/en-GB/en-GB.mod_agosm.ini index a637b094..77753e2d 100644 --- a/j4/pkg_agosms/src/modules/mod_agosm/language/en-GB/en-GB.mod_agosm.ini +++ b/j4/pkg_agosms/src/modules/mod_agosm/language/en-GB/en-GB.mod_agosm.ini @@ -1,7 +1,7 @@ MOD_AGOSM="Agosm Module" -MOD_AGOSM_XML_DESCRIPTION="Shows OpenStreetMap with markers (pins) and controlls." +MOD_AGOSM_XML_DESCRIPTION="Shows OpenStreetMap with markers (pins) and controlls. If you have any problems, please open an issue at https://github.com/astridx/pkg_agosms/issues." MOD_AGOSMS="Agosm Module" -MOD_AGOSMS_XML_DESCRIPTION="Shows OpenStreetMap with markers (pins) and controlls." +MOD_AGOSMS_XML_DESCRIPTION="Shows OpenStreetMap with markers (pins) and controlls. If you have any problems, please open an issue at https://github.com/astridx/pkg_agosms/issues." ;Routing MOD_AGOSM_ROUTING_SIMPLE_TEXT_STUNDEN=" hours. " MOD_AGOSM_ROUTING_SIMPLE_TEXT_KILOMETER=" kilometers. " diff --git a/j4/pkg_agosms/src/modules/mod_agosm/mod_agosm.php b/j4/pkg_agosms/src/modules/mod_agosm/mod_agosm.php index da4a57ec..5a0d9ad0 100644 --- a/j4/pkg_agosms/src/modules/mod_agosm/mod_agosm.php +++ b/j4/pkg_agosms/src/modules/mod_agosm/mod_agosm.php @@ -10,131 +10,109 @@ defined('_JEXEC') or die; -// Include the agosm functions only once -require_once __DIR__ . '/helper.php'; -require_once __DIR__ . '/Helper/EasyFileUploaderHelper.php'; - -$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx')); +use Joomla\CMS\Helper\ModuleHelper; +use AG\Module\Agosm\Site\Helper\AgosmsCategoryHelper; // Include skripts/styles to the header $document = JFactory::getDocument(); $leafletIsLoaded = false; -foreach ($document->_scripts as $key => $script) -{ +foreach ($document->_scripts as $key => $script) { $leafletPath = "leaflet/leaflet.js"; - if (strpos($key, $leafletPath)) - { + if (strpos($key, $leafletPath)) { $leafletIsLoaded = true; } } -if (!$leafletIsLoaded) -{ +if (!$leafletIsLoaded) { $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/leaflet/leaflet.css'); $document->addScript(JURI::root(true) . '/media/mod_agosm/leaflet/leaflet.js'); } -if ($params->get('showgeocoder', '1') == 1 || $params->get('showrouting', '1') == 1) -{ +if ($params->get('showgeocoder', '1') == 1 || $params->get('showrouting', '1') == 1) { $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/css/Control.Geocoder.css'); $document->addScript(JURI::root(true) . '/media/mod_agosm/js/Control.Geocoder.js'); } -if ($params->get('useesri', '1') == 1) -{ +if ($params->get('useesri', '1') == 1) { $document->addScript(JURI::root(true) . '/media/mod_agosm/js/esri-leaflet.js'); $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/css/esri-leaflet-geocoder.css'); $document->addScript(JURI::root(true) . '/media/mod_agosm/js/esri-leaflet-geocoder.js'); } -if ($params->get('showrouting_simple', '1') == 1) -{ +if ($params->get('showrouting_simple', '1') == 1) { $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/css/LeafletControlRoutingtoaddress.css'); $document->addScript(JURI::root(true) . '/media/mod_agosm/js/LeafletControlRoutingtoaddress.js'); } -if ($params->get('showrouting', '1') == 1) -{ +if ($params->get('showrouting', '1') == 1) { $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/css/leaflet-routing-machine.css'); $document->addScript(JURI::root(true) . '/media/mod_agosm/js/leaflet-routing-machine.js'); } -if ($params->get('showpin', '1') === "1" || $params->get('showcustompin', '1') === "1" || $params->get('showcustomfieldpin', '1') === "1") -{ +if ($params->get('showpin', '1') === "1" || $params->get('showcustompin', '1') === "1" || $params->get('showcustomfieldpin', '1') === "1") { $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/css/font-awesome.min.css'); $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/Leaflet.awesome-markers/leaflet.awesome-markers.css'); $document->addScript(JURI::root(true) . '/media/mod_agosm/Leaflet.awesome-markers/leaflet.awesome-markers.js'); } -if (true || $params->get('showcustomfieldpin', '0') === "1") -{ +if (true || $params->get('showcustomfieldpin', '0') === "1") { $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/cluster/MarkerCluster.css'); $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/cluster/MarkerCluster.Default.css'); $document->addScript(JURI::root(true) . '/media/mod_agosm/cluster/leaflet.markercluster-src.js'); } -if ($params->get('baselayer', 'mapnik') == 'google') -{ +if ($params->get('baselayer', 'mapnik') == 'google') { $document->addScript('https://maps.googleapis.com/maps/api/js?key=' . $params->get('googlekey', '')); $document->addScript(JURI::root(true) . '/media/mod_agosm/js/Leaflet.GoogleMutant.js'); } -if ($params->get('scrollwheelzoom') === "2") -{ +if ($params->get('scrollwheelzoom') === "2") { $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/GoogleGestureHandling/leaflet-gesture-handling.min.css'); $document->addScript(JURI::root(true) . '/media/mod_agosm/GoogleGestureHandling/leaflet-gesture-handling.min.js'); } -if ($params->get('showcomponentpin', '0') === "1") -{ - $list = ModagosmHelper::getList($params); +if ($params->get('showcomponentpin', '0') === "1") { + $list = AgosmsCategoryHelper::getList($params); } -if ($params->get('showcomponentpinone', '0') === "1") -{ - $listone = ModagosmHelper::getListone($params); +if ($params->get('showcomponentpinone', '0') === "1") { + $listone = AgosmsCategoryHelper::getListone($params); } -if ($params->get('showcustomfieldpin', '0') === "1") -{ - if (!empty(ModagosmHelper::getListCustomField($params))) - { - $listcf = ModagosmHelper::getListCustomField($params); +if ($params->get('showcustomfieldpin', '0') === "1") { + if (!empty(AgosmsCategoryHelper::getListCustomField($params))) { + $listcf = AgosmsCategoryHelper::getListCustomField($params); } } -if ($params->get('showmarkerfromexternaldb', '0') === "1") -{ - $listexternaldb = ModagosmHelper::getListExternaldb($params); +if ($params->get('showmarkerfromexternaldb', '0') === "1") { + $listexternaldb = AgosmsCategoryHelper::getListExternaldb($params); } $document->addScript(JURI::root(true) . '/media/mod_agosm/js/agosm.js'); -if ($params->get('showrouting_simple', '1') == 1 && $params->get('showrouting_places', '1') == 1) -{ +if ($params->get('showrouting_simple', '1') == 1 && $params->get('showrouting_places', '1') == 1) { $document->addScript(JURI::root(true) . '/media/mod_agosm/js/places.js'); } -if ($params->get('showlocate', '1') == 1) -{ +if ($params->get('showlocate', '1') == 1) { $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/locate/L.Control.Locate.css'); $document->addScript(JURI::root(true) . '/media/mod_agosm/locate/L.Control.Locate.min.js'); } -if ($params->get('showfullscreen', '1') == 1) -{ +if ($params->get('showfullscreen', '1') == 1) { $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/fullscreen/leaflet.fullscreen.css'); $document->addScript(JURI::root(true) . '/media/mod_agosm/fullscreen/Leaflet.fullscreen.min.js'); } -if ($params->get('spacermouseposition', '1') == 1) -{ +if ($params->get('spacermouseposition', '1') == 1) { $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/mouseposition/L.Control.MousePosition.css'); $document->addScript(JURI::root(true) . '/media/mod_agosm/mouseposition/L.Control.MousePosition.js'); } $document->addStyleSheet(JURI::root(true) . '/media/mod_agosm/css/agosms.css'); -require JModuleHelper::getLayoutPath('mod_agosm', $params->get('layout', 'default')); + +require ModuleHelper::getLayoutPath('mod_agosm', $params->get('layout', 'default')); diff --git a/j4/pkg_agosms/src/modules/mod_agosm/mod_agosm.xml b/j4/pkg_agosms/src/modules/mod_agosm/mod_agosm.xml index f067fefe..087dde5f 100644 --- a/j4/pkg_agosms/src/modules/mod_agosm/mod_agosm.xml +++ b/j4/pkg_agosms/src/modules/mod_agosm/mod_agosm.xml @@ -9,7 +9,7 @@ www.astrid-guenther.de ##VERSION## MOD_AGOSM_XML_DESCRIPTION - AG\Module\Agosms + AG\Module\Agosm script.php @@ -20,7 +20,6 @@ language tmpl script.php - helper.php Helper mod_agosm.php @@ -37,10 +36,8 @@ js mouseposition leaflet + joomla.asset.json - - ##LANGUAGE_FILES## - @@ -433,7 +430,6 @@
- @@ -455,7 +451,7 @@
-
+
diff --git a/j4/pkg_agosms/src/modules/mod_agosm/models/fields/field/agosm.php b/j4/pkg_agosms/src/modules/mod_agosm/models/fields/field/agosm.php index 2269907e..4df791fa 100644 --- a/j4/pkg_agosms/src/modules/mod_agosm/models/fields/field/agosm.php +++ b/j4/pkg_agosms/src/modules/mod_agosm/models/fields/field/agosm.php @@ -45,10 +45,10 @@ protected function getLayoutPaths() { $template = JFactory::getApplication()->getTemplate(); - return array( + return [ JPATH_ADMINISTRATOR . '/templates/' . $template . '/html/layouts/plugins/system/stats', dirname(__DIR__) . '/layouts', JPATH_SITE . '/layouts' - ); + ]; } } diff --git a/j4/pkg_agosms/src/modules/mod_agosm/models/fields/field/agosmsaddressfinder.php b/j4/pkg_agosms/src/modules/mod_agosm/models/fields/field/agosmsaddressfinder.php index d839da6b..513c3372 100644 --- a/j4/pkg_agosms/src/modules/mod_agosm/models/fields/field/agosmsaddressfinder.php +++ b/j4/pkg_agosms/src/modules/mod_agosm/models/fields/field/agosmsaddressfinder.php @@ -55,8 +55,7 @@ class JFormFieldAgosmsaddressfinder extends TextField */ public function __get($name) { - switch ($name) - { + switch ($name) { case 'mapheight': return $this->$name; } @@ -82,8 +81,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) { $result = parent::setup($element, $value, $group); - if ($result == true) - { + if ($result == true) { $this->mapheight = (int) $this->element['mapheight']; } @@ -102,8 +100,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) */ public function __set($name, $value) { - switch ($name) - { + switch ($name) { case 'mapheight': $this->mapheight = (int) $value; break; @@ -124,11 +121,11 @@ protected function getLayoutPaths() { $template = JFactory::getApplication()->getTemplate(); - return array( + return [ JPATH_ADMINISTRATOR . '/templates/' . $template . '/html/layouts/modules/agosmsaddressfinder', dirname(__DIR__) . '/layouts', JPATH_SITE . '/layouts' - ); + ]; } /** @@ -159,10 +156,10 @@ protected function getLayoutData() $options = (array) $this->getOptions(); - $extraData = array( + $extraData = [ 'mapheight' => $this->mapheight, 'options' => $options, - ); + ]; return array_merge($data, $extraData); } @@ -176,34 +173,28 @@ protected function getLayoutData() protected function getOptions() { $fieldname = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname); - $options = array(); + $options = []; - foreach ($this->element->xpath('option') as $option) - { + foreach ($this->element->xpath('option') as $option) { // Filter requirements - if ($requires = explode(',', (string) $option['requires'])) - { + if ($requires = explode(',', (string) $option['requires'])) { // Requires multilanguage - if (in_array('multilanguage', $requires) && !JLanguageMultilang::isEnabled()) - { + if (in_array('multilanguage', $requires) && !JLanguageMultilang::isEnabled()) { continue; } // Requires associations - if (in_array('associations', $requires) && !JLanguageAssociations::isEnabled()) - { + if (in_array('associations', $requires) && !JLanguageAssociations::isEnabled()) { continue; } // Requires adminlanguage - if (in_array('adminlanguage', $requires) && !JModuleHelper::isAdminMultilang()) - { + if (in_array('adminlanguage', $requires) && !JModuleHelper::isAdminMultilang()) { continue; } // Requires vote plugin - if (in_array('vote', $requires) && !JPluginHelper::isEnabled('content', 'vote')) - { + if (in_array('vote', $requires) && !JPluginHelper::isEnabled('content', 'vote')) { continue; } } @@ -221,21 +212,20 @@ protected function getOptions() $selected = (string) $option['selected']; $selected = ($selected == 'true' || $selected == 'selected' || $selected == '1'); - $tmp = array( + $tmp = [ 'value' => $value, 'text' => JText::alt($text, $fieldname), 'disable' => $disabled, 'class' => (string) $option['class'], 'selected' => ($checked || $selected), 'checked' => ($checked || $selected), - ); + ]; // Set some event handler attributes. But really, should be using unobtrusive js. $tmp['onclick'] = (string) $option['onclick']; $tmp['onchange'] = (string) $option['onchange']; - if ((string) $option['showon']) - { + if ((string) $option['showon']) { $tmp['optionattr'] = " data-showon='" . json_encode( JFormHelper::parseShowOnConditions((string) $option['showon'], $this->formControl, $this->group) @@ -247,16 +237,14 @@ protected function getOptions() $options[] = (object) $tmp; } - if ($this->element['useglobal']) - { + if ($this->element['useglobal']) { $tmp = new stdClass; $tmp->value = ''; $tmp->text = JText::_('JGLOBAL_USE_GLOBAL'); $component = JFactory::getApplication()->input->getCmd('option'); // Get correct component for menu items - if ($component == 'com_menus') - { + if ($component == 'com_menus') { $link = $this->form->getData()->get('link'); $uri = new JUri($link); $component = $uri->getVar('option', 'com_menus'); @@ -266,25 +254,20 @@ protected function getOptions() $value = $params->get($this->fieldname); // Try with global configuration - if (is_null($value)) - { + if (is_null($value)) { $value = JFactory::getConfig()->get($this->fieldname); } // Try with menu configuration - if (is_null($value) && JFactory::getApplication()->input->getCmd('option') == 'com_menus') - { + if (is_null($value) && JFactory::getApplication()->input->getCmd('option') == 'com_menus') { $value = JComponentHelper::getParams('com_menus')->get($this->fieldname); } - if (!is_null($value)) - { + if (!is_null($value)) { $value = (string) $value; - foreach ($options as $option) - { - if ($option->value === $value) - { + foreach ($options as $option) { + if ($option->value === $value) { $value = $option->text; break; @@ -312,14 +295,12 @@ protected function getOptions() * * @since 1.0.40 */ - public function addOption($text, $attributes = array()) + public function addOption($text, $attributes = []) { - if ($text && $this->element instanceof SimpleXMLElement) - { + if ($text && $this->element instanceof SimpleXMLElement) { $child = $this->element->addChild('option', $text); - foreach ($attributes as $name => $value) - { + foreach ($attributes as $name => $value) { $child->addAttribute($name, $value); } } diff --git a/j4/pkg_agosms/src/modules/mod_agosm/models/fields/field/falist.php b/j4/pkg_agosms/src/modules/mod_agosm/models/fields/field/falist.php index f2a1c712..b59cd8b1 100644 --- a/j4/pkg_agosms/src/modules/mod_agosm/models/fields/field/falist.php +++ b/j4/pkg_agosms/src/modules/mod_agosm/models/fields/field/falist.php @@ -43,7 +43,7 @@ protected function getInput() }'; $document->addStyleDeclaration($style); - $html = array(); + $html = []; $attr = ''; // Initialize some field attributes. @@ -55,8 +55,7 @@ protected function getInput() $attr .= ' style="font-family: \'FontAwesome\';" '; // To avoid user's confusion, readonly="true" should imply disabled="true". - if ((string) $this->readonly == '1' || (string) $this->readonly == 'true' || (string) $this->disabled == '1' || (string) $this->disabled == 'true') - { + if ((string) $this->readonly == '1' || (string) $this->readonly == 'true' || (string) $this->disabled == '1' || (string) $this->disabled == 'true') { $attr .= ' disabled="disabled"'; } @@ -67,30 +66,22 @@ protected function getInput() $options = (array) $this->getOptions(); // Create a read-only list (no name) with hidden input(s) to store the value(s). - if ((string) $this->readonly == '1' || (string) $this->readonly == 'true') - { + if ((string) $this->readonly == '1' || (string) $this->readonly == 'true') { $html[] = JHtml::_('select.genericlist', $options, '', trim($attr), 'value', 'text', $this->value, $this->id); // E.g. form field type tag sends $this->value as array - if ($this->multiple && is_array($this->value)) - { - if (!count($this->value)) - { + if ($this->multiple && is_array($this->value)) { + if (!count($this->value)) { $this->value[] = ''; } - foreach ($this->value as $value) - { + foreach ($this->value as $value) { $html[] = ''; } - } - else - { + } else { $html[] = ''; } - } - else - // Create a regular list. + } else // Create a regular list. { $html[] = JHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id); } @@ -108,7 +99,7 @@ protected function getInput() protected function getOptions() { $fieldname = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname); - $options = array(); + $options = []; $fontawesome_icons = [ "" => "no icon", @@ -905,16 +896,15 @@ protected function getOptions() "youtube-square" => "", ]; - foreach ($fontawesome_icons as $fontawesome_icon_key => $fontawesome_icon_value) - { - $tmp = array( + foreach ($fontawesome_icons as $fontawesome_icon_key => $fontawesome_icon_value) { + $tmp = [ 'value' => $fontawesome_icon_key, 'text' => $fontawesome_icon_value, 'disable' => 0, 'class' => '', 'selected' => 0, 'checked' => 0, - ); + ]; $options[] = (object) $tmp; } @@ -932,8 +922,7 @@ protected function getOptions() */ public function __get($name) { - if ($name == 'options') - { + if ($name == 'options') { return $this->getOptions(); } diff --git a/j4/pkg_agosms/src/modules/mod_agosm/models/fields/layouts/agosm.php b/j4/pkg_agosms/src/modules/mod_agosm/models/fields/layouts/agosm.php index b2c91066..60946e1f 100644 --- a/j4/pkg_agosms/src/modules/mod_agosm/models/fields/layouts/agosm.php +++ b/j4/pkg_agosms/src/modules/mod_agosm/models/fields/layouts/agosm.php @@ -19,18 +19,15 @@ //JHtml::_('script', 'media/com_agosms/js/admin-agosms-button-default.js'); // Tooltip for INPUT showing whole image path -$options = array( +$options = [ 'onShow' => 'jMediaRefreshImgpathTip', -); +]; JHtml::_('behavior.tooltip', '.hasTipImgpath', $options); -if (!empty($class)) -{ +if (!empty($class)) { $class .= ' hasTipImgpath'; -} -else -{ +} else { $class = 'hasTipImgpath'; } diff --git a/j4/pkg_agosms/src/modules/mod_agosm/models/fields/layouts/agosmsaddressfinder.php b/j4/pkg_agosms/src/modules/mod_agosm/models/fields/layouts/agosmsaddressfinder.php index f6227547..fdfd2076 100644 --- a/j4/pkg_agosms/src/modules/mod_agosm/models/fields/layouts/agosmsaddressfinder.php +++ b/j4/pkg_agosms/src/modules/mod_agosm/models/fields/layouts/agosmsaddressfinder.php @@ -17,12 +17,12 @@ $document->addScript(JURI::root(true) . '/media/mod_agosm/leaflet/leaflet.js', true); $document->addScript(JURI::root(true) . '/media/mod_agosm/js/agosmsaddressfinder.js', true); -JHtml::_('stylesheet', 'mod_agosm/agomsaddressfinder.css', array('version' => 'auto', 'relative' => true)); +JHtml::_('stylesheet', 'mod_agosm/agomsaddressfinder.css', ['version' => 'auto', 'relative' => true]); JText::script('MOD_AGOSM_ADDRESSFINDER_ADDRESSE_ERROR'); JText::script('MOD_AGOSM_ADDRESSFINDER_ADDRESSE_NOTICE'); -$attributes = array( +$attributes = [ !empty($class) ? 'class="' . $class . '"' : '', !empty($size) ? 'size="' . $size . '"' : '', $disabled ? 'disabled' : '', @@ -36,37 +36,33 @@ $spellcheck ? '' : 'spellcheck="false"', !empty($inputmode) ? $inputmode : '', !empty($pattern) ? 'pattern="' . $pattern . '"' : '', -); +]; // Define defaults $app = JFactory::getApplication(); $context = 'com_content.article'; // Com_categorie -if ($app->input->getCmd('option') === 'com_categories') -{ +if ($app->input->getCmd('option') === 'com_categories') { $context = $app->input->getCmd('extension') . '.categories'; } // Com_users -elseif ($app->input->getCmd('option') === 'com_users') -{ +else if ($app->input->getCmd('option') === 'com_users') { $context = 'com_users.user'; } // Com_contact -elseif ($app->input->getCmd('option') === 'com_contact') -{ +else if ($app->input->getCmd('option') === 'com_contact') { //JFactory::getApplication()->enqueueMessage(JText::_('MOD_AGOSM_ADDRESSFINDER_SUPPORTET'), 'message'); $context = 'com_contact.contact'; } // Third Party -elseif ($app->input->getCmd('option') !== 'com_users' +else if ($app->input->getCmd('option') !== 'com_users' && $app->input->getCmd('option') !== 'com_content' && $app->input->getCmd('option') !== 'com_categories' - && $app->input->getCmd('option') !== 'com_contact') -{ + && $app->input->getCmd('option') !== 'com_contact') { $context = $app->input->getCmd('option') . '.' . $app->input->getCmd('view'); } diff --git a/j4/pkg_agosms/src/modules/mod_agosm/src/Helper/AgosmsCategoryHelper.php b/j4/pkg_agosms/src/modules/mod_agosm/src/Helper/AgosmsCategoryHelper.php new file mode 100644 index 00000000..c45b403f --- /dev/null +++ b/j4/pkg_agosms/src/modules/mod_agosm/src/Helper/AgosmsCategoryHelper.php @@ -0,0 +1,219 @@ +bootComponent('com_agosms')->getMVCFactory(); + + // Get an instance of the generic agosms model + $agosms = $factory->createModel('Agosms', 'Site', ['ignore_request' => true]); + + $items = $agosms->getItems(); + + return $items; + } + /** + * Get a list of agosms from a custom field + * + * @param \Joomla\Registry\Registry &$params object holding the models parameters + * + * @return mixed + * + * @since 1.6 + */ + public static function getListCustomField(&$params) + { + + $app = Factory::getApplication(); + $factory = $app->bootComponent('com_content')->getMVCFactory(); + + // Get an instance of the generic articles model + $articles = $factory->createModel('Articles', 'Site', ['ignore_request' => true]); + + // Set application parameters in model + $input = $app->input; + $appParams = $app->getParams(); + $articles->setState('params', $appParams); + + $articles->setState('list.start', 0); + //$articles->setState('filter.published', ContentComponent::CONDITION_PUBLISHED); + + // Set the filters based on the module params + $articles->setState('list.limit', (int) $params->get('count', 0)); + $articles->setState('load_tags', $params->get('show_tags', 0) || $params->get('article_grouping', 'none') === 'tags'); + + // Access filter + $access = !ComponentHelper::getParams('com_content')->get('show_noauth'); + $authorised = Access::getAuthorisedViewLevels(Factory::getUser()->get('id')); + $articles->setState('filter.access', $access); + + $items = $articles->getItems(); + $itemsfiltered = []; + + foreach ($items as $key => $item) { + $fields = FieldsHelper::getFields('com_content.article', $item, true); + + $fieldsData = []; + + if (!empty($fields)) { + foreach ($fields as $key => $field) { + $itemfiltered = new \stdClass; + + if ($field->title == 'lat, lon') { + $itemfiltered->cords = $field->value; + $test = explode(",", $itemfiltered->cords); + + if (is_numeric($test[0]) && is_numeric($test[1])) { + $itemfiltered->title = $item->title; + $itemfiltered->id = $item->id; + $itemfiltered->type = $field->type; + } + } + + if ($field->type == 'agosmsmarker') { + $itemfiltered->cords = $field->value; + $test = explode(",", $itemfiltered->cords); + + if (is_numeric($test[0]) && is_numeric($test[1])) { + $itemfiltered->title = $item->title; + $itemfiltered->id = $item->id; + $itemfiltered->type = $field->type; + } + } + + if ($field->type == 'agosmsaddressmarker') { + // Get plugin parameters + $popup = $field->fieldparams->get('popup', '0'); + $specialicon = $field->fieldparams->get('specialicon', '0'); + + $itemfiltered->cords = $field->rawvalue; + $test = explode(",", $itemfiltered->cords); + + if (sizeof($test) > 5 && is_numeric($test[0]) && is_numeric($test[1])) { + $itemfiltered->title = $item->title; + $itemfiltered->id = $item->id; + $itemfiltered->type = $field->type; + $itemfiltered->lat = $test[0]; + $itemfiltered->lon = $test[1]; + + if ($specialicon) { + $itemfiltered->iconcolor = $test[2]; + $itemfiltered->markercolor = $test[3]; + $itemfiltered->icon = $test[4]; + } + + if ($popup) { + $itemfiltered->popuptext = $test[5]; + } + } + } + + $itemsfiltered[] = $itemfiltered; + } + if ($itemsfiltered) { + return $itemsfiltered; + } + } + } + + return []; + } + + /** + * Get one agosms + * + * @param \Joomla\Registry\Registry &$params object holding the models parameters + * + * @return mixed + * + * @since 1.6 + */ + public static function getListone(&$params) + { + $app = Factory::getApplication(); + $factory = $app->bootComponent('com_agosms')->getMVCFactory(); + + // Get an instance of the generic agosms model + $agosm = $factory->createModel('Agosm', 'Site', ['ignore_request' => true]); + + $id = $params->get('showcomponentpinoneid', null); + + $items = $agosm->getItem((int)$id); + + return $items; + } + + /** + * Get one agosms + * + * @param \Joomla\Registry\Registry &$params object holding the models parameters + * + * @return mixed + * + * @since 1.6 + */ + public static function getListExternaldb(&$params) + { + $options = [ + 'driver' => 'mysqli', + 'host' => 'localhost', + 'user' => 'root', + 'password' => 'Schweden1!', + 'database' => 'joomla_db' + ]; + + $externalDb = JDatabaseDriver::getInstance($options); + $query = $externalDb->getQuery(true); + + $query->select($externalDb->quoteName(['*'])); + $query->from($externalDb->quoteName('j3_agosms')); + + // Reset the query using our newly populated query object. + $externalDb->setQuery($query); + + // Load the results as a list of stdClass objects (see later for more options on retrieving data). + $results = $externalDb->loadObjectList(); + + return $results; + } +} diff --git a/j4/pkg_agosms/src/modules/mod_agosm/tmpl/default.php b/j4/pkg_agosms/src/modules/mod_agosm/tmpl/default.php index 9b00c9be..eb3648a0 100644 --- a/j4/pkg_agosms/src/modules/mod_agosm/tmpl/default.php +++ b/j4/pkg_agosms/src/modules/mod_agosm/tmpl/default.php @@ -133,38 +133,38 @@ class="btn btn-success b" get('agmarkerlist', '0') && $params->get('showcustomfieldpin', '1') && isset($listcf)) : ?> '; ?> - id . '">' . $marker->popuptext . ''; - } + id . '">' . $marker->popuptext . ''; } + } ?> ' . JText::_('MOD_AGOSMCF_MARKERLIST_BOTTOM'); ?> get('agmarkerlist', '0') && $params->get('showcomponentpin', '1') && isset($list)) : ?> '; ?> - id . '">' . $marker->popuptext . '' . JText::_('MOD_AGOSM_MARKERLIST_OPEN') . ''; - } + id . '">' . $marker->popuptext . '' . JText::_('MOD_AGOSM_MARKERLIST_OPEN') . ''; } + } ?> ' . JText::_('MOD_AGOSM_MARKERLISTCOMONENT_BOTTOM'); ?> get('agmarkerlist', '0') && $params->get('showpin', '1')) : ?> '; ?> - get('specialpins', null) as $marker) { - $index++; - if(property_exists($marker, 'popuptext')){ - echo '
  • ' . $marker->popuptext . '' . JText::_('MOD_AGOSM_MARKERLIST_OPEN') . ''; - } + foreach ($params->get('specialpins', null) as $marker) { + $index++; + if (property_exists($marker, 'popuptext')) { + echo '
  • ' . $marker->popuptext . '' . JText::_('MOD_AGOSM_MARKERLIST_OPEN') . ''; } + } ?> ' . JText::_('MOD_AGOSM_MARKERLISTSPECIAL_BOTTOM'); ?> diff --git a/j4/pkg_agosms/src/modules/mod_agosm/tmpl/upload.php b/j4/pkg_agosms/src/modules/mod_agosm/tmpl/upload.php index afce3ce2..80d3771b 100644 --- a/j4/pkg_agosms/src/modules/mod_agosm/tmpl/upload.php +++ b/j4/pkg_agosms/src/modules/mod_agosm/tmpl/upload.php @@ -13,8 +13,7 @@ use Joomla\CMS\Uri\Uri; use AG\Module\Agosms\Site\Helper\EasyFileUploaderHelper; -if (isset($_FILES[$params->get('ag_variable')])) -{ +if (isset($_FILES[$params->get('ag_variable')])) { $result = EasyFileUploaderHelper::getFileToUpload($params); } @@ -35,8 +34,7 @@ $total = intval($params->get('ag_multiple')); $gpxfile = ""; -if (isset($_FILES[$params->get('ag_variable')])) -{ +if (isset($_FILES[$params->get('ag_variable')])) { for ($i = 0; $i < $total; $i++) { $gpxfile .= JURI::base() . $result[$i]['rpath'] . DIRECTORY_SEPARATOR . $_FILES[$params->get('ag_variable')]["name"][$i] . ';;'; } @@ -63,22 +61,22 @@ - +
    - get('ag_multiple') == "1"): ?> + get('ag_multiple') == "1") : ?> - +
    get('ag_multiple')); - for ($i = 0; $i < $max; $i++): + for ($i = 0; $i < $max; $i++) : ?> get('ag_variable') . '[]"'; ?> id=get('ag_variable') . '[]"'; ?> />
    - get('ag_default_replace') == false && $params->get('ag_replace') == true): /* 1 means 'Yes' or true. 0 means 'No' or false. */ ?> + get('ag_default_replace') == false && $params->get('ag_replace') == true) : /* 1 means 'Yes' or true. 0 means 'No' or false. */ ?>


    diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/helper.php b/j4/pkg_agosms/src/modules/mod_agosms_search/helper.php index 5c9b4cc5..fb25a393 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/helper.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/helper.php @@ -23,8 +23,7 @@ function __construct($params = null) function getModuleParams($id, $native = false) { - if (!$id) - { + if (!$id) { return; } @@ -38,12 +37,9 @@ function getModuleParams($id, $native = false) $result = $db->loadObject(); - if ($native) - { + if ($native) { $moduleParams = new JRegistry($result->params); - } - else - { + } else { $moduleParams = json_decode($result->params); } @@ -53,77 +49,55 @@ function getModuleParams($id, $native = false) function getCategories($parent = 0, $params = null) { $db = JFactory::getDbo(); - $categories = Array(); + $categories = []; - if ($parent) - { + if ($parent) { $query = "SELECT id, title, level FROM #__categories WHERE extension = 'com_content' AND parent_id = {$parent} AND published = 1 ORDER BY title ASC"; - } - else - { - if ($params) - { - if ($params->get("restrict")) - { + } else { + if ($params) { + if ($params->get("restrict")) { $categories_restriction = $this->getCategoriesRestriction($params); } } - if ($params && count($categories_restriction)) - { + if ($params && count($categories_restriction)) { $query = "SELECT id, title, level FROM #__categories WHERE extension = 'com_content' AND id IN (" . implode(",", $categories_restriction) . ") ORDER BY title ASC"; - } - else - { + } else { $query = "SELECT id, title, level FROM #__categories WHERE extension = 'com_content' AND level = 1 AND published = 1 ORDER BY title ASC"; } } - try - { + try { $db->setQuery($query); $results = $db->loadObjectList(); - } - catch (Exception $e) - { + } catch (Exception $e) { echo $e->getMessage(); echo "

    " . $query; } - foreach ($results as $category) - { + foreach ($results as $category) { $categories[] = $category; - if (JFactory::getApplication()->isSite() && $params) - { - if ($params->get("restrict")) - { - if ($params->get("restsub")) - { + if (JFactory::getApplication()->isSite() && $params) { + if ($params->get("restrict")) { + if ($params->get("restsub")) { $subs = (array) $this->getCategories($category->id, $params); - if (count($subs)) - { + if (count($subs)) { $categories = array_merge($categories, $subs); } } - } - else - { + } else { $subs = (array) $this->getCategories($category->id, $params); - if (count($subs)) - { + if (count($subs)) { $categories = array_merge($categories, $subs); } } - } - else - { + } else { $subs = (array) $this->getCategories($category->id, $params); - if (count($subs)) - { + if (count($subs)) { $categories = array_merge($categories, $subs); } } @@ -134,44 +108,38 @@ function getCategories($parent = 0, $params = null) function getCategoriesRestriction($params, $module_id = null) { - $categories = Array(); - - switch ($params->get("restmode")) - { - case 0 : // Selected - if ($params->get("restcat") == "") - { - return array(); + $categories = []; + + switch ($params->get("restmode")) { + case 0: // Selected + if ($params->get("restcat") == "") { + return []; } $categories = explode("\r\n", $params->get("restcat")); - break; + break; - case 1 : // Auto + case 1: // Auto $view = ''; - if (JFactory::getApplication()->input->get->get('view')) - { + if (JFactory::getApplication()->input->get->get('view')) { $active = JFactory::getApplication()->input->get->get('view'); } $requestid = 0; - if (JFactory::getApplication()->input->get->get('id')) - { + if (JFactory::getApplication()->input->get->get('id')) { $active = JFactory::getApplication()->input->get->get('id'); } - if (in_array($view, Array("featured", "category"))) - { + if (in_array($view, ["featured", "category"])) { $categories[] = $requestid; } - if (!count($categories)) - { + if (!count($categories)) { $categories[] = 1; } - break; + break; } return $categories; @@ -184,10 +152,9 @@ function getSubCategories($parent) $db->setQuery($query); $results = $db->loadColumn(); - $categories = array(); + $categories = []; - foreach ($results as $catid) - { + foreach ($results as $catid) { $categories[] = $catid; $subs = (array) $this->getSubCategories($catid); $categories = array_merge($categories, $subs); @@ -198,20 +165,17 @@ function getSubCategories($parent) function getTags($params) { - $items = Array(); + $items = []; $db = JFactory::getDbo(); $query = "SELECT id FROM #__content WHERE state = 1"; - if ($params->get("restrict")) - { + if ($params->get("restrict")) { $categories = $this->getCategories(0, $params); - if (count($categories)) - { - $ids = Array(); + if (count($categories)) { + $ids = []; - foreach ($categories as $c) - { + foreach ($categories as $c) { $ids[] = $c->id; } @@ -219,13 +183,10 @@ function getTags($params) } } - try - { + try { $db->setQuery($query); $items = $db->loadColumn(); - } - catch (Exception $e) - { + } catch (Exception $e) { echo $e->getMessage(); echo "

    " . $query; } @@ -234,14 +195,11 @@ function getTags($params) $query .= " LEFT JOIN #__contentitem_tag_map AS tm ON t.id = tm.tag_id"; $query .= " WHERE published = 1"; - if (count($items)) - { + if (count($items)) { $query .= " AND content_item_id IN (" . implode(",", $items) . ")"; $query .= " ORDER BY t.title ASC"; - } - else - { - return array(); // No tags if no items + } else { + return []; // No tags if no items } $db->setQuery($query); @@ -251,16 +209,14 @@ function getTags($params) function getAuthors($params) { - $items = Array(); + $items = []; $db = JFactory::getDbo(); $query = "SELECT created_by FROM #__content WHERE state = 1"; - if ($params->get("restrict")) - { + if ($params->get("restrict")) { $categories = $this->getCategoriesRestriction($params); - if (count($categories)) - { + if (count($categories)) { $query .= " AND catid IN (" . implode(",", $categories) . ")"; } } @@ -268,19 +224,15 @@ function getAuthors($params) $db->setQuery($query); $items = $db->loadColumn(); - $authors = Array(); + $authors = []; - if (count($items)) - { - foreach ($items as $created_by) - { + if (count($items)) { + foreach ($items as $created_by) { $authors[$created_by] = $created_by; } $query = "SELECT id, name FROM #__users WHERE id IN (" . implode(',', $authors) . ")"; - } - else - { + } else { return $authors; // No authors if no items } @@ -309,16 +261,13 @@ function getFieldValuesFromText($field_id, $type, $module_id) // Category restriction $module_params = $this->getModuleParams($module_id, true); - if ($module_params->get('restrict')) - { + if ($module_params->get('restrict')) { $category_restriction = $this->getCategoriesRestriction($module_params); - if ($module_params->get('restsub')) - { - $tmp = array(); + if ($module_params->get('restsub')) { + $tmp = []; - foreach ($category_restriction as $catid) - { + foreach ($category_restriction as $catid) { $cats = $this->getSubCategories($catid); $cats[] = $catid; $tmp = array_merge($tmp, $cats); @@ -327,8 +276,7 @@ function getFieldValuesFromText($field_id, $type, $module_id) $category_restriction = $tmp; } - if (count($category_restriction)) - { + if (count($category_restriction)) { $query .= " AND i.catid IN (" . implode(",", $category_restriction) . ")"; } } @@ -337,18 +285,14 @@ function getFieldValuesFromText($field_id, $type, $module_id) $db->setQuery($query); $result = $db->loadObjectList(); - $return = Array(); + $return = []; - if (count($result)) - { - foreach ($result as $item) - { - if ($item->value) - { + if (count($result)) { + foreach ($result as $item) { + if ($item->value) { $value = explode("|", $item->value); - foreach ($value as $val) - { + foreach ($value as $val) { $return[] = $type == "text" ? $val : (int) $val; } } @@ -373,16 +317,13 @@ function getMultiFieldValuesFromText($field_id, $sub_field, $type, $module_id) // Category restriction $module_params = $this->getModuleParams($module_id, true); - if ($module_params->get('restrict')) - { + if ($module_params->get('restrict')) { $category_restriction = $this->getCategoriesRestriction($module_params); - if ($module_params->get('restsub')) - { - $tmp = array(); + if ($module_params->get('restsub')) { + $tmp = []; - foreach ($category_restriction as $catid) - { + foreach ($category_restriction as $catid) { $cats = $this->getSubCategories($catid); $cats[] = $catid; $tmp = array_merge($tmp, $cats); @@ -391,8 +332,7 @@ function getMultiFieldValuesFromText($field_id, $sub_field, $type, $module_id) $category_restriction = $tmp; } - if (count($category_restriction)) - { + if (count($category_restriction)) { $query .= " AND i.catid IN (" . implode(",", $category_restriction) . ")"; } } @@ -401,26 +341,19 @@ function getMultiFieldValuesFromText($field_id, $sub_field, $type, $module_id) $db->setQuery($query); $result = $db->loadObjectList(); - $return = Array(); + $return = []; - if (count($result)) - { - foreach ($result as $item) - { - if ($item->value) - { + if (count($result)) { + foreach ($result as $item) { + if ($item->value) { $value = explode("|", $item->value); - foreach ($value as $val) - { + foreach ($value as $val) { $val = json_decode($val); - if ($val) - { - foreach ($val as $repeatable) - { - if ($repeatable->{$sub_field}) - { + if ($val) { + foreach ($val as $repeatable) { + if ($repeatable->{$sub_field}) { $return[] = $type == "text" ? $repeatable->{$sub_field} : (int) $repeatable->{$sub_field}; } } @@ -462,16 +395,13 @@ function getItemsTitles($params) $query .= " WHERE state = 1"; // Category restriction - if ($params->get('restrict')) - { + if ($params->get('restrict')) { $category_restriction = $this->getCategoriesRestriction($params); - if ($params->get('restsub')) - { - $tmp = array(); + if ($params->get('restsub')) { + $tmp = []; - foreach ($category_restriction as $catid) - { + foreach ($category_restriction as $catid) { $cats = $this->getSubCategories($catid); $cats[] = $catid; $tmp = array_merge($tmp, $cats); @@ -480,8 +410,7 @@ function getItemsTitles($params) $category_restriction = $tmp; } - if (count($category_restriction)) - { + if (count($category_restriction)) { $query .= " AND i.catid IN (" . implode(",", $category_restriction) . ")"; } } diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/includes/categoryselect.php b/j4/pkg_agosms/src/modules/mod_agosms_search/includes/categoryselect.php index 6a7acf2e..a104de0a 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/includes/categoryselect.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/includes/categoryselect.php @@ -31,20 +31,17 @@ function fetchElement($name, $value, &$node, $control_name) $helper = new modAgosmsSearchHelper; $categories = $helper->getCategories(); - foreach ($categories as $category) - { + foreach ($categories as $category) { $indent = ""; - for ($i = 1; $i < $category->level; - $i++) - { + for ($i = 1; $i < $category->level; $i++) { $indent .= " - "; } $mitems[] = JHTML::_('select.option', $category->id, $indent . $category->title); } - $output = JHTML::_('select.genericlist', $mitems, '', 'class="ValueSelect inputbox"', 'value', 'text', '0'); + $output = JHTML::_('select.genericlist', $mitems, '', 'class="ValueSelect inputbox"', 'value', 'text', '0'); $output .= "
      "; $output .= "
      "; $output .= ""; @@ -123,15 +120,11 @@ function load_base() { function addOptions(&$mitems, $category) { - while ($category->subs) - { - foreach ($category->subs as $category) - { + while ($category->subs) { + foreach ($category->subs as $category) { $indent = ""; - for ($i = 0; $i < $category->level; - $i++) - { + for ($i = 0; $i < $category->level; $i++) { $indent .= " - "; } @@ -141,5 +134,3 @@ function addOptions(&$mitems, $category) } } } - - diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/includes/fieldselect.php b/j4/pkg_agosms/src/modules/mod_agosms_search/includes/fieldselect.php index 645d2d55..d6e68be7 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/includes/fieldselect.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/includes/fieldselect.php @@ -33,94 +33,77 @@ function fetchElement($name, $value, &$node, $control_name) ORDER BY g.id, f.label "; - try - { + try { $fields = JFactory::getDBO()->setQuery($query)->loadObjectList(); - } - catch (Exception $e) - { + } catch (Exception $e) { $mitems[] = JHTML::_("select.option", "", "Custom Fields available from Joomla 3.8+"); } - if (count($fields)) - { + if (count($fields)) { $group = @$fields[0]->group_name; array_splice($fields, 0, 0, $group); - for ($i = 1; $i < count($fields); $i++) - { + for ($i = 1; $i < count($fields); $i++) { $new_group = $fields[$i]->group_name; - if ($new_group != $group) - { + if ($new_group != $group) { array_splice($fields, $i, 0, $new_group); $group = $new_group; } } - foreach ($fields as $field) - { - if (is_object($field)) - { + foreach ($fields as $field) { + if (is_object($field)) { $field->group_name ? $offset = "      " : $offset = "   "; - if ($field->type == 'radicalmultifield') - { + if ($field->type == 'radicalmultifield') { continue; // Do not use for ordering for now $field_params = json_decode($field->fieldparams); - $sub_fields = array(); + $sub_fields = []; - foreach ($field_params->listtype as $k => $sub_field) - { + foreach ($field_params->listtype as $k => $sub_field) { $sub_fields[$k] = new stdClass; $sub_fields[$k]->name = $sub_field->name; $sub_fields[$k]->title = $sub_field->title; } $tmp = array_values($sub_fields); - $sub_fields = array(); + $sub_fields = []; $sub_fields['radicalmultifield_fields'] = $tmp; $sub_fields = json_encode($sub_fields); $mitems[] = JHTML::_("select.option", "field:{$field->id}:{$field->type}:{$sub_fields}", $offset . JText::_("{$field->label} [id: {$field->id}]")); - } - elseif ($field->type == 'repeatable') - { + } else if ($field->type == 'repeatable') { continue; // Do not use for ordering for now $field_params = json_decode($field->fieldparams); - $sub_fields = array(); + $sub_fields = []; - foreach ($field_params->fields as $k => $sub_field) - { + foreach ($field_params->fields as $k => $sub_field) { $sub_fields[$k] = new stdClass; $sub_fields[$k]->name = $sub_field->fieldname; $sub_fields[$k]->title = $sub_field->fieldname; } $tmp = array_values($sub_fields); - $sub_fields = array(); + $sub_fields = []; $sub_fields['repeatable_fields'] = $tmp; $sub_fields = json_encode($sub_fields); $mitems[] = JHTML::_("select.option", "field:{$field->id}:{$field->type}:{$sub_fields}", $offset . JText::_("{$field->label} [id: {$field->id}]")); - } - else - { - $extra = array( + } else { + $extra = [ 'name' => $field->label, - ); + ]; $extra = json_encode($extra); $mitems[] = JHTML::_("select.option", "field:{$field->id}:{$field->type}:{$extra}", $offset . JText::_("{$field->label} [id: {$field->id}]")); } - } - else - { + } else { $mitems[] = JHTML::_("select.option", "", "   -- {$field} --"); } } } - $output = JHTML::_('select.genericlist', $mitems, '', 'class="ValueSelect inputbox"', 'value', 'text', '0'); + $output = JHTML::_('select.genericlist', $mitems, '', 'class="ValueSelect inputbox"', 'value', 'text', '0'); $output .= "
        "; $output .= "
        "; $output .= " @@ -133,5 +116,3 @@ function fetchElement($name, $value, &$node, $control_name) return $output; } } - - diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/includes/filters.php b/j4/pkg_agosms/src/modules/mod_agosms_search/includes/filters.php index 2f19681d..3bc698d6 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/includes/filters.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/includes/filters.php @@ -42,93 +42,74 @@ function fetchElement($name, $value, &$node, $control_name) ORDER BY g.id, f.label "; - try - { + try { $db->setQuery($query); $fields = $db->loadObjectList(); - } - catch (Exception $e) - { + } catch (Exception $e) { $mitems[] = JHTML::_("select.option", "", "Custom Fields available from Joomla 3.8+"); } - if (count($fields)) - { + if (count($fields)) { $group = @$fields[0]->group_name; array_splice($fields, 0, 0, $group); - for ($i = 1; $i < count($fields); $i++) - { + for ($i = 1; $i < count($fields); $i++) { $new_group = $fields[$i]->group_name; - if ($new_group != $group) - { + if ($new_group != $group) { array_splice($fields, $i, 0, $new_group); $group = $new_group; } } - foreach ($fields as $field) - { - if (is_object($field)) - { + foreach ($fields as $field) { + if (is_object($field)) { $field->group_name ? $offset = "      " : $offset = "   "; - if ($field->type == 'radicalmultifield') - { + if ($field->type == 'radicalmultifield') { $field_params = json_decode($field->fieldparams); - $sub_fields = array(); + $sub_fields = []; - foreach ($field_params->listtype as $k => $sub_field) - { + foreach ($field_params->listtype as $k => $sub_field) { $sub_fields[$k] = new stdClass; $sub_fields[$k]->name = $sub_field->name; $sub_fields[$k]->title = $sub_field->title; } $tmp = array_values($sub_fields); - $sub_fields = array(); + $sub_fields = []; $sub_fields['radicalmultifield_fields'] = $tmp; $sub_fields = json_encode($sub_fields); $mitems[] = JHTML::_("select.option", "field:{$field->id}:{$field->type}:{$sub_fields}", $offset . JText::_("{$field->label} [id: {$field->id}]")); - } - elseif ($field->type == 'repeatable') - { + } else if ($field->type == 'repeatable') { $field_params = json_decode($field->fieldparams); - $sub_fields = array(); + $sub_fields = []; - foreach ($field_params->fields as $k => $sub_field) - { + foreach ($field_params->fields as $k => $sub_field) { $sub_fields[$k] = new stdClass; $sub_fields[$k]->name = $sub_field->fieldname; $sub_fields[$k]->title = $sub_field->fieldname; } $tmp = array_values($sub_fields); - $sub_fields = array(); + $sub_fields = []; $sub_fields['repeatable_fields'] = $tmp; $sub_fields = json_encode($sub_fields); $mitems[] = JHTML::_("select.option", "field:{$field->id}:{$field->type}:{$sub_fields}", $offset . JText::_("{$field->label} [id: {$field->id}]")); - } - else - { + } else { $mitems[] = JHTML::_("select.option", "field:{$field->id}:{$field->type}", $offset . JText::_("{$field->label} [id: {$field->id}]")); } - } - else - { + } else { $mitems[] = JHTML::_("select.option", "", "   -- {$field} --"); } } - } - else - { + } else { $mitems[] = JHTML::_('select.option', '', 'None'); } - $output = JHTML::_('select.genericlist', $mitems, '', 'class="ValueSelect inputbox"', 'value', 'text', '0'); + $output = JHTML::_('select.genericlist', $mitems, '', 'class="ValueSelect inputbox"', 'value', 'text', '0'); $output .= "
          "; $output .= "
          "; $output .= ""; diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/includes/moduletemplate.php b/j4/pkg_agosms/src/modules/mod_agosms_search/includes/moduletemplate.php index 558a1ed6..2d125fac 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/includes/moduletemplate.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/includes/moduletemplate.php @@ -42,24 +42,19 @@ function fetchElement($name, $value, &$node, $control_name) $defaultemplate = $db->loadResult(); $templatePath = JPATH_SITE . '/templates/' . $defaultemplate . '/html/mod_agosms_search'; - if (JFolder::exists($templatePath)) - { + if (JFolder::exists($templatePath)) { $templateFolders = JFolder::folders($templatePath); $folders = @array_merge($templateFolders, $moduleTemplatesFolders); $folders = @array_unique($folders); - } - else - { + } else { $folders = $moduleTemplatesFolders; } $exclude = 'Default'; - $options = array (); + $options = []; - foreach ($folders as $folder) - { - if ($folder == $exclude) - { + foreach ($folders as $folder) { + if ($folder == $exclude) { continue; } diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/includes/orderingselect.php b/j4/pkg_agosms/src/modules/mod_agosms_search/includes/orderingselect.php index c062f680..65ae661f 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/includes/orderingselect.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/includes/orderingselect.php @@ -40,84 +40,67 @@ function fetchElement($name, $value, &$node, $control_name) ORDER BY g.id, f.label "; - try - { + try { $fields = JFactory::getDBO()->setQuery($query)->loadObjectList(); - } - catch (Exception $e) - { + } catch (Exception $e) { $mitems[] = JHTML::_("select.option", "", "Custom Fields available from Joomla 3.8+"); } - if (count($fields)) - { + if (count($fields)) { $group = @$fields[0]->group_name; array_splice($fields, 0, 0, $group); - for ($i = 1; $i < count($fields); $i++) - { + for ($i = 1; $i < count($fields); $i++) { $new_group = $fields[$i]->group_name; - if ($new_group != $group) - { + if ($new_group != $group) { array_splice($fields, $i, 0, $new_group); $group = $new_group; } } - foreach ($fields as $field) - { - if (is_object($field)) - { + foreach ($fields as $field) { + if (is_object($field)) { $field->group_name ? $offset = "      " : $offset = "   "; - if ($field->type == 'radicalmultifield') - { + if ($field->type == 'radicalmultifield') { continue; // Do not use for ordering for now $field_params = json_decode($field->fieldparams); - $sub_fields = array(); + $sub_fields = []; - foreach ($field_params->listtype as $k => $sub_field) - { + foreach ($field_params->listtype as $k => $sub_field) { $sub_fields[$k] = new stdClass; $sub_fields[$k]->name = $sub_field->name; $sub_fields[$k]->title = $sub_field->title; } $tmp = array_values($sub_fields); - $sub_fields = array(); + $sub_fields = []; $sub_fields['radicalmultifield_fields'] = $tmp; $sub_fields = json_encode($sub_fields); $mitems[] = JHTML::_("select.option", "field:{$field->id}:{$field->type}:{$sub_fields}", $offset . JText::_("{$field->label} [id: {$field->id}]")); - } - elseif ($field->type == 'repeatable') - { + } else if ($field->type == 'repeatable') { continue; // Do not use for ordering for now $field_params = json_decode($field->fieldparams); - $sub_fields = array(); + $sub_fields = []; - foreach ($field_params->fields as $k => $sub_field) - { + foreach ($field_params->fields as $k => $sub_field) { $sub_fields[$k] = new stdClass; $sub_fields[$k]->name = $sub_field->fieldname; $sub_fields[$k]->title = $sub_field->fieldname; } $tmp = array_values($sub_fields); - $sub_fields = array(); + $sub_fields = []; $sub_fields['repeatable_fields'] = $tmp; $sub_fields = json_encode($sub_fields); $mitems[] = JHTML::_("select.option", "field:{$field->id}:{$field->type}:{$sub_fields}", $offset . JText::_("{$field->label} [id: {$field->id}]")); - } - else - { + } else { $mitems[] = JHTML::_("select.option", "field{$field->id}", $offset . JText::_("{$field->label} [id: {$field->id}]")); } - } - else - { + } else { $mitems[] = JHTML::_("select.option", "", "   -- {$field} --"); } } @@ -126,5 +109,3 @@ function fetchElement($name, $value, &$node, $control_name) return JHTML::_('select.genericlist', $mitems, $name, 'class="inputbox"', 'value', 'text', $value, $control_name . $name); } } - - diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/includes/statslink.php b/j4/pkg_agosms/src/modules/mod_agosms_search/includes/statslink.php index 73095e4c..6fc2929d 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/includes/statslink.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/includes/statslink.php @@ -28,7 +28,4 @@ public function fetchElement($name, $value, &$node, $control_name) ' . JText::_('MOD_AGOSMSSEARCHSEARCH_STATS_LINK') . ' '; } - } - - diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/mod_agosms_search.php b/j4/pkg_agosms/src/modules/mod_agosms_search/mod_agosms_search.php index 1e0e0e29..40f4d152 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/mod_agosms_search.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/mod_agosms_search.php @@ -18,21 +18,18 @@ $filters = $params->get('filters'); -if (!JPluginHelper::isEnabled('system', 'agosmssearch')) -{ +if (!JPluginHelper::isEnabled('system', 'agosmssearch')) { echo JText::_('MOD_AGOSMS_PLUGIN_NOT_PUBLISHED'); } -if ($filters == "") -{ +if ($filters == "") { echo JText::_('MOD_AGOSMS_PLUGIN_NO_FIELDS'); return; } -if ($params->get('savesearch') && JFactory::getSession()->get("SaveSearchValues")) -{ - $skip = array( +if ($params->get('savesearch') && JFactory::getSession()->get("SaveSearchValues")) { + $skip = [ "option", "task", "view", @@ -40,12 +37,10 @@ "search_mode", "field_id", "field_type" - ); + ]; - foreach (JFactory::getSession()->get("SaveSearchValues") as $key => $value) - { - if (in_array($key, $skip)) - { + foreach (JFactory::getSession()->get("SaveSearchValues") as $key => $value) { + if (in_array($key, $skip)) { continue; } @@ -54,20 +49,17 @@ } $filters_tmp = explode("\r\n", $filters); -$filters = Array(); +$filters = []; -foreach ($filters_tmp as $k => $filter) -{ +foreach ($filters_tmp as $k => $filter) { $filter = explode(":", $filter); $filters[$k] = new stdClass; - if ($filter[0] == 'field') - { + if ($filter[0] == 'field') { $instance = $helper->getCustomField($filter[1]); $filters[$k]->id = $filter[1]; - if ($filter[2] == "") - { + if ($filter[2] == "") { $filter[2] = $instance->type; } @@ -77,13 +69,10 @@ // Added for compatibility with radical multifield $flt = explode('{', $filters_tmp[$k], 2); - if (!empty($flt[1]) && $flt[1] != '') - { + if (!empty($flt[1]) && $flt[1] != '') { $filters[$k]->extra_params = '{' . $flt[1]; } - } - else - { + } else { $filters[$k]->id = '1000' . $k; $filters[$k]->type = $filter[0]; } @@ -97,26 +86,21 @@ $leafletIsLoaded = false; -foreach ($document->_scripts as $key => $script) -{ +foreach ($document->_scripts as $key => $script) { $leafletPath = "leaflet/leaflet.js"; - if (strpos($key, $leafletPath)) - { + if (strpos($key, $leafletPath)) { $leafletIsLoaded = true; } } -if ($params->get('showlocate', "1") == "1") -{ +if ($params->get('showlocate', "1") == "1") { $document->addStyleSheet(JURI::root(true) . '/media/mod_agosms_search/locate/L.Control.Locate.css'); $document->addScript(JURI::root(true) . '/media/mod_agosms_search/locate/L.Control.Locate.min.js'); } -if ($params->get('show_map', "1") === "1") -{ - if (!$leafletIsLoaded) - { +if ($params->get('show_map', "1") === "1") { + if (!$leafletIsLoaded) { $document->addStyleSheet(JURI::root(true) . '/media/mod_agosms_search/leaflet/leaflet.css'); $document->addScript(JURI::root(true) . '/media/mod_agosms_search/leaflet/leaflet.js'); } diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/acounter.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/acounter.php index 13041c05..06d20640 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/acounter.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/acounter.php @@ -1,4 +1,4 @@ -get("ajax_container"); -if($ajax_container == "div.ajax_container") { +if ($ajax_container == "div.ajax_container") { $ajax_container = "#ajax_container{$module->id}"; echo '
          '; } @@ -52,10 +52,10 @@ function ajax_resultsid; ?>() { jQuery(document).ready(function() { jQuery("#GSearchid; ?> input[type=submit]").on("click", function() { - get("search_history")) { ?> + get("search_history")) { ?> search_historyid; ?>(); - get("search_stats")) { ?> + get("search_stats")) { ?> search_statsid; ?>(); ajax_resultsid; ?>(); diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/clear_btn.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/clear_btn.php index 374092f7..28c1b33d 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/clear_btn.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/clear_btn.php @@ -1,4 +1,4 @@ -get("field_connection")); -foreach($connected_fields as $k=>$connected) { - if($connected != "") { +foreach ($connected_fields as $k => $connected) { + if ($connected != "") { $connected_fields[$k] = explode("->", $connected); - } - else { + } else { unset($connected_fields[$k]); } } //get connection instances for script -$connected = Array(); +$connected = []; $result = ''; -foreach($connected_fields as $connection) { - $fields = Array(); - foreach($connection as $field) { +foreach ($connected_fields as $connection) { + $fields = []; + foreach ($connection as $field) { $fields[] = '"'.trim(preg_replace('/\s\s+/iu', '', $field)).'"'; } $connected[] = "[".implode(", ", $fields)."]"; @@ -61,7 +60,7 @@ && prevSelectBox.find("option[hidden!=hidden]").not(".empty").length // skip if no any values exists ) ) { - + selectBox.attr("disabled", "disabled").addClass("disabled"); selectBox.parents(".gsearch-cell").addClass("disabled"); if(selectBox.parent().hasClass("bootstrap-select")) { @@ -127,13 +126,13 @@ var nextAll = jQuery(this).parents('#GSearchid; ?>').find('select.connected:gt('+elemIndex+')'); nextAll.each(function(index, nextSelect) { - + jQuery(nextSelect).attr("disabled", "disabled").addClass("disabled"); jQuery(nextSelect).parents(".gsearch-cell").addClass("disabled").removeClass("showed"); if(selectedVals.attr("class") == "empty" && jQuery(this).attr("multiple") != "multiple") { jQuery(nextSelect).find("option.empty").prop("selected", "selected"); - + jQuery(this).find("option").each(function(k) { //show if(jQuery(this).parent('span').length) { diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/search_history.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/search_history.php index 322811a3..b3d623d6 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/search_history.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/search_history.php @@ -1,4 +1,4 @@ -id]); -if($history) { +if ($history) { echo "
            "; - foreach($history as $h) { + foreach ($history as $h) { echo "
          • {$h->title}
          • "; } echo " diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/search_stats.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/search_stats.php index bc5e3b82..2443b083 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/search_stats.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/elements/search_stats.php @@ -1,4 +1,4 @@ -input->get->get('author')) { $active = JFactory::getApplication()->input->get->get('author'); } @@ -24,15 +24,15 @@ - + diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/basic/date.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/basic/date.php index 2af95644..3848a239 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/basic/date.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/basic/date.php @@ -17,12 +17,12 @@ $active_from_text = ''; $active_to_text = ''; -if($active_from) { +if ($active_from) { $active_from_text = DateTime::createFromFormat("Y-m-d", $active_from)->getTimestamp(); $active_from_text = trim(strftime($date_format, $active_from_text)); $active_from_text = mb_convert_case($active_from_text, MB_CASE_TITLE, 'UTF-8'); } -if($active_to) { +if ($active_to) { $active_to_text = DateTime::createFromFormat("Y-m-d", $active_to)->getTimestamp(); $active_to_text = trim(strftime($date_format, $active_to_text)); $active_to_text = mb_convert_case($active_to_text, MB_CASE_TITLE, 'UTF-8'); diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/basic/tag.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/basic/tag.php index d8fbeaa1..9cf7d233 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/basic/tag.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/basic/tag.php @@ -12,7 +12,7 @@ // no direct access defined('_JEXEC') or die; -$active = array(); +$active = []; if (JFactory::getApplication()->input->get->get('tag')) { $active = JFactory::getApplication()->input->get->get('tag'); } @@ -25,10 +25,10 @@ - - diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/agosmsaddressmarkerslider.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/agosmsaddressmarkerslider.php index bbc792e9..f2833113 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/agosmsaddressmarkerslider.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/agosmsaddressmarkerslider.php @@ -23,13 +23,11 @@ $address = ''; $moduleParams = new JRegistry($module->params); -if($field->instance->type == "agosmsaddressmarker") { +if ($field->instance->type == "agosmsaddressmarker") { $min = $moduleParams->get('first', 0); $max = $moduleParams->get('last', 2000); $step = $moduleParams->get('step', 10); -} -else -{ +} else { $values = $helper->getFieldValuesFromText($field->id, "int", $module->id); $min = $values[0]; $max = $values[count($values) - 1]; @@ -95,7 +93,7 @@ class="agSliderField" /* - }).on("slideStop", function(ev) { + }).on("slideStop", function(ev) { $("input#amount-id}-{$module->id}"; ?>").val(ev.value[0] + ' - ' + ev.value[1]); $("input[name=id}-from"; ?>]").val(ev.value[0]); $("input[name=id}-to"; ?>]").val(ev.value[1]); diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/calendar.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/calendar.php index 25953b7d..4d9e3ca6 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/calendar.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/calendar.php @@ -15,11 +15,11 @@ $fieldid = ''; if (JFactory::getApplication()->input->get->get("field" . $field->id)) { $fieldid = JFactory::getApplication()->input->get->get("field" . $field->id); -} +} $active = $fieldid; $active_text = ''; -if($active) { +if ($active) { $active_text = DateTime::createFromFormat("Y-m-d", $active)->getTimestamp(); $active_text = trim(strftime($date_format, $active_text)); $active_text = mb_convert_case($active_text, MB_CASE_TITLE, 'UTF-8'); diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/calendar_range.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/calendar_range.php index 11efad13..88e5c289 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/calendar_range.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/calendar_range.php @@ -26,13 +26,13 @@ $active_from_text_init = ''; $active_to_text_init = ''; -if($active_from) { +if ($active_from) { $active_from_text_init = DateTime::createFromFormat("Y-m-d", $active_from)->getTimestamp(); $active_from_text_format = trim(strftime($date_format_init, $active_from_text)); $active_from_text = mb_convert_case($active_from_text_format, MB_CASE_TITLE, 'UTF-8'); } -if($active_to) { +if ($active_to) { $active_to_text_init = DateTime::createFromFormat("Y-m-d", $active_to)->getTimestamp(); $active_to_text_format = trim(strftime($date_format_init, $active_to_text)); $active_to_text = mb_convert_case($active_to_text_format, MB_CASE_TITLE, 'UTF-8'); diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/calendar_range_custom.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/calendar_range_custom.php index 40714cbc..bea3ea9e 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/calendar_range_custom.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Default/fields/custom_fields/calendar_range_custom.php @@ -17,19 +17,19 @@ $curr_locale = JFactory::getLanguage()->getLocale(); setlocale(LC_ALL, $curr_locale); -$active = array(); +$active = []; if (JFactory::getApplication()->input->get->get('field-date-custom'.$field_id_from)) { $active = JFactory::getApplication()->input->get->get('field-date-custom'.$field_id_from); } $parts = explode(":", $active); list($active_from, $active_to) = explode(",", $parts[1]); -if($active_from) { +if ($active_from) { $active_from = DateTime::createFromFormat("Y-m-d", $active_from)->getTimestamp(); // custom format $active_from = trim(strftime('%b %e %Y', $active_from)); $active_from = mb_convert_case($active_from, MB_CASE_TITLE, 'UTF-8'); } -if($active_to) { +if ($active_to) { $active_to = DateTime::createFromFormat("Y-m-d", $active_to)->getTimestamp(); // custom format $active_to = trim(strftime('%b %e %Y', $active_to)); $active_to = mb_convert_case($active_to, MB_CASE_TITLE, 'UTF-8'); @@ -52,19 +52,19 @@
          - getTag(); $lang = explode("-", $lang)[0]; - if($lang) { + if ($lang) { $document->addScript(JURI::root(true) . '/media/mod_agosms_search/datepicker/locales/bootstrap-datepicker' . $lang . '.min.js'); - } ?> + } ?> -addStyleSheet(JURI::root(true) . '/media/mod_agosms_search/select/bootstrap-select.min.css'); @@ -100,7 +100,7 @@ function submit_form_id; ?>() { $(el).datepicker({ autoclose: true, format: '', - + language: "", }).on('changeDate', function(e) { @@ -135,145 +135,144 @@ function prepareDatesid; ?>(el) { el_val.val(date_val); } -addStyleSheet(JURI::root(true) . '/media/mod_agosms_search/datepicker/css/bootstrap-datepicker.min.css'); $document->addScript(JURI::root(true) . '/media/mod_agosms_search/datepicker/js/bootstrap-datepicker.min.js'); ?> -addScript(JURI::root(true) . '/media/mod_agosms_search/datepicker/locales/bootstrap-datepicker' . $lang . '.min.js'); - } +} ?>
          - get('descr') != "") : ?> + get('descr') != "") : ?>

          get('descr'); ?>

          - + ?>
          - type) { - case 'keyword' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/keyword')); - break; + type) { + case 'keyword': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/keyword')); + break; - case 'title_select' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/title_select')); - break; + case 'title_select': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/title_select')); + break; - case 'tag' : - $tags = (array)$helper->getTags($params); - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/tag')); + case 'tag': + $tags = (array)$helper->getTags($params); + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/tag')); break; - case 'category' : - $categories = (array)$helper->getCategories(null, $params); - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/category')); - break; + case 'category': + $categories = (array)$helper->getCategories(null, $params); + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/category')); + break; - case 'author' : - $authors = (array)$helper->getAuthors($params); - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/author')); + case 'author': + $authors = (array)$helper->getAuthors($params); + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/author')); break; - case 'date' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/date')); + case 'date': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/date')); break; - //custom fields - case 'text' : - case 'textarea' : - case 'url' : - case 'editor' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/text')); + //custom fields + case 'text': + case 'textarea': + case 'url': + case 'editor': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/text')); break; - case 'text_range' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/text_range')); + case 'text_range': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/text_range')); break; - case 'select' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/select')); + case 'select': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/select')); break; - case 'list' : - case 'multi' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/multi')); + case 'list': + case 'multi': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/multi')); break; - case 'checkboxes' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/checkboxes')); + case 'checkboxes': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/checkboxes')); break; - case 'radio' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/radio')); + case 'radio': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/radio')); break; - case 'agosmsaddressmarker' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/agosmsaddressmarkerslider')); + case 'agosmsaddressmarker': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/agosmsaddressmarkerslider')); break; - case 'integer' : - case 'slider-range' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/slider')); + case 'integer': + case 'slider-range': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/slider')); break; - case 'calendar' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/calendar')); + case 'calendar': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/calendar')); break; - case 'calendar_range' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/calendar_range')); + case 'calendar_range': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/calendar_range')); break; - case 'custom_select' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/custom_select')); + case 'custom_select': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/custom_select')); break; - //added for compatibility with radical multifield - case 'radicalmultifield' : - $extra_params = json_decode($field->extra_params); - $sub_field = $extra_params->selected; - if(!$sub_field) { - echo "Select radicalmultifield in the module parameters"; - break; - } - $field_type = $extra_params->type ? $extra_params->type : "text"; - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/radicalmultifield/'.$field_type)); + //added for compatibility with radical multifield + case 'radicalmultifield': + $extra_params = json_decode($field->extra_params); + $sub_field = $extra_params->selected; + if (!$sub_field) { + echo "Select radicalmultifield in the module parameters"; + break; + } + $field_type = $extra_params->type ? $extra_params->type : "text"; + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/radicalmultifield/'.$field_type)); break; - //added for compatibility with repeatable field - case 'repeatable' : - $extra_params = json_decode($field->extra_params); - $sub_field = $extra_params->selected; - if(!$sub_field) { - echo "Select repeatable field in the module parameters"; - break; - } - $field_type = $extra_params->type ? $extra_params->type : "text"; - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/repeatable/'.$field_type)); + //added for compatibility with repeatable field + case 'repeatable': + $extra_params = json_decode($field->extra_params); + $sub_field = $extra_params->selected; + if (!$sub_field) { + echo "Select repeatable field in the module parameters"; + break; + } + $field_type = $extra_params->type ? $extra_params->type : "text"; + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/repeatable/'.$field_type)); break; - - } + } ?>
          -
          get("clear_btn_show", 1)) { - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/elements/clear_btn')); + if ($params->get("clear_btn_show", 1)) { + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/elements/clear_btn')); } ?>
          @@ -283,29 +282,29 @@ function prepareDatesid; ?>(el) { - get("Itemid")) { ?> + get("Itemid")) { ?> " /> - get("acounter")) { ?> + get("acounter")) { ?> get('module_template', 'Default') . '/elements/acounter')); ?> - get("field_connection") != "" && + get("field_connection") != "" && $params->get("field_connection") != "FieldLabel->FieldLabel2->FieldLabel3") { ?> get('module_template', 'Default') . '/elements/connected_single')); ?> - get("search_history")) { ?> + get("search_history")) { ?> get('module_template', 'Default') . '/elements/search_history')); ?> - get("search_stats")) { ?> + get("search_stats")) { ?> get('module_template', 'Default') . '/elements/search_stats')); ?> - get("search_type") == "ajax") { ?> + get("search_type") == "ajax") { ?> get('module_template', 'Default') . '/elements/ajax_search')); ?>
          \ No newline at end of file diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/acounter.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/acounter.php index 13041c05..06d20640 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/acounter.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/acounter.php @@ -1,4 +1,4 @@ -get("ajax_container"); -if($ajax_container == "div.ajax_container") { +if ($ajax_container == "div.ajax_container") { $ajax_container = "#ajax_container{$module->id}"; echo '
          '; } @@ -52,10 +52,10 @@ function ajax_resultsid; ?>() { jQuery(document).ready(function() { jQuery("#GSearchid; ?> input[type=submit]").on("click", function() { - get("search_history")) { ?> + get("search_history")) { ?> search_historyid; ?>(); - get("search_stats")) { ?> + get("search_stats")) { ?> search_statsid; ?>(); ajax_resultsid; ?>(); diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/clear_btn.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/clear_btn.php index 374092f7..28c1b33d 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/clear_btn.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/clear_btn.php @@ -1,4 +1,4 @@ -get("field_connection")); -foreach($connected_fields as $k=>$connected) { - if($connected != "") { +foreach ($connected_fields as $k => $connected) { + if ($connected != "") { $connected_fields[$k] = explode("->", $connected); - } - else { + } else { unset($connected_fields[$k]); } } //get connection instances for script -$connected = Array(); +$connected = []; $result = ''; -foreach($connected_fields as $connection) { - $fields = Array(); - foreach($connection as $field) { +foreach ($connected_fields as $connection) { + $fields = []; + foreach ($connection as $field) { $fields[] = '"'.trim(preg_replace('/\s\s+/iu', '', $field)).'"'; } $connected[] = "[".implode(", ", $fields)."]"; @@ -61,7 +60,7 @@ && prevSelectBox.find("option[hidden!=hidden]").not(".empty").length // skip if no any values exists ) ) { - + selectBox.attr("disabled", "disabled").addClass("disabled"); selectBox.parents(".gsearch-cell").addClass("disabled"); if(selectBox.parent().hasClass("bootstrap-select")) { @@ -127,13 +126,13 @@ var nextAll = jQuery(this).parents('#GSearchid; ?>').find('select.connected:gt('+elemIndex+')'); nextAll.each(function(index, nextSelect) { - + jQuery(nextSelect).attr("disabled", "disabled").addClass("disabled"); jQuery(nextSelect).parents(".gsearch-cell").addClass("disabled").removeClass("showed"); if(selectedVals.attr("class") == "empty" && jQuery(this).attr("multiple") != "multiple") { jQuery(nextSelect).find("option.empty").prop("selected", "selected"); - + jQuery(this).find("option").each(function(k) { //show if(jQuery(this).parent('span').length) { diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/search_history.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/search_history.php index 322811a3..b3d623d6 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/search_history.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/search_history.php @@ -1,4 +1,4 @@ -id]); -if($history) { +if ($history) { echo "
            "; - foreach($history as $h) { + foreach ($history as $h) { echo "
          • {$h->title}
          • "; } echo " diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/search_stats.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/search_stats.php index bc5e3b82..2443b083 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/search_stats.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/elements/search_stats.php @@ -1,4 +1,4 @@ -input->get->get('author')) { $active = JFactory::getApplication()->input->get->get('author'); } @@ -24,15 +24,15 @@ - + diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/basic/date.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/basic/date.php index 2af95644..3848a239 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/basic/date.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/basic/date.php @@ -17,12 +17,12 @@ $active_from_text = ''; $active_to_text = ''; -if($active_from) { +if ($active_from) { $active_from_text = DateTime::createFromFormat("Y-m-d", $active_from)->getTimestamp(); $active_from_text = trim(strftime($date_format, $active_from_text)); $active_from_text = mb_convert_case($active_from_text, MB_CASE_TITLE, 'UTF-8'); } -if($active_to) { +if ($active_to) { $active_to_text = DateTime::createFromFormat("Y-m-d", $active_to)->getTimestamp(); $active_to_text = trim(strftime($date_format, $active_to_text)); $active_to_text = mb_convert_case($active_to_text, MB_CASE_TITLE, 'UTF-8'); diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/basic/tag.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/basic/tag.php index d8fbeaa1..9cf7d233 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/basic/tag.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/basic/tag.php @@ -12,7 +12,7 @@ // no direct access defined('_JEXEC') or die; -$active = array(); +$active = []; if (JFactory::getApplication()->input->get->get('tag')) { $active = JFactory::getApplication()->input->get->get('tag'); } @@ -25,10 +25,10 @@ - - diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/agosmsaddressmarkerslider.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/agosmsaddressmarkerslider.php index bbc792e9..f2833113 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/agosmsaddressmarkerslider.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/agosmsaddressmarkerslider.php @@ -23,13 +23,11 @@ $address = ''; $moduleParams = new JRegistry($module->params); -if($field->instance->type == "agosmsaddressmarker") { +if ($field->instance->type == "agosmsaddressmarker") { $min = $moduleParams->get('first', 0); $max = $moduleParams->get('last', 2000); $step = $moduleParams->get('step', 10); -} -else -{ +} else { $values = $helper->getFieldValuesFromText($field->id, "int", $module->id); $min = $values[0]; $max = $values[count($values) - 1]; @@ -95,7 +93,7 @@ class="agSliderField" /* - }).on("slideStop", function(ev) { + }).on("slideStop", function(ev) { $("input#amount-id}-{$module->id}"; ?>").val(ev.value[0] + ' - ' + ev.value[1]); $("input[name=id}-from"; ?>]").val(ev.value[0]); $("input[name=id}-to"; ?>]").val(ev.value[1]); diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/calendar.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/calendar.php index 25953b7d..4d9e3ca6 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/calendar.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/calendar.php @@ -15,11 +15,11 @@ $fieldid = ''; if (JFactory::getApplication()->input->get->get("field" . $field->id)) { $fieldid = JFactory::getApplication()->input->get->get("field" . $field->id); -} +} $active = $fieldid; $active_text = ''; -if($active) { +if ($active) { $active_text = DateTime::createFromFormat("Y-m-d", $active)->getTimestamp(); $active_text = trim(strftime($date_format, $active_text)); $active_text = mb_convert_case($active_text, MB_CASE_TITLE, 'UTF-8'); diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/calendar_range.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/calendar_range.php index 11efad13..88e5c289 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/calendar_range.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/calendar_range.php @@ -26,13 +26,13 @@ $active_from_text_init = ''; $active_to_text_init = ''; -if($active_from) { +if ($active_from) { $active_from_text_init = DateTime::createFromFormat("Y-m-d", $active_from)->getTimestamp(); $active_from_text_format = trim(strftime($date_format_init, $active_from_text)); $active_from_text = mb_convert_case($active_from_text_format, MB_CASE_TITLE, 'UTF-8'); } -if($active_to) { +if ($active_to) { $active_to_text_init = DateTime::createFromFormat("Y-m-d", $active_to)->getTimestamp(); $active_to_text_format = trim(strftime($date_format_init, $active_to_text)); $active_to_text = mb_convert_case($active_to_text_format, MB_CASE_TITLE, 'UTF-8'); diff --git a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/calendar_range_custom.php b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/calendar_range_custom.php index 40714cbc..bea3ea9e 100644 --- a/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/calendar_range_custom.php +++ b/j4/pkg_agosms/src/modules/mod_agosms_search/tmpl/Helix/fields/custom_fields/calendar_range_custom.php @@ -17,19 +17,19 @@ $curr_locale = JFactory::getLanguage()->getLocale(); setlocale(LC_ALL, $curr_locale); -$active = array(); +$active = []; if (JFactory::getApplication()->input->get->get('field-date-custom'.$field_id_from)) { $active = JFactory::getApplication()->input->get->get('field-date-custom'.$field_id_from); } $parts = explode(":", $active); list($active_from, $active_to) = explode(",", $parts[1]); -if($active_from) { +if ($active_from) { $active_from = DateTime::createFromFormat("Y-m-d", $active_from)->getTimestamp(); // custom format $active_from = trim(strftime('%b %e %Y', $active_from)); $active_from = mb_convert_case($active_from, MB_CASE_TITLE, 'UTF-8'); } -if($active_to) { +if ($active_to) { $active_to = DateTime::createFromFormat("Y-m-d", $active_to)->getTimestamp(); // custom format $active_to = trim(strftime('%b %e %Y', $active_to)); $active_to = mb_convert_case($active_to, MB_CASE_TITLE, 'UTF-8'); @@ -52,19 +52,19 @@
          - getTag(); $lang = explode("-", $lang)[0]; - if($lang) { + if ($lang) { $document->addScript(JURI::root(true) . '/media/mod_agosms_search/datepicker/locales/bootstrap-datepicker' . $lang . '.min.js'); - } ?> + } ?> -addStyleSheet(JURI::root(true) . '/media/mod_agosms_search/select/bootstrap-select.min.css'); @@ -100,7 +100,7 @@ function submit_form_id; ?>() { $(el).datepicker({ autoclose: true, format: '', - + language: "", }).on('changeDate', function(e) { @@ -135,148 +135,147 @@ function prepareDatesid; ?>(el) { el_val.val(date_val); } -addStyleSheet(JURI::root(true) . '/media/mod_agosms_search/datepicker/css/bootstrap-datepicker.min.css'); $document->addScript(JURI::root(true) . '/media/mod_agosms_search/datepicker/js/bootstrap-datepicker.min.js'); ?> -addScript(JURI::root(true) . '/media/mod_agosms_search/datepicker/locales/bootstrap-datepicker' . $lang . '.min.js'); - } +} ?> -addStyleSheet(JURI::root(true) . '/media/mod_agosms_search/css/agosms_search_helix_template.css'); ?>
          - get('descr') != "") : ?> + get('descr') != "") : ?>

          get('descr'); ?>

          - + ?>
          - type) { - case 'keyword' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/keyword')); - break; + type) { + case 'keyword': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/keyword')); + break; - case 'title_select' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/title_select')); - break; + case 'title_select': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/title_select')); + break; - case 'tag' : - $tags = (array)$helper->getTags($params); - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/tag')); + case 'tag': + $tags = (array)$helper->getTags($params); + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/tag')); break; - case 'category' : - $categories = (array)$helper->getCategories(null, $params); - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/category')); - break; + case 'category': + $categories = (array)$helper->getCategories(null, $params); + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/category')); + break; - case 'author' : - $authors = (array)$helper->getAuthors($params); - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/author')); + case 'author': + $authors = (array)$helper->getAuthors($params); + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/author')); break; - case 'date' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/date')); + case 'date': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/basic/date')); break; - //custom fields - case 'text' : - case 'textarea' : - case 'url' : - case 'editor' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/text')); + //custom fields + case 'text': + case 'textarea': + case 'url': + case 'editor': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/text')); break; - case 'text_range' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/text_range')); + case 'text_range': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/text_range')); break; - case 'select' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/select')); + case 'select': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/select')); break; - case 'list' : - case 'multi' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/multi')); + case 'list': + case 'multi': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/multi')); break; - case 'checkboxes' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/checkboxes')); + case 'checkboxes': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/checkboxes')); break; - case 'radio' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/radio')); + case 'radio': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/radio')); break; - case 'agosmsaddressmarker' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/agosmsaddressmarkerslider')); + case 'agosmsaddressmarker': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/agosmsaddressmarkerslider')); break; - case 'integer' : - case 'slider-range' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/slider')); + case 'integer': + case 'slider-range': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/slider')); break; - case 'calendar' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/calendar')); + case 'calendar': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/calendar')); break; - case 'calendar_range' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/calendar_range')); + case 'calendar_range': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/calendar_range')); break; - case 'custom_select' : - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/custom_select')); + case 'custom_select': + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/custom_select')); break; - //added for compatibility with radical multifield - case 'radicalmultifield' : - $extra_params = json_decode($field->extra_params); - $sub_field = $extra_params->selected; - if(!$sub_field) { - echo "Select radicalmultifield in the module parameters"; - break; - } - $field_type = $extra_params->type ? $extra_params->type : "text"; - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/radicalmultifield/'.$field_type)); + //added for compatibility with radical multifield + case 'radicalmultifield': + $extra_params = json_decode($field->extra_params); + $sub_field = $extra_params->selected; + if (!$sub_field) { + echo "Select radicalmultifield in the module parameters"; + break; + } + $field_type = $extra_params->type ? $extra_params->type : "text"; + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/radicalmultifield/'.$field_type)); break; - //added for compatibility with repeatable field - case 'repeatable' : - $extra_params = json_decode($field->extra_params); - $sub_field = $extra_params->selected; - if(!$sub_field) { - echo "Select repeatable field in the module parameters"; - break; - } - $field_type = $extra_params->type ? $extra_params->type : "text"; - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/repeatable/'.$field_type)); + //added for compatibility with repeatable field + case 'repeatable': + $extra_params = json_decode($field->extra_params); + $sub_field = $extra_params->selected; + if (!$sub_field) { + echo "Select repeatable field in the module parameters"; + break; + } + $field_type = $extra_params->type ? $extra_params->type : "text"; + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/fields/custom_fields/repeatable/'.$field_type)); break; - - } + } ?>
          -
          get("clear_btn_show", 1)) { - require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/elements/clear_btn')); + if ($params->get("clear_btn_show", 1)) { + require(JModuleHelper::getLayoutPath('mod_agosms_search', $params->get('module_template', 'Default') . '/elements/clear_btn')); } ?>
          @@ -286,29 +285,29 @@ function prepareDatesid; ?>(el) { - get("Itemid")) { ?> + get("Itemid")) { ?> " /> - get("acounter")) { ?> + get("acounter")) { ?> get('module_template', 'Default') . '/elements/acounter')); ?> - get("field_connection") != "" && + get("field_connection") != "" && $params->get("field_connection") != "FieldLabel->FieldLabel2->FieldLabel3") { ?> get('module_template', 'Default') . '/elements/connected_single')); ?> - get("search_history")) { ?> + get("search_history")) { ?> get('module_template', 'Default') . '/elements/search_history')); ?> - get("search_stats")) { ?> + get("search_stats")) { ?> get('module_template', 'Default') . '/elements/search_stats')); ?> - get("search_type") == "ajax") { ?> + get("search_type") == "ajax") { ?> get('module_template', 'Default') . '/elements/ajax_search')); ?>
          \ No newline at end of file diff --git a/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/agosmsaddressmarker.php b/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/agosmsaddressmarker.php index 2eca7f85..f622d0f8 100644 --- a/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/agosmsaddressmarker.php +++ b/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/agosmsaddressmarker.php @@ -27,7 +27,7 @@ class PlgFieldsAgosmsaddressmarker extends FieldsPlugin * * @since 1.0.40 */ - public function __construct(& $subject, $config) + public function __construct(&$subject, $config) { parent::__construct($subject, $config); JFormHelper::addFieldPath(__DIR__ . '/field'); @@ -47,12 +47,11 @@ public function onCustomFieldsPrepareDom($field, DOMElement $parent, JForm $form { $fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form); - if (!$fieldNode) - { + if (!$fieldNode) { return $fieldNode; } - $addressfields = json_encode($field->fieldparams->get('addressfields', array()), true); + $addressfields = json_encode($field->fieldparams->get('addressfields', []), true); $fieldNode->setAttribute('addressfields', $addressfields); return $fieldNode; diff --git a/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/field/agosmsaddressmarker.php b/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/field/agosmsaddressmarker.php index ff96eabc..36b85948 100644 --- a/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/field/agosmsaddressmarker.php +++ b/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/field/agosmsaddressmarker.php @@ -146,8 +146,7 @@ class JFormFieldAgosmsaddressmarker extends JFormFieldText */ public function __get($name) { - switch ($name) - { + switch ($name) { case 'latmin': case 'latmax': case 'lonmin': @@ -186,8 +185,7 @@ public function setup(SimpleXMLElement $element, $value, $group = null) { $result = parent::setup($element, $value, $group); - if ($result == true) - { + if ($result == true) { $this->latmax = (int) $this->element['latmax']; $this->latmin = (int) $this->element['latmin']; $this->lonmax = (int) $this->element['lonmax']; @@ -221,8 +219,7 @@ public function setup(SimpleXMLElement $element, $value, $group = null) */ public function __set($name, $value) { - switch ($name) - { + switch ($name) { case 'mapheight': $this->mapheight = (int) $value; break; @@ -305,11 +302,11 @@ protected function getLayoutPaths() { $template = JFactory::getApplication()->getTemplate(); - return array( + return [ JPATH_ADMINISTRATOR . '/templates/' . $template . '/html/layouts/plugins/fields/agosmsaddressmarker', dirname(__DIR__) . '/layouts', JPATH_SITE . '/layouts' - ); + ]; } /** @@ -340,7 +337,7 @@ protected function getLayoutData() $options = (array) $this->getOptions(); - $extraData = array( + $extraData = [ 'latmin' => $this->latmin, 'latmax' => $this->latmax, 'lonmin' => $this->lonmin, @@ -358,7 +355,7 @@ protected function getLayoutData() 'popup' => $this->popup, 'showroutingcontrol' => $this->showroutingcontrol, 'options' => $options, - ); + ]; return array_merge($data, $extraData); } @@ -372,34 +369,28 @@ protected function getLayoutData() protected function getOptions() { $fieldname = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname); - $options = array(); + $options = []; - foreach ($this->element->xpath('option') as $option) - { + foreach ($this->element->xpath('option') as $option) { // Filter requirements - if ($requires = explode(',', (string) $option['requires'])) - { + if ($requires = explode(',', (string) $option['requires'])) { // Requires multilanguage - if (in_array('multilanguage', $requires) && !JLanguageMultilang::isEnabled()) - { + if (in_array('multilanguage', $requires) && !JLanguageMultilang::isEnabled()) { continue; } // Requires associations - if (in_array('associations', $requires) && !JLanguageAssociations::isEnabled()) - { + if (in_array('associations', $requires) && !JLanguageAssociations::isEnabled()) { continue; } // Requires adminlanguage - if (in_array('adminlanguage', $requires) && !JModuleHelper::isAdminMultilang()) - { + if (in_array('adminlanguage', $requires) && !JModuleHelper::isAdminMultilang()) { continue; } // Requires vote plugin - if (in_array('vote', $requires) && !JPluginHelper::isEnabled('content', 'vote')) - { + if (in_array('vote', $requires) && !JPluginHelper::isEnabled('content', 'vote')) { continue; } } @@ -417,21 +408,20 @@ protected function getOptions() $selected = (string) $option['selected']; $selected = ($selected == 'true' || $selected == 'selected' || $selected == '1'); - $tmp = array( + $tmp = [ 'value' => $value, 'text' => JText::alt($text, $fieldname), 'disable' => $disabled, 'class' => (string) $option['class'], 'selected' => ($checked || $selected), 'checked' => ($checked || $selected), - ); + ]; // Set some event handler attributes. But really, should be using unobtrusive js. $tmp['onclick'] = (string) $option['onclick']; $tmp['onchange'] = (string) $option['onchange']; - if ((string) $option['showon']) - { + if ((string) $option['showon']) { $tmp['optionattr'] = " data-showon='" . json_encode( JFormHelper::parseShowOnConditions((string) $option['showon'], $this->formControl, $this->group) @@ -443,16 +433,14 @@ protected function getOptions() $options[] = (object) $tmp; } - if ($this->element['useglobal']) - { + if ($this->element['useglobal']) { $tmp = new stdClass; $tmp->value = ''; $tmp->text = JText::_('JGLOBAL_USE_GLOBAL'); $component = JFactory::getApplication()->input->getCmd('option'); // Get correct component for menu items - if ($component == 'com_menus') - { + if ($component == 'com_menus') { $link = $this->form->getData()->get('link'); $uri = new JUri($link); $component = $uri->getVar('option', 'com_menus'); @@ -462,25 +450,20 @@ protected function getOptions() $value = $params->get($this->fieldname); // Try with global configuration - if (is_null($value)) - { + if (is_null($value)) { $value = JFactory::getConfig()->get($this->fieldname); } // Try with menu configuration - if (is_null($value) && JFactory::getApplication()->input->getCmd('option') == 'com_menus') - { + if (is_null($value) && JFactory::getApplication()->input->getCmd('option') == 'com_menus') { $value = JComponentHelper::getParams('com_menus')->get($this->fieldname); } - if (!is_null($value)) - { + if (!is_null($value)) { $value = (string) $value; - foreach ($options as $option) - { - if ($option->value === $value) - { + foreach ($options as $option) { + if ($option->value === $value) { $value = $option->text; break; @@ -508,14 +491,12 @@ protected function getOptions() * * @since 1.0.40 */ - public function addOption($text, $attributes = array()) + public function addOption($text, $attributes = []) { - if ($text && $this->element instanceof SimpleXMLElement) - { + if ($text && $this->element instanceof SimpleXMLElement) { $child = $this->element->addChild('option', $text); - foreach ($attributes as $name => $value) - { + foreach ($attributes as $name => $value) { $child->addAttribute($name, $value); } } diff --git a/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/field/cfield.php b/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/field/cfield.php index 2131a65d..7acde2f2 100644 --- a/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/field/cfield.php +++ b/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/field/cfield.php @@ -36,7 +36,7 @@ class JFormFieldCfield extends JFormFieldList * @var array * @since 1.0.40 */ - protected static $options = array(); + protected static $options = []; /** * Method to get the options to populate list @@ -53,8 +53,7 @@ protected function getOptions() $app = JFactory::getApplication(); $context = $app->input->getCmd('context'); - if (!isset(static::$options[$hash])) - { + if (!isset(static::$options[$hash])) { static::$options[$hash] = parent::getOptions(); $db = Factory::getDbo(); @@ -73,8 +72,7 @@ protected function getOptions() $db->setQuery($query); // Return the result - if ($options = $db->loadObjectList()) - { + if ($options = $db->loadObjectList()) { static::$options[$hash] = array_merge(static::$options[$hash], $options); } } diff --git a/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/layouts/agosmsaddressmarker.php b/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/layouts/agosmsaddressmarker.php index 3eca5fba..7fb39435 100644 --- a/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/layouts/agosmsaddressmarker.php +++ b/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/layouts/agosmsaddressmarker.php @@ -16,34 +16,31 @@ //JHtml::_('jquery.framework'); $showspecialicon = "display:none"; -if ($specialicon) -{ +if ($specialicon) { $showspecialicon = ""; } $showpopup = "display:none"; -if ($popup) -{ +if ($popup) { $showpopup = ""; } $document = JFactory::getDocument(); $document->addScript(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/leaflet/leaflet.js'); -JHtml::_('script', 'plg_fields_agosmsaddressmarker/admin-agosmsaddressmarker.js', array('version' => 'auto', 'relative' => true)); +JHtml::_('script', 'plg_fields_agosmsaddressmarker/admin-agosmsaddressmarker.js', ['version' => 'auto', 'relative' => true]); -if ($specialicon) -{ +if ($specialicon) { $document->addStyleSheet(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/css/font-awesome.min.css'); } -JHtml::_('stylesheet', 'plg_fields_agosmsaddressmarker/agosmsaddressmarker.css', array('version' => 'auto', 'relative' => true)); +JHtml::_('stylesheet', 'plg_fields_agosmsaddressmarker/agosmsaddressmarker.css', ['version' => 'auto', 'relative' => true]); JText::script('PLG_AGOSMSADDRESSMARKER_ADDRESSE_ERROR'); JText::script('PLG_AGOSMSADDRESSMARKER_ADDRESSE_NOTICE'); JText::script('PLG_AGOSMSADDRESSMARKER_LAT_ERROR'); JText::script('PLG_AGOSMSADDRESSMARKER_LON_ERROR'); -$attributes = array( +$attributes = [ !empty($class) ? 'class="' . $class . '"' : '', !empty($size) ? 'size="' . $size . '"' : '', $disabled ? 'disabled' : '', @@ -57,37 +54,33 @@ $spellcheck ? '' : 'spellcheck="false"', !empty($inputmode) ? $inputmode : '', !empty($pattern) ? 'pattern="' . $pattern . '"' : '', -); +]; // Define defaults $app = JFactory::getApplication(); $context = 'com_content.article'; // Com_categorie -if ($app->input->getCmd('option') === 'com_categories') -{ +if ($app->input->getCmd('option') === 'com_categories') { $context = $app->input->getCmd('extension') . '.categories'; } // Com_users -elseif ($app->input->getCmd('option') === 'com_users') -{ +else if ($app->input->getCmd('option') === 'com_users') { $context = 'com_users.user'; } // Com_contact -elseif ($app->input->getCmd('option') === 'com_contact') -{ +else if ($app->input->getCmd('option') === 'com_contact') { //JFactory::getApplication()->enqueueMessage(JText::_('PLG_AGOSMSADDRESSMARKER_SUPPORTET'), 'message'); $context = 'com_contact.contact'; } // Third Party -elseif ($app->input->getCmd('option') !== 'com_users' +else if ($app->input->getCmd('option') !== 'com_users' && $app->input->getCmd('option') !== 'com_content' && $app->input->getCmd('option') !== 'com_categories' - && $app->input->getCmd('option') !== 'com_contact') -{ + && $app->input->getCmd('option') !== 'com_contact') { $context = $app->input->getCmd('option') . '.' . $app->input->getCmd('view'); } @@ -95,14 +88,12 @@ // Load fields with prepared values $fields = FieldsHelper::getFields($context); -$addressfieldsvalues = array(); +$addressfieldsvalues = []; $addressfieldsArray = json_decode($addressfields); -if (!empty($addressfieldsArray)) -{ +if (!empty($addressfieldsArray)) { foreach ($addressfieldsArray as $a) { - if(property_exists($a, 'value')) - { + if (property_exists($a, 'value')) { $addressfieldsvalues[] = $a->value; } } @@ -110,14 +101,12 @@ // Build the string with the field names from the selected fields $fieldnames = ""; -$fieldsNameArray = array(); +$fieldsNameArray = []; -if (!empty($fields)) -{ +if (!empty($fields)) { foreach ($fields as $field) { // Save value to fieldnames, if field is in the options of this custom field - if (in_array($field->id, $addressfieldsvalues)) - { + if (in_array($field->id, $addressfieldsvalues)) { $fieldsNameArray[] = 'jform' . '_com_fields_' . str_replace('-', '_', $field->name); $fieldnames .= $field->label . ', '; } diff --git a/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/tmpl/agosmsaddressmarker.php b/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/tmpl/agosmsaddressmarker.php index d9de4e45..a7a53c67 100644 --- a/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/tmpl/agosmsaddressmarker.php +++ b/j4/pkg_agosms/src/plugins/fields/agosmsaddressmarker/tmpl/agosmsaddressmarker.php @@ -24,45 +24,38 @@ $leafletIsLoaded = false; -foreach ($document->_scripts as $key => $script) -{ +foreach ($document->_scripts as $key => $script) { $leafletPath = "leaflet/leaflet.js"; - if (strpos($key, $leafletPath)) - { + if (strpos($key, $leafletPath)) { $leafletIsLoaded = true; } } -if (!$leafletIsLoaded) -{ +if (!$leafletIsLoaded) { $document->addStyleSheet(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/leaflet/leaflet.css'); $document->addScript(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/leaflet/leaflet.js'); $document->addScript(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker.js'); } -if ($fieldParams->get('showroutingcontrol', '0') == 1) -{ +if ($fieldParams->get('showroutingcontrol', '0') == 1) { $document->addStyleSheet(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/Routing/leaflet-routing-machine/leaflet-routing-machine.css'); $document->addScript(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/Routing/leaflet-routing-machine/leaflet-routing-machine.js'); $document->addScript(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/Routing/leaflet-routing-machine/Control.Geocoder.js'); } -if ($fieldParams->get('specialicon', '0') === "1") -{ +if ($fieldParams->get('specialicon', '0') === "1") { $document->addStyleSheet(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/css/font-awesome.min.css'); $document->addStyleSheet(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/Leaflet.awesome-markers/leaflet.awesome-markers.css'); $document->addScript(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/Leaflet.awesome-markers/leaflet.awesome-markers.js'); } -if ($fieldParams->get('scrollwheelzoom') === "2") -{ +if ($fieldParams->get('scrollwheelzoom') === "2") { $document->addStyleSheet(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/GoogleGestureHandling/leaflet-gesture-handling.min.css'); $document->addScript(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/GoogleGestureHandling/leaflet-gesture-handling.min.js'); } -if ($fieldParams->get('maptype') === "google") -{ +if ($fieldParams->get('maptype') === "google") { $document->addScript(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/GoogleMutant/Leaflet.GoogleMutant.js'); } @@ -71,8 +64,7 @@ // We need this for list views $unique = $field->id . '_' . uniqid(); -if ($value == '') -{ +if ($value == '') { return; } @@ -89,8 +81,10 @@ ?>
          id="map" class = 'agosmsaddressmarkerleafletmap' @@ -126,13 +120,17 @@ class = 'agosmsaddressmarkerleafletmap'
          get('addprivacybox', '0')) : ?>

          class="p">

          get('show_map', "1") === "1") { ?> - +
          get('baselayer', 'mapbox')) : ?> + get('baselayer', 'mapbox')) : ?> data-mapboxmaptype="get('mapboxmaptype', 'streets'); ?>" data-mapboxkey="get('mapboxkey', ''); ?>" - -get('baselayer', 'thunderforest')) : ?> + + get('baselayer', 'thunderforest')) : ?> data-thunderforestkey="get('thunderforestkey', ''); ?>" data-thunderforestmaptype="get('thunderforestmaptype', 'cycle'); ?>" - -get('baselayer', 'stamen')) : ?> + + get('baselayer', 'stamen')) : ?> data-stamenmaptype="get('stamenmaptype', 'watercolor'); ?>" - -get('baselayer', 'google')) : ?> + + get('baselayer', 'google')) : ?> data-googlemapstype="get('googlemapstype', 'satellite'); ?>" - -get('baselayer', 'custom')) : ?> + + get('baselayer', 'custom')) : ?> data-customBaselayer="get('customBaselayer', 'maxZoom: 18,'); ?>" data-customBaselayerURL="get('customBaselayerURL', 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'); ?>" - + data-attr-module="get('attrModule', 1); ?>" -get('scale') !== null) : ?> + get('scale') !== null) : ?> data-scale="get('scale')); ?>" - - data-specialcustomfieldpins=" + data-specialcustomfieldpins="" data-scale-metric="get('scale', $defaultArray)); ?>" data-scale-imperial="get('scale', $defaultArray)); ?>" @@ -133,69 +126,54 @@ class="leafletmapModSearch" get('show_resultlist', "1") === "1") { ?> - - +
          - module_params->ordering_show) - if (false) - { - ?> + module_params->ordering_show) + if (false) { + ?>
          - +
          - +
          $item) - { - if (!property_exists($item, "parent_alias")) - { + foreach ($items as $items_counter => $item) { + if (!property_exists($item, "parent_alias")) { $item->parent_alias = false; } - if (!property_exists($item, "alias")) - { + if (!property_exists($item, "alias")) { $item->alias = false; } $item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; - if ($item->parent_alias == 'root' || !property_exists($item, "parent_id")) - { + if ($item->parent_alias == 'root' || !property_exists($item, "parent_id")) { $item->parent_slug = null; - } - else - { + } else { $item->parent_slug = ($item->parent_alias) ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id; } - if (property_exists($item, "catslug")) - { + if (property_exists($item, "catslug")) { $item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid; - } - else - { + } else { $item->catslug = null; } ?> module_params->results_template == "") - { + if ($model->module_params->results_template == "") { $model->module_params->results_template = "standard"; } - if ($model->module_params->results_template == "standard") - { + if ($model->module_params->results_template == "standard") { require dirname(__FILE__) . '/gsearch_blog_item.php'; - } - else - { + } else { require dirname(__FILE__) . "/gsearch_blog_item_{$model->module_params->results_template}.php"; } ?> @@ -214,35 +192,24 @@ class="leafletmapModSearch" $PagesLinks = preg_replace('/\?page-start=.[0-9]*/', '', $PagesLinks); $PagesLinks = preg_replace('/\?start=/', '?page-start=', $PagesLinks); - if (strpos($PagesLinks, "?") === false) - { + if (strpos($PagesLinks, "?") === false) { $PagesLinks = preg_replace('/&page-start=/', '?page-start=', $PagesLinks); } - if (strpos($PagesLinks, "page-start") === false) - { + if (strpos($PagesLinks, "page-start") === false) { $PagesLinks = preg_replace_callback( '/(title="([^"]*)"[^>]*gsearch=1)/smix', function ($matches) use ($model) { - if ((int) $matches[2] != 0) - { + if ((int) $matches[2] != 0) { // Is page number return $matches[1] . '&page-start=' . ($matches[2] - 1) * $model->limit; - } - elseif ($matches[2] == "Prev") - { + } else if ($matches[2] == "Prev") { return $matches[1] . '&page-start=' . ($model->input->get("page-start") - $model->limit); - } - elseif ($matches[2] == "Next") - { + } else if ($matches[2] == "Next") { return $matches[1] . '&page-start=' . ($model->input->get("page-start") + $model->limit); - } - elseif ($matches[2] == "End") - { + } else if ($matches[2] == "End") { return $matches[1] . '&page-start=' . ($model->total_items - 1); - } - else - { + } else { return $matches[0]; } }, @@ -252,8 +219,8 @@ function ($matches) use ($model) { echo $PagesLinks; ?> - getPagesCounter(); + getPagesCounter(); ?>
          diff --git a/j4/pkg_agosms/src/plugins/system/agosmssearch/template/com_content/gsearch_blog_item.php b/j4/pkg_agosms/src/plugins/system/agosmssearch/template/com_content/gsearch_blog_item.php index da3ac9cf..127933f9 100644 --- a/j4/pkg_agosms/src/plugins/system/agosmssearch/template/com_content/gsearch_blog_item.php +++ b/j4/pkg_agosms/src/plugins/system/agosmssearch/template/com_content/gsearch_blog_item.php @@ -20,7 +20,7 @@ $fields = FieldsHelper::getFields('com_content.article', $item, true); $tmp = new stdClass; -foreach($fields as $field) { +foreach ($fields as $field) { $name = $field->name; $tmp->{$name} = $field; } @@ -30,7 +30,7 @@ //echo $fields->{"test1"}->title . ' - ' . $fields->{"test1"}->value; $image_type = $model->module_params->image_type; -$images = json_decode($item->images); +$images = json_decode($item->images); //$ImageIntro = strlen($images->image_intro) > 1 ? 1 : 0; $ImageIntro = 0; preg_match('/(]+>)/i', $item->introtext, $matches); @@ -41,22 +41,20 @@ $item->introtext = trim(strip_tags($item->introtext, '

          ')); } -if($model->module_params->text_limit) { - preg_match('/(]+>)/i', $item->introtext, $images_text); +if ($model->module_params->text_limit) { + preg_match('/(]+>)/i', $item->introtext, $images_text); $item->introtext = trim(strip_tags($item->introtext, '

          ')); - if(extension_loaded('mbstring')) { + if (extension_loaded('mbstring')) { $item->introtext = mb_strimwidth($item->introtext, 0, $model->module_params->text_limit, '...', 'utf-8'); - } - else { + } else { $item->introtext = strlen($item->introtext) > $model->module_params->text_limit ? substr($item->introtext, 0, $model->module_params->text_limit) . '...' : $item->introtext; } - if(count($images_text) && + if (count($images_text) && ($image_type == "text" || ($image_type == "" && !$ImageIntro)) ) { - - if(strpos($images_text[0], '://') === false) { + if (strpos($images_text[0], '://') === false) { $parts = explode('src="', $images_text[0]); $images_text[0] = $parts[0] . 'src="' . JURI::root() . $parts[1]; } @@ -67,8 +65,7 @@ $distance = ""; -if (isset($item->distance)) -{ +if (isset($item->distance)) { $distance = round($item->distance, 2); } ?> @@ -94,9 +91,9 @@

          - module_params->image_empty; - if(((!$ImageIntro && $image_type == "intro") || (!$ImageInText && $image_type == "text") || (!$ImageIntro && !$ImageInText && $image_type == "")) && $image_empty != "" && $image_empty != "-1" && !$ImagesTab) { ?> + if (((!$ImageIntro && $image_type == "intro") || (!$ImageInText && $image_type == "text") || (!$ImageIntro && !$ImageInText && $image_type == "")) && $image_empty != "" && $image_empty != "-1" && !$ImagesTab) { ?> - module_params->show_introtext) { ?> + module_params->show_introtext) { ?>
          introtext; ?> @@ -112,13 +109,13 @@
          - module_params->show_readmore && property_exists($item, "slug")) { ?> + module_params->show_readmore && property_exists($item, "slug")) { ?>
          - module_params->show_info) { ?> + module_params->show_info) { ?>
          - module_params->image_empty; - if(((!$ImageIntro && $image_type == "intro") || (!$ImageInText && $image_type == "text") || (!$ImageIntro && !$ImageInText && $image_type == "")) && $image_empty != "" && $image_empty != "-1" && !$ImagesTab) { ?> + if (((!$ImageIntro && $image_type == "intro") || (!$ImageInText && $image_type == "text") || (!$ImageIntro && !$ImageInText && $image_type == "")) && $image_empty != "" && $image_empty != "-1" && !$ImagesTab) { ?>
          @@ -106,7 +103,7 @@
          introtext; ?> @@ -137,14 +134,14 @@
          - module_params->show_readmore && property_exists($item, "slug")) { ?> + module_params->show_readmore && property_exists($item, "slug")) { ?>
          - $value) { - if(in_array($param, Array("id", "start", "option", "view", "task", "limit", "limitstart", "featured"))) continue; - ?> + $value) { + if (in_array($param, ["id", "start", "option", "view", "task", "limit", "limitstart", "featured"])) { + continue; + } + ?>
          diff --git a/j4/pkg_agosms/src/plugins/system/agosmssearch/template/search_stats/list.php b/j4/pkg_agosms/src/plugins/system/agosmssearch/template/search_stats/list.php index 5dfb31b2..62cc7dce 100644 --- a/j4/pkg_agosms/src/plugins/system/agosmssearch/template/search_stats/list.php +++ b/j4/pkg_agosms/src/plugins/system/agosmssearch/template/search_stats/list.php @@ -15,7 +15,7 @@ //check for template override $override = JPATH_SITE . "/templates/{$mainframe->getTemplate()}/html/com_content/search_stats/list.php"; $file_path = __FILE__; -if(JFile::exists($override) +if (JFile::exists($override) && strpos($file_path, "html") === false //do not trigger in override file ) { ob_start(); @@ -94,7 +94,7 @@
          - $item) { ?> + $item) { ?>
          input->get("limitstart", 0) + $items_counter + 1; ?>
          @@ -122,9 +122,11 @@
          - $value) { - if(in_array($param, Array("id", "start", "option", "view", "task", "limit", "limitstart", "featured"))) continue; - ?> + $value) { + if (in_array($param, ["id", "start", "option", "view", "task", "limit", "limitstart", "featured"])) { + continue; + } + ?>
          diff --git a/j4/pkg_agosms/src/plugins/system/agosmssearch/view/com_content/view.count.php b/j4/pkg_agosms/src/plugins/system/agosmssearch/view/com_content/view.count.php index caf4adbd..736c346f 100644 --- a/j4/pkg_agosms/src/plugins/system/agosmssearch/view/com_content/view.count.php +++ b/j4/pkg_agosms/src/plugins/system/agosmssearch/view/com_content/view.count.php @@ -21,5 +21,3 @@ function display($search_type = "com_content") die; } } - - diff --git a/j4/pkg_agosms/src/plugins/system/agosmssearch/view/com_content/view.html.php b/j4/pkg_agosms/src/plugins/system/agosmssearch/view/com_content/view.html.php index c230e4ea..91b8a1e7 100644 --- a/j4/pkg_agosms/src/plugins/system/agosmssearch/view/com_content/view.html.php +++ b/j4/pkg_agosms/src/plugins/system/agosmssearch/view/com_content/view.html.php @@ -18,15 +18,12 @@ function display($search_type = "com_content") $mainframe = JFactory::getApplication(); $override = JPATH_SITE . "/templates/{$mainframe->getTemplate()}/html/com_content/gsearch_blog.php"; - if (JFile::exists($override)) - { + if (JFile::exists($override)) { ob_start(); require $override; $return = ob_get_contents(); ob_end_clean(); - } - else - { + } else { ob_start(); require JPATH_SITE . "/plugins/system/agosmssearch/template/com_content/gsearch_blog.php"; $return = ob_get_contents(); @@ -36,5 +33,3 @@ function display($search_type = "com_content") return $return; } } - - diff --git a/j4/pkg_agosms/src/plugins/system/agosmssearch/view/com_content/view.raw.php b/j4/pkg_agosms/src/plugins/system/agosmssearch/view/com_content/view.raw.php index 45dff01a..363397b3 100644 --- a/j4/pkg_agosms/src/plugins/system/agosmssearch/view/com_content/view.raw.php +++ b/j4/pkg_agosms/src/plugins/system/agosmssearch/view/com_content/view.raw.php @@ -18,15 +18,12 @@ function display($search_type = "com_content") $mainframe = JFactory::getApplication(); $override = JPATH_SITE . "/templates/{$mainframe->getTemplate()}/html/com_content/gsearch_blog.php"; - if (JFile::exists($override)) - { + if (JFile::exists($override)) { ob_start(); require $override; $return = ob_get_contents(); ob_end_clean(); - } - else - { + } else { ob_start(); require JPATH_SITE . "/plugins/system/agosmssearch/template/com_content/gsearch_blog.php"; $return = ob_get_contents(); @@ -37,5 +34,3 @@ function display($search_type = "com_content") die; } } - - diff --git a/src/media/mod_agosm/js/agosm.js b/src/media/mod_agosm/js/agosm.js index a2d55756..f44be3c1 100644 --- a/src/media/mod_agosm/js/agosm.js +++ b/src/media/mod_agosm/js/agosm.js @@ -229,7 +229,7 @@ document.addEventListener('DOMContentLoaded', function () { zoomOffset: -1, id: mapboxmaptype, accessToken: mapboxkey - }); + }); } if (baselayer === 'mapnikde') { tileLayer = L.tileLayer('https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', { @@ -515,34 +515,32 @@ document.addEventListener('DOMContentLoaded', function () { tempMarker.openPopup(); }); } - window['mymap' + moduleId].on("moveend", function (event) { - var bounds = event.target.getBounds(); + window['mymap' + moduleId].on("moveend", function (event) { + var bounds = event.target.getBounds(); var indexhidemove = 0; for (var specialpin in specialpins) { indexhidemove++; - var hidemove = document.querySelector('.agmarkerlistli_specialpin' + indexhidemove); - if(hidemove){ + if (document.querySelector('.agmarkerlistli_specialpin' + indexhidemove)) { var cords = L.latLng(specialpins[specialpin].latlonpin.split(",", 3)); if (!bounds.contains(cords)) { - hidemove.hidden = true; + document.querySelector('.agmarkerlistli_specialpin' + indexhidemove).hidden = true; } else { - hidemove.hidden = false; + document.querySelector('.agmarkerlistli_specialpin' + indexhidemove).hidden = false; } } } }); - window['mymap' + moduleId].on("zoomend", function (event) { - var bounds = event.target.getBounds(); + window['mymap' + moduleId].on("zoomend", function (event) { + var bounds = event.target.getBounds(); var indexhidezoom = 0; for (var specialpin in specialpins) { indexhidezoom++; - var hidezoom = document.querySelector('.agmarkerlistli_specialpin' + indexhidezoom); - if(hidezoom){ + if (document.querySelector('.agmarkerlistli_specialpin' + indexhidezoom)) { var cords = L.latLng(specialpins[specialpin].latlonpin.split(",", 3)); if (!bounds.contains(cords)) { - hidezoom.hidden = true; + document.querySelector('.agmarkerlistli_specialpin' + indexhidezoom).hidden = true; } else { - hidezoom.hidden = false; + document.querySelector('.agmarkerlistli_specialpin' + indexhidezoom).hidden = false; } } } @@ -554,47 +552,46 @@ document.addEventListener('DOMContentLoaded', function () { // Show Pins from component if (showcomponentpin === '1') { - var clustermarkers = L.markerClusterGroup({ - maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center - iconCreateFunction: null, - clusterPane: L.Marker.prototype.options.pane, - - spiderfyOnMaxZoom: true, - showCoverageOnHover: true, - zoomToBoundsOnClick: true, - singleMarkerMode: false, - - disableClusteringAtZoom: disableClusteringAtZoom, - - // Setting this to false prevents the removal of any clusters outside of the viewpoint, which - // is the default behaviour for performance reasons. - removeOutsideVisibleBounds: true, - - // Set to false to disable all animations (zoom and spiderfy). - // If false, option animateAddingMarkers below has no effect. - // If L.DomUtil.TRANSITION is falsy, this option has no effect. - animate: true, - - //Whether to animate adding markers after adding the MarkerClusterGroup to the map - // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains. - animateAddingMarkers: false, - - //Increase to increase the distance away that spiderfied markers appear from the center - spiderfyDistanceMultiplier: 1, - - // Make it possible to specify a polyline options on a spider leg - spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, - - // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts - chunkedLoading: false, - chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback) - chunkDelay: 50, // at the end of each interval, give n milliseconds back to system/browser - chunkProgress: null, // progress callback: function(processed, total, elapsed) (e.g. for a progress indicator) - - //Options to pass to the L.Polygon constructor - polygonOptions: {} - }); + maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center + iconCreateFunction: null, + clusterPane: L.Marker.prototype.options.pane, + + spiderfyOnMaxZoom: true, + showCoverageOnHover: true, + zoomToBoundsOnClick: true, + singleMarkerMode: false, + + disableClusteringAtZoom: disableClusteringAtZoom, + + // Setting this to false prevents the removal of any clusters outside of the viewpoint, which + // is the default behaviour for performance reasons. + removeOutsideVisibleBounds: true, + + // Set to false to disable all animations (zoom and spiderfy). + // If false, option animateAddingMarkers below has no effect. + // If L.DomUtil.TRANSITION is falsy, this option has no effect. + animate: true, + + //Whether to animate adding markers after adding the MarkerClusterGroup to the map + // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains. + animateAddingMarkers: false, + + //Increase to increase the distance away that spiderfied markers appear from the center + spiderfyDistanceMultiplier: 1, + + // Make it possible to specify a polyline options on a spider leg + spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, + + // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts + chunkedLoading: false, + chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback) + chunkDelay: 50, // at the end of each interval, give n milliseconds back to system/browser + chunkProgress: null, // progress callback: function(processed, total, elapsed) (e.g. for a progress indicator) + + //Options to pass to the L.Polygon constructor + polygonOptions: {} + }); for (var specialcomponentpin in specialcomponentpins) { // skip loop if the property is from prototype @@ -685,33 +682,37 @@ document.addEventListener('DOMContentLoaded', function () { tempMarker.openPopup(); }); } - window['mymap' + moduleId].on("moveend", function (event) { - var bounds = event.target.getBounds(); + window['mymap' + moduleId].on("moveend", function (event) { + var bounds = event.target.getBounds(); for (var specialcomponentpin in specialcomponentpins) { - if(specialcomponentpins[specialcomponentpin].id){ + if (specialcomponentpins[specialcomponentpin].id) { var cords = L.latLng(specialcomponentpins[specialcomponentpin].coordinates.split(",", 3)); - if (!bounds.contains(cords)) { - document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = true; - } else { - document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = false; + if (document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id)) { + if (!bounds.contains(cords)) { + document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = true; + } else { + document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = false; + } } } } }); - window['mymap' + moduleId].on("zoomend", function (event) { - var bounds = event.target.getBounds(); + window['mymap' + moduleId].on("zoomend", function (event) { + var bounds = event.target.getBounds(); for (var specialcomponentpin in specialcomponentpins) { - if(specialcomponentpins[specialcomponentpin].id){ + if (specialcomponentpins[specialcomponentpin].id) { var cords = L.latLng(specialcomponentpins[specialcomponentpin].coordinates.split(",", 3)); - if (!bounds.contains(cords)) { - document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = true; - } else { - document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = false; + if (document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id)) { + if (!bounds.contains(cords)) { + document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = true; + } else { + document.querySelector('.agmarkerlistli_component' + specialcomponentpins[specialcomponentpin].id).hidden = false; + } } } } }); - + } if (JSON.parse(sessionStorage.getItem('mapState')) && savestate === "1") { @@ -725,47 +726,46 @@ document.addEventListener('DOMContentLoaded', function () { // One Pin from component if (showcomponentpinone === '1') { - var clustermarkers = L.markerClusterGroup({ - maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center - iconCreateFunction: null, - clusterPane: L.Marker.prototype.options.pane, - - spiderfyOnMaxZoom: true, - showCoverageOnHover: true, - zoomToBoundsOnClick: true, - singleMarkerMode: false, - - disableClusteringAtZoom: disableClusteringAtZoom, - - // Setting this to false prevents the removal of any clusters outside of the viewpoint, which - // is the default behaviour for performance reasons. - removeOutsideVisibleBounds: true, - - // Set to false to disable all animations (zoom and spiderfy). - // If false, option animateAddingMarkers below has no effect. - // If L.DomUtil.TRANSITION is falsy, this option has no effect. - animate: true, - - //Whether to animate adding markers after adding the MarkerClusterGroup to the map - // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains. - animateAddingMarkers: false, - - //Increase to increase the distance away that spiderfied markers appear from the center - spiderfyDistanceMultiplier: 1, - - // Make it possible to specify a polyline options on a spider leg - spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, - - // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts - chunkedLoading: false, - chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback) - chunkDelay: 50, // at the end of each interval, give n milliseconds back to system/browser - chunkProgress: null, // progress callback: function(processed, total, elapsed) (e.g. for a progress indicator) - - //Options to pass to the L.Polygon constructor - polygonOptions: {} - }); + maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center + iconCreateFunction: null, + clusterPane: L.Marker.prototype.options.pane, + + spiderfyOnMaxZoom: true, + showCoverageOnHover: true, + zoomToBoundsOnClick: true, + singleMarkerMode: false, + + disableClusteringAtZoom: disableClusteringAtZoom, + + // Setting this to false prevents the removal of any clusters outside of the viewpoint, which + // is the default behaviour for performance reasons. + removeOutsideVisibleBounds: true, + + // Set to false to disable all animations (zoom and spiderfy). + // If false, option animateAddingMarkers below has no effect. + // If L.DomUtil.TRANSITION is falsy, this option has no effect. + animate: true, + + //Whether to animate adding markers after adding the MarkerClusterGroup to the map + // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains. + animateAddingMarkers: false, + + //Increase to increase the distance away that spiderfied markers appear from the center + spiderfyDistanceMultiplier: 1, + + // Make it possible to specify a polyline options on a spider leg + spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, + + // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts + chunkedLoading: false, + chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback) + chunkDelay: 50, // at the end of each interval, give n milliseconds back to system/browser + chunkProgress: null, // progress callback: function(processed, total, elapsed) (e.g. for a progress indicator) + + //Options to pass to the L.Polygon constructor + polygonOptions: {} + }); var obj = specialcomponentpinone; let tempMarker = L.marker(obj.coordinates.split(",", 3)); @@ -861,45 +861,45 @@ document.addEventListener('DOMContentLoaded', function () { // Show Pins from customfield if (showcustomfieldpin === '1') { var clustermarkers = L.markerClusterGroup({ - maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center - iconCreateFunction: null, - clusterPane: L.Marker.prototype.options.pane, - - spiderfyOnMaxZoom: true, - showCoverageOnHover: true, - zoomToBoundsOnClick: true, - singleMarkerMode: false, - - disableClusteringAtZoom: disableClusteringAtZoom, - - // Setting this to false prevents the removal of any clusters outside of the viewpoint, which - // is the default behaviour for performance reasons. - removeOutsideVisibleBounds: true, - - // Set to false to disable all animations (zoom and spiderfy). - // If false, option animateAddingMarkers below has no effect. - // If L.DomUtil.TRANSITION is falsy, this option has no effect. - animate: true, - - //Whether to animate adding markers after adding the MarkerClusterGroup to the map - // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains. - animateAddingMarkers: false, - - //Increase to increase the distance away that spiderfied markers appear from the center - spiderfyDistanceMultiplier: 1, - - // Make it possible to specify a polyline options on a spider leg - spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, - - // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts - chunkedLoading: false, - chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback) - chunkDelay: 50, // at the end of each interval, give n milliseconds back to system/browser - chunkProgress: null, // progress callback: function(processed, total, elapsed) (e.g. for a progress indicator) - - //Options to pass to the L.Polygon constructor - polygonOptions: {} - }); + maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center + iconCreateFunction: null, + clusterPane: L.Marker.prototype.options.pane, + + spiderfyOnMaxZoom: true, + showCoverageOnHover: true, + zoomToBoundsOnClick: true, + singleMarkerMode: false, + + disableClusteringAtZoom: disableClusteringAtZoom, + + // Setting this to false prevents the removal of any clusters outside of the viewpoint, which + // is the default behaviour for performance reasons. + removeOutsideVisibleBounds: true, + + // Set to false to disable all animations (zoom and spiderfy). + // If false, option animateAddingMarkers below has no effect. + // If L.DomUtil.TRANSITION is falsy, this option has no effect. + animate: true, + + //Whether to animate adding markers after adding the MarkerClusterGroup to the map + // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains. + animateAddingMarkers: false, + + //Increase to increase the distance away that spiderfied markers appear from the center + spiderfyDistanceMultiplier: 1, + + // Make it possible to specify a polyline options on a spider leg + spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, + + // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts + chunkedLoading: false, + chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback) + chunkDelay: 50, // at the end of each interval, give n milliseconds back to system/browser + chunkProgress: null, // progress callback: function(processed, total, elapsed) (e.g. for a progress indicator) + + //Options to pass to the L.Polygon constructor + polygonOptions: {} + }); for (var specialcustomfieldpin in specialcustomfieldpins) { // skip loop if the property is from prototype @@ -963,34 +963,38 @@ document.addEventListener('DOMContentLoaded', function () { tempMarkercf.openPopup(); }); } - window['mymap' + moduleId].on("moveend", function (event) { - var bounds = event.target.getBounds(); + window['mymap' + moduleId].on("moveend", function (event) { + var bounds = event.target.getBounds(); for (var specialcustomfieldpin in specialcustomfieldpins) { - if(specialcustomfieldpins[specialcustomfieldpin].id){ + if (specialcustomfieldpins[specialcustomfieldpin].id) { var cords = L.latLng(specialcustomfieldpins[specialcustomfieldpin].cords.split(",").slice(0, 2)); - if (!bounds.contains(cords)) { - document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = true; - } else { - document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = false; + if (document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id)) { + if (!bounds.contains(cords)) { + document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = true; + } else { + document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = false; + } } } } }); - - window['mymap' + moduleId].on("zoomend", function (event) { - var bounds = event.target.getBounds(); + + window['mymap' + moduleId].on("zoomend", function (event) { + var bounds = event.target.getBounds(); for (var specialcustomfieldpin in specialcustomfieldpins) { - if(specialcustomfieldpins[specialcustomfieldpin].id){ + if (specialcustomfieldpins[specialcustomfieldpin].id) { var cords = L.latLng(specialcustomfieldpins[specialcustomfieldpin].cords.split(",").slice(0, 2)); - if (!bounds.contains(cords)) { - document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = true; - } else { - document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = false; + if (document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id)) { + if (!bounds.contains(cords)) { + document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = true; + } else { + document.querySelector('.agmarkerlistli' + specialcustomfieldpins[specialcustomfieldpin].id).hidden = false; + } } } } }); - + tempMarkercf.addTo(clustermarkers); } } @@ -1027,44 +1031,44 @@ document.addEventListener('DOMContentLoaded', function () { if (geojson === '1') { // Get Style Start - function areaStyle(feature){ + function areaStyle(feature) { return { fillColor: getAreaFill(feature), color: getAreaStroke(feature), weight: getAreaStrokeWidth(feature), opacity: getAreaStrokeOpacity(feature), fillOpacity: getAreaFillOpacity(feature) - } - }; - function getAreaFill(feature){ + } + }; + function getAreaFill(feature) { if (feature.properties.fill) { return feature.properties.fill; } else { return 'blue'; } }; - function getAreaStroke(feature){ + function getAreaStroke(feature) { if (feature.properties.stroke) { return feature.properties.stroke; } else { return 'blue'; } }; - function getAreaStrokeWidth(feature){ + function getAreaStrokeWidth(feature) { if (feature.properties["stroke-width"]) { return feature.properties["stroke-width"]; } else { return 2; } }; - function getAreaStrokeOpacity(feature){ + function getAreaStrokeOpacity(feature) { if (feature.properties["stroke-opacity"]) { return feature.properties["stroke-opacity"]; } else { return 1; } }; - function getAreaFillOpacity(feature){ + function getAreaFillOpacity(feature) { if (feature.properties["fill-opacity"]) { return feature.properties["fill-opacity"]; } else { @@ -1078,7 +1082,7 @@ document.addEventListener('DOMContentLoaded', function () { if (geojsonTextRaw === '{}') { console.log('No GeoJson Object'); } else { - L.geoJSON(geojsonText, {style: areaStyle}).addTo(window['mymap' + moduleId]); + L.geoJSON(geojsonText, { style: areaStyle }).addTo(window['mymap' + moduleId]); } } catch (e) { @@ -1102,7 +1106,7 @@ document.addEventListener('DOMContentLoaded', function () { if (geojsonTextRaw === '{}') { console.log('No GeoJson Object'); } else { - L.geoJSON(geojsonTextRaw, {style: areaStyle}).addTo(window['mymap' + moduleId]); + L.geoJSON(geojsonTextRaw, { style: areaStyle }).addTo(window['mymap' + moduleId]); } } catch (e) { diff --git a/src/media/mod_agosm/js/agosm_.js b/src/media/mod_agosm/js/agosm_.js new file mode 100644 index 00000000..a2d55756 --- /dev/null +++ b/src/media/mod_agosm/js/agosm_.js @@ -0,0 +1,1149 @@ +document.addEventListener('DOMContentLoaded', function () { + + var leafletmapsMod = document.querySelectorAll('.leafletmapMod'); + + [].forEach.call(leafletmapsMod, function (element) { + + var savestate = element.getAttribute('data-savestate'); + var fullscreen = element.getAttribute('data-fullscreen'); + var locate = element.getAttribute('data-locate'); + var mouseposition = element.getAttribute('data-mouseposition'); + + var geojson = element.getAttribute('data-geojson'); + var geojsonTextRaw = element.getAttribute('data-geojson-text'); + var geojsonText = JSON.parse(element.getAttribute('data-geojson-text')); + var geojsonfile = element.getAttribute('data-geojsonfile'); + var geojsonfilename = element.getAttribute('data-geojson-file'); + + var uriroot = element.getAttribute('data-uriroot'); + var scrollwheelzoom = element.getAttribute('data-scrollwheelzoom'); + var noWorldWarp = element.getAttribute('data-no-world-warp'); + var moduleId = element.getAttribute('data-module-id'); + var detectRetina = element.getAttribute('data-detect-retina'); + var baselayer = element.getAttribute('data-baselayer'); + var lonlat = element.getAttribute('data-lonlat').split(",", 3); + var zoom = element.getAttribute('data-zoom'); + var disableClusteringAtZoom = element.getAttribute('data-disable-clustering-at-zoom'); + var mapboxkey = element.getAttribute('data-mapboxkey'); + var thunderforestkey = element.getAttribute('data-thunderforestkey'); + var stamenmaptype = element.getAttribute('data-stamenmaptype'); + var thunderforestmaptype = element.getAttribute('data-thunderforestmaptype'); + var googlemapstype = element.getAttribute('data-googlemapstype'); + var mapboxmaptype = element.getAttribute('data-mapboxmaptype'); + var attrModule = element.getAttribute('data-attr-module'); + var customBaselayer = element.getAttribute('data-customBaselayer'); + var customBaselayerURL = element.getAttribute('data-customBaselayerURL'); + var scale = element.getAttribute('data-scale'); + var scaleMetric = element.getAttribute('data-scale-metric'); + var scaleImperial = element.getAttribute('data-scale-imperial'); + var showgeocoder = element.getAttribute('data-showgeocoder'); + var useesri = element.getAttribute('data-useesri'); + var esrireversegeocoding = element.getAttribute('data-esrireversegeocoding'); + var geocodercollapsed = (element.getAttribute('data-geocodercollapsed') === "true"); + var geocoderposition = element.getAttribute('data-geocoderposition'); + var expand = element.getAttribute('data-expand'); + var dataEsrigeocoderopengetaddress = (element.getAttribute('data-esrigeocoderopengetaddress') === "true"); + var showgeocoderesri = element.getAttribute('data-showgeocoderesri'); + var positionesrigeocoder = element.getAttribute('data-positionesrigeocoder'); + var esrigeocoderzoomToResult = (element.getAttribute('data-esrigeocoderzoomToResult') === "true"); + var esrigeocoderuseMapBounds = (element.getAttribute('data-esrigeocoderuseMapBounds') === "true"); + var esrigeocodercollapseAfterResult = (element.getAttribute('data-esrigeocodercollapseAfterResult') === "true"); + var esrigeocoderexpanded = (element.getAttribute('data-esrigeocoderexpanded') === "true"); + var esriallowMultipleResults = (element.getAttribute('data-esriallowMultipleResults') === "true"); + var showrouting_simple = element.getAttribute('data-showrouting-simple'); + + var addprivacybox = element.getAttribute('data-addprivacybox'); + var unique = element.getAttribute('data-unique'); + var buttons = document.getElementsByClassName('b' + unique); + var privacyfields = document.getElementsByClassName('p' + unique); + + if (showrouting_simple === '1') { + var routesimpleposition = element.getAttribute('data-route-simple-position'); + var routesimpletarget = element.getAttribute('data-route-simple-target'); + var routesimplerouter = element.getAttribute('data-route-simple-router'); + var routesimplerouterkey = element.getAttribute('data-route-simple-routerkey'); + } + var showrouting = element.getAttribute('data-showrouting'); + if (showrouting === '1') { + var routingstart = element.getAttribute('data-routingstart').split(",", 3); + var routingend = element.getAttribute('data-routingend').split(",", 3); + var mapboxkeyRouting = element.getAttribute('data-mapboxkey-routing'); + var routingprofile = element.getAttribute('data-routingprofile'); + var routinglanguage = element.getAttribute('data-routinglanguage'); + var routingmetric = element.getAttribute('data-routingmetric'); + var routewhiledragging = element.getAttribute('data-routewhiledragging'); + } + var showpin = element.getAttribute('data-showpin'); + if (showpin === '1') { + var specialpins = JSON.parse(element.getAttribute('data-specialpins')); + } + var showcomponentpin = element.getAttribute('data-showcomponentpin'); + if (showcomponentpin === '1') { + var specialcomponentpins = JSON.parse(element.getAttribute('data-specialcomponentpins')); + } + var showcomponentpinone = element.getAttribute('data-showcomponentpinone'); + if (showcomponentpinone === '1') { + var specialcomponentpinone = JSON.parse(element.getAttribute('data-specialcomponentpinone')); + } + + var showcustomfieldpin = element.getAttribute('data-showcustomfieldpin'); + if (showcustomfieldpin === '1') { + var specialcustomfieldpins = JSON.parse(element.getAttribute('data-specialcustomfieldpins')); + } + var touch = element.getAttribute('data-touch'); + var scroll = element.getAttribute('data-scroll'); + var scrollmac = element.getAttribute('data-scrollmac'); + var owngooglegesturetext = element.getAttribute('data-owngooglegesturetext'); + + // Fetch the States + if (JSON.parse(sessionStorage.getItem('mapState')) && savestate === "1") { + var mapState = JSON.parse(sessionStorage.getItem('mapState')); + zoom = mapState.zoom; + lonlat = mapState.center; + } + + // Default: worldCopyJump: false && scrollWheelZoom: true + if (noWorldWarp === "1" && scrollwheelzoom === "0") { + window['mymap' + moduleId] = new L.Map('map' + moduleId, { + scrollWheelZoom: false, + worldCopyJump: false, + maxBounds: [[82, -180], [-82, 180]] + }).setView(lonlat, zoom); + } else if (noWorldWarp === "1" && scrollwheelzoom === "1") { + window['mymap' + moduleId] = new L.Map('map' + moduleId, { + worldCopyJump: false, + maxBounds: [[82, -180], [-82, 180]] + }).setView(lonlat, zoom); + } else if (noWorldWarp === "1" && scrollwheelzoom === "2") { + if (owngooglegesturetext === "1") { + window['mymap' + moduleId] = new L.Map('map' + moduleId, { + worldCopyJump: false, + maxBounds: [[82, -180], [-82, 180]], + gestureHandling: true, + gestureHandlingText: { + touch: touch, + scroll: scroll, + scrollMac: scrollmac + } + }).setView(lonlat, zoom); + } else { + window['mymap' + moduleId] = new L.Map('map' + moduleId, { + worldCopyJump: false, + maxBounds: [[82, -180], [-82, 180]], + gestureHandling: true + }).setView(lonlat, zoom); + } + } else if (noWorldWarp === "0" && scrollwheelzoom === "0") { + window['mymap' + moduleId] = new L.Map('map' + moduleId, { + scrollWheelZoom: false, + worldCopyJump: true + }).setView(lonlat, zoom); + } else if (noWorldWarp === "0" && scrollwheelzoom === "2") { + if (owngooglegesturetext === "1") { + window['mymap' + moduleId] = new L.Map('map' + moduleId, { + worldCopyJump: true, + gestureHandling: true, + gestureHandlingText: { + touch: touch, + scroll: scroll, + scrollMac: scrollmac + } + }).setView(lonlat, zoom); + } else { + window['mymap' + moduleId] = new L.Map('map' + moduleId, { + worldCopyJump: true, + gestureHandling: true + }).setView(lonlat, zoom); + } + } else { + window['mymap' + moduleId] = new L.Map('map' + moduleId, { + worldCopyJump: true + }).setView(lonlat, zoom); + } + + // Privacy + if (localStorage.getItem("privacyState") === null) { + localStorage.setItem("privacyState", '0') + } + + var i; + for (i = 0; i < buttons.length; i++) { + if (localStorage.getItem("privacyState") === '0') { + buttons[i].innerHTML = Joomla.JText._('PLG_AGOSMSADDRESSMARKER_PRIVACYBUTTON_SHOW_MAP'); + privacyfields[i].innerHTML = Joomla.JText._('PLG_AGOSMSADDRESSMARKER_PRIVACYTEXT_SHOW_MAP'); + } else { + buttons[i].innerHTML = Joomla.JText._('PLG_AGOSMSADDRESSMARKER_PRIVACYBUTTON_HIDE_MAP'); + privacyfields[i].innerHTML = Joomla.JText._('PLG_AGOSMSADDRESSMARKER_PRIVACYTEXT_HIDE_MAP'); + } + buttons[i].onclick = function () { + if (localStorage.getItem("privacyState") === '0') { + document.getElementById('map' + moduleId).style.display = "block"; + localStorage.setItem("privacyState", '1'); + } else { + localStorage.setItem("privacyState", '0'); + } + window.location.reload(); + } + } + + if (addprivacybox === '1' && (localStorage.getItem("privacyState") === '0')) { + document.getElementById('map' + moduleId).style.display = "none"; + return; + } + + // Add Scrollwheele Listener, so that you can activate it on mouse click + if (scrollwheelzoom === "0") { + window['mymap' + moduleId].on('click', function () { + if (window['mymap' + moduleId].scrollWheelZoom.enabled()) { + window['mymap' + moduleId].scrollWheelZoom.disable(); + } else { + window['mymap' + moduleId].scrollWheelZoom.enable(); + } + }); + } + + // Baselayer + var nowarp = "noWrap: false, "; + if (noWorldWarp === "1") { + nowarp = "noWrap: true, "; + } + var detectRetina = "detectRetina: false, "; + if (detectRetina === "1") { + detectRetina = "detectRetina: true, "; + } + + // Base layer url + var astrid = ''; + if (attrModule === '1') { + astrid = ' ' + Joomla.JText._('MOD_AGOSM_MODULE_BY') + ' Astrid Günther'; + } + var tileLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + maxZoom: 18, + attribution: '© OpenStreetMap' + astrid + }); + if (baselayer === 'mapbox') { + tileLayer = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', { + attribution: '© Mapbox © OpenStreetMap Improve this map' + astrid, + tileSize: 512, + maxZoom: 18, + zoomOffset: -1, + id: mapboxmaptype, + accessToken: mapboxkey + }); + } + if (baselayer === 'mapnikde') { + tileLayer = L.tileLayer('https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', { + maxZoom: 18, + attribution: '© OpenStreetMap' + astrid + }); + } + if (baselayer === 'stamen') { + tileLayer = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/' + stamenmaptype + '/{z}/{x}/{y}.png', { + subdomains: 'abcd', minZoom: 1, maxZoom: 16, + attribution: 'Map data © OpenStreetMap contributors, ' + + 'CC-BY 3.0, ' + + 'Imagery © Stamen Design' + astrid, + id: '' + }); + } + if (baselayer === 'opentopomap') { + tileLayer = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', { + maxZoom: 16, + attribution: 'CC-BY 3.0, ' + + 'Imagery © SRTM' + astrid, + id: '' + }); + } + if (baselayer === 'humanitarian') { + tileLayer = L.tileLayer('https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', { + maxZoom: 20, + attribution: 'CC-BY 3.0, ' + + 'Imagery © Humanitarian OpenStreetMap Team' + astrid, + id: '' + }); + } + if (baselayer === 'custom') { + //tileLayer = L.tileLayer(customBaselayerURL, {customBaselayer}); + } + if (baselayer === 'google') { + tileLayer = L.gridLayer.googleMutant({ + type: googlemapstype, + attribution: astrid + }); + } + if (baselayer === 'thunderforest') { + tileLayer = L.tileLayer('https://{s}.tile.thunderforest.com/' + thunderforestmaptype + '/{z}/{x}/{y}.png?apikey={apikey}', { + maxZoom: 22, + apikey: thunderforestkey, + attribution: '© Thunderforest, © OpenStreetMap' + }); + } + + tileLayer.addTo(window['mymap' + moduleId]); + + // SCALE CONTROL + if ((scale) !== '0') { + let aggpxScale = L.control.scale(); + + if (scaleMetric !== '1') { + aggpxScale.options.metric = false; + } + + if (scaleImperial !== '1') { + aggpxScale.options.imperial = false; + } + + aggpxScale.addTo(window['mymap' + moduleId]); + + } + + // Add Geocoder + if (showgeocoder === "1") { + var osmGeocoder = new L.Control.Geocoder({ + collapsed: geocodercollapsed, + position: geocoderposition, + geocoder: new L.Control.Geocoder.Nominatim(), + expand: expand, + placeholder: Joomla.JText._('MOD_AGOSM_DEFAULT_TEXT_PLACEHOLDER'), + errorMessage: Joomla.JText._('MOD_AGOSM_DEFAULT_TEXT_ERRORMESSAGE') + }); + window['mymap' + moduleId].addControl(osmGeocoder); + } + + // Add ESRI Geocoder + if (useesri === "1") { + if (dataEsrigeocoderopengetaddress) { + function getURLParameter(name) { + var value = decodeURIComponent((RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [, ""])[1]); + return (value !== 'null') ? value : false; + } + var address = decodeURIComponent(getURLParameter('address')); + L.esri.Geocoding.geocode().text(address).run(function (err, result, response) { + if (typeof result !== 'undefined' && result.length > 0) { + L.marker(result.results[0].latlng).addTo(window['mymap' + moduleId]); + window['mymap' + moduleId].setView(result.results[0].latlng, 13); + } + }); + } + + + if (esrireversegeocoding === 'true') { + var r = L.marker(); + window['mymap' + moduleId].on('click', function (e) { + L.esri.Geocoding.reverseGeocode() + .latlng(e.latlng) + .run(function (error, result, response) { + r = L.marker(result.latlng).addTo(window['mymap' + moduleId]).bindPopup(result.address.Match_addr).openPopup(); + }); + }); + } + + if (showgeocoderesri === '1') { + var esriGeocoder = L.esri.Geocoding.geosearch({ + position: positionesrigeocoder, + zoomToResult: esrigeocoderzoomToResult, + useMapBounds: esrigeocoderuseMapBounds, + collapseAfterResult: esrigeocodercollapseAfterResult, + expanded: esrigeocoderexpanded, + allowMultipleResults: esriallowMultipleResults, + placeholder: Joomla.JText._('MOD_AGOSM_DEFAULT_ESRI_GEOCODER_PLACEHOLDER'), + title: Joomla.JText._('MOD_AGOSM_DEFAULT_ESRI_GEOCODER_TITLE') + }); + var results = L.layerGroup().addTo(window['mymap' + moduleId]); + esriGeocoder.on('results', function (data) { + results.clearLayers(); + for (var i = data.results.length - 1; i >= 0; i--) { + results.addLayer(L.marker(data.results[i].latlng)); + } + }); + window['mymap' + moduleId].addControl(esriGeocoder); + } + } + + // Add Routing Simple + if (showrouting_simple === '1') { + L.leafletControlRoutingtoaddress({ + position: routesimpleposition, + router: routesimplerouter, + token: routesimplerouterkey, + placeholder: Joomla.JText._('MOD_AGOSM_ROUTING_SIMPLE_TEXT_PLACEHOLDER'), + errormessage: Joomla.JText._('MOD_AGOSM_ROUTING_SIMPLE_TEXT_ERRORMESSAGE'), + distance: Joomla.JText._('MOD_AGOSM_ROUTING_SIMPLE_TEXT_DISTANCE'), + duration: Joomla.JText._('MOD_AGOSM_ROUTING_SIMPLE_TEXT_DURATION'), + kilometer: Joomla.JText._('MOD_AGOSM_ROUTING_SIMPLE_TEXT_KILOMETER'), + stunden: Joomla.JText._('MOD_AGOSM_ROUTING_SIMPLE_TEXT_STUNDEN'), + target: routesimpletarget, + addresserror: Joomla.JText._('MOD_AGOSM_ROUTING_SIMPLE_TEXT_ADDRESSERROR'), + requesterror: Joomla.JText._('MOD_AGOSM_ROUTING_SIMPLE_TEXT_REQUESTERROR') + }).addTo(window['mymap' + moduleId]); + + } + + // Add Routing Mapbox + if (showrouting === '1') { + function button(label, container) { + var btn = L.DomUtil.create('button', '', container); + btn.setAttribute('type', 'button'); + btn.innerHTML = label; + return btn; + } + + if (routingstart == '0,0' || routingend == '0,0') { + var control = L.Routing.control({ + geocoder: L.Control.Geocoder.nominatim({}), + collapsible: true, + show: false, + autoRoute: true, + router: L.Routing.mapbox(mapboxkeyRouting, + { + profile: routingprofile, + language: routinglanguage, + }), + units: routingmetric, + reverseWaypoints: true, + routeWhileDragging: routewhiledragging + }).addTo(window['mymap' + moduleId]); + } else { + var control = L.Routing.control({ + geocoder: L.Control.Geocoder.nominatim({}), + waypoints: [ + L.latLng(routingstart), + L.latLng(routingend) + ], + collapsible: true, + show: false, + autoRoute: true, + router: L.Routing.mapbox(mapboxkeyRouting, + { + profile: routingprofile, + language: routinglanguage, + }), + units: routingmetric, + reverseWaypoints: true, + routeWhileDragging: routewhiledragging + }).addTo(window['mymap' + moduleId]); + } + + (window['mymap' + moduleId]).on('click', function (e) { + var container = L.DomUtil.create('div'); + var startBtn = button('Start', container); + var destBtn = button('End', container); + L.DomEvent.on(startBtn, 'click', function () { + control.spliceWaypoints(0, 1, e.latlng); + (window['mymap' + moduleId]).closePopup(); + }); + L.DomEvent.on(destBtn, 'click', function () { + control.spliceWaypoints(control.getWaypoints().length - 1, 1, e.latlng); + (window['mymap' + moduleId]).closePopup(); + }); + L.popup().setContent(container).setLatLng(e.latlng).openOn(window['mymap' + moduleId]); + }); + } + + // Special Pins + if (showpin === '1') { + var index = 0; + for (var specialpin in specialpins) { + // skip loop if the property is from prototype + if (!specialpins.hasOwnProperty(specialpin)) + continue; + + var obj = specialpins[specialpin]; + let tempMarker = L.marker(obj.latlonpin.split(",", 3)); + + if (obj.pin === "2" && obj.customPinPath != "") { + var LeafIcon = L.Icon.extend({ + options: { + iconUrl: obj.customPinPath, + shadowUrl: obj.customPinShadowPath, + iconSize: obj.customPinSize.split(",", 3).map(function (e) { + return parseInt(e); + }), + shadowSize: obj.customPinShadowSize.split(",", 3).map(function (e) { + return parseInt(e); + }), + iconAnchor: obj.customPinOffset.split(",", 3).map(function (e) { + return parseInt(e); + }), + popupAnchor: obj.customPinPopupOffset.split(",", 3).map(function (e) { + return parseInt(e); + }) + } + }); + tempMarker.setIcon(new LeafIcon()); + } + + if (obj.pin === "3") { + var AwesomeIcon = new L.AwesomeMarkers.icon( + { + icon: obj.awesomeicon_icon, + markerColor: obj.awesomeicon_markercolor, + iconColor: obj.awesomeicon_iconcolor, + prefix: 'fa', + spin: (obj.awesomeicon_spin === "true"), + extraClasses: obj.awesomeicon_extraclasses, + }) + tempMarker.setIcon(AwesomeIcon); + } + + tempMarker.addTo(window['mymap' + moduleId]); + + if (obj.popup === "1") { + tempMarker.bindPopup(obj.popuptext.replace(/ 4 && objcf.type !== 'agosmsaddressmarker') { + var AwesomeIcon = new L.AwesomeMarkers.icon( + { + icon: values[4], + markerColor: values[2], + iconColor: values[3], + prefix: 'fa', + spin: false, + extraClasses: "agosmsmarkerextraklasse", + }) + tempMarkercf.setIcon(AwesomeIcon); + } + + if (objcf.type === 'agosmsaddressmarker' && objcf.iconcolor && objcf.markercolor && objcf.icon) { + var AwesomeIcon = new L.AwesomeMarkers.icon( + { + icon: objcf.icon, + markerColor: objcf.markercolor, + iconColor: objcf.iconcolor, + prefix: 'fa', + spin: false, + extraClasses: "agosmsaddressmarkerextraklasse", + }) + tempMarkercf.setIcon(AwesomeIcon); + } + + let url = "index.php?option=com_content&view=article&id=" + objcf.id; + let title = objcf.title; + + if (values.length > 5 && values[5].trim() != '') { + title = values[5]; + } + + let popuptext = " " + title + " "; + tempMarkercf.bindPopup(popuptext.replace(/ { + geojsonTextRaw = response; + + try { + if (geojsonTextRaw === '{}') { + console.log('No GeoJson Object'); + } else { + L.geoJSON(geojsonTextRaw, {style: areaStyle}).addTo(window['mymap' + moduleId]); + } + } + catch (e) { + console.log('GeoJsonError: ' + geojsonTextRaw); + } + }); + } + } + + // Save the state + if (savestate === "1") { + window['mymap' + moduleId].on('zoom', function (ev) { + var center = window['mymap' + moduleId].getCenter(); + var bounds = window['mymap' + moduleId].getBounds(); + var mapState = { + zoom: window['mymap' + moduleId].getZoom(), + center: [center.lat, center.lng], + bounds: [ + [bounds.getNorth(), bounds.getWest()], + [bounds.getSouth(), bounds.getEast()] + ], + }; + sessionStorage.setItem('mapState', JSON.stringify(mapState)); + }); + } + + if (savestate === "1") { + window['mymap' + moduleId].on('move', function (ev) { + var center = window['mymap' + moduleId].getCenter(); + var bounds = window['mymap' + moduleId].getBounds(); + var mapState = { + zoom: window['mymap' + moduleId].getZoom(), + center: [center.lat, center.lng], + bounds: [ + [bounds.getNorth(), bounds.getWest()], + [bounds.getSouth(), bounds.getEast()] + ], + }; + sessionStorage.setItem('mapState', JSON.stringify(mapState)); + }); + } + }) +}, false); + diff --git a/vscode/vscode/launch.json b/vscode/vscode/launch.json new file mode 100644 index 00000000..caeb66bc --- /dev/null +++ b/vscode/vscode/launch.json @@ -0,0 +1,51 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Listen for Xdebug", + "type": "php", + "request": "launch", + "pathMappings": { + "/var/www/html/agosmsj4dev" : "/home/astrid/ag-joomla-docker/data/www/web1/agosmsj4dev", + }, + "port": 9003 + }, + { + "name": "Launch currently open script", + "type": "php", + "request": "launch", + "program": "${file}", + "cwd": "${fileDirname}", + "port": 0, + "runtimeArgs": [ + "-dxdebug.start_with_request=yes" + ], + "env": { + "XDEBUG_MODE": "debug,develop", + "XDEBUG_CONFIG": "client_port=${port}" + } + }, + { + "name": "Launch Built-in web server", + "type": "php", + "request": "launch", + "runtimeArgs": [ + "-dxdebug.mode=debug", + "-dxdebug.start_with_request=yes", + "-S", + "localhost:0" + ], + "program": "", + "cwd": "${workspaceRoot}", + "port": 9003, + "serverReadyAction": { + "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started", + "uriFormat": "http://localhost:%s", + "action": "openExternally" + } + } + ] +} \ No newline at end of file