[TASK] Merge changes from work for westfalia 88/35288/2 master
authorSebastian Fischer <typo3@evoweb.de>
Thu, 11 Dec 2014 10:21:53 +0000 (11:21 +0100)
committerSebastian Fischer <typo3@evoweb.de>
Thu, 19 Feb 2015 06:52:28 +0000 (07:52 +0100)
Change-Id: Iec1f84a250fc39d344f7afe72897308a5e049ecf
Reviewed-on: http://review.typo3.org/35288
Reviewed-by: Sebastian Fischer <typo3@evoweb.de>
Tested-by: Sebastian Fischer <typo3@evoweb.de>
22 files changed:
Classes/Cache/CoordinatesCache.php
Classes/Controller/MapController.php
Classes/Domain/Model/Constraint.php
Classes/Domain/Model/Location.php
Classes/Domain/Repository/CountryRepository.php
Classes/Domain/Repository/LocationRepository.php
Classes/Service/GeocodeService.php
Classes/Task/GeocodeLocationsTask.php [new file with mode: 0644]
Classes/Utility/UpdateUtility.php
Classes/Validation/Validator/ConstraintValidator.php
Classes/Validation/Validator/RequiredValidator.php
Classes/Validation/ValidatorResolver.php
Classes/ViewHelpers/Form/SelectCountriesViewHelper.php
Configuration/TCA/tx_storefinder_domain_model_location.php
Configuration/TypoScript/setup.txt
Resources/Private/Language/de.locallang.xlf [new file with mode: 0644]
Resources/Private/Language/locallang_be.xml
Resources/Private/Language/locallang_db.xml
Resources/Private/Partials/Map.html
Resources/Public/JavaScript/map.js
ext_localconf.php
ext_tables.sql

index 9a18989..b4c1db5 100644 (file)
@@ -116,8 +116,8 @@ class CoordinatesCache {
                                }
 
                                if (is_array($coordinate)) {
-                                       $address->getLatitude($coordinate['latitude']);
-                                       $address->getLongitude($coordinate['longitude']);
+                                       $address->setLatitude($coordinate['latitude']);
+                                       $address->setLongitude($coordinate['longitude']);
                                        break;
                                }
                        }
@@ -152,9 +152,8 @@ class CoordinatesCache {
        }
 
        /**
-        * Flush both caches
+        * Flush both sql table and session caches
         *
-        * @throws \TYPO3\CMS\Core\Exception
         * @return void
         */
        public function flushCache() {
index cca9102..8ab206c 100644 (file)
@@ -68,6 +68,7 @@ class MapController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
                }
 
                $this->settings['allowedCountries'] = explode(',', $this->settings['allowedCountries']);
+               $this->geocodeService->setSettings($this->settings);
                $this->locationRepository->setSettings($this->settings);
        }
 
@@ -85,31 +86,58 @@ class MapController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
 
                if ($search !== NULL) {
                        $search = $this->geocodeService->geocodeAddress($search);
-                       $locations = $this->locationRepository->findByConstraint($search);
 
                        $center = $this->getCenter($search);
                        $center = $this->setZoomLevel($center, $search);
+                       $this->view->assign('center', $center);
 
                        $afterSearch = 1;
 
-                       $this->view->assign('center', $center);
-                       $this->view->assign('numberOfLocations', is_array($locations) ? count($locations) : $locations->count());
+                       $locations = $this->locationRepository->findByConstraint($search);
+                       // manual rewind needed because fluid doesnt do it
+                       $locations->rewind();
+                       $this->view->assign('numberOfLocations', $locations->count());
                        $this->view->assign('locations', $locations);
                } elseif ($this->settings['singleLocationId']) {
-                       $location = $this->locationRepository->findByUid($this->settings['singleLocationId']);
-
+                       /** @var Model\Constraint $search */
                        $search = $this->objectManager->get('Evoweb\\StoreFinder\\Domain\\Model\\Constraint');
 
+                       $center = $this->getCenter($search);
+                       $center = $this->setZoomLevel($center, $search);
+                       $this->view->assign('center', $center);
+
+                       $location = $this->locationRepository->findByUid($this->settings['singleLocationId']);
                        $this->view->assign('numberOfLocations', is_object($location) ? 1 : 0);
                        $this->view->assign('locations', array($location));
                } else {
+                       /** @var Model\Constraint $search */
                        $search = $this->objectManager->get('Evoweb\\StoreFinder\\Domain\\Model\\Constraint');
+
+                       if ($this->settings['showBeforeSearch'] & 2 && is_array($this->settings['defaultConstraint'])) {
+                               $search = $this->addDefaultConstraint($search);
+                               $search = $this->geocodeService->geocodeAddress($search);
+
+                               $center = $this->getCenter($search);
+                               $center = $this->setZoomLevel($center, $search);
+                               $this->view->assign('center', $center);
+
+                               if ($this->settings['showLocationsForDefaultConstraint']) {
+                                       $locations = $this->locationRepository->findByConstraint($search);
+                                       // manual rewind needed because fluid doesnt do it
+                                       $locations->rewind();
+                                       $this->view->assign('numberOfLocations', $locations->count());
+                                       $this->view->assign('locations', $locations);
+                               }
+                       }
                }
 
                $this->addCategoryFilterToView();
                $this->view->assign('afterSearch', $afterSearch);
                $this->view->assign('search', $search);
-               $this->view->assign('static_info_tables', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables') ? 1 : 0);
+               $this->view->assign(
+                       'static_info_tables',
+                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables') ? 1 : 0
+               );
        }
 
 
@@ -176,7 +204,7 @@ class MapController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
                if ($constraint !== NULL) {
                        if ($constraint->getLatitude() && $constraint->getLongitude()) {
                                /** @var Model\Location $center */
-                               $center = $this->objectManager->get('Evoweb\StoreFinder\Domain\Model\Location');
+                               $center = $this->objectManager->get('Evoweb\\StoreFinder\\Domain\\Model\\Location');
                                $center->setLatitude($constraint->getLatitude());
                                $center->setLongitude($constraint->getLongitude());
                        } else {
@@ -225,4 +253,21 @@ class MapController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
                $location->setZoom(18 - $zoom);
                return $location;
        }
+
+       /**
+        * @param Model\Constraint $search
+        * @return Model\Constraint
+        */
+       private function addDefaultConstraint($search) {
+               $defaultConstraint = $this->settings['defaultConstraint'];
+
+               foreach ($defaultConstraint as $property => $value) {
+                       $setter = 'set' . ucfirst($property);
+                       if (method_exists($search, $setter)) {
+                               $search->{$setter}($value);
+                       }
+               }
+
+               return $search;
+       }
 }
\ No newline at end of file
index dee73a6..291fa65 100644 (file)
@@ -329,7 +329,7 @@ class Constraint extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
         * @return integer
         */
        public function getZoom() {
-               return $this->zoom;
+               return (int)$this->zoom;
        }
 
        /**
index 7948249..b9102fc 100644 (file)
@@ -723,7 +723,7 @@ class Location extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
         * @return integer
         */
        public function getZoom() {
-               return $this->zoom;
+               return (int)$this->zoom;
        }
 
        /**
index a8598fa..d8b0018 100644 (file)
@@ -38,7 +38,10 @@ class CountryRepository extends \SJBR\StaticInfoTables\Domain\Repository\Country
 
                $nsSeparator = strpos($this->getRepositoryClassName(), '\\') !== FALSE ? '\\\\' : '_';
                $this->objectType = preg_replace(
-                       array('/' . $nsSeparator . 'Repository' . $nsSeparator . '(?!.*' . $nsSeparator . 'Repository' . $nsSeparator . ')/', '/Repository$/'),
+                       array(
+                               '/' . $nsSeparator . 'Repository' . $nsSeparator . '(?!.*' . $nsSeparator . 'Repository' . $nsSeparator . ')/',
+                               '/Repository$/'
+                       ),
                        array($nsSeparator . 'Model' . $nsSeparator, ''),
                        get_parent_class($this)
                );
index e101a1e..0dba686 100644 (file)
@@ -67,11 +67,12 @@ class LocationRepository extends \TYPO3\CMS\Extbase\Persistence\Repository  {
                $this->settings = $settings;
        }
 
+
        /**
         * Find locations by contraint
         *
         * @param \Evoweb\StoreFinder\Domain\Model\Constraint $constraint
-        * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array
+        * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
         */
        public function findByConstraint($constraint) {
                /** @var \TYPO3\CMS\Extbase\Persistence\Generic\Query $query */
@@ -107,7 +108,14 @@ class LocationRepository extends \TYPO3\CMS\Extbase\Persistence\Repository  {
                /** @var \TYPO3\CMS\Core\Database\DatabaseConnection $database */
                $database = $GLOBALS['TYPO3_DB'];
 
-               $sql = $database->SELECTquery($queryParts['SELECT'], $queryParts['FROM'], $queryParts['WHERE'], $queryParts['GROUPBY'], $queryParts['ORDERBY'], $queryParts['LIMIT']);
+               $sql = $database->SELECTquery(
+                       $queryParts['SELECT'],
+                       $queryParts['FROM'],
+                       $queryParts['WHERE'],
+                       $queryParts['GROUPBY'],
+                       $queryParts['ORDERBY'],
+                       $queryParts['LIMIT']
+               );
                $query->statement($sql);
 
                return $query->execute();
@@ -126,7 +134,8 @@ class LocationRepository extends \TYPO3\CMS\Extbase\Persistence\Repository  {
 
                if ($constraint->getCountry()) {
                        $queryParts['FROM'] .= ' INNER JOIN static_countries sc ON (l.country = sc.cn_short_en)';
-                       $queryParts['WHERE'] .= ' AND sc.' . (is_int($constraint->getCountry()) ? 'uid = ' : 'cn_iso_3 = ') . $database->fullQuoteStr(strtoupper($constraint->getCountry()), 'static_countries');
+                       $queryParts['WHERE'] .= ' AND sc.' . (is_int($constraint->getCountry()) ? 'uid = ' : 'cn_iso_3 = ') .
+                               $database->fullQuoteStr(strtoupper($constraint->getCountry()), 'static_countries');
                }
 
                return $queryParts;
@@ -145,14 +154,17 @@ class LocationRepository extends \TYPO3\CMS\Extbase\Persistence\Repository  {
 
                if ($this->settings['categoryPriority'] == 'limitResultsToCategories') {
                        $constraint->setCategory(GeneralUtility::intExplode(',', $this->settings['categories'], 1));
-               } elseif ($this->settings['categoryPriority'] == 'useSelectedCategoriesIfNoFilterSelected' && !count($constraint->getCategory())) {
+               } elseif (
+                       $this->settings['categoryPriority'] == 'useSelectedCategoriesIfNoFilterSelected' && !count($constraint->getCategory())
+               ) {
                        $constraint->setCategory(GeneralUtility::intExplode(',', $this->settings['categories'], 1));
                }
 
                $categories = $this->fetchCategoriesRecursive($constraint->getCategory());
 
                if (!empty($categories)) {
-                       $queryParts['FROM'] .= ' INNER JOIN sys_category_record_mm c ON (l.uid = c.uid_foreign AND c.tablenames = \'tx_storefinder_domain_model_location\' AND c.fieldname = \'categories\')';
+                       $queryParts['FROM'] .= ' INNER JOIN sys_category_record_mm c ON (l.uid = c.uid_foreign
+                               AND c.tablenames = \'tx_storefinder_domain_model_location\' AND c.fieldname = \'categories\')';
                        $queryParts['WHERE'] .= ' AND c.uid_local IN (' . implode(',', $database->cleanIntArray($categories)) . ')';
                }
 
@@ -353,4 +365,28 @@ class LocationRepository extends \TYPO3\CMS\Extbase\Persistence\Repository  {
 
                return $whereClause;
        }
+
+
+       /**
+        * Query location repository for all locations that
+        * have latitude or longitude empty or geocode set to 1
+        *
+        * @param int $limit
+        * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
+        */
+       public function findAllWithoutLatLon($limit = 500) {
+               $query = $this->createQuery();
+
+               $query->matching($query->logicalOr(
+                       $query->equals('geocode', 1),
+                       $query->logicalOr(
+                               $query->equals('latitude', 0),
+                               $query->equals('longitude', 0)
+                       )
+               ));
+               $query->setLimit($limit);
+               $query->getQuerySettings()->setRespectStoragePage(FALSE);
+
+               return $query->execute();
+       }
 }
\ No newline at end of file
index 4e1f011..3679598 100644 (file)
@@ -32,6 +32,12 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  * @package Evoweb\StoreFinder\Service
  */
 class GeocodeService {
+
+       /**
+        * @var string
+        */
+       protected $defaultApiUrl = 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false';
+
        /**
         * @var array
         */
@@ -52,6 +58,9 @@ class GeocodeService {
        public function __construct(array $settings = array()) {
                if (count($settings)) {
                        $this->setSettings($settings);
+               } else {
+                       $this->settings['geocodeUrl'] = $this->defaultApiUrl;
+                       $this->settings['geocodeLimit'] = 2500;
                }
        }
 
@@ -64,19 +73,17 @@ class GeocodeService {
        public function setSettings(array &$settings) {
                $this->settings = &$settings;
 
-               $this->settings['geocodeLimit'] = $this->settings['geocodeLimit'] ? (int) $this->settings['geocodeLimit'] : '2500';
-               $this->settings['geocodeUrl'] = $this->settings['geocodeUrl'] ?
-                       $this->settings['geocodeUrl'] :
-                       'http://maps.googleapis.com/maps/api/geocode/json?sensor=false';
+               $this->settings['geocodeLimit'] = $this->settings['geocodeLimit'] ? (int) $this->settings['geocodeLimit'] : 2500;
+               $this->settings['geocodeUrl'] = $this->settings['geocodeUrl'] ? $this->settings['geocodeUrl'] : $this->defaultApiUrl;
        }
 
        /**
         * Geocode address and retries if first attempt or value in session
         * is not geocoded
         *
-        * @param Model\Constraint $address
+        * @param Model\Constraint|Model\Location $address
         * @param bool $forceGeocoding
-        * @return Model\Constraint
+        * @return Model\Constraint|Model\Location
         */
        public function geocodeAddress($address, $forceGeocoding = FALSE) {
                $geocodedAddress = $this->coordinatesCache->getCoordinateByAddress($address);
@@ -137,7 +144,7 @@ class GeocodeService {
         * @return array
         */
        protected function prepareValuesForQuery($location, $fields) {
-                       // for urlencoding
+               // for urlencoding
                $queryValues = array();
                foreach ($fields as $field) {
                        $methodName = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $field)));
diff --git a/Classes/Task/GeocodeLocationsTask.php b/Classes/Task/GeocodeLocationsTask.php
new file mode 100644 (file)
index 0000000..d747b72
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+namespace Evoweb\StoreFinder\Task;
+
+/**
+ * Class GeocodeLocationsTask
+ *
+ * @package Evoweb\StoreFinder\Task
+ */
+class GeocodeLocationsTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
+       /**
+        * @return bool
+        */
+       public function execute() {
+               $globalConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['store_finder']);
+
+               /**
+                * @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager
+                */
+               $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
+
+               /**
+                * @var \Evoweb\StoreFinder\Domain\Repository\LocationRepository $locationRepository
+                */
+               $locationRepository = $objectManager->get('Evoweb\\StoreFinder\\Domain\\Repository\\LocationRepository');
+
+               /**
+                * @var \Evoweb\StoreFinder\Service\GeocodeService $geocodeService
+                */
+               $geocodeService = $objectManager->get('Evoweb\\StoreFinder\\Service\\GeocodeService', $globalConfiguration);
+
+               /**
+                * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager $persistenceManager
+                */
+               $persistenceManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
+
+               $loopCount = 0;
+               $locationsToGeocode = $locationRepository->findAllWithoutLatLon();
+               /** @var \Evoweb\StoreFinder\Domain\Model\Constraint $location */
+               foreach ($locationsToGeocode as $location) {
+                       $location = $geocodeService->geocodeAddress($location);
+
+                       if ($location->getLatitude() && $location->getLongitude()) {
+                               $location->setGeocode(0);
+                       }
+
+                       $locationRepository->update($location);
+                       $loopCount++;
+
+                       if ($loopCount > 9) {
+                               $persistenceManager->persistAll();
+                               $loopCount = 0;
+                       }
+               }
+
+               if ($loopCount) {
+                       $persistenceManager->persistAll();
+               }
+
+               return TRUE;
+       }
+}
\ No newline at end of file
index 36db808..0b7e4f8 100644 (file)
@@ -62,7 +62,8 @@ class UpdateUtility {
                        'fe_group' => 'fe_group',
                        'storename' => 'name',
                        'storeid' => 'storeid',
-                       'attributes' => 'comma:mm:attributes:tx_storefinder_location_attribute_mm:uid_local:tx_storefinder_domain_model_attribute:attributes',
+                       'attributes' =>
+                               'comma:mm:attributes:tx_storefinder_location_attribute_mm:uid_local:tx_storefinder_domain_model_attribute:attributes',
                        'address' => 'address',
                        'additionaladdress' => 'additionaladdress',
                        'city' => 'city',
@@ -91,7 +92,8 @@ class UpdateUtility {
                        'lat' => 'latitude',
                        'lon' => 'longitude',
                        'geocode' => '',
-                       'relatedto' => 'finish_comma:mm:locations:tx_storefinder_location_location_mm:uid_local:tx_storefinder_domain_model_location:related',
+                       'relatedto' =>
+                               'finish_comma:mm:locations:tx_storefinder_location_location_mm:uid_local:tx_storefinder_domain_model_location:related',
                ),
        );
 
@@ -205,10 +207,13 @@ class UpdateUtility {
                                \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('tx_extensionmanager_tools_extensionmanagerextensionmanager')
                ));
 
-               $content = '</br>Do you want to start the migration?</br>
-                       <form action="' . $action . '" method="POST">
+               $content = sprintf(
+                       '</br>Do you want to start the migration?</br>
+                       <form action="%1$s" method="POST">
                                <button name="tx_storefinder_update[confirm]" value="1">Start migration</button>
-                       </form>';
+                       </form>',
+                       $action
+               );
 
                return $content;
        }
@@ -609,7 +614,8 @@ class UpdateUtility {
                                $storageRecord = $storage->getStorageRecord();
                                $configuration = $storage->getConfiguration();
                                $isLocalDriver = $storageRecord['driver'] === 'Local';
-                               $isOnFileadmin = !empty($configuration['basePath']) && \TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($configuration['basePath'], $fileadminDirectory);
+                               $isOnFileadmin = !empty($configuration['basePath']) &&
+                                       \TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($configuration['basePath'], $fileadminDirectory);
                                if ($isLocalDriver && $isOnFileadmin) {
                                        $this->storage = $storage;
                                        break;
@@ -621,8 +627,11 @@ class UpdateUtility {
                        }
 
                        $this->fileFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
-                       $this->fileIndexRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository');
-                       $this->targetDirectory = PATH_site . $fileadminDirectory . \TYPO3\CMS\Install\Updates\TtContentUploadsUpdateWizard::FOLDER_ContentUploads . '/';
+                       $this->fileIndexRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
+                               'TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository'
+                       );
+                       $this->targetDirectory = PATH_site . $fileadminDirectory .
+                               \TYPO3\CMS\Install\Updates\TtContentUploadsUpdateWizard::FOLDER_ContentUploads . '/';
                }
        }
 
@@ -633,7 +642,10 @@ class UpdateUtility {
         */
        protected function checkPrerequisites() {
                if (!$this->storage->hasFolder(\TYPO3\CMS\Install\Updates\TtContentUploadsUpdateWizard::FOLDER_ContentUploads)) {
-                       $this->storage->createFolder(\TYPO3\CMS\Install\Updates\TtContentUploadsUpdateWizard::FOLDER_ContentUploads, $this->storage->getRootLevelFolder());
+                       $this->storage->createFolder(
+                               \TYPO3\CMS\Install\Updates\TtContentUploadsUpdateWizard::FOLDER_ContentUploads,
+                               $this->storage->getRootLevelFolder()
+                       );
                }
        }
 
@@ -654,7 +666,9 @@ class UpdateUtility {
                        if (file_exists($path . $file)) {
                                \TYPO3\CMS\Core\Utility\GeneralUtility::upload_copy_move($path . $file, $this->targetDirectory . $file);
                                /** @var \TYPO3\CMS\Core\Resource\File $fileObject */
-                               $fileObject = $this->storage->getFile(\TYPO3\CMS\Install\Updates\TtContentUploadsUpdateWizard::FOLDER_ContentUploads . '/' . $file);
+                               $fileObject = $this->storage->getFile(
+                                       \TYPO3\CMS\Install\Updates\TtContentUploadsUpdateWizard::FOLDER_ContentUploads . '/' . $file
+                               );
                                $this->fileIndexRepository->add($fileObject);
 
                                $count = $this->database->exec_SELECTcountRows(
index 8b550ef..6338f0b 100644 (file)
@@ -26,7 +26,8 @@ namespace Evoweb\StoreFinder\Validation\Validator;
 /**
  * A Uservalidator
  */
-class ConstraintValidator extends \TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {
+class ConstraintValidator extends \TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator
+       implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {
 
        /**
         * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage
@@ -106,8 +107,12 @@ class ConstraintValidator extends \TYPO3\CMS\Extbase\Validation\Validator\Generi
         */
        public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager $configurationManager) {
                $this->configurationManager = $configurationManager;
-               $this->settings = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS);
-               $this->frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
+               $this->settings = $this->configurationManager->getConfiguration(
+                       \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS
+               );
+               $this->frameworkConfiguration = $this->configurationManager->getConfiguration(
+                       \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK
+               );
        }
 
        /**
@@ -127,7 +132,9 @@ class ConstraintValidator extends \TYPO3\CMS\Extbase\Validation\Validator\Generi
                        return $messages;
                }
                if (!$this->canValidate($object)) {
-                       $messages->addError(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_notvalidatable', 'StoreFinder'), 1301599551);
+                       $messages->addError(
+                               \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_notvalidatable', 'StoreFinder'), 1301599551
+                       );
                        return $messages;
                }
                if (self::$instancesCurrentlyUnderValidation->contains($object)) {
@@ -200,7 +207,10 @@ class ConstraintValidator extends \TYPO3\CMS\Extbase\Validation\Validator\Generi
                $this->currentValidatorOptions = (array) $currentValidator['validatorOptions'];
 
                /** @var $validatorObject \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator */
-               $validatorObject = $this->validatorResolver->createValidator($currentValidator['validatorName'], $this->currentValidatorOptions);
+               $validatorObject = $this->validatorResolver->createValidator(
+                       $currentValidator['validatorName'],
+                       $this->currentValidatorOptions
+               );
 
                if (method_exists($validatorObject, 'setModel')) {
                        /** @noinspection PhpUndefinedMethodInspection */
@@ -267,5 +277,3 @@ class ConstraintValidator extends \TYPO3\CMS\Extbase\Validation\Validator\Generi
                }
        }
 }
-
-?>
\ No newline at end of file
index 75726a9..1d10e56 100644 (file)
@@ -28,7 +28,8 @@ namespace Evoweb\StoreFinder\Validation\Validator;
  *
  * @scope singleton
  */
-class RequiredValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {
+class RequiredValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator
+       implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {
        /**
         * Override to be able to validate empty values
         *
@@ -58,5 +59,3 @@ class RequiredValidator extends \TYPO3\CMS\Extbase\Validation\Validator\Abstract
                return $result;
        }
 }
-
-?>
\ No newline at end of file
index 09d1c36..38cdf6c 100644 (file)
@@ -37,5 +37,3 @@ class ValidatorResolver extends \TYPO3\CMS\Extbase\Validation\ValidatorResolver
                return $this->parseValidatorAnnotation($validateValue);
        }
 }
-
-?>
\ No newline at end of file
index 006b72c..0de078e 100644 (file)
@@ -56,9 +56,26 @@ class SelectCountriesViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\Select
        public function initializeArguments() {
                parent::initializeArguments();
 
-               $this->overrideArgument('options', 'object', 'Associative array with internal IDs as key, and the values are displayed in the select box', FALSE);
-               $this->overrideArgument('optionValueField', 'string', 'If specified, will call the appropriate getter on each object to determine the value.', FALSE, 'isoCodeA2');
-               $this->overrideArgument('optionLabelField', 'string', 'If specified, will call the appropriate getter on each object to determine the label.', FALSE, 'shortNameLocal');
+               $this->overrideArgument(
+                       'options',
+                       'object',
+                       'Associative array with internal IDs as key, and the values are displayed in the select box',
+                       FALSE
+               );
+               $this->overrideArgument(
+                       'optionValueField',
+                       'string',
+                       'If specified, will call the appropriate getter on each object to determine the value.',
+                       FALSE,
+                       'isoCodeA2'
+               );
+               $this->overrideArgument(
+                       'optionLabelField',
+                       'string',
+                       'If specified, will call the appropriate getter on each object to determine the label.',
+                       FALSE,
+                       'shortNameLocal'
+               );
                $this->overrideArgument('sortByOptionLabel', 'boolean', 'If true, List will be sorted by label.', FALSE, TRUE);
                $this->registerArgument('allowedCountries', 'array', 'Array with countries allowed to be displayed.', FALSE, array());
        }
index d62d147..37a8dfd 100644 (file)
@@ -26,7 +26,9 @@ return array(
        ),
 
        'interface' => array(
-               'showRecordFieldList' => 'hidden,endtime,fe_group,name,storeid,address,additionaladdress,person,city,state,zipcode,country,attributes,products,phone,mobile,hours,url,notes,image,icon,content,use_coordinate,categories,latitude,longitude,geocode'
+               'showRecordFieldList' => 'hidden, endtime, fe_group, name, storeid, address, additionaladdress, person, city, state,
+                       zipcode, country, attributes, products, phone, mobile, hours, url, notes, image, icon, content, use_coordinate,
+                       categories, latitude, longitude, geocode'
        ),
 
        'columns' => array(
@@ -49,7 +51,8 @@ return array(
                                        )
                                ),
                                'foreign_table' => 'tx_storefinder_domain_model_location',
-                               'foreign_table_where' => 'AND tx_storefinder_domain_model_location.pid=###CURRENT_PID### AND tx_storefinder_domain_model_location.sys_language_uid IN (-1,0)'
+                               'foreign_table_where' => 'AND tx_storefinder_domain_model_location.pid=###CURRENT_PID###
+                                       AND tx_storefinder_domain_model_location.sys_language_uid IN (-1,0)'
                        )
                ),
 
@@ -88,7 +91,8 @@ return array(
 
                'additionaladdress' => array(
                        'exclude' => 0,
-                       'label' => 'LLL:EXT:store_finder/Resources/Private/Language/locallang_db.xml:tx_storefinder_domain_model_location.additionaladdress',
+                       'label' =>
+                               'LLL:EXT:store_finder/Resources/Private/Language/locallang_db.xml:tx_storefinder_domain_model_location.additionaladdress',
                        'config' => array(
                                'type' => 'input',
                                'size' => '30',
@@ -221,7 +225,8 @@ return array(
                                        Array('', 0)
                                ),
                                'foreign_table' => 'tx_storefinder_domain_model_location',
-                               'foreign_table_where' => 'AND tx_storefinder_domain_model_location.uid != ###THIS_UID### ORDER BY tx_storefinder_domain_model_location.name',
+                               'foreign_table_where' => 'AND tx_storefinder_domain_model_location.uid != ###THIS_UID###
+                                       ORDER BY tx_storefinder_domain_model_location.name',
                                'MM' => 'sys_category_record_mm',
                                'MM_match_fields' => array(
                                        'tablenames' => 'tx_storefinder_domain_model_location',
@@ -278,7 +283,8 @@ return array(
                        'config' => array(
                                'type' => 'select',
                                'foreign_table' => 'tx_storefinder_domain_model_attribute',
-                               'foreign_table_where' => ' AND tx_storefinder_domain_model_attribute.sys_language_uid = 0 AND tx_storefinder_domain_model_attribute.pid = ###CURRENT_PID###',
+                               'foreign_table_where' => ' AND tx_storefinder_domain_model_attribute.sys_language_uid = 0
+                                       AND tx_storefinder_domain_model_attribute.pid = ###CURRENT_PID###',
                                'MM' => 'tx_storefinder_location_attribute_mm',
                                'MM_match_fields' => array(
                                        'tablenames' => 'tx_storefinder_domain_model_attribute',
@@ -363,6 +369,14 @@ return array(
                        )
                ),
 
+               'geocode' => array(
+                       'exclude' => 1,
+                       'label' => 'LLL:EXT:store_finder/Resources/Private/Language/locallang_db.xml:tx_storefinder_domain_model_location.geocode',
+                       'config' => array(
+                               'type' => 'check',
+                       )
+               ),
+
                'distance' => array(
                        'exclude' => 0,
                        'label' => 'LLL:EXT:store_finder/Resources/Private/Language/locallang_db.xml:tx_storefinder_domain_model_location.distance',
@@ -560,7 +574,7 @@ return array(
 
        'palettes' => array(
                'coordinates' => array(
-                       'showitem' => 'latitude, longitude, center',
+                       'showitem' => 'latitude, longitude, center, geocode',
                        'canNotCollapse' => 1
                ),
                'visibility' => array(
index e9251a5..0f716cd 100644 (file)
@@ -9,6 +9,16 @@ plugin.tx_storefinder.settings {
        # [miles, kilometer]
        distanceUnit = miles
 
+       showLocationsForDefaultConstraint = 0
+       defaultConstraint {
+               limit = 1000
+               # radius in kilometer
+               radius = 1000
+               zipcode =
+               city =
+               country =
+       }
+
        mapConfiguration {
                # traffic, weather, bicycling,  panoramio, kml
                apiV3Layers =
@@ -17,8 +27,8 @@ plugin.tx_storefinder.settings {
        }
 
        mapSize {
-               height = 400
-               width = 600
+               height = 400px
+               width = 600px
        }
 
        validation {
diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf
new file mode 100644 (file)
index 0000000..067ae60
--- /dev/null
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<xliff version="1.0">
+       <file source-language="en" datatype="plaintext" original="messages" date="2013-01-04T12:14:30Z" product-name="store_finder">
+               <header/>
+               <body>
+                       <trans-unit id="name">
+                               <source>Storename</source>
+                               <target>Name</target>
+                       </trans-unit>
+                       <trans-unit id="address">
+                               <source>Address</source>
+                               <target>Anschrift</target>
+                       </trans-unit>
+                       <trans-unit id="zipcode">
+                               <source>Zipcode</source>
+                               <target>Postleitzahl</target>
+                       </trans-unit>
+                       <trans-unit id="city">
+                               <source>City</source>
+                               <target>Stadt</target>
+                       </trans-unit>
+                       <trans-unit id="country">
+                               <source>Country</source>
+                               <target>Land</target>
+                       </trans-unit>
+                       <trans-unit id="latitude">
+                               <source>Latitude</source>
+                               <target>Längengrad</target>
+                       </trans-unit>
+                       <trans-unit id="longitude">
+                               <source>Longitude</source>
+                               <target>Breitengrad</target>
+                       </trans-unit>
+                       <trans-unit id="products">
+                               <source>Products comma separated</source>
+                               <target>Produkte (Komma-separiert)</target>
+                       </trans-unit>
+                       <trans-unit id="category">
+                               <source>Restrict on Categories</source>
+                               <target>Beschränkt auf Kategroien</target>
+                       </trans-unit>
+                       <trans-unit id="radius">
+                               <source>Radius (km)</source>
+                       </trans-unit>
+                       <trans-unit id="submit_find">
+                               <source>Find Store</source>
+                               <target>Geschäft finden</target>
+                       </trans-unit>
+                       <trans-unit id="route">
+                               <source>Route</source>
+                       </trans-unit>
+                       <trans-unit id="error_notvalidatable">
+                               <source>Model is not validatable</source>
+                               <target>Model ist nicht validierbar</target>
+                       </trans-unit>
+                       <trans-unit id="error_required">
+                               <source>Required field may not be empty</source>
+                               <target>Pflichtfeld darf nicht leer sein</target>
+                       </trans-unit>
+                       <trans-unit id="error_notexists">
+                               <source>Field does not exists</source>
+                               <target>Diese Feld gibt es nicht</target>
+                       </trans-unit>
+               </body>
+       </file>
+</xliff>
\ No newline at end of file
index 1e56bc9..890be60 100644 (file)
                        <label index="pi_flexform.categoryPriority.useAsFilterInFrontend">Filter utilized by the user in frontend</label>
                        <label index="pi_flexform.categoryPriority.limitResultsToCategories">Filter used for the query without user utilization</label>
                        <label index="pi_flexform.categoryPriority.useParentIfNoFilterSelected">Filter utilized by the user in frontend or as filter if the user selected none</label>
+
+                       <label index="geocodeLocations.name">Geocode locations</label>
+                       <label index="geocodeLocations.description">Fetch locations without latitute/logitude or with geocode set to 1, geocodes it and writes back to database</label>
                </languageKey>
        </data>
 </T3locallang>
\ No newline at end of file
index 8a0d170..1656599 100644 (file)
@@ -35,6 +35,7 @@
                        <label index="tx_storefinder_domain_model_location.latitude">Latitude</label>
                        <label index="tx_storefinder_domain_model_location.longitude">Longitude</label>
                        <label index="tx_storefinder_domain_model_location.center">Use as center</label>
+                       <label index="tx_storefinder_domain_model_location.geocode">Geocode this location</label>
                        <label index="tx_storefinder_domain_model_location.distance">Calculated value by search query</label>
 
                        <label index="sys_category.add">Add category</label>
@@ -78,6 +79,9 @@
                        <label index="tx_storefinder_domain_model_location.categories">Kategorien</label>
                        <label index="tx_storefinder_domain_model_location.latitude">Breitengrad</label>
                        <label index="tx_storefinder_domain_model_location.longitude">Längengrad</label>
+                       <label index="tx_storefinder_domain_model_location.center">Als Mitte verwenden</label>
+                       <label index="tx_storefinder_domain_model_location.geocode">Diese Location geo kodieren</label>
+                       <label index="tx_storefinder_domain_model_location.distance">Berechnete Entfernung</label>
 
                        <label index="tx_storefinder_domain_model_attribute">Filial Attribute</label>
                        <label index="tx_storefinder_domain_model_attribute.name">Name</label>
index 859b35b..896ce6e 100644 (file)
@@ -14,7 +14,7 @@
                        lat: <f:format.number decimals="7">{center.latitude}</f:format.number>,
                        lng: <f:format.number decimals="7">{center.longitude}</f:format.number>
                },
-               zoom: '{center.zoom}'
+               zoom: {center.zoom}
        </sf:minify>};
 
        var locations = [<f:for each="{locations}" as="location" iteration="loop">
@@ -43,7 +43,9 @@
                                state: '{location.state}',
                                country: '{location.country}',
                                image: '<f:for each="{location.image}" as="image">{f:uri.image(src: image.uid, width: 70, treatIdAsReference: 1)}</f:for>',
-                               media: '{location.media}'
+                               media: '{location.media}',
+                               lat: {location.latitude},
+                               lng: {location.longitude}
                        }
                }</sf:minify><f:if condition="{loop.isLast}"><f:then/><f:else>,</f:else></f:if></f:for>
        ];
@@ -55,7 +57,7 @@
                <div class="right">
                        <div class="image">{{#image}}<img src="{{image}}"/>{{/image}}</div>
                        <div class="displayRoute">
-                               <a href="https://maps.google.com/?daddr={{lat}},{{lng}}" target="_top"><f:translate key="route"/></a>
+                               <a href="https://maps.google.com/?daddr={{lat}},{{lng}}" target="_blank"><f:translate key="route"/></a>
                        </div>
                </div>
                <div class="left">
index 7322cdf..2e23559 100644 (file)
@@ -106,17 +106,19 @@ function initializeLocation() {
        'use strict';
 
        var index, location;
-       for (index = 0; index < locations.length; index++) {
-               location = locations[index];
-
-               location.marker = new google.maps.Marker({
-                       map: map,
-                       title: location.name,
-                       position: new google.maps.LatLng(location.lat, location.lng)
-               });
-               location.marker.sfLocation = location;
-
-               google.maps.event.addListener(location.marker, 'click', showInformations);
+       if (locations.length) {
+               for (index = 0; index < locations.length; index++) {
+                       location = locations[index];
+
+                       location.marker = new google.maps.Marker({
+                               map: map,
+                               title: location.name,
+                               position: new google.maps.LatLng(location.lat, location.lng)
+                       });
+                       location.marker.sfLocation = location;
+
+                       google.maps.event.addListener(location.marker, 'click', showInformations);
+               }
        }
 }
 
@@ -135,6 +137,7 @@ function initializeMap() {
                center: new google.maps.LatLng(mapConfiguration.center.lat, mapConfiguration.center.lng),
                mapTypeId: google.maps.MapTypeId.ROADMAP
        };
+       console.log(mapOptions);
        map = new google.maps.Map($('#tx_storefinder_map')[0], mapOptions);
 
        initializeLayer();
index d4b9bee..b0115d4 100644 (file)
@@ -19,7 +19,9 @@ if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations
 );
 
 /** @noinspection PhpIncludeInspection */
-require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('store_finder') . 'Classes/Utility/ExtensionConfigurationUtility.php');
+require_once(
+       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('store_finder') . 'Classes/Utility/ExtensionConfigurationUtility.php'
+);
 $configuration = \Evoweb\StoreFinder\Utility\ExtensionConfigurationUtility::getConfiguration();
 
 
@@ -44,4 +46,12 @@ $configuration = \Evoweb\StoreFinder\Utility\ExtensionConfigurationUtility::getC
 
 
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['store_finder'] =
-       'EXT:store_finder/Classes/Hook/TceMainHook.php:Evoweb\StoreFinder\Hook\TceMainHook';
+       'EXT:store_finder/Classes/Hook/TceMainHook.php:Evoweb\\StoreFinder\\Hook\\TceMainHook';
+
+
+// Add location geocodeing task
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['Evoweb\\StoreFinder\\Task\\GeocodeLocationsTask'] = array(
+       'extension' => $_EXTKEY,
+       'title' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_be.xml:geocodeLocations.name',
+       'description' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_be.xml:geocodeLocations.description'
+);
\ No newline at end of file
index 1a8a91b..d810e94 100644 (file)
@@ -48,6 +48,7 @@ CREATE TABLE tx_storefinder_domain_model_location (
        longitude double(11,7) DEFAULT '0.0000000' NOT NULL,
        center int(4) DEFAULT '0' NOT NULL,
        distance double(11,3) DEFAULT '0.000' NOT NULL,
+       geocode int(4) DEFAULT '0' NOT NULL,
 
        import_id int(11) DEFAULT '0' NOT NULL,