diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..06d085f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +.check-author.yml export-ignore +.gitattributes export-ignore +.github export-ignore +.gitignore export-ignore +.travis.yml export-ignore +build.default.properties export-ignore +build.xml export-ignore +phpunit.xml.dist export-ignore +/tests export-ignore +/specs export-ignore diff --git a/.gitignore b/.gitignore index 7c9521e..a4e22b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,24 @@ -/vendor/ -/bin/ -/demo/ -/assets/js/*.js -/node_modules/ -/.tx/ +# OS +.DS_Store +Thumbs.db +.directory -coverage.xml +# IDEs +.buildpath +.project +.settings/ +.build/ +.external*/ +.idea/ +nbproject/ + +# composer related +vendor/ composer.lock -npm-debug.log + +# build +build/ +build.properties + +# Translations +.tx diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..900991b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,28 @@ +language: php + +php: + - "5.6" + - "7.0" + - "7.1" + +env: + - CONTAO_VERSION=contao/core-bundle ^4.4.2 + +matrix: + exclude: + +sudo: false + +install: + - travis_retry composer self-update && composer --version + - travis_retry composer require $CONTAO_VERSION --no-update + - travis_retry composer update --prefer-dist --no-interaction + +script: ant -keep-going + +git: + depth: 2147483647 + +cache: + directories: + - vendor diff --git a/build.default.properties b/build.default.properties new file mode 100644 index 0000000..0f40b56 --- /dev/null +++ b/build.default.properties @@ -0,0 +1,4 @@ +phpcs.standard=${basedir}/vendor/phpcq/coding-standard/phpcs/PhpCodeQuality/ruleset.xml +phpmd.ruleset=${basedir}/vendor/phpcq/coding-standard/phpmd/ruleset.xml +phpcs.excluded = src/Resources/contao/languages +phpcpd.excluded = contao diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..ae62054 --- /dev/null +++ b/build.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/composer.json b/composer.json index 43e23ec..61bf2d5 100644 --- a/composer.json +++ b/composer.json @@ -24,17 +24,13 @@ "source": "https://github.com/contao-bootstrap/core" }, "require": { - "php": ">=5.5.0", - "contao/core-bundle": "^4.4.2", - "contao-community-alliance/composer-plugin": "~2.4 || ~3.0", + "php": ">=5.6.0", + "contao/core-bundle": "~4.4.0", "netzmacht/contao-leaflet-libraries": "~1.0" }, "require-dev": { - "netzmacht/contao-build-tools": "~1.1", - "contao/manager-plugin": "^2.0" - }, - "conflict": { - "contao/manager-plugin": "<2.0 || >=3.0" + "contao/manager-plugin": "^2.0", + "phpcq/all-tasks": "^1.2" }, "suggest": { "netzmacht/contao-leaflet-maps": "Leaflet Maps for Contao" @@ -50,7 +46,5 @@ "dev-develop": "1.1.x-dev" }, "contao-manager-plugin": "Netzmacht\\Contao\\Leaflet\\GeocodeWidget\\ContaoManager\\Plugin" - }, - "minimum-stability": "dev", - "prefer-stable": true + } } diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php index ce8132e..5d6628a 100644 --- a/src/ContaoManager/Plugin.php +++ b/src/ContaoManager/Plugin.php @@ -1,11 +1,13 @@ - * @copyright 2017 netzmacht David Molineus. All rights reserved. + * @copyright 2016-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-geocode-widget/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\GeocodeWidget\ContaoManager; @@ -17,7 +19,7 @@ use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; use Netzmacht\Contao\Leaflet\GeocodeWidget\LeafletGeocodeWidgetBundle; /** - * Class Plugin + * Contao Manager plugin. * * @package Netzmacht\Contao\Leaflet\GeocodeWidget\ContaoManager */ diff --git a/src/GeocodeWidget.php b/src/GeocodeWidget.php index de6f8b8..d869b17 100644 --- a/src/GeocodeWidget.php +++ b/src/GeocodeWidget.php @@ -1,11 +1,13 @@ - * @copyright 2017 netzmacht David Molineus. All rights reserved. + * @copyright 2016-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-geocode-widget/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\GeocodeWidget; @@ -51,6 +53,8 @@ class GeocodeWidget extends \Widget * @param mixed $value Given value. * * @return mixed + * + * @SuppressWarnings(PHPMD.Superglobals) */ protected function validator($value) { @@ -60,13 +64,11 @@ class GeocodeWidget extends \Widget return $value; } - if ( - // See: http://stackoverflow.com/a/18690202 - !preg_match( - '#^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)(,[-+]?\d+)?$#', - $value - ) - ) { + // See: http://stackoverflow.com/a/18690202 + if (!preg_match( + '#^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)(,[-+]?\d+)?$#', + $value + )) { $this->addError( sprintf( $GLOBALS['TL_LANG']['ERR']['leafletInvalidCoordinate'], diff --git a/src/LeafletGeocodeWidgetBundle.php b/src/LeafletGeocodeWidgetBundle.php index 78db4bd..9546d82 100644 --- a/src/LeafletGeocodeWidgetBundle.php +++ b/src/LeafletGeocodeWidgetBundle.php @@ -1,11 +1,13 @@ - * @copyright 2017 netzmacht David Molineus. All rights reserved. + * @copyright 2016-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-geocode-widget/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\GeocodeWidget; diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index 5692e6c..3f03f84 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -1,11 +1,13 @@ - * @copyright 2017 netzmacht David Molineus. All rights reserved. + * @copyright 2016-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-geocode-widget/blob/master/LICENSE * @filesource - * */ $GLOBALS['BE_FFL']['leaflet_geocode'] = 'Netzmacht\Contao\Leaflet\GeocodeWidget\GeocodeWidget'; diff --git a/src/Resources/contao/languages/de/default.php b/src/Resources/contao/languages/de/default.php index 7e95399..44e3e13 100644 --- a/src/Resources/contao/languages/de/default.php +++ b/src/Resources/contao/languages/de/default.php @@ -1,11 +1,13 @@ - * @copyright 2017 netzmacht David Molineus. All rights reserved. + * @copyright 2016-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-geocode-widget/blob/master/LICENSE * @filesource - * */ $GLOBALS['TL_LANG']['ERR']['leafletInvalidCoordinate'] = 'Die angegebenen Koordinaten sind ungültig.'; diff --git a/src/Resources/contao/languages/en/default.php b/src/Resources/contao/languages/en/default.php index b229234..61d74e9 100644 --- a/src/Resources/contao/languages/en/default.php +++ b/src/Resources/contao/languages/en/default.php @@ -1,11 +1,13 @@ - * @copyright 2017 netzmacht David Molineus. All rights reserved. + * @copyright 2016-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-geocode-widget/blob/master/LICENSE * @filesource - * */ $GLOBALS['TL_LANG']['ERR']['leafletInvalidCoordinate'] = 'Invalid coordinates given.'; diff --git a/src/Resources/public/js/geocode.widget.js b/src/Resources/public/js/geocode.widget.js index 292b2c9..d2435a1 100644 --- a/src/Resources/public/js/geocode.widget.js +++ b/src/Resources/public/js/geocode.widget.js @@ -1,3 +1,13 @@ +/** + * Geocode backend widget based on Leaflet. + * + * @package netzmacht + * @author David Molineus + * @copyright 2016-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-geocode-widget/blob/master/LICENSE + * @filesource + */ + var LeafletGeocodeWidget = L.Class.extend({ options: { mapTemplate: '
', @@ -31,8 +41,12 @@ var LeafletGeocodeWidget = L.Class.extend({ 'hideFooter': true, 'draggable': false, 'overlayOpacity': .5, - 'onShow': function() { document.body.setStyle('overflow', 'hidden'); }, - 'onHide': function() { document.body.setStyle('overflow', 'auto'); } + 'onShow': function () { + document.body.setStyle('overflow', 'hidden'); + }, + 'onHide': function () { + document.body.setStyle('overflow', 'auto'); + } }); }, _createMap: function (modal) { @@ -69,7 +83,7 @@ var LeafletGeocodeWidget = L.Class.extend({ link.set('style', 'margin-left: 10px;'); link.appendText(this.options.applyPositionLabel); - link.addEvent('click', function(e) { + link.addEvent('click', function (e) { e.stop(); this.element.set('value', result.center.lat + ',' + result.center.lng);