Skip to content

Commit

Permalink
Merge pull request #23 from hr-it-solutions/dev
Browse files Browse the repository at this point in the history
Release v1.1.1.4
  • Loading branch information
HRIT-Florian authored Sep 8, 2017
2 parents 3882e8f + 192c5eb commit abcdf87
Show file tree
Hide file tree
Showing 12 changed files with 324 additions and 44 deletions.
14 changes: 2 additions & 12 deletions fields/country.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,11 @@ public function getOptions()
$countries = $obj->extension->countries->country;
}

// Default field
$options[0] = new StdClass;
$options[0]->value = 0;
$options[0]->text = JText::_('MOD_DD_GMAPS_MODULE_COUNTRY_SELECT');

$i = 1;

foreach ($countries as $country)
{
$options[$i] = new StdClass;
$options[$i]->value = 'MOD_DD_GMAPS_MODULE_COUNTRY_NAME_' . $country->name;
$options[$i]->text = JText::_('MOD_DD_GMAPS_MODULE_COUNTRY_NAME_' . $country->name);
++$i;
$options[] = JHtml::_('select.option', 'MOD_DD_GMAPS_MODULE_COUNTRY_NAME_' . $country->name, JText::_('MOD_DD_GMAPS_MODULE_COUNTRY_NAME_' . $country->name));
}

return $options;
return array_merge(parent::getOptions(), $options);
}
}
57 changes: 57 additions & 0 deletions fields/extcplugins.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* @package DD_GMaps_Module
*
* @author HR IT-Solutions Florian Häusler <[email protected]>
* @copyright Copyright (C) 2017 - 2017 Didldu e.K. | HR IT-Solutions
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
**/

defined('_JEXEC') or die('Restricted access');

JFormHelper::loadFieldClass('list');

jimport('joomla.application.categories');

class JFormFieldExtCPlugins extends JFormFieldList {

protected $type = 'ExtCPlugins';

/**
* Get Options
*
* @return array
*
* @since Version 1.0.0.0
*/
public function getOptions()
{
$categories = JCategories::getInstance('DD_GMaps_Locations');
$subCategories = $categories->get()->getChildren(true);

// Default field
$options[0] = new StdClass;
$options[0]->value = 0;
$options[0]->text = JText::_('MOD_DD_GMAPS_MODULE_ADDON_DDGMAPS_LOCATIONS_EXTCID_SELECT');

$i = 1;

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->qn('element'))
->from($db->qn('#__extensions'))
->where($db->qn('folder') . ' = ' . $db->quote('dd_gmaps_locations'))
->where($db->qn('element') . ' LIKE ' . $db->quote('dd_ext_c_%'));
$db->setQuery($query);
$rows = $db->loadObjectList();

foreach( $rows as $row ) {
$options[$i] = new StdClass;
$options[$i]->value = 'com_' . trim($row->element, 'dd_ext_c_');
$options[$i]->text = strtoupper(trim($row->element, 'dd_ext_c_')) . ' Component';
++$i;
}

return $options;
}
}
54 changes: 54 additions & 0 deletions fields/locationcategory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* @package DD_GMaps_Module
*
* @author HR IT-Solutions Florian Häusler <[email protected]>
* @copyright Copyright (C) 2017 - 2017 Didldu e.K. | HR IT-Solutions
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
**/

defined('_JEXEC') or die('Restricted access');

JFormHelper::loadFieldClass('list');

jimport('joomla.application.categories');

class JFormFieldLocationCategory extends JFormFieldList {

protected $type = 'LocationCategory';

/**
* Get Options
*
* @return array
*
* @since Version 1.0.0.0
*/
public function getOptions()
{
$categories = JCategories::getInstance('DD_GMaps_Locations');
$subCategories = $categories->get()->getChildren(true);

// Default field
$options[0] = new StdClass;
$options[0]->value = 0;
$options[0]->text = JText::_('JOPTION_SELECT_CATEGORY');

$i = 1;

// If DD GMaps Locations
if (file_exists(JPATH_ADMINISTRATOR . '/components/com_dd_gmaps_locations/dd_gmaps_locations.php')
&& JComponentHelper::getComponent('com_dd_gmaps_locations', true)->enabled)
{
foreach ($subCategories as $category)
{
$options[$i] = new StdClass;
$options[$i]->value = $category->id;
$options[$i]->text = $category->title;
++$i;
}
}

return $options;
}
}
108 changes: 99 additions & 9 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

defined('_JEXEC') or die;

$checkMultiload_DD_GMaps_Module = true;

/**
* Helper for mod_dd_gmaps_module
*
Expand All @@ -20,6 +18,20 @@ class ModDD_GMaps_Module_Helper
{
protected $params;

protected static $loaded = null;

public static function isloaded()
{
if (is_null(self::$loaded))
{
self::$loaded = true;

return false;
}

return true;
}

/**
* existsDDGMapsLocations
*
Expand Down Expand Up @@ -108,9 +120,44 @@ protected function getDDGMapsLocatiosItems()

$db = JFactory::getDbo();
$query = $model->getListQuery();

$jinput = JFactory::getApplication()->input;

$module = JModuleHelper::getModule('mod_dd_gmaps_module');
$params = new JRegistry($module->params);

// Load only locationcategory items outside of com_dd_gmaps_locations view locations
if ($jinput->get('option') !== 'com_dd_gmaps_locations') // Important case to not break locations association
{
if ($params->get('locationcategory') !== 0)
{
$query->where($db->quoteName('catid') . '= ' . (int) $params->get('locationcategory'));
}
}

$db->setQuery($query);

return $db->loadObjectList();
$results = $db->loadObjectList();

// Extc Plugins
if ($params->get('extcplugins') !== '0')
{
// Get param, expected 'com_k2' etc...
$extc_plugin = $params->get('extcplugins');

JPluginHelper::importPlugin('dd_gmaps_locations');
$dispatcher = JEventDispatcher::getInstance();
$plg_results = $dispatcher->trigger('onextc', array(&$results, &$extc_plugin))[0];

if (!empty($plg_results))
{
// Prepear plg_results in loop
$results = $plg_results;
}
}

return $results;

}

/**
Expand Down Expand Up @@ -143,9 +190,30 @@ protected function getItem()
$return[0]->latitude = $params->get('latitude', '48.0000000');
$return[0]->longitude = $params->get('longitude', '2.0000000');

// If geoCode plugin is not enabled, geCode addresses on the fly without saving!
if (!JPluginHelper::getPlugin('system', 'dd_gmaps_locations_geocode'))
// Try to get geoCode HardCoding
if (($params->get('geohardcode') !== '0'))
{
if ($this->validateLatLong($params->get('latitude_hardcode'), $params->get('longitude_hardcode')))
{
$return[0]->latitude = $params->get('latitude_hardcode');
$return[0]->longitude = $params->get('longitude_hardcode');
}
else
{
JFactory::getApplication()->enqueueMessage(
JText::_('MOD_DD_GMAPS_MODULE_API_ALERT_GEOLOCATION_FAILED_ZERO_RESULTS_HARDCODE'),
'warning'
);
goto fallbackGeoCode;
}
}

// If geoCode plugin is not enabled and geoCode HardCoding ist not enabled,
// geCode addresses on the fly without saving!
if (!JPluginHelper::getPlugin('system', 'dd_gmaps_locations_geocode')
&& $params->get('geohardcode') !== '1' )
{
fallbackGeoCode:
// Get latitude and longitude
$latlng = $this->Geocode_Location_To_LatLng($return, $params->get('google_api_key_geocode'));
$return[0]->latitude = $latlng['latitude'];
Expand All @@ -155,6 +223,22 @@ protected function getItem()
return $return;
}

/**
* Validates coordinate
* Adapted from https://gist.github.com/arubacao/b5683b1dab4e4a47ee18fd55d9efbdd1
*
* @param float $lat Latitude
* @param float $long Longitude
*
* @return bool `true` if the coordinate is valid, `false` if not
*/
private function validateLatLong($lat, $long)
{
$latlong = preg_replace("/[^0-9,.]/", "", $lat . ',' . $long);

return preg_match('/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?),[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/', $latlong);
}

/**
* Get latitude and longitude by address from Google GeoCode API
*
Expand Down Expand Up @@ -254,12 +338,18 @@ public function paramLatLong($params)
{
if ($params->get('set_as_default_position'))
{
if (($params->get('geohardcode') !== '0'))
{
if ($this->validateLatLong($params->get('latitude_hardcode'), $params->get('longitude_hardcode')))
{
return (float) $params->get('latitude_hardcode') . ', ' . (float) $params->get('longitude_hardcode');
}
}

return (float) $params->get('latitude') . ', ' . (float) $params->get('longitude');
}
else
{
return '48.0000000, 2.0000000';
}

return '48.0000000, 2.0000000';
}

/**
Expand Down
22 changes: 12 additions & 10 deletions inc/scriptheader.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,21 @@ function Sanitize_output($buffer)
settingsZoomLevel = <?php echo (int) $params->get('zoomlevel') ?>,
GMapsLocations = [
<?php
$location_index = 0;

foreach ( $items as $i => $item ):
$title = htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8');

if ($location_index == 0 && $params->get('extended_location') && !$params->get('only_extended_locations'))
{
$title = htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8');
}
elseif ($isDDGMapsLocationsExtended || $extended_location)
if (($isDDGMapsLocationsExtended || $extended_location) && $item->id != 0)
{
$title_link = JRoute::_('index.php?option=com_dd_gmaps_locations&view=profile&id=' . (int) $item->id . ':' . htmlspecialchars($item->alias, ENT_QUOTES, 'UTF-8'));
if (isset($item->ext_c_id) && $item->ext_c_id !== '0' && isset($item->extc_link))
{
// Ext C 3rd Party Links
$title_link = JRoute::_($item->extc_link);
}
else
{
$title_link = JRoute::_('index.php?option=com_dd_gmaps_locations&view=profile&id=' . (int) $item->id . ':' . htmlspecialchars($item->alias, ENT_QUOTES, 'UTF-8'));
}

$title = '<a href="' . $title_link . '">' . $title . '</a>';
}

Expand Down Expand Up @@ -103,7 +106,6 @@ function Sanitize_output($buffer)
},
content: '<?php echo '<span class="info-content">' . $title . '<br>' . htmlspecialchars($item->street, ENT_QUOTES, 'UTF-8') . '<br>' . htmlspecialchars($item->location, ENT_QUOTES, 'UTF-8') . '</span>'; ?>'
},<?php
$location_index = $i;
endforeach; ?>
];
<?php // Initialize Map ?>
Expand All @@ -123,7 +125,7 @@ function Sanitize_output($buffer)
echo "launchLocateInfoWindow($lat,$lng,'$content',$zoom,'$markertitle','$markericon');";
}

if ($input->get('profile_id') != 0 || $location_index == 0)
if ($input->get('profile_id') != 0)
{
echo 'setTimeout(function(){
var profileObj = jQuery.grep(GMapsLocations, function(e){ return e.id == ' . $input->get('profile_id', 0) . '; });
Expand Down
17 changes: 15 additions & 2 deletions language/de-DE/de-DE.mod_dd_gmaps_module.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ MOD_DD_GMAPS_MODULE_LATITUDE_DESC="Die Koordinaten (Breitengrad) für die GeoCod
MOD_DD_GMAPS_MODULE_LONGITUDE_LABEL="Längengrad"
MOD_DD_GMAPS_MODULE_LONGITUDE_DESC="Die Koordinaten (Längengrad) für die GeoCoding Google API, wird nach dem Speichern befüllt. Koordinaten können nicht bearbeitet werden."

MOD_DD_GMAPS_MODULE_GEOHARDCODE="<hr style='margin-top: 60px'><p class='alert alert-warning' style='margin-bottom: -10px'><span class='icon-location'></span>GeoCoding Harte Codierung!</p>"
MOD_DD_GMAPS_MODULE_GEOHARDCODE_LABEL="GeoCoding Harte Codierung: (Experimentell)"
MOD_DD_GMAPS_MODULE_GEOHARDCODE_DESC="Diese Einstellung überschreibt die aus der Adresse automatisch generierten Standortdaten!""Enable GeoCoding Hard Coding: (Experimental)"

MOD_DD_GMAPS_MODULE_MAPS_PRELOADER="Karte wird geladen ..."

MOD_DD_GMAPS_MODULE_WARNING_GEOCODE_PLUGIN_MUST_BE_ENABLED="Das System-Plugin (DD GMaps Locations GeoCode) muss für die Geokodierung installiert und aktiviert sein!"
Expand All @@ -54,6 +58,7 @@ MOD_DD_GMAPS_MODULE_API_KEY_GEOCODE_LABEL="Google Geocode API Key"
MOD_DD_GMAPS_MODULE_API_KEY_GEOCODE_DESC="Google Geocode API Key (Schlüssel) für Geocode API"

MOD_DD_GMAPS_MODULE_API_ALERT_GEOLOCATION_FAILED_ZERO_RESULTS="Die Standortbestimmung ist fehlgeschlagen! Bitte überprüfen Sie die "_QQ_"GEO Addresse"__QQ" (Standort Adress-Daten). Meist liegt dies an falschen Adress-Informationen wie (Straße, PLZ, Ort, Land)."
MOD_DD_GMAPS_MODULE_API_ALERT_GEOLOCATION_FAILED_ZERO_RESULTS_HARDCODE="Die Standortbestimmung ist fehlgeschlagen! Bitte überprüfen Sie die "_QQ_"GEO Addresse"_QQ_" HardCode GeoData oder deaktiviere Geo HarteCodierung. Backend Module > DD GMaps Module > Standard Addresse > HardCoding Einstellung (deaktivieren)."

MOD_DD_GMAPS_MODULE_API_KEY_REQUIRED_COMPONENT="Google Places API Key erforderlich! Bitte geben Sie im Backend unter Komponenten > DD GMaps Locations > Optionen > Google API Einstellungen > Ihren Google API Key (Schlüssel) ein."
MOD_DD_GMAPS_MODULE_API_KEY_REQUIRED="Google Places API Key erforderlich! Bitte geben Sie im Backend unter Module > DD GMaps Module > Google API Einstellungen > Ihren Google API Key (Schlüssel) ein."
Expand All @@ -67,11 +72,19 @@ MOD_DD_GMAPS_MODULE_CLUSTERMARKER_IMAGE_DESC="Cluster Marker Bild (max. Größe

MOD_DD_GMAPS_MODULE_ADDONFEATURES_LABEL="Addon Funktionen"
MOD_DD_GMAPS_MODULE_ADDONFEATURES_DESC="Erweiterte Erweiterung. DD GMaps Locations Komponente erforderlich."
MOD_DD_GMAPS_MODULE_ADDON_DDGMAPS_LOCATIONS="<b><hr>Addon Funktionen für DD GMaps Location</b>:"
MOD_DD_GMAPS_MODULE_ADDON_DDGMAPS_LOCATIONS="<b>Addon Funktionen für DD GMaps Location</b>:"
MOD_DD_GMAPS_MODULE_EXTENDED_LOCATION_LABEL="Erweiterte Standorte"
MOD_DD_GMAPS_MODULE_EXTENDED_LOCATION_DESC="DD GMaps Locations Komponente erforderlich. Damit können alle Standorte aus der Komponente zusammen mit dem einzelnen Standort geladen werden."
MOD_DD_GMAPS_MODULE_ONLY_EXTENDED_LOCATIONS_LABEL="Nur erweiterte Standorte"
MOD_DD_GMAPS_MODULE_ONLY_EXTENDED_LOCATIONS_DESC="Zeigen Sie nur die Komponentenstandorte ohne den einzelnen Standort aus diesem Modul und ohne den einzelnen Standort PopUp (Info-Fenster)."
MOD_DD_GMAPS_MODULE_ONLY_EXTENDED_LOCATIONS_DESC="Zeige nur Komponentenstandorte ohne den einzelnen Standort aus diesem Modul und ohne den einzelnen Standort PopUp (Info-Fenster)."
MOD_DD_GMAPS_MODULE_ONLY_LOCATION_CATEGORY_LABEL="Standalone: Nur Standorte von Kategorie"
MOD_DD_GMAPS_MODULE_ONLY_LOCATION_CATEGORY_DESC="Zeige nur Standorte, welche der ausgewählten Kategorie zugeordnet sind. Notiz: Dieses feature läuft nur ausserhalb von com_dd_gmaps_locations, sprich als alleinstehendes Modul!"

MOD_DD_GMAPS_MODULE_ADDON_DDGMAPS_LOCATIONS_EXTCID="<hr><p class='alert alert-info'>3rd Party erweiterte Erweiterung. (DD_GMaps_Locations_ext_c) System Plugin(s) erforderlich.<br><b>Note:</b> Dies erforder die DD GMaps Locations Komponent und ein DD_GMaps_Locations_ext_c System Plugin!</p><b>Addon Funktionen für DD GMaps Location in Kombination mit...:</b>:"
MOD_DD_GMAPS_MODULE_ADDON_DDGMAPS_LOCATIONS_EXTCID_SELECT="- DD Ext_C_Plugin wählen -"
MOD_DD_GMAPS_MODULE_ONLY_LOCATION_EXTCID_LABEL="Ext_C_ID: Verbunden mit:"
MOD_DD_GMAPS_MODULE_ONLY_LOCATION_EXTCID_DESC="Wählen Sie die 3rd Party Extension aus, die mit der Location Ext_C_ID verbunden werden soll. Note: Die location/marker sind dann über die ext_c_id verlinkt mit der ausgewählten Drittanbieter Erweiterung auf deren component view item id, anstatt mit der dd_gmaps_locations Standortdetail Seite. Und nur, falls die ext_c_id unter dem standorteintrag gesetzt wurde. Falls keine ext_c_id beim dd_gmaps_locations Standort gesetzt ist, wird die location zur normalen dd_gmaps_locations Standortseite verlinkt."
MOD_DD_GMAPS_MODULE_ADDON_DDGMAPS_LOCATIONS_EXTCID_NOTE="<p class='alert alert-warning'>Final wird dadurch die Location mit dessen Standort Daten auf die jeweiligen Drittanbieter Extension Einträge verlinkt.<br><br>Die benötigten Plugins sind nicht Bestandteil der Hauptkomponente DD GMaps Locations.<br>Für mehr Informationen, siehe: <a href='index.php?option=com_config&view=component&component=com_dd_gmaps_locations' target='_blank'><span class='icon-new-tab-2'></span>DD Gmaps Locations Options</a> / unter 3rd Party Einstellungen.</p>"

MOD_DD_GMAPS_MODULE_YOUR_LOCATION="Ihr Standort"
MOD_DD_GMAPS_MODULE_YOUR_LATITUDE="Breitengrad"
Expand Down
Loading

0 comments on commit abcdf87

Please sign in to comment.