Remove Google geolocation service
This commit is contained in:
@@ -27,7 +27,6 @@ namespace EP\EpProducts\Hook;
|
|||||||
* This copyright notice MUST APPEAR in all copies of the script!
|
* This copyright notice MUST APPEAR in all copies of the script!
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
|
|
||||||
use EP\EpProducts\Service\GeolocationService;
|
|
||||||
use EP\EpProducts\Utility\DbUtility;
|
use EP\EpProducts\Utility\DbUtility;
|
||||||
use TYPO3\CMS\Core\DataHandling\DataHandler;
|
use TYPO3\CMS\Core\DataHandling\DataHandler;
|
||||||
use TYPO3\CMS\Core\Messaging\FlashMessage;
|
use TYPO3\CMS\Core\Messaging\FlashMessage;
|
||||||
@@ -55,16 +54,6 @@ class Tcemain
|
|||||||
*/
|
*/
|
||||||
public function processDatamap_preProcessFieldArray(array &$fields, $table, $id, DataHandler $obj)
|
public function processDatamap_preProcessFieldArray(array &$fields, $table, $id, DataHandler $obj)
|
||||||
{
|
{
|
||||||
if ($fields['name'] !== '' && $fields['latitude'] === '' && $fields['longitude'] === '' && in_array($table, $this->tables)) {
|
|
||||||
$coordinates = GeolocationService::getCoordinates($fields['name']);
|
|
||||||
$fields['latitude'] = $coordinates['latitude'];
|
|
||||||
$fields['longitude'] = $coordinates['longitude'];
|
|
||||||
}
|
|
||||||
if ($table === 'tx_epproducts_domain_model_hotel' && $fields['address'] !== ''&& $fields['latitude'] === '' && $fields['longitude'] === '') {
|
|
||||||
$coordinates = GeolocationService::getCoordinates($fields['address']);
|
|
||||||
$fields['latitude'] = $coordinates['latitude'];
|
|
||||||
$fields['longitude'] = $coordinates['longitude'];
|
|
||||||
}
|
|
||||||
// Render flash message in case of duplicate entry
|
// Render flash message in case of duplicate entry
|
||||||
if ($table === 'tx_epproducts_domain_model_matchcode' && $fields['code'] !== '') {
|
if ($table === 'tx_epproducts_domain_model_matchcode' && $fields['code'] !== '') {
|
||||||
$code = $fields['code'];
|
$code = $fields['code'];
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace EP\EpProducts\Service;
|
|
||||||
|
|
||||||
/***************************************************************
|
|
||||||
*
|
|
||||||
* Copyright notice
|
|
||||||
*
|
|
||||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
|
||||||
*
|
|
||||||
* All rights reserved
|
|
||||||
*
|
|
||||||
* This script is part of the TYPO3 project. The TYPO3 project is
|
|
||||||
* free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* The GNU General Public License can be found at
|
|
||||||
* http://www.gnu.org/copyleft/gpl.html.
|
|
||||||
*
|
|
||||||
* This script is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* This copyright notice MUST APPEAR in all copies of the script!
|
|
||||||
***************************************************************/
|
|
||||||
|
|
||||||
class GeolocationService
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $place
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function getCoordinates($place)
|
|
||||||
{
|
|
||||||
$coordinates = [];
|
|
||||||
$apiUrl = urlencode('http://maps.googleapis.com/maps/api/geocode/xml?address=' . $place);
|
|
||||||
$result = @simplexml_load_file($apiUrl);
|
|
||||||
if ($result !== false) {
|
|
||||||
$coordinates['latitude'] = (string) $result->result->geometry->location->lat;
|
|
||||||
$coordinates['longitude'] = (string) $result->result->geometry->location->lng;
|
|
||||||
}
|
|
||||||
return $coordinates;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user