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 .= '';
- }
-
- // Clear agosm button
- if ($allowClear) {
- $html .= '';
- }
-
- 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 @@
-