diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..618a292 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +.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 +/js export-ignore diff --git a/.gitignore b/.gitignore index 7c9521e..107dd49 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,28 @@ -/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 + +# NPM +node_modules +package-lock.json diff --git a/.travis.yml b/.travis.yml index a983487..9918e23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,28 @@ language: php php: - - "5.4" - - "5.5" - - "5.6" - "7.0" - - "nightly" + - "7.1" + - "7.2" env: - - CONTAO_VERSION=~3.5.1 + - CONTAO_VERSION=contao/core-bundle ~4.4.0 + +matrix: + exclude: sudo: false install: - travis_retry composer self-update && composer --version - - travis_retry composer require contao/core $CONTAO_VERSION --no-update + - travis_retry composer require $CONTAO_VERSION --no-update - travis_retry composer update --prefer-dist --no-interaction script: ant -keep-going -matrix: - allow_failures: - - php: "7.0" - - php: "nightly" - -# Hack to make things work again - we can not use a shallow repository. git: depth: 2147483647 + +cache: + directories: + - vendor diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6e0a267 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,42 @@ + +Changelog +========= + +3.0.0 (2018-01-05) +------------------ + +[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.0.0-beta1...3.0.0) + + - Make hook/dca listener services public + +3.0.0-beta1 (2017-11-15) +------------------------ + +[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.0.0-alpha2...3.0.0-beta1) + +Enhancements + + - Updated translations + +Bugfixes + + - Broken service definitions + - Broken file layer id + +3.0.0-alpha2 +------------ + +[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.0.0-alpha2...2.0.0-alpha3) + +3.0.0-alpha1 (2017-10-19) +------------------------ + +[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.0.0-alpha1...2.0.0-alpha2) + +Implemented enhancements + + - Refactor to a more service oriented architecture + - Use a proper template for the map templates (Customize templates has to be adjusted!) + - New file layer for gpx,kml,wkt,topojson,geojson files added + - Bypass filesystem cache in debug mode + - Changelog added diff --git a/README.md b/README.md index c40c958..0e4d64a 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,19 @@ Features - Define Leaflet maps with multiple layers. - Manage map controls - - [Layers control](http://leafletjs.com/reference-1.0.0.html#control-layers) - - [Zoom control](http://leafletjs.com/reference-1.0.0.html#control-zoom) - - [Scale control]((http://leafletjs.com/reference-1.0.0.html#control-scale)) - - [Attribution control](http://leafletjs.com/reference-1.0.0.html#control-attribution) + - [Layers control](http://leafletjs.com/reference-1.2.0.html#control-layers) + - [Zoom control](http://leafletjs.com/reference-1.2.0.html#control-zoom) + - [Scale control]((http://leafletjs.com/reference-1.2.0.html#control-scale)) + - [Attribution control](http://leafletjs.com/reference-1.2.0.html#control-attribution) - [Loading control](https://github.com/ebrelsford/Leaflet.loading) - Manage layers - [Tile provider](https://github.com/leaflet-extras/leaflet-providers) - - Markers - A set of [markers](http://leafletjs.com/reference-1.0.0.html#marker) - - Vectors - A set of [vectors](http://leafletjs.com/reference-1.0.0.html) + - Markers - A set of [markers](http://leafletjs.com/reference-1.2.0.html#marker) + - Vectors - A set of [vectors](http://leafletjs.com/reference-1.2.0.html) - Groups - A group of layers - Reference - A link to another layer + - [Markercluster](https://github.com/Leaflet/Leaflet.markercluster) + - External geo data files (gpx,kml,wkt,geojson,topojson) - Manage marker icons - Manage vector styles - Optional deferred ajax loading of layer data @@ -36,11 +38,22 @@ Features - Autoloading of required assets. - [Layer for MetaModels](https://github.com/netzmacht/contao-leaflet-metamodels) +Changelog +--------- + +View the [CHANGELOG.md](CHANGELOG.md) for the latest changes. + +Requirements +------------ + + - Contao 4.4 + - PHP >= 7.0 + Install ------- ``` -$ php composer.phar require netzmacht/contao-leaflet-maps:~2.0 +$ php composer.phar require netzmacht/contao-leaflet-maps:~3.0 ``` Credits diff --git a/assets/js/.keep b/assets/js/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/assets/maps/contao-leaflet.js b/assets/maps/contao-leaflet.js deleted file mode 100644 index 9414982..0000000 --- a/assets/maps/contao-leaflet.js +++ /dev/null @@ -1 +0,0 @@ -L.Contao=L.Class.extend({includes:L.Mixin.Events,statics:{ATTRIBUTION:' | netzmacht'},maps:{},icons:{},initialize:function(){L.Icon.Default.imagePath="assets/leaflet/libs/leaflet/images/",this.setGeoJsonListeners(L.GeoJSON)},addMap:function(t,o){return this.maps[t]=o,this.fire("map:added",{id:t,map:o}),this},getMap:function(t){return"undefined"==typeof this.maps[t]?null:this.maps[t]},addIcon:function(t,o){return this.icons[t]=o,this.fire("icon:added",{id:t,icon:o}),this},loadIcons:function(t){for(var o=0;o=200&&t<300||304===t}function i(){void 0===a.status||n(a.status)?o.call(a,null,a):o.call(a,a,null)}var s=!1;if("undefined"==typeof window.XMLHttpRequest)return o(Error("Browser not supported"));if("undefined"==typeof e){var r=t.match(/^\s*https?:\/\/[^\/]*/);e=r&&r[0]!==location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}var a=new window.XMLHttpRequest;if(e&&!("withCredentials"in a)){a=new window.XDomainRequest;var p=o;o=function(){if(s)p.apply(this,arguments);else{var t=this,o=arguments;setTimeout(function(){p.apply(t,o)},0)}}}return"onload"in a?a.onload=i:a.onreadystatechange=function(){4===a.readyState&&i()},a.onerror=function(t){o.call(this,t||!0,null),o=function(){}},a.onprogress=function(){},a.ontimeout=function(t){o.call(this,t,null),o=function(){}},a.onabort=function(t){o.call(this,t,null),o=function(){}},a.open("GET",t,!0),a.send(null),s=!0,a}}); \ No newline at end of file diff --git a/build.default.properties b/build.default.properties new file mode 100644 index 0000000..384a373 --- /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/Bundle/Resources/contao/languages,src/Bundle/Resources/public/js +phpcpd.excluded = contao diff --git a/build.properties b/build.properties deleted file mode 100644 index df1e841..0000000 --- a/build.properties +++ /dev/null @@ -1,2 +0,0 @@ - -phpcq.bin.dir = ${basedir}/bin diff --git a/build.xml b/build.xml index ccf97f7..3471b6b 100644 --- a/build.xml +++ b/build.xml @@ -1,5 +1,5 @@ - + diff --git a/composer.json b/composer.json index d01387b..1bdfbcf 100644 --- a/composer.json +++ b/composer.json @@ -1,66 +1,66 @@ { - "name":"netzmacht/contao-leaflet-maps", - "description":"Contao Leaflet maps integration", - "keywords":["contao", "maps", "leaflet"], - "type":"contao-module", - "license":"LGPL-3.0+", - "authors":[ - { - "name":"David Molineus", - "email":"mail@netzmacht.de", - "homepage":"http://www.netzmacht.de", - "role":"Project leader" - } - ], - "support":{ - "email":"mail@netzmacht.de", - "issues":"https://github.com/netzmacht/contao-leaflet-maps/issues", - "source":"https://github.com/netzmacht/contao-leaflet-maps" - }, - "require":{ - "php":">=5.4", - "contao/core":"^3.5", - "contao-community-alliance/dependency-container":"^1.0", - "contao-community-alliance/event-dispatcher":"^1.0", - "netzmacht/contao-leaflet-libraries": "^1.0", - "netzmacht/php-javascript-builder": "^1.0", - "netzmacht/php-leaflet": "^1.0", - "netzmacht/contao-toolkit":"^2.0", - "contao-community-alliance/meta-palettes": "^1.5", - "menatwork/contao-multicolumnwizard": "^3.2", - "doctrine/cache": "^1.0" - }, - "require-dev":{ - "netzmacht/contao-build-tools": "^1.1" - }, - "autoload": { - "psr-0": { - "Netzmacht\\Contao\\Leaflet\\": "src/" - } - }, - "config": { - "bin-dir": "bin" - }, - "prefer-stable": true, - "minimum-stability": "dev", - "extra":{ - "branch-alias": { - "dev-master": "2.0.x-dev", - "dev-develop": "2.1.x-dev", - "dev-support/0.7.x": "0.7.x-dev" - }, - "contao": { - "sources":{ - "module": "system/modules/leaflet", - "assets/maps": "assets/leaflet/maps", - "assets/js": "assets/leaflet/js" - }, - "transifex": { - "project": "contao-leaflet-maps", - "prefix": "core-", - "languages_cto": "module/languages", - "languages_tx": ".tx" - } - } + "name": "netzmacht/contao-leaflet-maps", + "description": "Contao Leaflet maps integration", + "keywords": [ + "contao", + "maps", + "leaflet" + ], + "type": "contao-bundle", + "license": "LGPL-3.0+", + "authors": [ + { + "name": "David Molineus", + "email": "mail@netzmacht.de", + "homepage": "https://netzmacht.de", + "role": "Developer" } + ], + "support": { + "email": "mail@netzmacht.de", + "issues": "https://github.com/netzmacht/contao-leaflet-maps/issues", + "source": "https://github.com/netzmacht/contao-leaflet-maps" + }, + "require": { + "php": ">=7.0", + "contao/core-bundle": "~4.4", + "netzmacht/contao-leaflet-libraries": "^1.0", + "netzmacht/contao-leaflet-geocode-widget": "^1.2", + "netzmacht/php-javascript-builder": "^1.0", + "netzmacht/php-leaflet": "^1.0.2", + "netzmacht/contao-toolkit": "~3.0", + "contao-community-alliance/meta-palettes": "^2.0 || ^1.5", + "menatwork/contao-multicolumnwizard": "^3.2", + "doctrine/cache": "^1.0" + }, + "require-dev": { + "phpcq/all-tasks": "^1.2", + "contao/manager-plugin": "^2.1" + }, + "autoload": { + "psr-4": { + "Netzmacht\\Contao\\Leaflet\\": "src/" + } + }, + "autoload-dev": { + "files": [ + "vendor/phpcq/autoload-validation/hacks/contao-hack.php" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev", + "dev-develop": "3.1.x-dev", + "dev-support/2.x": "2.0.x-dev" + }, + "contao-manager-plugin": "Netzmacht\\Contao\\Leaflet\\Bundle\\ContaoManager\\Plugin", + "contao": { + "transifex": { + "project": "contao-leaflet-maps", + "prefix": "core-", + "languages_cto": "src/Bundle/Resources/contao/languages", + "languages_tx": ".tx" + } + } + } } diff --git a/gulpfile.js b/gulpfile.js index cd55cd9..384c1d6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,8 +5,8 @@ var concat = require('gulp-concat'); var paths = { minified: 'contao-leaflet.js', - scripts: ['assets/maps/src/*.js'], - dest: 'assets/maps' + scripts: ['js/*.js'], + dest: 'src/Bundle/Resources/public/js' }; gulp.task('clear', function() { diff --git a/assets/maps/src/Contao.js b/js/Contao.js similarity index 92% rename from assets/maps/src/Contao.js rename to js/Contao.js index 5912337..004d65e 100644 --- a/assets/maps/src/Contao.js +++ b/js/Contao.js @@ -3,9 +3,7 @@ * * This class provides some helpers for loading layer data manages maps and map objects. */ -L.Contao = L.Class.extend({ - includes: L.Mixin.Events, - +L.Contao = L.Evented.extend({ statics: { /** * Contao extension attribution. @@ -126,8 +124,22 @@ L.Contao = L.Class.extend({ * @param map Pass a map object so that the data loading events are passed to the map. */ load: function (hash, type, options, customLayer, map) { - var url = this.createRequestUrl(hash, map), - layer = omnivore[type](url, options, customLayer); + var url = this.createRequestUrl(hash, map); + + return this.loadFile(url, type, options, customLayer, map); + }, + + /** + * Load data from an url into a layer using omnivore. + * + * @param url A file url. + * @param type The response content format. + * @param options Parser options + * @param customLayer optional custom layer. + * @param map Pass a map object so that the data loading events are passed to the map. + */ + loadFile: function (url, type, options, customLayer, map) { + var layer = omnivore[type](url, options, customLayer); if (map) { // Required because Control.Loading tries to get _leafet_id which is created here. diff --git a/assets/maps/src/Mixin.Attribution.js b/js/Mixin.Attribution.js similarity index 100% rename from assets/maps/src/Mixin.Attribution.js rename to js/Mixin.Attribution.js diff --git a/assets/maps/src/Mixin.GeoJSON.js b/js/Mixin.GeoJSON.js similarity index 100% rename from assets/maps/src/Mixin.GeoJSON.js rename to js/Mixin.GeoJSON.js diff --git a/assets/maps/src/Mixin.Map.js b/js/Mixin.Map.js similarity index 100% rename from assets/maps/src/Mixin.Map.js rename to js/Mixin.Map.js diff --git a/assets/maps/src/OverpassLayer.js b/js/OverpassLayer.js similarity index 100% rename from assets/maps/src/OverpassLayer.js rename to js/OverpassLayer.js diff --git a/module/assets/css/backend.css b/module/assets/css/backend.css deleted file mode 100644 index 62c126d..0000000 --- a/module/assets/css/backend.css +++ /dev/null @@ -1,28 +0,0 @@ - -.tl_listing_container.tree_view ul > li.tl_file { - background: url('./../img/fol-placeholder.gif') no-repeat 6px 1px; -} - -.tl_listing_container.tree_view ul > li.tl_file > div { - line-height: 18px; -} - -.tl_listing_container.tree_view > ul > li.tl_file { - padding-left: 26px; -} - -.tl_listing_container.tree_view ul > li.parent > ul { - padding-left: 20px; -} - -.tl_listing_container.tree_view ul > li > .tl_left > a { - margin-left: -20px; -} - -.tl_listing_container.tree_view ul[class="level_1"] li.tl_file > .tl_left { - padding-left: 20px !important; -} - -.long .tl_text_2 { - width: 325px; -} diff --git a/module/config/autoload.ini b/module/config/autoload.ini deleted file mode 100644 index 2524a49..0000000 --- a/module/config/autoload.ini +++ /dev/null @@ -1 +0,0 @@ -requires[] = 'toolkit' diff --git a/module/config/autoload.php b/module/config/autoload.php deleted file mode 100644 index 15e4fd5..0000000 --- a/module/config/autoload.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -TemplateLoader::addFiles( - array( - 'ce_leaflet_map' => 'system/modules/leaflet/templates', - 'leaflet_map_js' => 'system/modules/leaflet/templates', - 'leaflet_map_html' => 'system/modules/leaflet/templates', - 'mod_leaflet_map' => 'system/modules/leaflet/templates', - 'be_leaflet_geocode' => 'system/modules/leaflet/templates', - 'be_leaflet_about' => 'system/modules/leaflet/templates', - ) -); diff --git a/module/config/config.php b/module/config/config.php deleted file mode 100644 index f729f1b..0000000 --- a/module/config/config.php +++ /dev/null @@ -1,382 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -/* - * Backend module. - */ -array_insert( - $GLOBALS['BE_MOD'], - 1, - array( - 'leaflet' => array - ( - 'leaflet_map' => array - ( - 'tables' => array - ( - 'tl_leaflet_map', - 'tl_leaflet_control', - ), - 'icon' => 'system/modules/leaflet/assets/img/map.png', - 'stylesheet' => 'system/modules/leaflet/assets/css/backend.css', - ), - 'leaflet_layer' => array - ( - 'tables' => array - ( - 'tl_leaflet_layer', - 'tl_leaflet_marker', - 'tl_leaflet_vector', - 'tl_leaflet_icon', - 'tl_leaflet_style', - 'tl_leaflet_popup', - ), - 'icon' => 'system/modules/leaflet/assets/img/layers.png', - 'stylesheet' => 'system/modules/leaflet/assets/css/backend.css', - ), - 'leaflet_about' => array - ( - 'callback' => 'Netzmacht\Contao\Leaflet\Backend\About', - 'icon' => 'system/modules/leaflet/assets/img/about.png', - 'stylesheet' => 'system/modules/leaflet/assets/css/about.css', - ) - ) - ) -); - - -/* - * Content elements. - */ -$GLOBALS['TL_CTE']['includes']['leaflet'] = 'Netzmacht\Contao\Toolkit\Component\ContentElement\ContentElementDecorator'; - - -/* - * Frontend modules - */ -$GLOBALS['FE_MOD']['includes']['leaflet'] = 'Netzmacht\Contao\Toolkit\Component\Module\ModuleDecorator'; - - -/* - * Models. - */ -$GLOBALS['TL_MODELS']['tl_leaflet_control'] = 'Netzmacht\Contao\Leaflet\Model\ControlModel'; -$GLOBALS['TL_MODELS']['tl_leaflet_icon'] = 'Netzmacht\Contao\Leaflet\Model\IconModel'; -$GLOBALS['TL_MODELS']['tl_leaflet_layer'] = 'Netzmacht\Contao\Leaflet\Model\LayerModel'; -$GLOBALS['TL_MODELS']['tl_leaflet_map'] = 'Netzmacht\Contao\Leaflet\Model\MapModel'; -$GLOBALS['TL_MODELS']['tl_leaflet_marker'] = 'Netzmacht\Contao\Leaflet\Model\MarkerModel'; -$GLOBALS['TL_MODELS']['tl_leaflet_popup'] = 'Netzmacht\Contao\Leaflet\Model\PopupModel'; -$GLOBALS['TL_MODELS']['tl_leaflet_style'] = 'Netzmacht\Contao\Leaflet\Model\StyleModel'; -$GLOBALS['TL_MODELS']['tl_leaflet_vector'] = 'Netzmacht\Contao\Leaflet\Model\VectorModel'; - - -/* - * Leaflet mappers. - * - * Mappers do the translations between the database models and the leaflet definition. - */ -$GLOBALS['LEAFLET_MAPPERS'] = array(); -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\MapMapper'; - -// Layer mappers. -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\TileLayerMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = function () { - return new \Netzmacht\Contao\Leaflet\Mapper\Layer\ProviderLayerMapper( - $GLOBALS['LEAFLET_TILE_PROVIDERS'] - ); -}; - -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLayerMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\GroupLayerMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\ReferenceLayerMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\OverpassLayerMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = function () { - return new \Netzmacht\Contao\Leaflet\Mapper\Layer\MarkerClusterLayerMapper( - $GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::MAP_ASSETS] - ); -}; - -// Control mappers. -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\ZoomControlMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\ScaleControlMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\LayersControlMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\AttributionControlMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\LoadingControlMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\FullscreenControlMapper'; - -// Vector mappers. -$GLOBALS['LEAFLET_MAPPERS'][] = function () { - return new Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper( - $GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER] - ); -}; -$GLOBALS['LEAFLET_MAPPERS'][] = function () { - return new Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolylineMapper( - $GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER] - ); -}; -$GLOBALS['LEAFLET_MAPPERS'][] = function () { - return new Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonMapper( - $GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER] - ); -}; -$GLOBALS['LEAFLET_MAPPERS'][] = function () { - return new Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolygonMapper( - $GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER] - ); -}; -$GLOBALS['LEAFLET_MAPPERS'][] = function () { - return new Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMapper( - $GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER] - ); -}; -$GLOBALS['LEAFLET_MAPPERS'][] = function () { - return new Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMarkerMapper( - $GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER] - ); -}; -$GLOBALS['LEAFLET_MAPPERS'][] = function () { - return new Netzmacht\Contao\Leaflet\Mapper\Vector\RectangleMapper( - $GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER] - ); -}; - -// Miscellaneous mappers. -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\UI\PopupMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\ImageIconMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\DivIconMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\ExtraMarkersIconMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Style\FixedStyleMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = function () { - return new \Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper( - $GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER] - ); -}; - -/* - * Leaflet encoders. - * - * The encoders transforms the definitions into javascript. The encoders has to be an implementation of the - * EventDispatcherInterface of the event dispatcher. - * - * You can define the encoders using the syntax of the cca event dispatcher implementation. - * - * @see https://github.com/contao-community-alliance/event-dispatcher#event-subscriber-per-configuration - */ -$GLOBALS['LEAFLET_ENCODERS'] = array(); -$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\MapEncoder'; -$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\ControlEncoder'; -$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\GroupEncoder'; -$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\RasterEncoder'; -$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\VectorEncoder'; -$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\UIEncoder'; -$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\TypeEncoder'; -$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\Contao\Leaflet\Subscriber\EncoderSubscriber'; - -/* - * Leaflet layer types. - * - * The type is used for the database driven definitions. - */ -$GLOBALS['LEAFLET_LAYERS'] = array -( - 'provider' => array - ( - 'children' => false, - 'icon' => 'system/modules/leaflet/assets/img/provider.png', - 'label' => function ($row, $label) { - if (!empty($GLOBALS['TL_LANG']['leaflet_provider'][$row['tile_provider']][0])) { - $provider = $GLOBALS['TL_LANG']['leaflet_provider'][$row['tile_provider']][0]; - } else { - $provider = $row['tile_provider']; - } - - $label .= sprintf(' (%s)', $provider); - - return $label; - } - ), - 'group' => array - ( - 'children' => true, - 'icon' => 'system/modules/leaflet/assets/img/group.png', - ), - 'markers' => array - ( - 'children' => false, - 'icon' => 'system/modules/leaflet/assets/img/markers.png', - 'markers' => true, - 'boundsMode' => array( - 'extend' => true, - 'fit' => 'deferred' - ), - 'label' => function ($row, $label) { - $count = \Netzmacht\Contao\Leaflet\Model\MarkerModel::countBy('pid', $row['id']); - $label .= sprintf( - ' (%s %s)', - $count, - $GLOBALS['TL_LANG']['tl_leaflet_layer']['countEntries'] - ); - - return $label; - } - ), - 'vectors' => array - ( - 'children' => false, - 'icon' => 'system/modules/leaflet/assets/img/vectors.png', - 'vectors' => true, - 'boundsMode' => array( - 'extend' => true, - ), - 'label' => function ($row, $label) { - $count = \Netzmacht\Contao\Leaflet\Model\VectorModel::countBy('pid', $row['id']); - $label .= sprintf( - ' (%s %s)', - $count, - $GLOBALS['TL_LANG']['tl_leaflet_layer']['countEntries'] - ); - - return $label; - } - ), - 'reference' => array - ( - 'children' => false, - 'icon' => 'system/modules/leaflet/assets/img/reference.png', - 'label' => function ($row, $label) { - $reference = \Netzmacht\Contao\Leaflet\Model\LayerModel::findByPk($row['reference']); - - if ($reference) { - $label .= ' (' . $reference->title . ')'; - } - - return $label; - } - ), - 'markercluster' => array - ( - 'children' => true, - 'icon' => 'system/modules/leaflet/assets/img/cluster.png', - ), - 'tile' => array( - 'children' => false, - 'icon' => 'system/modules/leaflet/assets/img/tile.png', - ), - 'overpass' => array( - 'children' => false, - 'icon' => 'system/modules/leaflet/assets/img/overpass.png', - 'label' => function ($row, $label) { - if ($row['overpassQuery']) { - $label .= ' ' . \StringUtil::substr($row['overpassQuery'], 50) . ''; - } - - return $label; - }, - 'boundsMode' => array( - 'extend' => true, - 'fit' => true, - ), - ), -); - -/* - * leaflet controls. - * - * Supported leaflet control types. Register your type for the database driven definition here. - */ -$GLOBALS['LEAFLET_CONTROLS'] = array('zoom', 'layers', 'scale', 'attribution', 'loading', 'fullscreen'); - - -/* - * Leaflet icons. - * - * Supported leaflet icon types. Register you type for the database driven definition here. - */ -$GLOBALS['LEAFLET_ICONS'] = array('image', 'div', 'extra'); - - -/* - * The style concept is not part of the LeafletJS library. Styles are extracted from the Path options. Instead - * of defining the style for every vector again, manage them at one place. - * - * The goal is to provide different style strategies. For instance a random style chooser, one which uses a color - * range and so one. - */ -$GLOBALS['LEAFLET_STYLES'] = array('fixed'); - -/* - * Leaflet vectors. - * - * Supported leaflet vector types. Register you type for the database driven definition here. - */ -$GLOBALS['LEAFLET_VECTORS'] = array -( - 'polyline', - 'polygon', - 'multiPolyline', - 'multiPolygon', - 'rectangle', - 'circle', - 'circleMarker' -); - - -/* - * Leaflet tile layer providers. - */ -require_once TL_ROOT . '/system/modules/leaflet/config/leaflet_providers.php'; - -/* - * Leaflet assets. - * - * The leaflet definition are aware of the required javascript libraries. Register the assets so that they are - * loaded automatically. - * - * Each entry is an array of 2 values. The first is the resource. The second is a type. Supported types are: - * - url: An valid url. - * - file: An file path relative to the Contao Root. - * - source: Inline css/javascript. - * - * You don't have to define it as array if you simply add a file. Do not add |static and or media type flag to it. - * It's getting added by default if not being in debug mode. - */ -if (!isset($GLOBALS['LEAFLET_LIBRARIES'])) { - $GLOBALS['LEAFLET_LIBRARIES'] = array(); -} - -/* - * When creating a GeoJSON feature of a map object a feature.properties.model object is passed. - * Define the properties you always want to set. - * - * For more control you can subscribe the ConvertToGeoJsonEvent. - * - * The entry can be a string or an array. If an array is passed, the 2nd value is the type. Following types - * are supported. - * - array: Use deserialize before adding the value - * - file: Thread value a uuid and find the path. - * - files: Thread values as a list of file uuids and get an array of paths. - */ -$GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES']['tl_leaflet_marker'][] = 'id'; -$GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES']['tl_leaflet_marker'][] = 'title'; -$GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES']['tl_leaflet_marker'][] = 'alias'; - -$GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES']['tl_leaflet_vector'][] = 'id'; -$GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES']['tl_leaflet_vector'][] = 'title'; -$GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES']['tl_leaflet_vector'][] = 'alias'; - - -/* - * Filters can be passed to a data request to get only specific data from a layer. - */ -$GLOBALS['LEAFLET_FILTERS']['bbox'] = 'Netzmacht\Contao\Leaflet\Filter\BboxFilter'; -$GLOBALS['LEAFLET_FILTERS']['distance'] = 'Netzmacht\Contao\Leaflet\Filter\DistanceFilter'; diff --git a/module/config/event_subscribers.php b/module/config/event_subscribers.php deleted file mode 100644 index 3bd139c..0000000 --- a/module/config/event_subscribers.php +++ /dev/null @@ -1,15 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ -return array( - $GLOBALS['container']['leaflet.boot.subscriber'], - 'Netzmacht\Contao\Leaflet\Subscriber\HashSubscriber', - $GLOBALS['container']['leaflet.subscriber.geo-json'], -); diff --git a/module/config/leaflet_amenities.php b/module/config/leaflet_amenities.php deleted file mode 100644 index 07e5210..0000000 --- a/module/config/leaflet_amenities.php +++ /dev/null @@ -1,213 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -return [ - 'administration', - 'advertising', - 'alm', - 'animal_boarding', - 'animal_breeding', - 'animal_shelter', - 'architect_office', - 'arts_centre', - 'artwork', - 'atm', - 'audiologist', - 'baby_hatch', - 'bank', - 'bar', - 'bbq', - 'bench', - 'bicycle_parking', - 'bicycle_rental', - 'bicycle_repair_station', - 'bicycle_trailer_sharing', - 'biergarten', - 'bikeshed', - 'boat_rental', - 'boat_sharing', - 'boat_storage', - 'brothel', - 'bts', - 'bureau_de_change', - 'bus_station', - 'cafe', - 'canoe_hire', - 'car_rental', - 'car_repair', - 'car_sharing', - 'car_wash', - 'casino', - 'charging_station', - 'childcare', - 'cinema', - 'citymap_post', - 'clinic', - 'clock', - 'club', - 'coast_guard', - 'coast_radar_station', - 'college', - 'community_center', - 'community_centre', - 'compressed_air', - 'concert_hall', - 'conference_centre', - 'courthouse', - 'coworking_space', - 'crematorium', - 'crucifix', - 'crypt', - 'customs', - 'dancing_school', - 'dead_pub', - 'dentist', - 'disused', - 'dive_centre', - 'doctors', - 'dog_bin', - 'dog_waste_bin', - 'dojo', - 'drinking_water', - '_driving_school', - 'education', - 'embassy', - 'emergency_phone', - 'emergency_service', - 'events_venue', - 'ev_charging', - 'exhibition_centre', - 'fast_food', - 'ferry_terminal', - 'festival_grounds', - 'financial_advice', - 'fire_hydrant', - 'fire_station', - 'first_aid', - 'fish_spa', - 'food_court', - 'fountain', - 'fuel', - 'gambling', - 'game_feeding', - 'garages', - 'grave_yard', - 'grit_bin', - 'harbourmaster', - 'hospice', - 'hospital', - 'hotel', - 'hunting_stand', - 'ice_cream', - 'internet_cafe', - 'jobcentre', - 'kindergarten', - 'kiosk', - 'kitchen', - 'Kneippbecken', - 'kneipp_water_cure', - 'language_school', - 'lavoir', - 'library', - 'lifeboat_station', - 'life_ring', - 'loading_dock', - 'love_hotel', - 'marae', - 'marketplace', - 'milk_dispenser', - 'mobile_library', - 'monastery', - 'money_transfer', - 'mortuary', - 'motorcycle_parking', - 'motorcycle_rental', - 'music_school', - 'music_venue', - 'nameplate', - 'nightclub', - 'nursery', - 'nursing_home', - 'park', - 'parking', - 'parking_entrance', - 'parking_space', - 'pharmacy', - 'photo_booth', - 'place_of_worship', - 'planetarium', - 'police', - 'post_box', - 'post_office', - 'preschool', - 'printer', - 'prison', - 'prison_camp', - 'proposed', - 'pub', - 'public_bath', - 'public_bookcase', - 'public_building', - 'public_hall', - 'ranger_station', - 'recycling', - 'refugee_housing', - 'register_office', - 'rescue_box', - 'rescue_station', - 'research_institute', - 'restaurant', - 'retirement_home', - 'sanatorium', - 'sanitary_dump_station', - 'sauna', - 'school', - 'scout_hut', - 'shelter', - 'shop', - 'shower', - 'ski_school', - 'smoking_area', - 'social_centre', - 'social_facility', - 'spa', - 'stables', - 'stripclub', - 'studio', - 'swimming_pool', - 'swingerclub', - 'table', - 'taxi', - 'telephone', - 'theatre', - 'ticket_booth', - 'ticket_validator', - 'toilets', - 'townhall', - 'trolley_bay', - 'university', - 'vacuum_cleaner', - 'vehicle_inspection', - 'vending_machine', - 'veterinary', - 'vivarium', - 'wash_center', - 'waste_basket', - 'waste_disposal', - 'waste_transfer_station', - 'water', - 'watering_place', - 'water_point', - 'weighbridge', - 'winery', - 'yacht_club', - 'youth_centre', -]; diff --git a/module/config/leaflet_providers.php b/module/config/leaflet_providers.php deleted file mode 100644 index d1531a8..0000000 --- a/module/config/leaflet_providers.php +++ /dev/null @@ -1,181 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -/* - * Support all providers and variants which are supported by leaflet-providers. - * See https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js - */ - -$GLOBALS['LEAFLET_TILE_PROVIDERS'] = array -( - 'OpenStreetMap' => array - ( - 'variants' => array('Mapnik', 'BlackAndWhite', 'DE', 'France', 'HOT', 'BZH'), - ), - 'OpenSeaMap' => array(), - 'OpenTopoMap' => array(), - 'Thunderforest' => array - ( - 'variants' => array( - 'OpenCycleMap', - 'Transport', - 'TransportDark', - 'SpinalMap', - 'Landscape', - 'Outdoors', - 'Pioneer' - ) - ), - 'OpenMapSurfer' => array - ( - 'variants' => array('Roads', 'AdminBounds', 'Grayscale') - ), - 'Hydda' => array( - 'variants' => array('Full', 'Base', 'RoadsAndLabels') - ), - 'MapBox' => array( - 'class' => 'Netzmacht\LeafletPHP\Plugins\LeafletProviders\MapBoxProvider', - 'options' => array( - 'key' => 'tile_provider_key' - ), - ), - 'Stamen' => array( - 'variants' => array( - 'Toner', - 'TonerBackground', - 'TonerHybrid', - 'TonerLines', - 'TonerLabels', - 'TonerLite', - 'Terrain', - 'TerrainBackground', - 'TopOSMRelief', - 'TopOSMFeatures', - 'Watercolor' - ) - ), - 'Esri' => array( - 'variants' => array( - 'WorldStreetMap', - 'DeLorme', - 'WorldTopoMap', - 'WorldImagery', - 'WorldTerrain', - 'WorldShadedRelief', - 'WorldPhysical', - 'OceanBasemap', - 'NatGeoWorldMap', - 'WorldGrayCanvas' - ) - ), - 'OpenWeatherMap' => array( - 'variants' => array( - 'Clouds', - 'CloudsClassic', - 'Precipitation', - 'PrecipitationClassic', - 'Rain', - 'RainClassic', - 'Pressure', - 'PressureContour', - 'Wind', - 'Temperature', - 'Snow' - ) - ), - 'HERE' => array( - 'variants' => array( - 'normalDay', - 'normalDayCustom', - 'normalDayGrey', - 'normalDayMobile', - 'normalDayGreyMobile', - 'normalDayTransit', - 'normalDayTransitMobile', - 'normalNight', - 'normalNightMobile', - 'normalNightGrey', - 'normalNightGreyMobile', - 'basicMap', - 'mapLabels', - 'trafficFlow', - 'carnavDayGrey', - 'hybridDay', - 'hybridDayMobile', - 'pedestrianDay', - 'pedestrianNight', - 'satelliteDay', - 'terrainDay', - 'terrainDayMobile', - ), - 'options' => array( - 'appId' => 'tile_provider_key', - 'appCode' => 'tile_provider_code', - ), - 'fields' => array('tile_provider_key', 'tile_provider_code'), - 'class' => 'Netzmacht\LeafletPHP\Plugins\LeafletProviders\HereProvider', - ), - 'JusticeMap' => array( - 'variants' => array( - 'income', - 'americanIndian', - 'asian', - 'black', - 'hispanic', - 'multi', - 'nonWhite', - 'white', - 'plurality' - ) - ), - 'FreeMapSK' => array(), - 'MtbMap' => array(), - 'CartoDB' => array( - 'variants' => array( - 'Positron', - 'PositronNoLabels', - 'PositronOnlyLabels', - 'DarkMatter', - 'DarkMatterNoLabels', - 'DarkMatterOnlyLabels', - ) - ), - 'HikeBike' => array( - 'variants' => array( - 'HikeBike', - 'HillShading', - ) - ), - 'BasemapAT' => array( - 'variants' => array( - 'basemap', - 'grau', - 'overlay', - 'highdpi', - 'orthofoto', - ) - ), - 'nlmaps' => array( - 'variants' => array('standaard', 'pastel', 'grijs', 'luchtfoto') - ), - 'NASAGIBS' => array( - 'variants' => array( - 'ModisTerraTrueColorCR', - 'ModisTerraBands367CR', - 'ViirsEarthAtNight2012', - 'ModisTerraLSTDay', - 'ModisTerraSnowCover', - 'ModisTerraAOD', - 'ModisTerraChlorophyll', - ) - ), - 'NLS' => array() -); diff --git a/module/config/services.php b/module/config/services.php deleted file mode 100644 index 8ed2ab0..0000000 --- a/module/config/services.php +++ /dev/null @@ -1,361 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -use Doctrine\Common\Cache\ArrayCache; -use Doctrine\Common\Cache\FilesystemCache; -use Interop\Container\ContainerInterface; -use Netzmacht\Contao\Leaflet\Alias\DefaultAliasFilter; -use Netzmacht\Contao\Leaflet\Boot; -use Netzmacht\Contao\Leaflet\ContaoAssets; -use Netzmacht\Contao\Leaflet\Dca\ControlCallbacks; -use Netzmacht\Contao\Leaflet\Dca\FrontendIntegration; -use Netzmacht\Contao\Leaflet\Dca\LayerCallbacks; -use Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks; -use Netzmacht\Contao\Leaflet\Dca\MapCallbacks; -use Netzmacht\Contao\Leaflet\Dca\Validator; -use Netzmacht\Contao\Leaflet\Dca\VectorCallbacks; -use Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices; -use Netzmacht\Contao\Leaflet\Frontend\MapElement; -use Netzmacht\Contao\Leaflet\Frontend\MapModule; -use Netzmacht\Contao\Leaflet\Frontend\ValueFilter; -use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; -use Netzmacht\Contao\Leaflet\MapProvider; -use Netzmacht\Contao\Leaflet\Subscriber\BootSubscriber; -use Netzmacht\Contao\Leaflet\Subscriber\GeoJsonSubscriber; -use Netzmacht\Contao\Toolkit\Data\Alias\Filter\ExistingAliasFilter; -use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SlugifyFilter; -use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SuffixFilter; -use Netzmacht\Contao\Toolkit\Data\Alias\FilterBasedAliasGenerator; -use Netzmacht\Contao\Toolkit\Data\Alias\Validator\UniqueDatabaseValueValidator; -use Netzmacht\Contao\Toolkit\DependencyInjection\Services; -use Netzmacht\JavascriptBuilder\Builder; -use Netzmacht\JavascriptBuilder\Encoder\ChainEncoder; -use Netzmacht\JavascriptBuilder\Encoder\JavascriptEncoder; -use Netzmacht\JavascriptBuilder\Encoder\MultipleObjectsEncoder; -use Netzmacht\JavascriptBuilder\Flags; -use Netzmacht\JavascriptBuilder\Output; -use Netzmacht\JavascriptBuilder\Symfony\EventDispatchingEncoder; -use Netzmacht\LeafletPHP\Leaflet; -use Symfony\Component\EventDispatcher\EventDispatcher; - -/** @var \Pimple $container */ -global $container; - -/* - * Leaflet map provider is a simply api entry to to get the leaflet map from the database. - */ -$container[LeafletServices::MAP_PROVIDER] = $container->share(function ($container) { - return new MapProvider( - $container[LeafletServices::DEFINITION_MAPPER], - $container[LeafletServices::DEFINITION_BUILDER], - $container[Services::EVENT_DISPATCHER], - $container[Services::INPUT], - $container[LeafletServices::MAP_ASSETS], - $container[LeafletServices::CACHE], - $GLOBALS['LEAFLET_FILTERS'], - \Config::get('debugMode') || \Config::get('displayErrors') - ); -}); - -/* - * Contao assets handler. Loads Leaflet assets as contao (static) assets. - */ -$container[LeafletServices::MAP_ASSETS] = $container->share(function ($container) { - return new ContaoAssets($container[Services::ASSETS_MANAGER]); -}); - -/* - * The leaflet boot. - */ -$container[LeafletServices::BOOT] = $container->share(function ($container) { - return new Boot($container[Services::EVENT_DISPATCHER]); -}); - -$container['leaflet.boot.subscriber'] = $container->share(function ($container) { - return new BootSubscriber( - $container[LeafletServices::MAP_ASSETS], - $GLOBALS['LEAFLET_MAPPERS'], - $GLOBALS['LEAFLET_ENCODERS'], - $GLOBALS['LEAFLET_LIBRARIES'] - ); -}); - - -/* - * The definition mapper. - */ -$container[LeafletServices::DEFINITION_MAPPER] = $container->share(function ($container) { - /** @var Boot $boot */ - $boot = $container[LeafletServices::BOOT]; - $mapper = new DefinitionMapper($container[Services::EVENT_DISPATCHER]); - - return $boot->initializeDefinitionMapper($mapper); -}); - - -/* - * The local event dispatcher is used for the leaflet javascript encoding system. - */ -$container[LeafletServices::DEFINITION_BUILDER_EVENT_DISPATCHER] = $container->share(function ($container) { - /** @var Boot $boot */ - $boot = $container[LeafletServices::BOOT]; - $dispatcher = new EventDispatcher(); - - return $boot->initializeEventDispatcher($dispatcher); -}); - -/* - * The javascript encoder factory being used for building the map javascript. - */ -$container[LeafletServices::DEFINITION_ENCODER_FACTORY] = function ($container) { - $dispatcher = $container[LeafletServices::DEFINITION_BUILDER_EVENT_DISPATCHER]; - - return function (Output $output) use ($dispatcher) { - $encoder = new ChainEncoder(); - $encoder - ->register(new MultipleObjectsEncoder()) - ->register(new EventDispatchingEncoder($dispatcher)) - ->register(new JavascriptEncoder($output, JSON_UNESCAPED_SLASHES)); - - return $encoder; - }; -}; - -/* - * The leaflet builder transforms the definition to javascript. - */ -$container[LeafletServices::DEFINITION_BUILDER] = $container->share(function($container) { - /** @var Boot $boot */ - $boot = $container[LeafletServices::BOOT]; - $dispatcher = $container[LeafletServices::DEFINITION_BUILDER_EVENT_DISPATCHER]; - $factory = $container[LeafletServices::DEFINITION_ENCODER_FACTORY]; - - $builder = new Builder($factory); - $leaflet = new Leaflet($builder, $dispatcher, array(), JSON_UNESCAPED_SLASHES ^ Flags::BUILD_STACK); - - return $boot->initializeLeafletBuilder($leaflet); -}); - -$container[LeafletServices::FRONTEND_VALUE_FILTER] = $container->share(function($container) { - return new ValueFilter($container[Services::INSERT_TAG_REPLACER]); -}); - -/** - * Internal used leaflet cache. - * - * @var Cache - */ -$container[LeafletServices::CACHE] = $container->share( - function ($container) { - if ($container[Services::PRODUCTION_MODE]) { - return new FilesystemCache(TL_ROOT . '/system/cache/leaflet'); - } else { - return new ArrayCache(); - } - } -); - -/** - * Leaflet alias generator. - * - * @return \Netzmacht\Contao\Toolkit\Data\Alias\AliasGenerator - */ -$container[LeafletServices::ALIAS_GENERATOR] = $container->share( - function ($container) { - return function ($dataContainerName, $aliasField, $fields) use ($container) { - $filters = [ - new ExistingAliasFilter(), - new SlugifyFilter($fields), - new DefaultAliasFilter($dataContainerName), - new SuffixFilter(), - ]; - - $validator = new UniqueDatabaseValueValidator( - $container[Services::DATABASE_CONNECTION], - $dataContainerName, - $aliasField - ); - - return new FilterBasedAliasGenerator($filters, $validator, $dataContainerName, $aliasField, '_'); - }; - } -); - -/** - * Leaflet alias generator. - * - * @return \Netzmacht\Contao\Toolkit\Data\Alias\AliasGenerator - */ -$container[LeafletServices::PARENT_ALIAS_GENERATOR] = $container->share( - function ($container) { - return function ($dataContainerName, $aliasField, $fields) use ($container) { - $filters = [ - new ExistingAliasFilter(), - new SlugifyFilter($fields), - new DefaultAliasFilter($dataContainerName), - new SuffixFilter(), - ]; - - $validator = new UniqueDatabaseValueValidator( - $container[Services::DATABASE_CONNECTION], - $dataContainerName, - $aliasField, - ['pid'] - ); - - return new FilterBasedAliasGenerator($filters, $validator, $dataContainerName, $aliasField, '_'); - }; - } -); - -/** - * Callback helper class for tl_leaflet_map. - * - * @return MapCallbacks - */ -$container['leaflet.dca.map-callbacks'] = $container->share( - function ($container) { - return new MapCallbacks( - $container[Services::DCA_MANAGER], - $container[Services::DATABASE_CONNECTION] - ); - } -); - -/** - * Callback helper class for tl_leaflet_layer. - * - * @return LayerCallbacks - */ -$container['leaflet.dca.layer-callbacks'] = $container->share( - function ($container) { - return new LayerCallbacks( - $container[Services::DCA_MANAGER], - $container[Services::DATABASE_CONNECTION], - $container[Services::TRANSLATOR], - $GLOBALS['LEAFLET_LAYERS'], - $GLOBALS['LEAFLET_TILE_PROVIDERS'], - require TL_ROOT . '/system/modules/leaflet/config/leaflet_amenities.php' - ); - } -); - -/** - * Callback helper class for tl_leaflet_control. - * - * @return ControlCallbacks - */ -$container['leaflet.dca.control-callbacks'] = $container->share( - function ($container) { - return new ControlCallbacks( - $container[Services::DCA_MANAGER], - $container[Services::DATABASE_CONNECTION] - ); - } -); - -/** - * Callback helper class for tl_leaflet_control. - * - * @return ControlCallbacks - */ -$container['leaflet.dca.vector-callbacks'] = $container->share( - function ($container) { - return new VectorCallbacks($container[Services::DCA_MANAGER]); - } -); - -/** - * Callback helper class for frontend integration. - * - * @return FrontendIntegration - */ -$container['leaflet.dca.frontend-integration'] = $container->share( - function ($container) { - return new FrontendIntegration( - $container[Services::TRANSLATOR] - ); - } -); - -/** - * Common callback helpers. - * - * @return LeafletCallbacks - */ -$container['leaflet.dca.common'] = $container->share( - function ($container) { - return new LeafletCallbacks( - $container[Services::FILE_SYSTEM] - ); - } -); - -/** - * Validator helper class. - * - * @return Validator - */ -$container['leaflet.dca.validator'] = $container->share( - function ($container) { - return new Validator( - $container[Services::TRANSLATOR] - ); - } -); - -/** - * Component factory for content element. - * - * @param ContentModel $model Content model. - * @param string $column Template section. - * @param ContainerInterface $container Container. - * - * @return MapElement - */ -$container[Services::CONTENT_ELEMENTS_MAP]['leaflet'] = function ($model, $column, ContainerInterface $container) { - return new MapElement( - $model, - $container->get(Services::TEMPLATE_FACTORY), - $container->get(Services::TRANSLATOR), - $container->get(LeafletServices::MAP_PROVIDER), - $container->get(Services::INPUT), - $container->get(Services::CONFIG), - $column - ); -}; - -/** - * Component factory for frontend module. - * - * @param ModuleModel $model Module model. - * @param string $column Template section. - * @param ContainerInterface $container Container. - * - * @return MapModule - */ -$container[Services::MODULES_MAP]['leaflet'] = function ($model, $column, ContainerInterface $container) { - return new MapModule( - $model, - $container->get(Services::TEMPLATE_FACTORY), - $container->get(Services::TRANSLATOR), - $container->get(LeafletServices::MAP_PROVIDER), - $container->get(Services::INPUT), - $container->get(Services::CONFIG), - $column - ); -}; - -$container['leaflet.subscriber.geo-json'] = $container->share(function () { - return new GeoJsonSubscriber( - $GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES'] - ); -}); diff --git a/module/dca/tl_content.php b/module/dca/tl_content.php deleted file mode 100644 index 45d2a7a..0000000 --- a/module/dca/tl_content.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -$GLOBALS['TL_DCA']['tl_content']['metapalettes']['leaflet'] = array( - 'type' => array('type', 'headline'), - 'leaflet' => array('leaflet_map', 'leaflet_mapId', 'leaflet_width', 'leaflet_height', 'leaflet_template'), - 'templates' => array(':hide', 'customTpl'), - 'protected' => array(':hide', 'protected'), - 'expert' => array(':hide', 'guests', 'cssID', 'space'), - 'invisible' => array(':hide', 'invisible', 'start', 'start') -); - -$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_map'] = array( - 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_map'], - 'inputType' => 'select', - 'exclude' => true, - 'options_callback' => \Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getMaps'), - 'wizard' => array( - \Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getEditMapLink'), - ), - 'eval' => array( - 'tl_class' => 'w50 wizard', - 'chosen' => true, - ), - 'sql' => "int(10) unsigned NOT NULL default '0'" -); - -$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_mapId'] = array( - 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_mapId'], - 'inputType' => 'text', - 'exclude' => true, - 'eval' => array( - 'tl_class' => 'w50', - 'chosen' => true, - 'maxlength' => 16, - ), - 'sql' => "varchar(16) NOT NULL default ''" -); - -$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_width'] = array( - 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_width'], - 'inputType' => 'inputUnit', - 'options' => array('px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'), - 'search' => false, - 'exclude' => true, - 'eval' => array('rgxp' => 'digit', 'tl_class' => 'clr w50'), - 'sql' => "varchar(64) NOT NULL default ''" -); - - -$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_height'] = array( - 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_height'], - 'inputType' => 'inputUnit', - 'options' => array('px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'), - 'search' => false, - 'exclude' => true, - 'eval' => array('rgxp' => 'digit', 'tl_class' => 'w50'), - 'sql' => "varchar(64) NOT NULL default ''" -); - -$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_template'] = array( - 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_template'], - 'inputType' => 'select', - 'exclude' => true, - 'options_callback' => \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::getTemplates('leaflet_map_js'), - 'eval' => array( - 'tl_class' => 'w50', - 'chosen' => true, - ), - 'sql' => "varchar(64) NOT NULL default ''" -); diff --git a/module/dca/tl_leaflet_control.php b/module/dca/tl_leaflet_control.php deleted file mode 100644 index 56ef50a..0000000 --- a/module/dca/tl_leaflet_control.php +++ /dev/null @@ -1,439 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ -\Controller::loadLanguageFile('leaflet'); - -$GLOBALS['TL_DCA']['tl_leaflet_control'] = array -( - 'config' => array( - 'dataContainer' => 'Table', - 'enableVersioning' => true, - 'ptable' => 'tl_leaflet_map', - 'sql' => array - ( - 'keys' => array - ( - 'id' => 'primary', - 'pid' => 'index', - ) - ), - 'onsubmit_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - - // List - 'list' => array - ( - 'sorting' => array - ( - 'mode' => 4, - 'fields' => array('sorting'), - 'headerFields' => array('title'), - 'flag' => 1, - 'sorting' => 2, - 'panelLayout' => 'filter,sort;search,limit', - 'child_record_callback' => \Netzmacht\Contao\Leaflet\Dca\ControlCallbacks::callback('generateRow'), - ), - 'label' => array - ( - 'fields' => array('title'), - 'format' => '%s', - ), - 'global_operations' => array - ( - 'all' => array - ( - 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], - 'href' => 'act=select', - 'class' => 'header_edit_all', - 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' - ) - ), - 'operations' => array - ( - 'edit' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['edit'], - 'href' => 'act=edit', - 'icon' => 'header.gif' - ), - 'copy' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['copy'], - 'href' => 'act=copy', - 'icon' => 'copy.gif' - ), - 'delete' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['delete'], - 'href' => 'act=delete', - 'icon' => 'delete.gif', - 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"' - ), - 'toggle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['toggle'], - 'icon' => 'visible.gif', - 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', - 'button_callback' => \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::stateButton('tl_leaflet_control', 'active') - ), - 'show' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['show'], - 'href' => 'act=show', - 'icon' => 'show.gif' - ) - ) - ), - - 'palettes' => array( - '__selector__' => array('type') - ), - - 'metapalettes' => array( - 'default' => array( - 'name' => array('title', 'alias', 'type', 'position'), - 'config' => array(), - 'active' => array('active'), - ), - 'zoom extends default' => array( - 'config' => array('zoomInText', 'zoomOutText', 'zoomInTitle', 'zoomOutTitle'), - ), - 'layers extends default' => array( - 'config' => array('layers', 'collapsed', 'autoZIndex') - ), - 'scale extends default' => array( - 'config' => array('maxWidth', 'metric', 'imperial', 'updateWhenIdle') - ), - 'attribution extends default' => array( - 'config' => array('attributions', 'prefix', 'disableDefault') - ), - 'loading extends default' => array( - 'config' => array('separate', 'zoomControl', 'spinjs') - ), - 'fullscreen extends default' => array( - 'config' => array('buttonTitle', 'separate', 'simulateFullScreen') - ), - ), - - 'metasubpalettes' => array( - 'spinjs' => array('spin') - ), - - 'fields' => array - ( - 'id' => array - ( - 'sql' => "int(10) unsigned NOT NULL auto_increment" - ), - 'pid' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'tstamp' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'sorting' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'", - 'sorting' => true, - ), - 'title' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['title'], - 'exclude' => true, - 'inputType' => 'text', - 'sorting' => true, - 'search' => true, - 'flag' => 1, - 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'alias' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['alias'], - 'exclude' => true, - 'inputType' => 'text', - 'search' => true, - 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::aliasGenerator( - 'tl_leaflet_control', - 'alias', - ['title'], - \Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::PARENT_ALIAS_GENERATOR - ), - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'), - ), - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'nullIfEmpty' => true), - 'sql' => "varchar(255) NULL" - ), - 'type' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['type'], - 'exclude' => true, - 'inputType' => 'select', - 'filter' => true, - 'sorting' => true, - 'eval' => array( - 'mandatory' => true, - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'submitOnChange' => true, - 'chosen' => true, - 'helpwizard' => true, - ), - 'options' => $GLOBALS['LEAFLET_CONTROLS'], - 'reference' => &$GLOBALS['TL_LANG']['leaflet_control'], - 'sql' => "varchar(32) NOT NULL default ''" - ), - 'position' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['position'], - 'exclude' => true, - 'inputType' => 'select', - 'filter' => true, - 'sorting' => true, - 'options' => array('topleft', 'topright', 'bottomleft', 'bottomright'), - 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_control'], - 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50', 'helpwizard' => true), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'active' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['active'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'filter' => true, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''", - 'save_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - 'zoomInText' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInText'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'zoomOutText' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInText'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'zoomInTitle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInTitle'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'zoomOutTitle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomOutTitle'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'collapsed' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['collapsed'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => '1', - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'autoZIndex' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['autoZIndex'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => '1', - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'layers' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['layers'], - 'exclude' => true, - 'inputType' => 'multiColumnWizard', - 'load_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\ControlCallbacks::callback('loadLayerRelations'), - ), - 'save_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\ControlCallbacks::callback('saveLayerRelations'), - ), - 'eval' => array - ( - 'tl_class' => 'clr', - 'columnFields' => array - ( - 'layer' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['layer'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => \Netzmacht\Contao\Leaflet\Dca\ControlCallbacks::callback('getLayers'), - 'eval' => array( - 'style' => 'width: 300px', - 'chosen' => true, - 'includeBlankOption' => true - ), - ), - 'mode' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['layerMode'], - 'exclude' => true, - 'inputType' => 'select', - 'options' => array('base', 'overlay'), - 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_control'], - 'eval' => array( - 'style' => 'width: 200px', - 'helpwizard' => true, - ), - ), - ) - ), - 'sql' => "mediumblob NULL" - ), - 'maxWidth' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['maxWidth'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => 100, - 'eval' => array('tl_class' => 'w50', 'rgxp' => 'digit'), - 'sql' => "int(5) NOT NULL default '100'" - ), - 'metric' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['metric'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => '1', - 'eval' => array('tl_class' => 'w50 clr'), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'imperial' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['imperial'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => '1', - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'updateWhenIdle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['updateWhenIdle'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'prefix' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['prefix'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'attributions' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['attributions'], - 'exclude' => true, - 'inputType' => 'listWizard', - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'clr', 'allowHtml' => true), - 'sql' => "mediumblob NULL" - ), - 'separate' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['separate'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => array('tl_class' => 'w50 m12'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'zoomControl' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomControl'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => \Netzmacht\Contao\Leaflet\Dca\ControlCallbacks::callback('getZoomControls'), - 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_control'], - 'eval' => array( - 'mandatory' => false, - 'tl_class' => 'w50', - 'chosen' => true, - 'includeBlankOption' => true - ), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'spinjs' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['spinjs'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'spin' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['spin'], - 'exclude' => true, - 'inputType' => 'textarea', - 'eval' => array( - 'style' => 'height:60px', - 'preserveTags' => true, - 'decodeEntities' => true, - 'allowHtml' => true, - 'rte' => 'ace|json', - 'tl_class' => 'clr' - ), - 'sql' => "mediumtext NULL" - ), - 'simulateFullScreen' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['simulateFullScreen'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => array('tl_class' => 'w50 m12'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'buttonTitle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['buttonTitle'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'disableDefault' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['disableDefault'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50 m12'), - 'sql' => "char(1) NOT NULL default ''" - ), - ), -); diff --git a/module/dca/tl_leaflet_control_layer.php b/module/dca/tl_leaflet_control_layer.php deleted file mode 100644 index dfdc01a..0000000 --- a/module/dca/tl_leaflet_control_layer.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -$GLOBALS['TL_DCA']['tl_leaflet_control_layer'] = array -( - 'config' => array( - 'dataContainer' => 'Table', - 'sql' => array - ( - 'keys' => array - ( - 'id' => 'primary', - 'cid,lid' => 'unique', - ) - ) - ), - - 'fields' => array - ( - 'id' => array - ( - 'sql' => "int(10) unsigned NOT NULL auto_increment" - ), - 'tstamp' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'sorting' => array( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'cid' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'lid' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'mode' => array - ( - 'sql' => "varchar(16) NOT NULL default ''" - ) - ) -); diff --git a/module/dca/tl_leaflet_icon.php b/module/dca/tl_leaflet_icon.php deleted file mode 100644 index b9ef4fc..0000000 --- a/module/dca/tl_leaflet_icon.php +++ /dev/null @@ -1,449 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -$GLOBALS['TL_DCA']['tl_leaflet_icon'] = array -( - 'config' => array( - 'dataContainer' => 'Table', - 'enableVersioning' => true, - 'sql' => array - ( - 'keys' => array - ( - 'id' => 'primary', - 'alias' => 'unique', - ) - ), - 'onsubmit_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - - 'list' => array - ( - 'sorting' => array - ( - 'mode' => 1, - 'fields' => array('title'), - 'flag' => 1, - 'panelLayout' => 'limit', - 'headerFields' => array('title', 'type'), - ), - 'label' => array - ( - 'fields' => array('title', 'type'), - 'format' => '%s [%s]', - ), - 'global_operations' => array - ( - 'layers' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['layersBtn'], - 'href' => 'table=tl_leaflet_layer', - 'icon' => 'system/modules/leaflet/assets/img/layers.png', - 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' - ), - 'styles' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['styles'], - 'href' => 'table=tl_leaflet_style', - 'icon' => 'system/modules/leaflet/assets/img/style.png', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ), - 'popups' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['popups'], - 'href' => 'table=tl_leaflet_popup', - 'icon' => 'system/modules/leaflet/assets/img/popup.png', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ), - 'all' => array - ( - 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], - 'href' => 'act=select', - 'class' => 'header_edit_all', - 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' - ), - ), - 'operations' => array - ( - 'edit' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['edit'], - 'href' => 'act=edit', - 'icon' => 'edit.gif' - ), - 'copy' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['copy'], - 'href' => 'act=copy', - 'icon' => 'copy.gif' - ), - 'delete' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['delete'], - 'href' => 'act=delete', - 'icon' => 'delete.gif', - 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"' - ), - 'toggle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['toggle'], - 'icon' => 'visible.gif', - 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', - 'button_callback' => \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::stateButton( - 'tl_leaflet_icon', - 'active' - ) - ), - 'show' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['show'], - 'href' => 'act=show', - 'icon' => 'show.gif' - ) - ) - ), - - 'palettes' => array( - '__selector__' => array('type') - ), - - 'metapalettes' => array( - 'default' => array( - 'title' => array('title', 'alias', 'type'), - ), - 'image extends default' => array( - 'config' => array( - 'iconImage', - 'iconRetinaImage', - 'iconAnchor', - 'popupAnchor', - 'className', - ), - 'shadow' => array( - 'shadowImage', - 'shadowRetinaImage', - 'shadowAnchor', - ), - 'active' => array( - 'active' - ) - ), - - 'div extends default' => array( - 'config' => array( - 'html', - 'iconSize', - 'iconAnchor', - 'popupAnchor', - 'className', - ), - 'active' => array( - 'active' - ) - ), - - 'extra extends default' => array( - 'config' => array( - 'icon', - 'prefix', - 'shape', - 'markerColor', - 'number', - 'iconColor', - ), - 'active' => array( - 'active' - ) - ), - ), - - 'fields' => array - ( - 'id' => array - ( - 'sql' => "int(10) unsigned NOT NULL auto_increment" - ), - 'tstamp' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'title' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['title'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'alias' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['alias'], - 'exclude' => true, - 'inputType' => 'text', - 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::aliasGenerator( - 'tl_leaflet_icon', - 'alias', - ['title'], - \Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR - ), - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'), - ), - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), - 'sql' => "varchar(255) NULL" - ), - 'type' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['type'], - 'exclude' => true, - 'inputType' => 'select', - 'eval' => array( - 'mandatory' => true, - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'submitOnChange' => true, - 'chosen' => true, - ), - 'options' => &$GLOBALS['LEAFLET_ICONS'], - 'reference' => &$GLOBALS['TL_LANG']['leaflet_icon'], - 'sql' => "varchar(32) NOT NULL default ''" - ), - 'active' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['active'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''", - 'save_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - 'iconImage' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['iconImage'], - 'exclude' => true, - 'inputType' => 'fileTree', - 'eval' => array( - 'filesOnly' => true, - 'fieldType' => 'radio', - 'mandatory' => true, - 'tl_class' => 'clr', - 'extensions' => 'gif,png,svg,jpg' - ), - 'sql' => "binary(16) NULL", - ), - 'iconRetinaImage' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['iconRetinaImage'], - 'exclude' => true, - 'inputType' => 'fileTree', - 'eval' => array( - 'filesOnly' => true, - 'fieldType' => 'radio', - 'mandatory' => false, - 'tl_class' => 'clr', - 'extensions' => 'gif,png,svg,jpg' - ), - 'sql' => "binary(16) NULL", - ), - 'shadowImage' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['shadowImage'], - 'exclude' => true, - 'inputType' => 'fileTree', - 'eval' => array( - 'filesOnly' => true, - 'fieldType' => 'radio', - 'mandatory' => false, - 'tl_class' => 'clr', - 'extensions' => 'gif,png,svg,jpg' - ), - 'sql' => "binary(16) NULL", - ), - 'shadowRetinaImage' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['shadowRetinaImage'], - 'exclude' => true, - 'inputType' => 'fileTree', - 'eval' => array( - 'filesOnly' => true, - 'fieldType' => 'radio', - 'mandatory' => false, - 'tl_class' => 'clr', - 'extensions' => 'gif,png,svg,jpg' - ), - 'sql' => "binary(16) NULL", - ), - 'iconAnchor' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['iconAnchor'], - 'exclude' => true, - 'inputType' => 'text', - 'save_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates') - ), - 'eval' => array( - 'maxlength' => 255, - 'tl_class' => 'w50', - 'nullIfEmpty' => true, - ), - 'sql' => "varchar(255) NULL" - ), - 'shadowAnchor' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['shadowAnchor'], - 'exclude' => true, - 'inputType' => 'text', - 'save_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates') - ), - 'eval' => array( - 'maxlength' => 255, - 'tl_class' => 'w50', - 'nullIfEmpty' => true, - ), - 'sql' => "varchar(255) NULL" - ), - 'popupAnchor' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['popupAnchor'], - 'exclude' => true, - 'inputType' => 'text', - 'save_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates') - ), - 'eval' => array( - 'maxlength' => 255, - 'tl_class' => 'w50', - 'nullIfEmpty' => true, - ), - 'sql' => "varchar(255) NULL" - ), - 'className' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['className'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 64, 'tl_class' => 'w50'), - 'sql' => "varchar(64) NOT NULL default ''" - ), - 'iconSize' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['iconSize'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array( - 'maxlength' => 64, - 'tl_class' => 'w50', - 'nullIfEmpty' => true, - ), - 'sql' => "varchar(64) NULL" - ), - 'html' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['html'], - 'exclude' => true, - 'inputType' => 'textarea', - 'eval' => array( - 'style' => 'height:60px', - 'preserveTags' => true, - 'decodeEntities' => true, - 'allowHtml' => true, - 'rte' => 'ace|html', - 'tl_class' => 'clr' - ), - 'sql' => "mediumtext NULL" - ), - 'icon' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['icon'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array( - 'maxlength' => 64, - 'tl_class' => 'w50', - 'nullIfEmpty' => true, - ), - 'sql' => "varchar(64) NULL" - ), - 'prefix' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['prefix'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array( - 'maxlength' => 64, - 'tl_class' => 'w50', - 'nullIfEmpty' => true, - ), - 'sql' => "varchar(64) NULL" - ), - 'shape' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['shape'], - 'exclude' => true, - 'inputType' => 'select', - 'default' => 'circle', - 'options' => ['circle', 'square', 'star', 'penta'], - 'eval' => array( - 'tl_class' => 'w50', - ), - 'sql' => "varchar(64) NULL" - ), - 'iconColor' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['iconColor'], - 'exclude' => true, - 'inputType' => 'text', - 'wizard' => array( - \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::colorPicker() - ), - 'eval' => array( - 'maxlength' => 64, - 'tl_class' => 'w50 wizard', - 'nullIfEmpty' => true, - ), - 'sql' => "varchar(16) NULL" - ), - 'markerColor' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['markerColor'], - 'exclude' => true, - 'inputType' => 'select', - 'default' => 'circle', - 'options' => [ - 'blue', - 'red', - 'orange-dark', - 'orange', - 'yellow', - 'blue-dark', - 'cyan', - 'purple', - 'violet', - 'pink', - 'green-dark', - 'green', - 'green-light', - 'black', - 'white' - ], - 'eval' => array( - 'tl_class' => 'w50', - 'nullIfEmpty' => true, - ), - 'sql' => "varchar(16) NULL" - ), - ), -); diff --git a/module/dca/tl_leaflet_layer.php b/module/dca/tl_leaflet_layer.php deleted file mode 100644 index bd36502..0000000 --- a/module/dca/tl_leaflet_layer.php +++ /dev/null @@ -1,930 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -$GLOBALS['TL_DCA']['tl_leaflet_layer'] = array -( - 'config' => array( - 'dataContainer' => 'Table', - 'enableVersioning' => true, - 'ctable' => array('tl_leaflet_vector', 'tl_leaflet_marker'), - 'ondelete_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\LayerCallbacks::callback('deleteRelations'), - ), - 'sql' => array - ( - 'keys' => array - ( - 'id' => 'primary', - 'pid' => 'index', - 'alias' => 'unique', - ) - ), - 'onload_callback' => array( - function() { - \Controller::loadLanguageFile('leaflet'); - } - ), - 'onsubmit_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - 'list' => array - ( - 'sorting' => array - ( - 'mode' => 5, - 'fields' => array('title'), - 'flag' => 1, - 'icon' => 'system/modules/leaflet/assets/img/layers.png', - 'panelLayout' => 'filter;search,limit', - 'paste_button_callback' => \Netzmacht\Contao\Leaflet\Dca\LayerCallbacks::callback('getPasteButtons'), - ), - 'label' => array - ( - 'fields' => array('title'), - 'format' => '%s', - 'label_callback' => \Netzmacht\Contao\Leaflet\Dca\LayerCallbacks::callback('generateRow') - ), - 'global_operations' => array - ( - 'styles' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['styles'], - 'href' => 'table=tl_leaflet_style', - 'icon' => 'system/modules/leaflet/assets/img/style.png', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ), - 'icons' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['icons'], - 'href' => 'table=tl_leaflet_icon', - 'icon' => 'system/modules/leaflet/assets/img/icons.png', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ), - 'popups' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['popups'], - 'href' => 'table=tl_leaflet_popup', - 'icon' => 'system/modules/leaflet/assets/img/popup.png', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ), - 'all' => array - ( - 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], - 'href' => 'act=select', - 'class' => 'header_edit_all', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ) - ), - 'operations' => array - ( - 'markers' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['markers'], - 'href' => 'table=tl_leaflet_marker', - 'icon' => 'edit.gif', - 'button_callback' => \Netzmacht\Contao\Leaflet\Dca\LayerCallbacks::callback('generateMarkersButton') - ), - 'vectors' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['vectors'], - 'href' => 'table=tl_leaflet_vector', - 'icon' => 'edit.gif', - 'button_callback' => \Netzmacht\Contao\Leaflet\Dca\LayerCallbacks::callback('generateVectorsButton'), - ), - 'edit' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['edit'], - 'href' => 'act=edit', - 'icon' => 'header.gif' - ), - 'copy' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['copy'], - 'href' => 'act=copy', - 'icon' => 'copy.gif' - ), - 'cut' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['cut'], - 'href' => 'act=paste&mode=cut', - 'icon' => 'cut.gif', - 'attributes' => 'onclick="Backend.getScrollOffset()"', - ), - 'delete' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['delete'], - 'href' => 'act=delete', - 'icon' => 'delete.gif', - 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"' - ), - 'toggle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['toggle'], - 'icon' => 'visible.gif', - 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', - 'button_callback' => \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::stateButton( - 'tl_leaflet_layer', - 'active' - ), - ), - 'show' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['show'], - 'href' => 'act=show', - 'icon' => 'show.gif' - ) - ) - ), - - 'palettes' => array( - '__selector__' => array('type'), - ), - - 'metapalettes' => array( - 'default' => array( - 'title' => array('title', 'alias', 'type'), - 'config' => array(), - 'style' => array(), - 'expert' => array(':hide'), - 'active' => array('active'), - ), - 'markers extends default' => array( - '+expert' => array('pointToLayer'), - '+config' => array('boundsMode', 'deferred') - ), - 'group extends default' => array( - '+title' => array('groupType'), - '+active' => array('boundsMode') - ), - 'vectors extends default' => array( - '+expert' => array('onEachFeature', 'pointToLayer'), - '+config' => array('boundsMode', 'deferred'), - ), - 'reference extends default' => array( - '+title' => array('reference', 'standalone') - ), - 'markercluster extends default' => array( - 'config' => array( - 'showCoverageOnHover', - 'zoomToBoundsOnClick', - 'removeOutsideVisibleBounds', - 'animateAddingMarkers', - 'spiderfyOnMaxZoom', - 'disableClusteringAtZoom', - 'maxClusterRadius', - 'singleMarkerMode', - ), - '+expert' => array( - 'polygonOptions', - 'iconCreateFunction', - 'disableDefaultStyle' - ) - ), - 'tile extends default' => array( - 'config' => array( - 'tileUrl', - 'subdomains', - 'attribution', - 'minZoom', - 'maxZoom', - ), - '+expert' => array( - 'errorTileUrl', - 'tileSize', - 'tms', - 'continuousWorld', - 'noWrap', - 'zoomReverse', - 'zoomOffset', - 'maxNativeZoom', - 'opacity', - 'zIndex', - 'unloadvisibleTiles', - 'updateWhenIdle', - 'detectRetina', - 'reuseTiles', - 'bounds' - ) - ), - 'overpass extends default' => array( - 'config' => array( - 'overpassQuery', - 'boundsMode', - 'minZoom', - 'overpassEndpoint', - 'overpassPopup' - ), - 'style' => array( - 'amenityIcons' - ), - '+expert' => array( - 'onEachFeature', - 'pointToLayer', - ), - ), - ), - - 'metasubselectpalettes' => array( - 'type' => array( - 'provider' => array('tile_provider', 'tile_provider_variant') - ), - 'tile_provider' => array( - 'MapBox' => array('tile_provider_key'), - 'HERE' => array('tile_provider_key', 'tile_provider_code'), - ), - ), - - 'metasubpalettes' => array( - 'spiderfyOnMaxZoom' => array('spiderfyDistanceMultiplier'), - 'deferred' => array('cache'), - 'cache' => array('cacheLifeTime') - ), - - 'fields' => array - ( - 'id' => array - ( - 'sql' => "int(10) unsigned NOT NULL auto_increment" - ), - 'pid' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'sorting' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'", - ), - 'tstamp' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'title' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['title'], - 'exclude' => true, - 'inputType' => 'text', - 'search' => true, - 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'alias' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['alias'], - 'exclude' => true, - 'inputType' => 'text', - 'search' => true, - 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::aliasGenerator( - 'tl_leaflet_layer', - 'alias', - ['title'], - \Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR - ), - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'), - ), - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), - 'sql' => "varchar(255) NULL" - ), - 'type' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['type'], - 'exclude' => true, - 'inputType' => 'select', - 'filter' => true, - 'eval' => array( - 'mandatory' => true, - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'submitOnChange' => true, - 'chosen' => true, - 'helpwizard' => true, - ), - 'options' => array_keys($GLOBALS['LEAFLET_LAYERS']), - 'reference' => &$GLOBALS['TL_LANG']['leaflet_layer'], - 'sql' => "varchar(32) NOT NULL default ''" - ), - 'active' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['active'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'filter' => true, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''", - 'save_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - 'tile_provider' => array( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider'], - 'exclude' => true, - 'inputType' => 'select', - 'eval' => array( - 'mandatory' => true, - 'tl_class' => 'w50 clr', - 'includeBlankOption' => true, - 'submitOnChange' => true, - 'chosen' => true, - ), - 'options' => array_keys($GLOBALS['LEAFLET_TILE_PROVIDERS']), - 'sql' => "varchar(32) NOT NULL default ''" - ), - 'tile_provider_variant' => array( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider_variant'], - 'exclude' => true, - 'inputType' => 'select', - 'eval' => array( - 'mandatory' => false, - 'tl_class' => 'w50', - 'submitOnChange' => true, - 'chosen' => false, - ), - 'options_callback' => \Netzmacht\Contao\Leaflet\Dca\LayerCallbacks::callback('getVariants'), - 'sql' => "varchar(32) NOT NULL default ''" - ), - 'tile_provider_key' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider_key'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'clr w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'tile_provider_code' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider_code'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'deferred' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['deferred'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => true, 'isBoolean' => true), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'groupType' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupType'], - 'exclude' => true, - 'inputType' => 'select', - 'eval' => array( - 'mandatory' => true, - 'tl_class' => 'w50', - 'submitOnChange' => true, - 'helpwizard' => true, - ), - 'default' => 'layer', - 'options' => array('layer', 'feature'), - 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes'], - 'sql' => "varchar(32) NOT NULL default ''" - ), - 'reference' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['reference'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => \Netzmacht\Contao\Leaflet\Dca\LayerCallbacks::callback('getLayers'), - 'eval' => array( - 'mandatory' => true, - 'tl_class' => 'w50', - 'chosen' => true, - 'includeBlankOption' => true, - ), - 'sql' => "int(10) unsigned NOT NULL default '0'", - ), - 'standalone' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['standalone'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'onEachFeature' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['onEachFeature'], - 'exclude' => true, - 'inputType' => 'textarea', - 'eval' => array( - 'preserveTags' => true, - 'decodeEntities' => true, - 'allowHtml' => true, - 'rte' => 'ace|javascript', - 'tl_class' => 'clr' - ), - 'sql' => "mediumtext NULL" - ), - 'pointToLayer' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['pointToLayer'], - 'exclude' => true, - 'inputType' => 'textarea', - 'eval' => array( - 'preserveTags' => true, - 'decodeEntities' => true, - 'allowHtml' => true, - 'rte' => 'ace|javascript', - 'tl_class' => 'clr' - ), - 'sql' => "mediumtext NULL" - ), - 'showCoverageOnHover' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['showCoverageOnHover'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'zoomToBoundsOnClick' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['zoomToBoundsOnClick'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'spiderfyOnMaxZoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['spiderfyOnMaxZoom'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => true, 'isBoolean' => true), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'removeOutsideVisibleBounds' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['removeOutsideVisibleBounds'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'animateAddingMarkers' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['animateAddingMarkers'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'disableClusteringAtZoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['disableClusteringAtZoom'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('getZoomLevels'), - 'default' => '', - 'eval' => array( - 'maxlength' => 4, - 'rgxp' => 'digit', - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'nullIfEmpty' => true - ), - 'sql' => "int(4) NULL" - ), - 'maxClusterRadius' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['maxClusterRadius'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => null, - 'eval' => array('maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true), - 'sql' => "int(5) NULL" - ), - 'singleMarkerMode' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['singleMarkerMode'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => false, 'isBoolean' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'polygonOptions' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['polygonOptions'], - 'exclude' => true, - 'inputType' => 'textarea', - 'eval' => array( - 'preserveTags' => true, - 'decodeEntities' => true, - 'allowHtml' => true, - 'rte' => 'ace|json', - 'tl_class' => 'clr' - ), - 'sql' => "mediumtext NULL" - ), - 'spiderfyDistanceMultiplier' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['spiderfyDistanceMultiplier'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => null, - 'eval' => array('maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true), - 'sql' => "int(5) NULL" - ), - 'iconCreateFunction' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['iconCreateFunction'], - 'exclude' => true, - 'inputType' => 'textarea', - 'eval' => array( - 'preserveTags' => true, - 'decodeEntities' => true, - 'allowHtml' => true, - 'rte' => 'ace|javascript', - 'tl_class' => 'clr' - ), - 'sql' => "mediumtext NULL" - ), - 'disableDefaultStyle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['disableDefaultStyle'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'boundsMode' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['boundsMode'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => \Netzmacht\Contao\Leaflet\Dca\LayerCallbacks::callback('getBoundsModes'), - 'eval' => array('tl_class' => 'w50', 'includeBlankOption' => true), - 'sql' => "varchar(6) NOT NULL default ''" - ), - 'tileUrl' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tileUrl'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => '', - 'eval' => array('maxlength' => 255, 'tl_class' => 'w50', 'mandatory' => true), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'minZoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['minZoom'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('getZoomLevels'), - 'eval' => array( - 'maxlength' => 4, - 'rgxp' => 'digit', - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'nullIfEmpty' => true - ), - 'sql' => "int(4) NULL" - ), - 'maxZoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['maxZoom'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('getZoomLevels'), - 'eval' => array( - 'maxlength' => 4, - 'rgxp' => 'digit', - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'nullIfEmpty' => true - ), - 'sql' => "int(4) NULL" - ), - 'maxNativeZoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['maxNativeZoom'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('getZoomLevels'), - 'eval' => array( - 'maxlength' => 4, - 'rgxp' => 'digit', - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'nullIfEmpty' => true - ), - 'sql' => "int(4) NULL" - ), - 'tileSize' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tileSize'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => null, - 'eval' => array('maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true), - 'sql' => "int(5) NULL" - ), - 'subdomains' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['subdomains'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => '', - 'eval' => array('maxlength' => 16, 'tl_class' => 'w50'), - 'sql' => "varchar(16) NOT NULL default ''" - ), - 'errorTileUrl' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['errorTileUrl'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => '', - 'eval' => array('maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'attribution' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['attribution'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => '', - 'eval' => array('maxlength' => 255, 'tl_class' => 'long', 'allowHtml' => true), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'tms' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tms'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'continuousWorld' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['continuousWorld'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'noWrap' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['noWrap'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'zoomOffset' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['zoomOffset'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => null, - 'eval' => array('maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true), - 'sql' => "int(5) NULL" - ), - 'zoomReverse' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['zoomReverse'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'opacity' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['opacity'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => '1.0', - 'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50 clr'), - 'sql' => "varchar(4) NOT NULL default ''" - ), - 'zIndex' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['zIndex'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => null, - 'eval' => array('maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true), - 'sql' => "int(5) NULL" - ), - 'unloadvisibleTiles' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['unloadvisibleTiles'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'updateWhenIdle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['updateWhenIdle'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'detectRetina' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['detectRetina'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'reuseTiles' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['reuseTiles'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'bounds' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['bounds'], - 'exclude' => true, - 'inputType' => 'text', - 'save_callback' => array( - ), - 'eval' => array( - 'maxlength' => 255, - 'multiple'=>true, - 'size'=>2, - 'tl_class' => 'long clr', - 'nullIfEmpty' => true, - ), - 'sql' => "mediumblob NULL" - ), - 'cache' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['cache'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'cacheLifeTime' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['cacheLifeTime'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => 0, - 'eval' => array('maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50'), - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'overpassQuery' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['overpassQuery'], - 'exclude' => true, - 'inputType' => 'textarea', - 'eval' => array( - 'preserveTags' => true, - 'decodeEntities' => true, - 'allowHtml' => true, - 'rte' => 'ace', - 'tl_class' => 'clr' - ), - 'sql' => "mediumtext NULL" - ), - 'overpassEndpoint' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['overpassEndpoint'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => '', - 'eval' => array('tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'overpassCallback' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['overpassCallback'], - 'exclude' => true, - 'inputType' => 'textarea', - 'eval' => array( - 'preserveTags' => true, - 'decodeEntities' => true, - 'allowHtml' => true, - 'rte' => 'ace|javascript', - 'tl_class' => 'clr' - ), - 'sql' => "mediumtext NULL" - ), - 'minZoomIndicatorPosition' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['minZoomIndicatorPosition'], - 'exclude' => true, - 'inputType' => 'select', - 'filter' => true, - 'sorting' => true, - 'options' => array('topleft', 'topright', 'bottomleft', 'bottomright'), - 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_layer'], - 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50', 'helpwizard' => true), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'minZoomIndicatorMessage' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['minZoomIndicatorMessage'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => '', - 'eval' => array('tl_class' => 'clr w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'minZoomIndicatorMessageNoLayer' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['minZoomIndicatorMessageNoLayer'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => '', - 'eval' => array('tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'debug' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['debug'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50 m12'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'amenityIcons' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['amenityIcons'], - 'exclude' => true, - 'inputType' => 'multiColumnWizard', - 'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'getIcons'), - 'eval' => array( - 'columnFields' => array( - 'amenity' => array( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['amenity'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => \Netzmacht\Contao\Leaflet\Dca\LayerCallbacks::callback('getAmenities'), - 'eval' => array( - 'mandatory' => true, - 'tl_class' => 'w50', - 'style' => 'width: 200px', - 'chosen' => true, - ), - ), - 'icon' => array( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['amenityIcon'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'getIcons'), - 'eval' => array( - 'mandatory' => true, - 'tl_class' => 'w50', - 'style' => 'width: 200px', - 'chosen' => true, - ), - ), - ), - ), - 'sql' => "blob NULL", - ), - 'overpassPopup' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['overpassPopup'], - 'exclude' => true, - 'inputType' => 'textarea', - 'eval' => array( - 'preserveTags' => true, - 'decodeEntities' => true, - 'allowHtml' => true, - 'rte' => 'ace|javascript', - 'tl_class' => 'clr' - ), - 'sql' => "mediumtext NULL" - ), - ) -); diff --git a/module/dca/tl_leaflet_map.php b/module/dca/tl_leaflet_map.php deleted file mode 100644 index 2af0667..0000000 --- a/module/dca/tl_leaflet_map.php +++ /dev/null @@ -1,585 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -$GLOBALS['TL_DCA']['tl_leaflet_map'] = array -( - 'config' => array( - 'dataContainer' => 'Table', - 'enableVersioning' => true, - 'ctable' => array('tl_leaflet_control'), - 'sql' => array - ( - 'keys' => array - ( - 'id' => 'primary', - 'alias' => 'unique', - ) - ), - 'onload_callback' => array( - function() { - \Controller::loadLanguageFile('leaflet'); - } - ), - 'onsubmit_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - - 'list' => array - ( - 'sorting' => array - ( - 'mode' => 1, - 'fields' => array('title'), - 'panelLayout' => 'search,limit', - 'flag' => 1, - ), - 'label' => array - ( - 'fields' => array('title', 'alias'), - 'format' => '%s [%s]' - ), - 'global_operations' => array - ( - 'all' => array - ( - 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], - 'href' => 'act=select', - 'class' => 'header_edit_all', - 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' - ), - ), - 'operations' => array - ( - 'edit' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['edit'], - 'href' => 'act=edit', - 'icon' => 'header.gif' - ), - 'controls' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['controls'], - 'href' => 'table=tl_leaflet_control', - 'icon' => 'system/modules/leaflet/assets/img/control.png', - 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' - ), - 'copy' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['copy'], - 'href' => 'act=copy', - 'icon' => 'copy.gif' - ), - 'delete' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['delete'], - 'href' => 'act=delete', - 'icon' => 'delete.gif', - 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"' - ), - 'show' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['show'], - 'href' => 'act=show', - 'icon' => 'show.gif' - ) - ) - ), - - 'metapalettes' => array( - 'default' => array( - 'title' => array('title', 'alias'), - 'zoom' => array('center', 'zoom', 'adjustZoomExtra', 'adjustBounds', 'dynamicLoad', 'boundsPadding'), - 'locate' => array('locate'), - 'layers' => array('layers'), - 'interaction' => array( - 'dragging', - 'touchZoom', - 'scrollWheelZoom', - 'doubleClickZoom', - 'boxZoom', - 'tap', - 'keyboard' - ), - 'behaviour' => array( - 'zoomControl', - 'trackResize', - 'closeOnClick', - 'bounceAtZoomLimits' - ), - 'expert' => array( - 'options', - 'cache', - ) - ), - ), - 'metasubpalettes' => array( - 'keyboard' => array( - 'keyboardPanOffset', - 'keyboardZoomOffset' - ), - 'adjustZoomExtra' => array( - 'minZoom', - 'maxZoom', - 'zoomSnap', - 'zoomDelta', - ), - 'locate' => array( - ':hide', - 'locateWatch', - 'locateSetView', - 'locateMaxZoom', - 'locateTimeout', - 'locateMaximumAge', - 'enableHighAccuracy' - ), - 'cache' => array( - 'cacheLifeTime' - ) - ), - - 'fields' => array - ( - 'id' => array - ( - 'sql' => "int(10) unsigned NOT NULL auto_increment" - ), - 'tstamp' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'title' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['title'], - 'exclude' => true, - 'inputType' => 'text', - 'search' => true, - 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'alias' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['alias'], - 'exclude' => true, - 'inputType' => 'text', - 'search' => true, - 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::aliasGenerator( - 'tl_leaflet_map', - 'alias', - ['title'], - \Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR - ), - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias') - ), - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), - 'sql' => "varchar(255) NULL" - ), - 'center' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['center'], - 'exclude' => true, - 'inputType' => 'text', - 'save_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates'), - ), - 'wizard' => array( - Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('getGeocoder') - ), - 'eval' => array( - 'maxlength' => 255, - 'tl_class' => 'long clr', - 'nullIfEmpty' => true, - ), - 'sql' => "varchar(255) NULL" - ), - 'layers' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['layers'], - 'exclude' => true, - 'inputType' => 'multiColumnWizard', - 'load_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\MapCallbacks::callback('loadLayerRelations'), - ), - 'save_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\MapCallbacks::callback('saveLayerRelations'), - ), - 'eval' => array( - 'multiple' => true, - 'doNotSaveEmpty' => true, - 'columnFields' => array( - 'reference' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['reference'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => \Netzmacht\Contao\Leaflet\Dca\MapCallbacks::callback('getLayers'), - 'eval' => array( - 'mandatory' => true, - 'tl_class' => 'w50', - 'chosen' => true, - 'includeBlankOption' => true, - 'style' => 'width: 300px' - ), - 'sql' => "int(10) unsigned NOT NULL default '0'", - ), - ), - 'flatArray' => true - ), - 'sql' => "mediumblob NULL" - ), - 'zoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoom'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('getZoomLevels'), - 'default' => '', - 'eval' => array( - 'maxlength' => 4, - 'rgxp' => 'digit', - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'nullIfEmpty' => true - ), - 'sql' => "int(4) NULL" - ), - 'adjustZoomExtra' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustZoomExtra'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'minZoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['minZoom'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('getZoomLevels'), - 'eval' => array( - 'maxlength' => 4, - 'rgxp' => 'digit', - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'nullIfEmpty' => true - ), - 'sql' => "int(4) NULL" - ), - 'maxZoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['maxZoom'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('getZoomLevels'), - 'eval' => array( - 'maxlength' => 4, - 'rgxp' => 'digit', - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'nullIfEmpty' => true - ), - 'sql' => "int(4) NULL" - ), - 'zoomSnap' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomSnap'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array( - 'maxlength' => 4, - 'rgxp' => 'digit', - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'nullIfEmpty' => true - ), - 'sql' => "varchar(4) NULL" - ), - 'zoomDelta' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomDelta'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array( - 'maxlength' => 4, - 'rgxp' => 'digit', - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'nullIfEmpty' => true - ), - 'sql' => "varchar(4) NULL" - ), - 'dragging' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['dragging'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'touchZoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['touchZoom'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'scrollWheelZoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['scrollWheelZoom'], - 'exclude' => true, - 'inputType' => 'select', - 'options' => array('1', 'center'), - 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'], - 'default' => true, - 'eval' => array( - 'tl_class' => 'w50', - 'helpwizard' => true, - 'includeBlankOption' => true, - 'blankOptionLabel' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'][''][0] - ), - 'sql' => "char(6) NOT NULL default ''" - ), - 'doubleClickZoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['doubleClickZoom'], - 'exclude' => true, - 'inputType' => 'select', - 'options' => array('1', 'center'), - 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'], - 'default' => true, - 'eval' => array( - 'tl_class' => 'w50', - 'helpwizard' => true, - 'includeBlankOption' => true, - 'blankOptionLabel' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'][''][0] - ), - 'sql' => "char(6) NOT NULL default ''" - ), - 'boxZoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['boxZoom'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'tap' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['tap'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'trackResize' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['trackResize'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'bounceAtZoomLimits' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['bounceAtZoomLimits'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'closeOnClick' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['closeOnClick'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'keyboard' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboard'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'keyboardPanOffset' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardPanOffset'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => 80, - 'eval' => array('mandatory' => true, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'clr w50'), - 'sql' => "int(4) NOT NULL default '80'" - ), - 'keyboardZoomOffset' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardZoomOffset'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => 1, - 'eval' => array('mandatory' => true, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'), - 'sql' => "int(4) NOT NULL default '1'" - ), - 'zoomControl' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomControl'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'options' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['options'], - 'exclude' => true, - 'inputType' => 'textarea', - 'eval' => array('tl_class' => 'clr lng', - 'allowHtml' => true, - 'style' => 'min-height: 40px;', - 'rte' => 'ace|json' - ), - 'sql' => "text NULL" - ), - 'adjustBounds' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBounds'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'options' => array('load', 'deferred'), - 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions'], - 'eval' => array('tl_class' => 'clr w50', 'multiple' => true, 'helpwizard' => true), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'dynamicLoad' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['dynamicLoad'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'clr w50', 'submitOnChange' => false), - 'sql' => "char(1) NOT NULL default ''" - ), - 'boundsPadding' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['boundsPadding'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array( - 'maxlength' => 32, - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'nullIfEmpty' => true - ), - 'sql' => "varchar(32) NULL" - ), - 'locate' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['locate'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'locateWatch' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['locateWatch'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'locateSetView' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['locateSetView'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => false), - 'sql' => "char(1) NOT NULL default ''" - ), - 'locateTimeout' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['locateTimeout'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => null, - 'eval' => array('maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true), - 'sql' => "int(9) NULL" - ), - 'locateMaximumAge' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaximumAge'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => null, - 'eval' => array('maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true), - 'sql' => "int(9) NULL" - ), - 'enableHighAccuracy' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['enableHighAccuracy'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50 m12'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'locateMaxZoom' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaxZoom'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('getZoomLevels'), - 'eval' => array( - 'maxlength' => 4, - 'rgxp' => 'digit', - 'tl_class' => 'clr w50', - 'includeBlankOption' => true, - 'nullIfEmpty' => true - ), - 'sql' => "int(4) NULL" - ), - 'cache' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['cache'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'cacheLifeTime' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['cacheLifeTime'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => 0, - 'eval' => array('maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50'), - 'sql' => "int(9) NOT NULL default '0'" - ), - ), -); diff --git a/module/dca/tl_leaflet_map_layer.php b/module/dca/tl_leaflet_map_layer.php deleted file mode 100644 index 49d73d0..0000000 --- a/module/dca/tl_leaflet_map_layer.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -$GLOBALS['TL_DCA']['tl_leaflet_map_layer'] = array -( - 'config' => array( - 'dataContainer' => 'Table', - 'sql' => array - ( - 'keys' => array - ( - 'id' => 'primary', - 'mid,lid' => 'unique', - ) - ) - ), - - 'fields' => array - ( - 'id' => array - ( - 'sql' => "int(10) unsigned NOT NULL auto_increment" - ), - 'tstamp' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'sorting' => array( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'mid' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'lid' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - ) -); diff --git a/module/dca/tl_leaflet_marker.php b/module/dca/tl_leaflet_marker.php deleted file mode 100644 index ad160f0..0000000 --- a/module/dca/tl_leaflet_marker.php +++ /dev/null @@ -1,376 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -$GLOBALS['TL_DCA']['tl_leaflet_marker'] = array -( - 'config' => array( - 'dataContainer' => 'Table', - 'enableVersioning' => true, - 'ptable' => 'tl_leaflet_layer', - 'sql' => array - ( - 'keys' => array - ( - 'id' => 'primary', - 'pid' => 'index', - 'alias' => 'unique', - ) - ), - 'onload_callback' => array( - function() { - \Controller::loadLanguageFile('leaflet'); - } - ), - 'onsubmit_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - - 'list' => array - ( - 'sorting' => array - ( - 'mode' => 4, - 'fields' => array('sorting'), - 'flag' => 1, - 'panelLayout' => 'sort,filter;search,limit', - 'headerFields' => array('title', 'type'), - 'child_record_callback' => array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'generateRow'), - ), - 'label' => array - ( - 'fields' => array('title'), - 'format' => '%s', - ), - 'global_operations' => array - ( - 'icons' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['icons'], - 'href' => 'table=tl_leaflet_icon&id=', - 'icon' => 'system/modules/leaflet/assets/img/icons.png', - 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' - ), - 'popups' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['popups'], - 'href' => 'table=tl_leaflet_popup', - 'icon' => 'system/modules/leaflet/assets/img/popup.png', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ), - 'all' => array - ( - 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], - 'href' => 'act=select', - 'class' => 'header_edit_all', - 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' - ), - ), - 'operations' => array - ( - 'edit' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['edit'], - 'href' => 'act=edit', - 'icon' => 'edit.gif' - ), - 'copy' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['copy'], - 'href' => 'act=copy', - 'icon' => 'copy.gif' - ), - 'delete' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['delete'], - 'href' => 'act=delete', - 'icon' => 'delete.gif', - 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"' - ), - 'toggle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['toggle'], - 'icon' => 'visible.gif', - 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', - 'button_callback' => \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::stateButton( - 'tl_leaflet_marker', - 'active' - ) - ), - 'show' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['show'], - 'href' => 'act=show', - 'icon' => 'show.gif' - ) - ) - ), - - 'metapalettes' => array( - 'default' => array( - 'title' => array('title', 'alias', 'coordinates'), - 'content' => array('tooltip', 'alt', 'addPopup'), - 'config' => array( - ':hide', - 'clickable', - 'draggable', - 'keyboard', - 'zIndexOffset', - 'opacity', - 'riseOnHover', - 'riseOffset', - 'customIcon', - ), - 'expert' => array(':hide', 'featureData'), - 'active' => array('active', 'ignoreForBounds') - ), - ), - 'metasubpalettes' => array( - 'addPopup' => array('popup', 'popupContent'), - 'customIcon' => array('icon') - ), - - 'fields' => array - ( - 'id' => array - ( - 'sql' => "int(10) unsigned NOT NULL auto_increment" - ), - 'tstamp' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'sorting' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'", - 'sorting' => true, - ), - 'pid' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'title' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['title'], - 'exclude' => true, - 'search' => true, - 'sorting' => true, - 'flag' => 1, - 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'alias' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['alias'], - 'exclude' => true, - 'inputType' => 'text', - 'search' => true, - 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::aliasGenerator( - 'tl_leaflet_marker', - 'alias', - ['title'], - \Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR - ), - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'), - ), - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), - 'sql' => "varchar(255) NULL" - ), - 'coordinates' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['coordinates'], - 'exclude' => true, - 'inputType' => 'text', - 'save_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates'), - array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'saveCoordinates') - ), - 'load_callback' => array( - array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'loadCoordinates') - ), - 'wizard' => array( - Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('getGeocoder') - ), - 'eval' => array( - 'maxlength' => 255, - 'tl_class' => 'long clr', - 'nullIfEmpty' => true, - 'doNotSaveEmpty' => true, - ), - ), - 'latitude' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['latitude'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "decimal(10,8) NULL" - ), - 'longitude' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['longitude'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "decimal(11,8) NULL" - ), - 'altitude' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['altitude'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "float NULL" - ), - 'active' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['active'], - 'exclude' => true, - 'filter' => true, - 'sorting' => true, - 'flag' => 12, - 'inputType' => 'checkbox', - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''", - 'save_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - 'tooltip' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['tooltip'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'alt' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['alt'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'addPopup' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['addPopup'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'filter' => true, - 'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'popup' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['popup'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'getPopups'), - 'eval' => array( - 'mandatory' => false, - 'tl_class' => 'w50', - 'chosen' => true, - 'includeBlankOption' => true, - ), - 'sql' => "int(10) unsigned NOT NULL default '0'", - ), - 'popupContent' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['popupContent'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'rte' => 'tinyMCE', 'helpwizard' => true, 'tl_class' => 'clr'), - 'explanation' => 'insertTags', - 'sql' => "mediumtext NULL" - ), - 'customIcon' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['customIcon'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => array('tl_class' => 'clr w50 m12', 'submitOnChange' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'icon' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['icon'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'getIcons'), - 'eval' => array( - 'mandatory' => true, - 'tl_class' => 'w50', - 'chosen' => true, - ), - 'sql' => "int(10) unsigned NOT NULL default '0'", - ), - 'draggable' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['draggable'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'clickable' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['clickable'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'keyboard' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['keyboard'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'zIndexOffset' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['zIndexOffset'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => 0, - 'eval' => array('maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'clr w50', 'nullIfEmpty' => true), - 'sql' => "int(5) NULL" - ), - 'ignoreForBounds' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['ignoreForBounds'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'featureData' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['featureData'], - 'exclude' => true, - 'inputType' => 'textarea', - 'eval' => array('tl_class' => 'clr lng', - 'allowHtml' => true, - 'style' => 'min-height: 40px;', - 'rte' => 'ace|json' - ), - 'sql' => "text NULL" - ), - ), -); diff --git a/module/dca/tl_leaflet_popup.php b/module/dca/tl_leaflet_popup.php deleted file mode 100644 index b8f2fec..0000000 --- a/module/dca/tl_leaflet_popup.php +++ /dev/null @@ -1,302 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -$GLOBALS['TL_DCA']['tl_leaflet_popup'] = array -( - 'config' => array( - 'dataContainer' => 'Table', - 'enableVersioning' => true, - 'sql' => array - ( - 'keys' => array - ( - 'id' => 'primary', - 'alias' => 'unique', - ) - ), - 'onsubmit_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - - 'list' => array - ( - 'sorting' => array - ( - 'mode' => 1, - 'fields' => array('title'), - 'flag' => 1, - 'panelLayout' => 'limit', - 'headerFields' => array('title', 'type'), - ), - 'label' => array - ( - 'fields' => array('title', 'type'), - 'format' => '%s [%s]', - ), - 'global_operations' => array - ( - 'layers' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['layersBtn'], - 'href' => 'table=tl_leaflet_layer', - 'icon' => 'system/modules/leaflet/assets/img/layers.png', - 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' - ), - 'styles' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['styles'], - 'href' => 'table=tl_leaflet_style', - 'icon' => 'system/modules/leaflet/assets/img/style.png', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ), - 'icons' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['icons'], - 'href' => 'table=tl_leaflet_icon', - 'icon' => 'system/modules/leaflet/assets/img/icons.png', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ), - 'all' => array - ( - 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], - 'href' => 'act=select', - 'class' => 'header_edit_all', - 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' - ), - ), - 'operations' => array - ( - 'edit' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['edit'], - 'href' => 'act=edit', - 'icon' => 'edit.gif' - ), - 'copy' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['copy'], - 'href' => 'act=copy', - 'icon' => 'copy.gif' - ), - 'delete' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['delete'], - 'href' => 'act=delete', - 'icon' => 'delete.gif', - 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"' - ), - 'toggle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['toggle'], - 'icon' => 'visible.gif', - 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', - 'button_callback' => \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::stateButton( - 'tl_leaflet_popup', - 'active' - ) - ), - 'show' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['show'], - 'href' => 'act=show', - 'icon' => 'show.gif' - ) - ) - ), - - 'palettes' => array( - '__selector__' => array('type') - ), - - 'metapalettes' => array( - 'default' => array( - 'title' => array('title', 'alias'), - 'size' => array('maxWidth', 'minWidth', 'maxHeight'), - 'config' => array( - ':hide', - 'closeButton', - 'keepInView', - 'closeOnClick', - 'zoomAnimation', - 'offset', - 'className', - 'autoPan' - ), - 'active' => array('active'), - ), - ), - - 'metasubpalettes' => array( - 'autoPan' => array('autoPanPadding') - ), - - 'fields' => array - ( - 'id' => array - ( - 'sql' => "int(10) unsigned NOT NULL auto_increment" - ), - 'tstamp' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'title' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['title'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'alias' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['alias'], - 'exclude' => true, - 'inputType' => 'text', - 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::aliasGenerator( - 'tl_leaflet_popup', - 'alias', - ['title'], - \Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR - ), - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'), - ), - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), - 'sql' => "varchar(255) NULL" - ), - 'maxWidth' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['maxWidth'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => null, - 'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'), - 'sql' => "int(4) NULL" - ), - 'minWidth' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['minWidth'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => null, - 'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'), - 'sql' => "int(4) NULL" - ), - 'maxHeight' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['maxHeight'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => null, - 'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'), - 'sql' => "int(4) NULL" - ), - 'autoPan' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['autoPan'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => true), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'keepInView' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['keepInView'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => false), - 'sql' => "char(1) NOT NULL default ''" - ), - 'closeButton' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['closeButton'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => false), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'offset' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['offset'], - 'exclude' => true, - 'inputType' => 'text', - 'save_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates') - ), - 'eval' => array( - 'maxlength' => 255, - 'tl_class' => 'w50', - 'nullIfEmpty' => true, - ), - 'sql' => "varchar(255) NULL" - ), - 'autoPanPadding' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['autoPanPadding'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array( - 'maxlength' => 255, - 'tl_class' => 'w50', - 'nullIfEmpty' => true, - 'multiple' => true, - 'size' => 2, - ), - 'sql' => "varchar(255) NULL" - ), - 'zoomAnimation' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['zoomAnimation'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => false), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'closeOnClick' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['closeOnClick'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => false), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'className' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['className'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 64, 'tl_class' => 'w50'), - 'sql' => "varchar(64) NOT NULL default ''" - ), - 'active' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['active'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'filter' => true, - 'sorting' => true, - 'search' => false, - 'flag' => 12, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''", - 'save_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - ), -); diff --git a/module/dca/tl_leaflet_style.php b/module/dca/tl_leaflet_style.php deleted file mode 100644 index e3a57c2..0000000 --- a/module/dca/tl_leaflet_style.php +++ /dev/null @@ -1,304 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ -$GLOBALS['TL_DCA']['tl_leaflet_style'] = array -( - 'config' => array( - 'dataContainer' => 'Table', - 'enableVersioning' => true, - 'sql' => array - ( - 'keys' => array - ( - 'id' => 'primary', - 'alias' => 'unique', - ) - ), - 'onsubmit_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - - 'list' => array - ( - 'sorting' => array - ( - 'mode' => 1, - 'fields' => array('title'), - 'flag' => 1, - 'panelLayout' => 'limit', - 'headerFields' => array('title', 'type'), - ), - 'label' => array - ( - 'fields' => array('title', 'type'), - 'format' => '%s [%s]', - ), - 'global_operations' => array - ( - 'layers' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['layersBtn'], - 'href' => 'table=tl_leaflet_layer', - 'icon' => 'system/modules/leaflet/assets/img/layers.png', - 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' - ), - 'icons' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['icons'], - 'href' => 'table=tl_leaflet_icon', - 'icon' => 'system/modules/leaflet/assets/img/icons.png', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ), - 'popups' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['popups'], - 'href' => 'table=tl_leaflet_popup', - 'icon' => 'system/modules/leaflet/assets/img/popup.png', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ), - 'all' => array - ( - 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], - 'href' => 'act=select', - 'class' => 'header_edit_all', - 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' - ), - ), - 'operations' => array - ( - 'edit' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['edit'], - 'href' => 'act=edit', - 'icon' => 'edit.gif' - ), - 'copy' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['copy'], - 'href' => 'act=copy', - 'icon' => 'copy.gif' - ), - 'delete' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['delete'], - 'href' => 'act=delete', - 'icon' => 'delete.gif', - 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"' - ), - 'toggle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['toggle'], - 'icon' => 'visible.gif', - 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', - 'button_callback' => \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::stateButton( - 'tl_leaflet_style', - 'active' - ) - ), - 'show' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['show'], - 'href' => 'act=show', - 'icon' => 'show.gif' - ) - ) - ), - - 'palettes' => array( - '__selector__' => array('type') - ), - - 'metapalettes' => array( - 'default' => array( - 'title' => array('title', 'alias', 'type'), - 'config' => array(), - 'active' => array('active'), - ), - 'fixed extends default' => array( - 'config' => array('stroke', 'fill'), - ), - ), - - 'metasubpalettes' => array( - 'stroke' => array('color', 'weight', 'opacity', 'dashArray', 'lineCap', 'lineJoin'), - 'fill' => array('fillColor', 'fillOpacity',) - ), - - 'fields' => array - ( - 'id' => array - ( - 'sql' => "int(10) unsigned NOT NULL auto_increment" - ), - 'tstamp' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'title' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['title'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'alias' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['alias'], - 'exclude' => true, - 'inputType' => 'text', - 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::aliasGenerator( - 'tl_leaflet_style', - 'alias', - ['title'], - \Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR - ), - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'), - ), - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), - 'sql' => "varchar(255) NULL" - ), - 'type' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['type'], - 'exclude' => true, - 'inputType' => 'select', - 'eval' => array( - 'mandatory' => true, - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'submitOnChange' => true, - 'chosen' => true, - ), - 'options' => &$GLOBALS['LEAFLET_STYLES'], - 'reference' => &$GLOBALS['TL_LANG']['leaflet_style'], - 'sql' => "varchar(32) NOT NULL default ''" - ), - 'stroke' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['stroke'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'w50', 'submitOnChange' => true), - 'sql' => "char(1) NOT NULL default '1'" - ), - 'color' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['color'], - 'exclude' => true, - 'inputType' => 'text', - 'wizard' => array( - \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::colorPicker() - ), - 'eval' => array( - 'tl_class' => 'w50 wizard clr', - 'maxlength' => 7, - 'decodeEntities' => true - ), - 'sql' => "varchar(8) NOT NULL default ''" - ), - 'weight' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['weight'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => 5, - 'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'), - 'sql' => "int(4) NOT NULL default '5'" - ), - 'opacity' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['opacity'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => '0.5', - 'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'), - 'sql' => "varchar(4) NOT NULL default '0.5'" - ), - 'fill' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['fill'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => array('tl_class' => 'clr w50', 'submitOnChange' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'fillColor' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['fillColor'], - 'exclude' => true, - 'inputType' => 'text', - 'wizard' => array( - \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::colorPicker() - ), - 'eval' => array( - 'tl_class' => 'clr w50 wizard', - 'maxlength' => 7, - 'decodeEntities' => true - ), - 'sql' => "varchar(8) NOT NULL default ''" - ), - 'fillOpacity' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['fillOpacity'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => '0.2', - 'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'), - 'sql' => "varchar(4) NOT NULL default '0.2'" - ), - 'dashArray' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['dashArray'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 32, 'tl_class' => 'w50'), - 'sql' => "varchar(32) NOT NULL default ''" - ), - 'lineCap' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['lineCap'], - 'exclude' => true, - 'inputType' => 'select', - 'options' => array('butt', 'round', 'square', 'inherit'), - 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['lineCaps'], - 'eval' => array('mandatory' => false, 'tl_class' => 'w50 clr', 'includeBlankOption' => true, 'helpwizard'), - 'sql' => "varchar(8) NOT NULL default ''" - ), - 'lineJoin' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['lineJoin'], - 'exclude' => true, - 'inputType' => 'select', - 'options' => array('miter', 'round', 'bevel', 'inherit'), - 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['lineJoins'], - 'eval' => array('mandatory' => false, 'tl_class' => 'w50', 'includeBlankOption' => true, 'helpwizard'), - 'sql' => "varchar(8) NOT NULL default ''" - ), - 'active' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['active'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'filter' => true, - 'sorting' => true, - 'search' => false, - 'flag' => 12, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''", - 'save_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - ), -); diff --git a/module/dca/tl_leaflet_vector.php b/module/dca/tl_leaflet_vector.php deleted file mode 100644 index b2a14ea..0000000 --- a/module/dca/tl_leaflet_vector.php +++ /dev/null @@ -1,415 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -$GLOBALS['TL_DCA']['tl_leaflet_vector'] = array -( - 'config' => array( - 'dataContainer' => 'Table', - 'enableVersioning' => true, - 'ptable' => 'tl_leaflet_layer', - 'sql' => array - ( - 'keys' => array - ( - 'id' => 'primary', - 'pid' => 'index', - 'alias' => 'unique', - ) - ), - 'onload_callback' => array( - function() { - \Controller::loadLanguageFile('leaflet'); - } - ), - 'onsubmit_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - - 'list' => array - ( - 'sorting' => array - ( - 'mode' => 4, - 'fields' => array('sorting'), - 'flag' => 1, - 'panelLayout' => 'sort,filter;search,limit', - 'headerFields' => array('title', 'type'), - 'child_record_callback' => Netzmacht\Contao\Leaflet\Dca\VectorCallbacks::callback('generateRow'), - ), - 'label' => array - ( - 'fields' => array('title'), - 'format' => '%s', - ), - 'global_operations' => array - ( - 'styles' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['styles'], - 'href' => 'table=tl_leaflet_style', - 'icon' => 'system/modules/leaflet/assets/img/style.png', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ), - 'popups' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popups'], - 'href' => 'table=tl_leaflet_popup', - 'icon' => 'system/modules/leaflet/assets/img/popup.png', - 'attributes' => 'onclick="Backend.getScrollOffset();"' - ), - 'all' => array - ( - 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], - 'href' => 'act=select', - 'class' => 'header_edit_all', - 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' - ), - ), - 'operations' => array - ( - 'edit' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['edit'], - 'href' => 'act=edit', - 'icon' => 'edit.gif' - ), - 'copy' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['copy'], - 'href' => 'act=copy', - 'icon' => 'copy.gif' - ), - 'cut' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['cut'], - 'href' => 'act=paste&mode=cut', - 'icon' => 'cut.gif', - 'attributes' => 'onclick="Backend.getScrollOffset()"', - ), - 'delete' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['delete'], - 'href' => 'act=delete', - 'icon' => 'delete.gif', - 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"' - ), - 'toggle' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['toggle'], - 'icon' => 'visible.gif', - 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', - 'button_callback' => \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::stateButton( - 'tl_leaflet_vector', - 'active' - ) - ), - 'show' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['show'], - 'href' => 'act=show', - 'icon' => 'show.gif' - ) - ) - ), - - 'palettes' => array( - '__selector__' => array('type') - ), - - 'metapalettes' => array( - 'default' => array( - 'title' => array('title', 'alias', 'type'), - 'data' => array(), - 'popup' => array(':hide','addPopup'), - 'config' => array(':hide', 'style', 'className', 'clickable'), - 'expert' => array(':hide', 'featureData'), - 'active' => array('active', 'ignoreForBounds') - ), - - 'polyline extends default' => array( - '+config' => array('smoothFactor', 'noClip'), - 'data' => array('data') - ), - - 'multiPolyline extends polyline' => array( - 'data' => array('multiData') - ), - - 'polygon extends polyline' => array(), - - 'multiPolygon extends multiPolyline' => array( - ), - - 'rectangle extends polygon' => array( - 'data' => array('bounds'), - ), - - 'circle extends default' => array( - '+data' => array('coordinates', 'radius'), - ), - - 'circleMarker extends circle' => array(), - ), - 'metasubpalettes' => array( - 'addPopup' => array('popup', 'popupContent'), - ), - - 'fields' => array - ( - 'id' => array - ( - 'sql' => "int(10) unsigned NOT NULL auto_increment" - ), - 'tstamp' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'pid' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'" - ), - 'sorting' => array - ( - 'sql' => "int(10) unsigned NOT NULL default '0'", - 'sorting' => true, - ), - 'title' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['title'], - 'exclude' => true, - 'inputType' => 'text', - 'filter' => false, - 'sorting' => true, - 'search' => true, - 'flag' => 1, - 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'), - 'sql' => "varchar(255) NOT NULL default ''" - ), - 'alias' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['alias'], - 'exclude' => true, - 'inputType' => 'text', - 'search' => true, - 'save_callback' => array( - \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::aliasGenerator( - 'tl_leaflet_vector', - 'alias', - ['title'], - \Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::ALIAS_GENERATOR - ), - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateAlias'), - ), - 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true), - 'sql' => "varchar(255) NULL" - ), - 'type' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['type'], - 'exclude' => true, - 'inputType' => 'select', - 'filter' => true, - 'sorting' => true, - 'search' => false, - 'flag' => 1, - 'eval' => array( - 'mandatory' => true, - 'tl_class' => 'w50', - 'includeBlankOption' => true, - 'submitOnChange' => true, - 'chosen' => true, - 'helpwizard' => true, - ), - 'options' => &$GLOBALS['LEAFLET_VECTORS'], - 'reference' => &$GLOBALS['TL_LANG']['leaflet_vector'], - 'sql' => "varchar(32) NOT NULL default ''" - ), - 'active' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['active'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'filter' => true, - 'sorting' => true, - 'search' => false, - 'flag' => 12, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''", - 'save_callback' => [ - \Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('clearCache'), - ], - ), - 'addPopup' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['addPopup'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'filter' => true, - 'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => true), - 'sql' => "char(1) NOT NULL default ''" - ), - 'popup' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popup'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'getPopups'), - 'eval' => array( - 'mandatory' => false, - 'tl_class' => 'w50', - 'chosen' => true, - 'includeBlankOption' => true, - ), - 'sql' => "int(10) unsigned NOT NULL default '0'", - ), - 'popupContent' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popupContent'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => true, 'rte' => 'tinyMCE', 'helpwizard' => true, 'tl_class' => 'clr'), - 'explanation' => 'insertTags', - 'sql' => "mediumtext NULL" - ), - 'style' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['style'], - 'exclude' => true, - 'inputType' => 'select', - 'options_callback' => Netzmacht\Contao\Leaflet\Dca\VectorCallbacks::callback('getStyles'), - 'eval' => array( - 'mandatory' => false, - 'tl_class' => 'w50', - 'chosen' => true, - 'includeBlankOption' => true, - ), - 'sql' => "int(10) unsigned NOT NULL default '0'", - ), - 'clickable' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['clickable'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => true, - 'eval' => array('tl_class' => 'm12 w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'className' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['className'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('mandatory' => false, 'maxlength' => 64, 'tl_class' => 'w50'), - 'sql' => "varchar(64) NOT NULL default ''" - ), - 'coordinates' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['coordinates'], - 'exclude' => true, - 'inputType' => 'text', - 'save_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateCoordinates') - ), - 'wizard' => array( - Netzmacht\Contao\Leaflet\Dca\LeafletCallbacks::callback('getGeocoder') - ), - 'eval' => array( - 'maxlength' => 255, - 'tl_class' => 'long clr', - 'nullIfEmpty' => true, - 'mandatory' => true, - ), - 'sql' => "varchar(255) NULL" - ), - 'radius' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['radius'], - 'exclude' => true, - 'inputType' => 'text', - 'default' => 5, - 'eval' => array('mandatory' => false, 'maxlength' => 10, 'rgxp' => 'digit', 'tl_class' => 'clr w50'), - 'sql' => "int(10) NOT NULL default '5'" - ), - 'data' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['data'], - 'inputType' => 'textarea', - 'search' => false, - 'eval' => array('mandatory' => true, 'alwaysSave' => true), - 'save_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateMultipleCoordinates') - ), - 'sql' => "longblob NULL" - ), - 'multiData' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['multiData'], - 'inputType' => 'multiColumnWizard', - 'search' => false, - 'eval' => array( - 'mandatory' => true, - 'alwaysSave' => true, - 'flatArray' => true, - 'columnFields' => array - ( - 'data' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['data'], - 'inputType' => 'textarea', - 'search' => false, - 'eval' => array('alwaysSave' => true, 'style' => 'width:600px'), - ) - ) - ), - 'save_callback' => array( - \Netzmacht\Contao\Leaflet\Dca\Validator::callback('validateMultipleCoordinateSets') - ), - 'sql' => "longblob NULL" - ), - 'bounds' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['bounds'], - 'exclude' => true, - 'inputType' => 'text', - 'save_callback' => array(), - 'eval' => array( - 'maxlength' => 255, - 'multiple'=>true, - 'size'=>2, - 'tl_class' => 'long clr', - 'nullIfEmpty' => true, - ), - 'sql' => "mediumblob NULL" - ), - 'ignoreForBounds' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['ignoreForBounds'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'default' => false, - 'eval' => array('tl_class' => 'w50'), - 'sql' => "char(1) NOT NULL default ''" - ), - 'featureData' => array - ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['featureData'], - 'exclude' => true, - 'inputType' => 'textarea', - 'eval' => array('tl_class' => 'clr lng', - 'allowHtml' => true, - 'style' => 'min-height: 40px;', - 'rte' => 'ace|json' - ), - 'sql' => "text NULL" - ), - ), -); diff --git a/module/dca/tl_module.php b/module/dca/tl_module.php deleted file mode 100644 index 0ef3d2e..0000000 --- a/module/dca/tl_module.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -$GLOBALS['TL_DCA']['tl_module']['metapalettes']['leaflet'] = array( - 'type' => array('name', 'type', 'headline'), - 'leaflet' => array('leaflet_map', 'leaflet_mapId', 'leaflet_width', 'leaflet_height', 'leaflet_template'), - 'templates' => array(':hide', 'customTpl'), - 'protected' => array(':hide', 'protected'), - 'expert' => array(':hide', 'guests', 'cssID', 'space'), - 'invisible' => array(':hide', 'invisible', 'start', 'start') -); - -$GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_map'] = array( - 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_map'], - 'inputType' => 'select', - 'exclude' => true, - 'options_callback' => \Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getMaps'), - 'wizard' => array( - \Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getEditMapLink'), - ), - 'eval' => array( - 'tl_class' => 'w50 wizard', - 'chosen' => true, - ), - 'sql' => "int(10) unsigned NOT NULL default '0'" -); - -$GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_mapId'] = array( - 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_mapId'], - 'inputType' => 'text', - 'exclude' => true, - 'eval' => array( - 'tl_class' => 'w50', - 'chosen' => true, - 'maxlength' => 16, - ), - 'sql' => "varchar(16) NOT NULL default ''" -); - -$GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_width'] = array( - 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_width'], - 'inputType' => 'inputUnit', - 'options' => array('px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'), - 'search' => false, - 'exclude' => true, - 'eval' => array('rgxp' => 'digit', 'tl_class' => 'clr w50'), - 'sql' => "varchar(64) NOT NULL default ''" -); - - -$GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_height'] = array( - 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_height'], - 'inputType' => 'inputUnit', - 'options' => array('px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'), - 'search' => false, - 'exclude' => true, - 'eval' => array('rgxp' => 'digit', 'tl_class' => 'w50'), - 'sql' => "varchar(64) NOT NULL default ''" -); - -$GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_template'] = array( - 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_template'], - 'inputType' => 'select', - 'exclude' => true, - 'options_callback' => \Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory::getTemplates('leaflet_map_js'), - 'eval' => array( - 'tl_class' => 'w50', - 'chosen' => true, - ), - 'sql' => "varchar(64) NOT NULL default ''" -); diff --git a/module/languages/en/tl_leaflet_map.php b/module/languages/en/tl_leaflet_map.php deleted file mode 100644 index d5f5721..0000000 --- a/module/languages/en/tl_leaflet_map.php +++ /dev/null @@ -1,107 +0,0 @@ -http://leafletjs.com/reference.html#map-options'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustZoomExtra'][0] = 'Adjust extra zoom settings'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustZoomExtra'][1] = 'Enable if you want to adjust minimum and maximum zoom as well'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['layers'][0] = 'Default layers'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['layers'][1] = 'Inital visible layers of the map. For optional layers use the layers control.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBounds'][0] = 'Adjust bounds'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBounds'][1] = 'If enabled the map will fit into bounds of data layers which are marked to affect the map bounds.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['locate'][0] = 'Locate user position'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['locate'][1] = 'Initial map zoom.Tries to locate the user using the Geolocation API.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['locateWatch'][0] = 'Watch continuously'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['locateWatch'][1] = 'If true, starts continous watching of location changes '; -$GLOBALS['TL_LANG']['tl_leaflet_map']['locateSetView'][0] = 'Update map center'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['locateSetView'][1] = 'If enabled, automatically sets the map view to the user location. Otherwise only the locationfound event is triggered.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaxZoom'][0] = 'Locate max zoom'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaxZoom'][1] = 'Max zoom when setting updating map view.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['locateTimeout'][0] = 'Locate timeout'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['locateTimeout'][1] = 'Number of milliseconds to wait for a response from geolocation.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['enableHighAccuracy'][0] = 'High accuracy'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['enableHighAccuracy'][1] = 'Enables high accuracy, see description in the W3C spec.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaximumAge'][0] = 'Locate maximum age'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaximumAge'][1] = 'Maximum age of detected location in milliseconds. Use cached value if time has not passed.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['dynamicLoad'][0] = 'Load data dynamically in bounds'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['dynamicLoad'][1] = 'If enabled the map requests data from the layers for the current bounds only and make a new request if bounds has changed.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['boundsPadding'][0] = 'Bounds padding'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['boundsPadding'][1] = 'Padding being used then applying bounds. Use comma separated values. If 2 values are given the padding option is set. If 4 values are given paddingTopLeft and paddingBottomRight is set.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['cache'][0] = 'Enable cache'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['cache'][1] = 'If enabled the generated map javascript is cached.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['cacheLifeTime'][0] = 'Cache lifetime'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['cacheLifeTime'][1] = 'Indicates how long a cache entry is valid in seconds.'; - -$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions']['load'][0] = 'At map initialization'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions']['load'][1] = 'Calculate bounds when the map is initialized. All static and already loaded deferred featured are included.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions']['deferred'][0] = 'After loading deferred feature'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions']['deferred'][1] = 'Recalculate bounds when a deferred feature is load.'; - -$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'][''][0] = 'Disable'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'][''][1] = 'Disable zoom function.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['1'][0] = 'Enable'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['1'][1] = 'Enable zoom function.'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['center'][0] = 'Center'; -$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['center'][1] = 'If passed \'center\', it will zoom to the center of the view regardless of where the mouse was.'; diff --git a/module/public/.htaccess b/module/public/.htaccess deleted file mode 100644 index 28cc359..0000000 --- a/module/public/.htaccess +++ /dev/null @@ -1,7 +0,0 @@ - - Order allow,deny - Allow from all - - - Require all granted - \ No newline at end of file diff --git a/module/templates/be_leaflet_about.html5 b/module/templates/be_leaflet_about.html5 deleted file mode 100644 index 84c8e0c..0000000 --- a/module/templates/be_leaflet_about.html5 +++ /dev/null @@ -1,125 +0,0 @@ -
-
-

headline; ?> version; ?>

-
- -
-

About

-
-

- The Leaflet maps integration for Contao CMS is an Open Source Software license under the LGPL 3.0. - This extension is only exists because of great other Open Source Software which it heavenly depends on. -

-

- This software ships with an visible attribution to netzmacht creative in the map attribution control. - If you want to remove this attribution, you have to purchase a commercial license. - For more details visit the project website. -

-
-
- > - -

- netzmacht
- David Molineus
-

-

- DAB Bank München
- IBAN: DE52701204008354237003
- BIC: DABBDEMMXXX -

-
- - - - -
-
-
- -
-

Support Contao Leaflet

- -
-
-

Report issues

-

If you found a bug, got some troubles or have a feature request - feel free to open an issue.

-

Issue tracker

-
-
-

Contribute

-

There are many ways you can con­tribute. Translations, - docu­mentation or code contributions are welcome. -

-

Contribute

-
-
-

Fund a feature

-

Contao Leaflet is not feature complete. Have a look at the list of planned feature and support them.

-

Planned features

-
-
-
- -
-

Individual development

-

If you have special requirements you can hire me for an individual development.

-

Contact

-
-
-

Commercial license

-

If you want to remove the attribution in the attribution control, you can purchase a commercial license.

-

Purchase license

-
-
-
- -
-

Credits

- - - - - - - - libraries): ?> - - - libraries as $library): ?> - - - - - - - - - - - - - - - - - - - - - - - dependencies): ?> - - - dependencies as $dep): ?> - - - - - - - -
NameVersionLicenseHomepage
Libraries
Graphics
Farm Fresh-Web Icons3.9.2CC BY 3.0 USfatcow.com/free-icons
Web Blog Icons by SEM Labs3.9.2CC BY 4.0semlabs.co.uk
Dependencies
-
-
diff --git a/module/templates/leaflet_map_html.html5 b/module/templates/leaflet_map_html.html5 deleted file mode 100644 index 3be0929..0000000 --- a/module/templates/leaflet_map_html.html5 +++ /dev/null @@ -1,6 +0,0 @@ -
- diff --git a/module/templates/leaflet_map_js.html5 b/module/templates/leaflet_map_js.html5 deleted file mode 100644 index 8f9f88f..0000000 --- a/module/templates/leaflet_map_js.html5 +++ /dev/null @@ -1,5 +0,0 @@ -L.contao.addMap('', function() { - - -return { map: map, layers: layers, controls: controls, icons: icons }; -}()); diff --git a/package.json b/package.json index 96a0656..187700b 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,10 @@ "description": "Leaflet maps for Contao", "main": "gulpfile.js", "dependencies": { - "del": "^2.2.2", + "del": "^3.0.0", "gulp": "^3.9.1", "gulp-concat": "^2.6.0", - "gulp-uglify": "^2.0.0" + "gulp-uglify": "^3.0.0" }, "devDependencies": {}, "scripts": { diff --git a/src/Netzmacht/Contao/Leaflet/Alias/DefaultAliasFilter.php b/src/Alias/DefaultAliasFilter.php similarity index 74% rename from src/Netzmacht/Contao/Leaflet/Alias/DefaultAliasFilter.php rename to src/Alias/DefaultAliasFilter.php index 3fe9e70..51f1b4a 100644 --- a/src/Netzmacht/Contao/Leaflet/Alias/DefaultAliasFilter.php +++ b/src/Alias/DefaultAliasFilter.php @@ -1,13 +1,17 @@ - * @copyright 2016 netzmacht David Molineus. All rights reserved. - * @filesource + * Leaflet maps for Contao CMS. * + * @package contao-leaflet-maps + * @author David Molineus + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource */ +declare(strict_types=1); + namespace Netzmacht\Contao\Leaflet\Alias; use Netzmacht\Contao\Toolkit\Data\Alias\Filter\AbstractFilter; @@ -42,7 +46,7 @@ class DefaultAliasFilter extends AbstractFilter /** * {@inheritdoc} */ - public function repeatUntilValid() + public function repeatUntilValid(): bool { return false; } @@ -50,7 +54,7 @@ class DefaultAliasFilter extends AbstractFilter /** * {@inheritdoc} */ - public function apply($model, $value, $separator) + public function apply($model, $value, string $separator): string { if (!$value) { return $this->prefix . $separator . $model->id; diff --git a/src/Alias/DefaultAliasGeneratorFactory.php b/src/Alias/DefaultAliasGeneratorFactory.php new file mode 100644 index 0000000..7a00ec7 --- /dev/null +++ b/src/Alias/DefaultAliasGeneratorFactory.php @@ -0,0 +1,66 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Alias; + +use Doctrine\DBAL\Connection; +use Netzmacht\Contao\Toolkit\Data\Alias\AliasGenerator; +use Netzmacht\Contao\Toolkit\Data\Alias\Factory\AliasGeneratorFactory; +use Netzmacht\Contao\Toolkit\Data\Alias\Filter\ExistingAliasFilter; +use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SlugifyFilter; +use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SuffixFilter; +use Netzmacht\Contao\Toolkit\Data\Alias\FilterBasedAliasGenerator; +use Netzmacht\Contao\Toolkit\Data\Alias\Validator\UniqueDatabaseValueValidator; + +/** + * Class DefaultAliasGeneratorFactory. + * + * @package Netzmacht\Contao\Leaflet\Alias + */ +class DefaultAliasGeneratorFactory implements AliasGeneratorFactory +{ + /** + * Database connection. + * + * @var Connection + */ + private $connection; + + /** + * DefaultAliasGeneratorFactory constructor. + * + * @param Connection $connection Database connection. + */ + public function __construct(Connection $connection) + { + $this->connection = $connection; + } + + /** + * {@inheritDoc} + */ + public function create(string $dataContainerName, string $aliasField, array $fields): AliasGenerator + { + $filters = [ + new ExistingAliasFilter(), + new SlugifyFilter($fields), + new DefaultAliasFilter($dataContainerName), + new SuffixFilter(), + ]; + + $validator = new UniqueDatabaseValueValidator($this->connection, $dataContainerName, $aliasField); + + return new FilterBasedAliasGenerator($filters, $validator, $dataContainerName, $aliasField, '_'); + } +} diff --git a/src/Alias/ParentAliasGeneratorFactory.php b/src/Alias/ParentAliasGeneratorFactory.php new file mode 100644 index 0000000..d5d3990 --- /dev/null +++ b/src/Alias/ParentAliasGeneratorFactory.php @@ -0,0 +1,66 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Alias; + +use Doctrine\DBAL\Connection; +use Netzmacht\Contao\Toolkit\Data\Alias\AliasGenerator; +use Netzmacht\Contao\Toolkit\Data\Alias\Factory\AliasGeneratorFactory; +use Netzmacht\Contao\Toolkit\Data\Alias\Filter\ExistingAliasFilter; +use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SlugifyFilter; +use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SuffixFilter; +use Netzmacht\Contao\Toolkit\Data\Alias\FilterBasedAliasGenerator; +use Netzmacht\Contao\Toolkit\Data\Alias\Validator\UniqueDatabaseValueValidator; + +/** + * Alias generator validating against the parent id (pid). + * + * @package Netzmacht\Contao\Leaflet\Alias + */ +class ParentAliasGeneratorFactory implements AliasGeneratorFactory +{ + /** + * Database connection. + * + * @var Connection + */ + private $connection; + + /** + * DefaultAliasGeneratorFactory constructor. + * + * @param Connection $connection Database connection. + */ + public function __construct(Connection $connection) + { + $this->connection = $connection; + } + + /** + * {@inheritDoc} + */ + public function create(string $dataContainerName, string $aliasField, array $fields): AliasGenerator + { + $filters = [ + new ExistingAliasFilter(), + new SlugifyFilter($fields), + new DefaultAliasFilter($dataContainerName), + new SuffixFilter(), + ]; + + $validator = new UniqueDatabaseValueValidator($this->connection, $dataContainerName, $aliasField, ['pid']); + + return new FilterBasedAliasGenerator($filters, $validator, $dataContainerName, $aliasField, '_'); + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Backend/About.php b/src/Backend/About.php similarity index 85% rename from src/Netzmacht/Contao/Leaflet/Backend/About.php rename to src/Backend/About.php index 8a1b350..50c9e13 100644 --- a/src/Netzmacht/Contao/Leaflet/Backend/About.php +++ b/src/Backend/About.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Backend; @@ -47,10 +48,10 @@ class About return array_map( function ($library) { $library = array_merge( - array( + [ 'homepage' => null, 'version' => null, - ), + ], $library ); @@ -81,34 +82,34 @@ class About */ private function extractFromComposer() { - $extFile = TL_ROOT . '/composer/vendor/netzmacht/contao-leaflet-maps/composer.json'; - $lockFile = TL_ROOT . '/composer/composer.lock'; + $extFile = TL_ROOT . '/vendor/netzmacht/contao-leaflet-maps/composer.json'; + $lockFile = TL_ROOT . '/composer.lock'; if (!file_exists($extFile) || !file_exists($lockFile)) { - return array(); + return []; } $extension = json_decode(file_get_contents($extFile), true); $installed = json_decode(file_get_contents($lockFile), true); - $deps = array(); + $deps = []; $version = null; foreach ($installed['packages'] as $package) { if ($package['name'] === 'netzmacht/contao-leaflet-maps') { $version = $package['version']; } elseif (isset($extension['require'][$package['name']])) { - $deps[] = array( + $deps[] = [ 'name' => $package['name'], 'version' => $package['version'], 'license' => !empty($package['license']) ? implode(', ', $package['license']) : '', 'homepage' => sprintf( 'Visit packagist', $package['name'] - ) - ); + ), + ]; } } - return array($version, $deps); + return [$version, $deps]; } } diff --git a/src/Backend/Renderer/Label/Layer/AbstractLabelRenderer.php b/src/Backend/Renderer/Label/Layer/AbstractLabelRenderer.php new file mode 100644 index 0000000..b89ba38 --- /dev/null +++ b/src/Backend/Renderer/Label/Layer/AbstractLabelRenderer.php @@ -0,0 +1,38 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer; + +/** + * Class AbstractLabelRenderer. + * + * @package Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer + */ +abstract class AbstractLabelRenderer implements LayerLabelRenderer +{ + /** + * {@inheritdoc} + */ + public function supports(array $row): bool + { + return $row['type'] === $this->getLayerType(); + } + + /** + * Get the supported layer type. + * + * @return string + */ + abstract protected function getLayerType(): string; +} diff --git a/src/Backend/Renderer/Label/Layer/ChainRenderer.php b/src/Backend/Renderer/Label/Layer/ChainRenderer.php new file mode 100644 index 0000000..9fa24e8 --- /dev/null +++ b/src/Backend/Renderer/Label/Layer/ChainRenderer.php @@ -0,0 +1,70 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer; + +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Class ChainRenderer. + * + * @package Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer + */ +final class ChainRenderer implements LayerLabelRenderer +{ + /** + * List of layer label renderer. + * + * @var array|LayerLabelRenderer[] + */ + private $renderer; + + /** + * ChainRenderer constructor. + * + * @param array|LayerLabelRenderer[] $renderer List of layer label renderer. + */ + public function __construct($renderer) + { + $this->renderer = $renderer; + } + + /** + * {@inheritDoc} + */ + public function supports(array $row): bool + { + foreach ($this->renderer as $renderer) { + if ($renderer->supports($row)) { + return true; + } + } + + return false; + } + + /** + * {@inheritDoc} + */ + public function render(array $row, string $label, Translator $translator): string + { + foreach ($this->renderer as $renderer) { + if ($renderer->supports($row)) { + return $renderer->render($row, $label, $translator); + } + } + + return $label; + } +} diff --git a/src/Backend/Renderer/Label/Layer/FileLabelRenderer.php b/src/Backend/Renderer/Label/Layer/FileLabelRenderer.php new file mode 100644 index 0000000..3c3a354 --- /dev/null +++ b/src/Backend/Renderer/Label/Layer/FileLabelRenderer.php @@ -0,0 +1,67 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer; + +use Contao\FilesModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Class FileLabelRenderer + * + * @package Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer + */ +class FileLabelRenderer extends AbstractLabelRenderer +{ + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * FileLabelRenderer constructor. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + } + + /** + * {@inheritDoc} + */ + protected function getLayerType(): string + { + return 'file'; + } + + /** + * {@inheritDoc} + */ + public function render(array $row, string $label, Translator $translator): string + { + $repository = $this->repositoryManager->getRepository(FilesModel::class); + $file = $repository->findByPk($row['file']); + + if ($file) { + $label .= ' (' . $file->path . ')'; + } + + return $label; + } +} diff --git a/src/Backend/Renderer/Label/Layer/LayerLabelRenderer.php b/src/Backend/Renderer/Label/Layer/LayerLabelRenderer.php new file mode 100644 index 0000000..4c5a71d --- /dev/null +++ b/src/Backend/Renderer/Label/Layer/LayerLabelRenderer.php @@ -0,0 +1,45 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer; + +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Interface LayerLabelRenderer. + * + * @package Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer + */ +interface LayerLabelRenderer +{ + /** + * Check if current row is supported. + * + * @param array $row Current row. + * + * @return bool + */ + public function supports(array $row): bool; + + /** + * Render the backend label of an layer. + * + * @param array $row Current row. + * @param string $label Default label. + * @param Translator $translator The translator. + * + * @return string + */ + public function render(array $row, string $label, Translator $translator): string; +} diff --git a/src/Backend/Renderer/Label/Layer/MarkersLabelRenderer.php b/src/Backend/Renderer/Label/Layer/MarkersLabelRenderer.php new file mode 100644 index 0000000..7a1e1f6 --- /dev/null +++ b/src/Backend/Renderer/Label/Layer/MarkersLabelRenderer.php @@ -0,0 +1,68 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer; + +use Netzmacht\Contao\Leaflet\Model\MarkerModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Class MarkersLabelRenderer. + * + * @package Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer + */ +final class MarkersLabelRenderer extends AbstractLabelRenderer +{ + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * FileLabelRenderer constructor. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + } + + /** + * {@inheritdoc} + */ + protected function getLayerType(): string + { + return 'markers'; + } + + /** + * {@inheritdoc} + */ + public function render(array $row, string $label, Translator $translator): string + { + $repository = $this->repositoryManager->getRepository(MarkerModel::class); + $count = $repository->countBy(['pid=?'], [$row['id']]); + $label .= sprintf( + ' (%s %s)', + $count, + $translator->trans('countEntries', [], 'contao_tl_leaflet_layer') + ); + + return $label; + } +} diff --git a/src/Backend/Renderer/Label/Layer/OverpassLabelRenderer.php b/src/Backend/Renderer/Label/Layer/OverpassLabelRenderer.php new file mode 100644 index 0000000..f32f19a --- /dev/null +++ b/src/Backend/Renderer/Label/Layer/OverpassLabelRenderer.php @@ -0,0 +1,46 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer; + +use Contao\StringUtil; +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Class OverpassLabelRenderer. + * + * @package Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer + */ +final class OverpassLabelRenderer extends AbstractLabelRenderer +{ + /** + * {@inheritdoc} + */ + protected function getLayerType(): string + { + return 'overpass'; + } + + /** + * {@inheritdoc} + */ + public function render(array $row, string $label, Translator $translator): string + { + if ($row['overpassQuery']) { + $label .= ' ' . StringUtil::substr($row['overpassQuery'], 50) . ''; + } + + return $label; + } +} diff --git a/src/Backend/Renderer/Label/Layer/ProviderLabelRenderer.php b/src/Backend/Renderer/Label/Layer/ProviderLabelRenderer.php new file mode 100644 index 0000000..9148b97 --- /dev/null +++ b/src/Backend/Renderer/Label/Layer/ProviderLabelRenderer.php @@ -0,0 +1,52 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer; + +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Backend label renderer for provider layer. + * + * @package Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer + */ +final class ProviderLabelRenderer extends AbstractLabelRenderer +{ + /** + * {@inheritdoc} + */ + protected function getLayerType(): string + { + return 'provider'; + } + + /** + * {@inheritdoc} + */ + public function render(array $row, string $label, Translator $translator): string + { + $langKey = 'leaflet_provider.' . $row['tile_provider'] . '.0'; + $translated = $translator->trans($langKey, [], 'contao_leaflet'); + + if ($translated !== $langKey) { + $provider = $translated; + } else { + $provider = $row['tile_provider']; + } + + $label .= sprintf(' (%s)', $provider); + + return $label; + } +} diff --git a/src/Backend/Renderer/Label/Layer/ReferenceLabelRenderer.php b/src/Backend/Renderer/Label/Layer/ReferenceLabelRenderer.php new file mode 100644 index 0000000..afb5497 --- /dev/null +++ b/src/Backend/Renderer/Label/Layer/ReferenceLabelRenderer.php @@ -0,0 +1,67 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer; + +use Netzmacht\Contao\Leaflet\Model\LayerModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Class ReferenceLabelRenderer. + * + * @package Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer + */ +final class ReferenceLabelRenderer extends AbstractLabelRenderer +{ + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * FileLabelRenderer constructor. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + } + + /** + * {@inheritdoc} + */ + protected function getLayerType(): string + { + return 'reference'; + } + + /** + * {@inheritdoc} + */ + public function render(array $row, string $label, Translator $translator): string + { + $repository = $this->repositoryManager->getRepository(LayerModel::class); + $reference = $repository->find((int) $row['reference']); + + if ($reference) { + $label .= ' (' . $reference->title . ')'; + } + + return $label; + } +} diff --git a/src/Backend/Renderer/Label/Layer/VectorsLabelRenderer.php b/src/Backend/Renderer/Label/Layer/VectorsLabelRenderer.php new file mode 100644 index 0000000..b892440 --- /dev/null +++ b/src/Backend/Renderer/Label/Layer/VectorsLabelRenderer.php @@ -0,0 +1,68 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer; + +use Netzmacht\Contao\Leaflet\Model\VectorModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Class VectorsLabelRenderer. + * + * @package Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer + */ +final class VectorsLabelRenderer extends AbstractLabelRenderer +{ + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * FileLabelRenderer constructor. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + } + + /** + * {@inheritdoc} + */ + protected function getLayerType(): string + { + return 'vectors'; + } + + /** + * {@inheritdoc} + */ + public function render(array $row, string $label, Translator $translator): string + { + $repository = $this->repositoryManager->getRepository(VectorModel::class); + $count = $repository->countBy(['pid=?'], [$row['id']]); + $label .= sprintf( + ' (%s %s)', + $count, + $translator->trans('countEntries', [], 'contao_tl_leaflet_layer') + ); + + return $label; + } +} diff --git a/src/Bundle/ContaoManager/Plugin.php b/src/Bundle/ContaoManager/Plugin.php new file mode 100644 index 0000000..8033179 --- /dev/null +++ b/src/Bundle/ContaoManager/Plugin.php @@ -0,0 +1,42 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Bundle\ContaoManager; + +use Contao\CoreBundle\ContaoCoreBundle; +use Contao\ManagerPlugin\Bundle\BundlePluginInterface; +use Contao\ManagerPlugin\Bundle\Config\BundleConfig; +use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; +use Netzmacht\Contao\Leaflet\Bundle\NetzmachtContaoLeafletBundle; +use Netzmacht\Contao\Toolkit\Bundle\NetzmachtContaoToolkitBundle; + +/** + * Contao manager plugin. + * + * @package Netzmacht\Contao\Leaflet\ContaoManager + */ +class Plugin implements BundlePluginInterface +{ + /** + * {@inheritdoc} + */ + public function getBundles(ParserInterface $parser) + { + return [ + BundleConfig::create(NetzmachtContaoLeafletBundle::class) + ->setLoadAfter([ContaoCoreBundle::class, NetzmachtContaoToolkitBundle::class]) + ->setReplace(['leaflet']), + ]; + } +} diff --git a/src/Bundle/DependencyInjection/NetzmachtContaoLeafletExtension.php b/src/Bundle/DependencyInjection/NetzmachtContaoLeafletExtension.php new file mode 100644 index 0000000..2dc6a92 --- /dev/null +++ b/src/Bundle/DependencyInjection/NetzmachtContaoLeafletExtension.php @@ -0,0 +1,61 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Bundle\DependencyInjection; + +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; + +/** + * Class NetzmachtContaoLeafletExtension. + * + * @package Netzmacht\Contao\Leaflet\DependencyInjection + */ +class NetzmachtContaoLeafletExtension extends Extension +{ + /** + * {@inheritdoc} + */ + public function load(array $configs, ContainerBuilder $container) + { + $loader = new YamlFileLoader( + $container, + new FileLocator(dirname(__DIR__) . '/Resources/config') + ); + + // Common config, services and listeners + $loader->load('config.yml'); + $loader->load('services.yml'); + $loader->load('listeners.yml'); + + // Amenities and providers config + $loader->load('amenities.yml'); + $loader->load('providers.yml'); + + // Other services + $loader->load('mappers.yml'); + $loader->load('encoders.yml'); + $loader->load('layers.yml'); + + if (!$container->hasDefinition('netzmacht.contao_leaflet.cache')) { + if ($container->getParameter('kernel.debug')) { + $container->setAlias('netzmacht.contao_leaflet.cache', 'netzmacht.contao_leaflet.cache.debug'); + } else { + $container->setAlias('netzmacht.contao_leaflet.cache', 'netzmacht.contao_leaflet.cache.default'); + } + } + } +} diff --git a/src/Bundle/DependencyInjection/Pass/RegisterDefinitionMapperPass.php b/src/Bundle/DependencyInjection/Pass/RegisterDefinitionMapperPass.php new file mode 100644 index 0000000..823d50d --- /dev/null +++ b/src/Bundle/DependencyInjection/Pass/RegisterDefinitionMapperPass.php @@ -0,0 +1,50 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass; + +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +/** + * Register all definition mappers. + * + * @package Netzmacht\Contao\Leaflet\DependencyInjection\Pass + */ +class RegisterDefinitionMapperPass implements CompilerPassInterface +{ + /** + * {@inheritDoc} + */ + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition('netzmacht.contao_leaflet.definition.mapper')) { + return; + } + + $definition = $container->getDefinition('netzmacht.contao_leaflet.definition.mapper'); + $taggedServices = $container->findTaggedServiceIds('netzmacht.contao_leaflet.mapper'); + + foreach ($taggedServices as $serviceId => $tags) { + foreach ($tags as $attributes) { + if (isset($attributes['priority'])) { + $definition->addMethodCall('register', [new Reference($serviceId), (int) $attributes['priority']]); + } else { + $definition->addMethodCall('register', [new Reference($serviceId)]); + } + } + } + } +} diff --git a/src/Bundle/DependencyInjection/Pass/RegisterEncodersPass.php b/src/Bundle/DependencyInjection/Pass/RegisterEncodersPass.php new file mode 100644 index 0000000..4add7f7 --- /dev/null +++ b/src/Bundle/DependencyInjection/Pass/RegisterEncodersPass.php @@ -0,0 +1,44 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass; + +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +/** + * Register all definition encoders. + * + * @package Netzmacht\Contao\Leaflet\DependencyInjection\Pass + */ +class RegisterEncodersPass implements CompilerPassInterface +{ + /** + * {@inheritDoc} + */ + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition('netzmacht.contao_leaflet.definition.builder.event_dispatcher')) { + return; + } + + $definition = $container->getDefinition('netzmacht.contao_leaflet.definition.builder.event_dispatcher'); + $serviceIds = $container->findTaggedServiceIds('netzmacht.contao_leaflet.encoder'); + + foreach (array_keys($serviceIds) as $serviceId) { + $definition->addMethodCall('addSubscriber', [new Reference($serviceId)]); + } + } +} diff --git a/src/Bundle/DependencyInjection/Pass/RegisterLibrariesPass.php b/src/Bundle/DependencyInjection/Pass/RegisterLibrariesPass.php new file mode 100644 index 0000000..84b4bdc --- /dev/null +++ b/src/Bundle/DependencyInjection/Pass/RegisterLibrariesPass.php @@ -0,0 +1,56 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass; + +use Netzmacht\LeafletPHP\Assets; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +/** + * Class RegisterLibrariesPass. + * + * @package Netzmacht\Contao\Leaflet\DependencyInjection\Pass + */ +class RegisterLibrariesPass implements CompilerPassInterface +{ + /** + * {@inheritDoc} + */ + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition('netzmacht.contao_leaflet.definition.builder')) { + return; + } + + if (!$container->hasParameter('netzmacht.contao_leaflet.libraries')) { + return; + } + + $definition = $container->getDefinition('netzmacht.contao_leaflet.definition.builder'); + $libraries = $container->getParameter('netzmacht.contao_leaflet.libraries'); + + foreach ($libraries as $name => $assets) { + if (!empty($assets['css'])) { + list ($source, $type) = (array) $assets['css']; + $definition->addMethodCall('registerStylesheet', [$name, $source, $type ?: Assets::TYPE_FILE]); + } + + if (!empty($assets['javascript'])) { + list ($source, $type) = (array) $assets['javascript']; + $definition->addMethodCall('registerJavascript', [$name, $source, $type ?: Assets::TYPE_FILE]); + } + } + } +} diff --git a/src/Bundle/NetzmachtContaoLeafletBundle.php b/src/Bundle/NetzmachtContaoLeafletBundle.php new file mode 100644 index 0000000..305463c --- /dev/null +++ b/src/Bundle/NetzmachtContaoLeafletBundle.php @@ -0,0 +1,46 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Bundle; + +use Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass\RegisterDefinitionMapperPass; +use Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass\RegisterEncodersPass; +use Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass\RegisterLibrariesPass; +use Netzmacht\Contao\Toolkit\Bundle\DependencyInjection\Compiler\AddTaggedServicesAsArgumentPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\Bundle\Bundle; + +/** + * Class NetzmachtContaoLeafletBundle. + * + * @package Netzmacht\Contao\Leaflet + */ +class NetzmachtContaoLeafletBundle extends Bundle +{ + /** + * {@inheritDoc} + */ + public function build(ContainerBuilder $container) + { + $container->addCompilerPass(new RegisterDefinitionMapperPass()); + $container->addCompilerPass(new RegisterEncodersPass()); + $container->addCompilerPass(new RegisterLibrariesPass()); + $container->addCompilerPass( + new AddTaggedServicesAsArgumentPass( + 'netzmacht.contao_leaflet.layer_label_renderer', + 'netzmacht.contao_leaflet.layer_label_renderer' + ) + ); + } +} diff --git a/src/Bundle/Resources/config/amenities.yml b/src/Bundle/Resources/config/amenities.yml new file mode 100644 index 0000000..1c063eb --- /dev/null +++ b/src/Bundle/Resources/config/amenities.yml @@ -0,0 +1,202 @@ +parameters: + netzmacht.contao_leaflet.amenities: + - 'administration' + - 'advertising' + - 'alm' + - 'animal_boarding' + - 'animal_breeding' + - 'animal_shelter' + - 'architect_office' + - 'arts_centre' + - 'artwork' + - 'atm' + - 'audiologist' + - 'baby_hatch' + - 'bank' + - 'bar' + - 'bbq' + - 'bench' + - 'bicycle_parking' + - 'bicycle_rental' + - 'bicycle_repair_station' + - 'bicycle_trailer_sharing' + - 'biergarten' + - 'bikeshed' + - 'boat_rental' + - 'boat_sharing' + - 'boat_storage' + - 'brothel' + - 'bts' + - 'bureau_de_change' + - 'bus_station' + - 'cafe' + - 'canoe_hire' + - 'car_rental' + - 'car_repair' + - 'car_sharing' + - 'car_wash' + - 'casino' + - 'charging_station' + - 'childcare' + - 'cinema' + - 'citymap_post' + - 'clinic' + - 'clock' + - 'club' + - 'coast_guard' + - 'coast_radar_station' + - 'college' + - 'community_center' + - 'community_centre' + - 'compressed_air' + - 'concert_hall' + - 'conference_centre' + - 'courthouse' + - 'coworking_space' + - 'crematorium' + - 'crucifix' + - 'crypt' + - 'customs' + - 'dancing_school' + - 'dead_pub' + - 'dentist' + - 'disused' + - 'dive_centre' + - 'doctors' + - 'dog_bin' + - 'dog_waste_bin' + - 'dojo' + - 'drinking_water' + - '_driving_school' + - 'education' + - 'embassy' + - 'emergency_phone' + - 'emergency_service' + - 'events_venue' + - 'ev_charging' + - 'exhibition_centre' + - 'fast_food' + - 'ferry_terminal' + - 'festival_grounds' + - 'financial_advice' + - 'fire_hydrant' + - 'fire_station' + - 'first_aid' + - 'fish_spa' + - 'food_court' + - 'fountain' + - 'fuel' + - 'gambling' + - 'game_feeding' + - 'garages' + - 'grave_yard' + - 'grit_bin' + - 'harbourmaster' + - 'hospice' + - 'hospital' + - 'hotel' + - 'hunting_stand' + - 'ice_cream' + - 'internet_cafe' + - 'jobcentre' + - 'kindergarten' + - 'kiosk' + - 'kitchen' + - 'Kneippbecken' + - 'kneipp_water_cure' + - 'language_school' + - 'lavoir' + - 'library' + - 'lifeboat_station' + - 'life_ring' + - 'loading_dock' + - 'love_hotel' + - 'marae' + - 'marketplace' + - 'milk_dispenser' + - 'mobile_library' + - 'monastery' + - 'money_transfer' + - 'mortuary' + - 'motorcycle_parking' + - 'motorcycle_rental' + - 'music_school' + - 'music_venue' + - 'nameplate' + - 'nightclub' + - 'nursery' + - 'nursing_home' + - 'park' + - 'parking' + - 'parking_entrance' + - 'parking_space' + - 'pharmacy' + - 'photo_booth' + - 'place_of_worship' + - 'planetarium' + - 'police' + - 'post_box' + - 'post_office' + - 'preschool' + - 'printer' + - 'prison' + - 'prison_camp' + - 'proposed' + - 'pub' + - 'public_bath' + - 'public_bookcase' + - 'public_building' + - 'public_hall' + - 'ranger_station' + - 'recycling' + - 'refugee_housing' + - 'register_office' + - 'rescue_box' + - 'rescue_station' + - 'research_institute' + - 'restaurant' + - 'retirement_home' + - 'sanatorium' + - 'sanitary_dump_station' + - 'sauna' + - 'school' + - 'scout_hut' + - 'shelter' + - 'shop' + - 'shower' + - 'ski_school' + - 'smoking_area' + - 'social_centre' + - 'social_facility' + - 'spa' + - 'stables' + - 'stripclub' + - 'studio' + - 'swimming_pool' + - 'swingerclub' + - 'table' + - 'taxi' + - 'telephone' + - 'theatre' + - 'ticket_booth' + - 'ticket_validator' + - 'toilets' + - 'townhall' + - 'trolley_bay' + - 'university' + - 'vacuum_cleaner' + - 'vehicle_inspection' + - 'vending_machine' + - 'veterinary' + - 'vivarium' + - 'wash_center' + - 'waste_basket' + - 'waste_disposal' + - 'waste_transfer_station' + - 'water' + - 'watering_place' + - 'water_point' + - 'weighbridge' + - 'winery' + - 'yacht_club' + - 'youth_centre' diff --git a/src/Bundle/Resources/config/config.yml b/src/Bundle/Resources/config/config.yml new file mode 100644 index 0000000..d912d2e --- /dev/null +++ b/src/Bundle/Resources/config/config.yml @@ -0,0 +1,72 @@ +parameters: + # leaflet controls. + # + # Supported leaflet control types. Register your type for the database driven definition here. + netzmacht.contao_leaflet.controls: + - 'zoom' + - 'layers' + - 'scale' + - 'attribution' + - 'loading' + - 'fullscreen' + + # Leaflet icons. + # + # Supported leaflet icon types. Register you type for the database driven definition here. + netzmacht.contao_leaflet.icons: + - 'image' + - 'div' + - 'extra' + + # The style concept is not part of the LeafletJS library. Styles are extracted from the Path options. Instead + # of defining the style for every vector again, manage them at one place. + # + # The goal is to provide different style strategies. For instance a random style chooser, one which uses a color + # range and so one. + netzmacht.contao_leaflet.styles: + - 'fixed' + + # Leaflet vectors. + # + # Supported leaflet vector types. Register you type for the database driven definition here. + netzmacht.contao_leaflet.vectors: + - 'polyline' + - 'polygon' + - 'multiPolyline' + - 'multiPolygon' + - 'rectangle' + - 'circle' + - 'circleMarker' + + netzmacht.contao_leaflet.file_formats: + gpx: ['gpx'] + kml: ['kml'] + wkt: ['wkt'] + geojson: ['json', 'geojson'] + topojson: ['json', 'topojson'] + + # When creating a GeoJSON feature of a map object a feature.properties.model object is passed. + # Define the properties you always want to set. + # + # For more control you can subscribe the ConvertToGeoJsonEvent. + # + # The entry can be a string or an array. If an array is passed, the 2nd value is the type. Following types + # are supported. + # - array: Use deserialize before adding the value + # - file: Thread value a uuid and find the path. + # - files: Thread values as a list of file uuids and get an array of paths. + netzmacht.contao_leaflet.feature_model_properties: + tl_leaflet_marker: + - 'id' + - 'title' + - 'alias' + + tl_leaflet_vector: + - 'id' + - 'title' + - 'alias' + + # Filters can be passed to a data request to get only specific data from a layer. + netzmacht.contao_leaflet.filters: + bbox: Netzmacht\Contao\Leaflet\Filter\BboxFilter + distance: Netzmacht\Contao\Leaflet\Filter\DistanceFilter diff --git a/src/Bundle/Resources/config/encoders.yml b/src/Bundle/Resources/config/encoders.yml new file mode 100644 index 0000000..62b6890 --- /dev/null +++ b/src/Bundle/Resources/config/encoders.yml @@ -0,0 +1,47 @@ +# Leaflet encoders. +# +# The encoders transforms the definitions into javascript. The encoders has to be an implementation of the +# EventSubscriberInterface of the event dispatcher. +services: + _defaults: + public: false + + netzmacht.contao_leaflet.encoder.map: + class: Netzmacht\LeafletPHP\Encoder\MapEncoder + tags: + - { name: netzmacht.contao_leaflet.encoder } + + netzmacht.contao_leaflet.encoder.control: + class: Netzmacht\LeafletPHP\Encoder\ControlEncoder + tags: + - { name: netzmacht.contao_leaflet.encoder } + + netzmacht.contao_leaflet.encoder.group: + class: Netzmacht\LeafletPHP\Encoder\GroupEncoder + tags: + - { name: netzmacht.contao_leaflet.encoder } + + netzmacht.contao_leaflet.encoder.raster: + class: Netzmacht\LeafletPHP\Encoder\RasterEncoder + tags: + - { name: netzmacht.contao_leaflet.encoder } + + netzmacht.contao_leaflet.encoder.vector: + class: Netzmacht\LeafletPHP\Encoder\VectorEncoder + tags: + - { name: netzmacht.contao_leaflet.encoder } + + netzmacht.contao_leaflet.encoder.ui: + class: Netzmacht\LeafletPHP\Encoder\UIEncoder + tags: + - { name: netzmacht.contao_leaflet.encoder } + + netzmacht.contao_leaflet.encoder.type: + class: Netzmacht\LeafletPHP\Encoder\TypeEncoder + tags: + - { name: netzmacht.contao_leaflet.encoder } + + netzmacht.contao_leaflet.encoder.subscriber: + class: Netzmacht\Contao\Leaflet\Encoder\Subscriber\EncoderSubscriber + tags: + - { name: netzmacht.contao_leaflet.encoder } diff --git a/src/Bundle/Resources/config/layers.yml b/src/Bundle/Resources/config/layers.yml new file mode 100644 index 0000000..c6dcc77 --- /dev/null +++ b/src/Bundle/Resources/config/layers.yml @@ -0,0 +1,99 @@ +# Leaflet layer types. +# +# The type is used for the database driven definitions. +parameters: + netzmacht.contao_leaflet.layers: + provider: + children: false + icon: 'bundles/netzmachtcontaoleaflet/img/provider.png' + + group: + children: true + icon: 'bundles/netzmachtcontaoleaflet/img/group.png' + + markers: + children: false + icon: 'bundles/netzmachtcontaoleaflet/img/markers.png' + markers: true + boundsMode: + extend: true + fit: 'deferred' + + vectors: + children: false + icon: 'bundles/netzmachtcontaoleaflet/img/vectors.png' + vectors: true + boundsMode: + extend: true + + reference: + children: false + icon: 'bundles/netzmachtcontaoleaflet/img/reference.png' + + markercluster: + children: true + icon: 'bundles/netzmachtcontaoleaflet/img/markercluster.png' + + tile: + children: false + icon: 'bundles/netzmachtcontaoleaflet/img/tile.png' + + overpass: + children: false + icon: 'bundles/netzmachtcontaoleaflet/img/overpass.png' + boundsMode: + extend: true + fit: true + + file: + children: false + icon: 'bundles/netzmachtcontaoleaflet/img/file.png' + boundsMode: + extend: true + +services: + _defaults: + public: false + + netzmacht.contao_leaflet.layer_label_renderer: + class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\ChainRenderer + arguments: + - [] + + netzmacht.contao_leaflet.layer_label_renderer.markers: + class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\MarkersLabelRenderer + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: 'netzmacht.contao_leaflet.layer_label_renderer' } + + netzmacht.contao_leaflet.layer_label_renderer.overpass: + class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\OverpassLabelRenderer + tags: + - { name: 'netzmacht.contao_leaflet.layer_label_renderer' } + + netzmacht.contao_leaflet.layer_label_renderer.provider: + class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\ProviderLabelRenderer + tags: + - { name: 'netzmacht.contao_leaflet.layer_label_renderer' } + + netzmacht.contao_leaflet.layer_label_renderer.reference: + class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\ReferenceLabelRenderer + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: 'netzmacht.contao_leaflet.layer_label_renderer' } + + netzmacht.contao_leaflet.layer_label_renderer.vectors: + class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\VectorsLabelRenderer + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: 'netzmacht.contao_leaflet.layer_label_renderer' } + + netzmacht.contao_leaflet.layer_label_renderer.file: + class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\FileLabelRenderer + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: 'netzmacht.contao_leaflet.layer_label_renderer' } diff --git a/src/Bundle/Resources/config/listeners.yml b/src/Bundle/Resources/config/listeners.yml new file mode 100644 index 0000000..16622f6 --- /dev/null +++ b/src/Bundle/Resources/config/listeners.yml @@ -0,0 +1,115 @@ +services: + netzmacht.contao_leaflet.listeners.dca.leaflet: + class: Netzmacht\Contao\Leaflet\Listener\Dca\LeafletDcaListener + public: true + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + - '@templating' + - '@filesystem' + - '@netzmacht.contao_toolkit.contao.system_adapter' + - '%netzmacht.contao_leaflet.cache_dir%' + + netzmacht.contao_leaflet.listeners.dca.validator: + class: Netzmacht\Contao\Leaflet\Listener\Dca\Validator + public: true + arguments: + - '@netzmacht.contao_toolkit.dca.manager' + - '@translator' + + netzmacht.contao_leaflet.listeners.dca.frontend_integration: + class: Netzmacht\Contao\Leaflet\Listener\Dca\FrontendIntegrationListener + public: true + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + - '@translator' + + netzmacht.contao_leaflet.listeners.dca.map: + class: Netzmacht\Contao\Leaflet\Listener\Dca\MapDcaListener + public: true + arguments: + - '@netzmacht.contao_toolkit.dca.manager' + - '@database_connection' + - '@netzmacht.contao_toolkit.repository_manager' + + netzmacht.contao_leaflet.listeners.dca.control: + class: Netzmacht\Contao\Leaflet\Listener\Dca\ControlDcaListener + public: true + arguments: + - '@netzmacht.contao_toolkit.dca.manager' + - '@database_connection' + - '@netzmacht.contao_toolkit.repository_manager' + - '%netzmacht.contao_leaflet.controls%' + + netzmacht.contao_leaflet.listeners.dca.layer: + class: Netzmacht\Contao\Leaflet\Listener\Dca\LayerDcaListener + public: true + arguments: + - '@netzmacht.contao_toolkit.dca.manager' + - '@database_connection' + - '@netzmacht.contao_toolkit.repository_manager' + - '@translator' + - '@netzmacht.contao_leaflet.layer_label_renderer' + - '@netzmacht.contao_toolkit.contao.backend_adapter' + - '%netzmacht.contao_leaflet.layers%' + - '%netzmacht.contao_leaflet.providers%' + - '%netzmacht.contao_leaflet.amenities%' + - '%netzmacht.contao_leaflet.file_formats%' + + netzmacht.contao_leaflet.listeners.dca.marker: + class: Netzmacht\Contao\Leaflet\Listener\Dca\MarkerDcaListener + public: true + arguments: + - '@database_connection' + - '@netzmacht.contao_toolkit.repository_manager' + + netzmacht.contao_leaflet.listeners.dca.vector: + class: Netzmacht\Contao\Leaflet\Listener\Dca\VectorDcaListener + public: true + arguments: + - '@netzmacht.contao_toolkit.dca.manager' + - '@netzmacht.contao_toolkit.repository_manager' + - '%netzmacht.contao_leaflet.vectors%' + + netzmacht.contao_leaflet.listeners.dca.icon: + class: Netzmacht\Contao\Leaflet\Listener\Dca\IconDcaListener + public: true + arguments: + - '%netzmacht.contao_leaflet.icons%' + + netzmacht.contao_leaflet.listeners.dca.style: + class: Netzmacht\Contao\Leaflet\Listener\Dca\StyleDcaListener + public: true + arguments: + - '%netzmacht.contao_leaflet.styles%' + + netzmacht.contao_leaflet.listeners.geo_json_listener: + class: Netzmacht\Contao\Leaflet\Listener\GeoJsonListener + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + - '%netzmacht.contao_leaflet.feature_model_properties%' + tags: + - { name: 'kernel.event_listener', event: 'netzmacht.contao_leaflet.mapper.convert_to_geojson', method: 'handle' } + + netzmacht.contao_leaflet.listeners.hash_subscriber: + class: Netzmacht\Contao\Leaflet\Listener\HashSubscriber + tags: + - { name: 'kernel.event_subscriber' } + + netzmacht.contao_leaflet.listeners.load_assets: + class: Netzmacht\Contao\Leaflet\Listener\LoadAssetsListener + arguments: + - '@netzmacht.contao_leaflet.map.assets' + - '@netzmacht.contao_leaflet.definition.mapper' + - '@netzmacht.contao_toolkit.repository_manager' + - '@netzmacht.contao_leaflet.libraries' + tags: + - { name: 'kernel.event_listener', event: 'netzmacht.contao_leaflet.get_javascript', method: 'onGetJavascriptEvent' } + + netzmacht.contao_leaflet.listeners.register_libraries: + class: Netzmacht\Contao\Leaflet\Listener\RegisterLibrariesListener + public: true + arguments: + - '@netzmacht.contao_leaflet.libraries' + - '@netzmacht.contao_leaflet.definition.builder' + tags: + - { name: 'contao.hook', hook: 'initializeSystem', method: 'onInitializeSystem' } diff --git a/src/Bundle/Resources/config/mappers.yml b/src/Bundle/Resources/config/mappers.yml new file mode 100644 index 0000000..39644e6 --- /dev/null +++ b/src/Bundle/Resources/config/mappers.yml @@ -0,0 +1,208 @@ +# Leaflet mappers. +# +# Mappers translate between the database models and the leaflet definition. +services: + _defaults: + public: false + + + # Map mapper + netzmacht.contao_leaflet.mapper.map: + class: Netzmacht\Contao\Leaflet\Mapper\MapMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + + # Layer mappers + netzmacht.contao_leaflet.mapper.tile_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\TileLayerMapper + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.provider_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\ProviderLayerMapper + arguments: + - '%netzmacht.contao_leaflet.providers%' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.markers_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLayerMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.group_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\GroupLayerMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.vectors_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.reference_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\ReferenceLayerMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.overpass_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\OverpassLayerMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.marker_cluster_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\MarkerClusterLayerMapper + arguments: + - '@netzmacht.contao_leaflet.map.assets' + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: netzmacht.contao_leflet_maps.mapper } + + netzmacht.contao_leaflet.mapper.file_layer: + class: Netzmacht\Contao\Leaflet\Mapper\Layer\FileLayerMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + # Control mappers + netzmacht.contao_leaflet.mapper.zoom_control: + class: Netzmacht\Contao\Leaflet\Mapper\Control\ZoomControlMapper + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.scale_control: + class: Netzmacht\Contao\Leaflet\Mapper\Control\ScaleControlMapper + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.layers_control: + class: Netzmacht\Contao\Leaflet\Mapper\Control\LayersControlMapper + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.attribution_control: + class: Netzmacht\Contao\Leaflet\Mapper\Control\AttributionControlMapper + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.loading_control: + class: Netzmacht\Contao\Leaflet\Mapper\Control\LoadingControlMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.fullscreen_control: + class: Netzmacht\Contao\Leaflet\Mapper\Control\FullscreenControlMapper + tags: + - { name: netzmacht.contao_leaflet.mapper } + + + # Vector mappers + netzmacht.contao_leaflet.mapper.polyline: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + - '@netzmacht.contao_leaflet.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.multi_polyline: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolylineMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + - '@netzmacht.contao_leaflet.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.polygon: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + - '@netzmacht.contao_leaflet.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.multi_polygon: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolygonMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + - '@netzmacht.contao_leaflet.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.circle: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + - '@netzmacht.contao_leaflet.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.circle_mapper: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMarkerMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + - '@netzmacht.contao_leaflet.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.rectangle_mapper: + class: Netzmacht\Contao\Leaflet\Mapper\Vector\RectangleMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + - '@netzmacht.contao_leaflet.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + + # Miscellaneous mappers + netzmacht.contao_leaflet.mapper.popup: + class: Netzmacht\Contao\Leaflet\Mapper\UI\PopupMapper + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.image_icon: + class: Netzmacht\Contao\Leaflet\Mapper\Type\ImageIconMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.div_icon: + class: Netzmacht\Contao\Leaflet\Mapper\Type\DivIconMapper + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.extra_markers: + class: Netzmacht\Contao\Leaflet\Mapper\Type\ExtraMarkersIconMapper + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.fixed_style: + class: Netzmacht\Contao\Leaflet\Mapper\Style\FixedStyleMapper + tags: + - { name: netzmacht.contao_leaflet.mapper } + + netzmacht.contao_leaflet.mapper.marker: + class: Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper + arguments: + - '@netzmacht.contao_toolkit.repository_manager' + - '@netzmacht.contao_leaflet.frontend.value_filter' + tags: + - { name: netzmacht.contao_leaflet.mapper } + diff --git a/src/Bundle/Resources/config/providers.yml b/src/Bundle/Resources/config/providers.yml new file mode 100644 index 0000000..880ddde --- /dev/null +++ b/src/Bundle/Resources/config/providers.yml @@ -0,0 +1,157 @@ +parameters: + netzmacht.contao_leaflet.providers: + OpenStreetMap: + variants: ['Mapnik', 'BlackAndWhite', 'DE', 'France', 'HOT', 'BZH'] + + OpenSeaMap: [] + + OpenTopoMap: [] + + Thunderforest: + variants: + - 'OpenCycleMap' + - 'Transport' + - 'TransportDark' + - 'SpinalMap' + - 'Landscape' + - 'Outdoors' + - 'Pioneer' + + OpenMapSurfer: + variants: ['Roads', 'AdminBounds', 'Grayscale'] + + Hydda: + variants: ['Full', 'Base', 'RoadsAndLabels'] + + MapBox: + class: 'Netzmacht\LeafletPHP\Plugins\LeafletProviders\MapBoxProvider' + options: + key: 'tile_provider_key' + + Stamen: + variants: + - 'Toner' + - 'TonerBackground' + - 'TonerHybrid' + - 'TonerLines' + - 'TonerLabels' + - 'TonerLite' + - 'Terrain' + - 'TerrainBackground' + - 'TopOSMRelief' + - 'TopOSMFeatures' + - 'Watercolor' + + Esri: + variants: + - 'WorldStreetMap' + - 'DeLorme' + - 'WorldTopoMap' + - 'WorldImagery' + - 'WorldTerrain' + - 'WorldShadedRelief' + - 'WorldPhysical' + - 'OceanBasemap' + - 'NatGeoWorldMap' + - 'WorldGrayCanvas' + + OpenWeatherMap: + variants: + - 'Clouds' + - 'CloudsClassic' + - 'Precipitation' + - 'PrecipitationClassic' + - 'Rain' + - 'RainClassic' + - 'Pressure' + - 'PressureContour' + - 'Wind' + - 'Temperature' + - 'Snow' + + HERE: + class: 'Netzmacht\LeafletPHP\Plugins\LeafletProviders\HereProvider' + variants: + - 'normalDay' + - 'normalDayCustom' + - 'normalDayGrey' + - 'normalDayMobile' + - 'normalDayGreyMobile' + - 'normalDayTransit' + - 'normalDayTransitMobile' + - 'normalNight' + - 'normalNightMobile' + - 'normalNightGrey' + - 'normalNightGreyMobile' + - 'basicMap' + - 'mapLabels' + - 'trafficFlow' + - 'carnavDayGrey' + - 'hybridDay' + - 'hybridDayMobile' + - 'pedestrianDay' + - 'pedestrianNight' + - 'satelliteDay' + - 'terrainDay' + - 'terrainDayMobile' + options: + appId: 'tile_provider_key' + appCode: 'tile_provider_code' + fields: ['tile_provider_key', 'tile_provider_code'] + + JusticeMap: + variants: + - 'income' + - 'americanIndian' + - 'asian' + - 'black' + - 'hispanic' + - 'multi' + - 'nonWhite' + - 'white' + - 'plurality' + + FreeMapSK: [] + + MtbMap: [] + + CartoDB: + variants: + - 'Positron' + - 'PositronNoLabels' + - 'PositronOnlyLabels' + - 'DarkMatter' + - 'DarkMatterNoLabels' + - 'DarkMatterOnlyLabels' + + HikeBike: + variants: + - 'HikeBike' + - 'HillShading' + + BasemapAT: + variants: + - 'basemap' + - 'grau' + - 'overlay' + - 'highdpi' + - 'orthofoto' + + nlmaps: + variants: + - 'standaard' + - 'pastel' + - 'grijs' + - 'luchtfoto' + + NASAGIBS: + variants: + - 'ModisTerraTrueColorCR' + - 'ModisTerraBands367CR' + - 'ViirsEarthAtNight2012' + - 'ModisTerraLSTDay' + - 'ModisTerraSnowCover' + - 'ModisTerraAOD' + - 'ModisTerraChlorophyll' + + NLS: [] diff --git a/src/Bundle/Resources/config/services.yml b/src/Bundle/Resources/config/services.yml new file mode 100644 index 0000000..c77c5b8 --- /dev/null +++ b/src/Bundle/Resources/config/services.yml @@ -0,0 +1,122 @@ +parameters: + netzmacht.contao_leaflet.cache_dir: '%kernel.cache_dir%/leaflet' + + # JSON_UNESCAPED_SLASHES ^ Netzmacht\JavascriptBuilder\Flags::BUILD_STACK + netzmacht.contao_leaflet.encoding_flags: 16448 + +services: + netzmacht.contao_leaflet.map.provider: + class: Netzmacht\Contao\Leaflet\MapProvider + arguments: + - '@netzmacht.contao_leaflet.definition.mapper' + - '@netzmacht.contao_leaflet.definition.builder' + - '@event_dispatcher' + - '@netzmacht.contao_toolkit.contao.input_adapter' + - '@netzmacht.contao_leaflet.map.assets' + - '@netzmacht.contao_leaflet.cache' + - '@netzmacht.contao_leaflet.frontend.data_controller' + - '@netzmacht.contao_toolkit.repository_manager' + - '@templating' + + netzmacht.contao_leaflet.libraries: + class: Netzmacht\Contao\Leaflet\Frontend\Assets\LibrariesConfiguration + arguments: + - '@contao.framework' + + netzmacht.contao_leaflet.filter_factory: + class: Netzmacht\Contao\Leaflet\Filter\FilterFactory + arguments: + - '%netzmacht.contao_leaflet.filters%' + + netzmacht.contao_leaflet.cache.default: + class: Doctrine\Common\Cache\FilesystemCache + arguments: + - '%netzmacht.contao_leaflet.cache_dir%' + + netzmacht.contao_leaflet.cache.debug: + class: Doctrine\Common\Cache\ArrayCache + + netzmacht.contao_leaflet.frontend.value_filter: + class: Netzmacht\Contao\Leaflet\Frontend\ValueFilter + arguments: + - '@contao.framework' + + netzmacht.contao_leaflet.map.assets: + class: Netzmacht\Contao\Leaflet\Encoder\ContaoAssets + arguments: + - '@netzmacht.contao_toolkit.assets_manager' + + netzmacht.contao_leaflet.definition.builder: + class: Netzmacht\LeafletPHP\Leaflet + arguments: + - '@netzmacht.contao_leaflet.definition.builder.javascript_builder' + - '@netzmacht.contao_leaflet.definition.builder.event_dispatcher' + - [] + - '%netzmacht.contao_leaflet.encoding_flags%' + + netzmacht.contao_leaflet.definition.builder.javascript_builder: + class: Netzmacht\JavascriptBuilder\Builder + arguments: + - '@netzmacht.contao_leaflet.definition.encoder_factory' + + netzmacht.contao_leaflet.definition.builder.event_dispatcher: + class: Symfony\Component\EventDispatcher\EventDispatcher + + netzmacht.contao_leaflet.definition.mapper: + class: Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper + arguments: + - '@event_dispatcher' + + netzmacht.contao_leaflet.definition.encoder_factory: + class: Netzmacht\Contao\Leaflet\Encoder\EncoderFactory + arguments: + - '@netzmacht.contao_leaflet.definition.builder.event_dispatcher' + + netzmacht.contao_leaflet.definition.alias_generator.factory_default: + class: Netzmacht\Contao\Leaflet\Alias\DefaultAliasGeneratorFactory + arguments: + - '@database_connection' + + netzmacht.contao_leaflet.definition.alias_generator.factory_parent: + class: Netzmacht\Contao\Leaflet\Alias\ParentAliasGeneratorFactory + arguments: + - '@database_connection' + + netzmacht.contao_leaflet.frontend.element_factory: + class: Netzmacht\Contao\Leaflet\Frontend\ContentElement\MapElementFactory + arguments: + - '@templating' + - '@translator' + - '@netzmacht.contao_leaflet.map.provider' + - '@netzmacht.contao_toolkit.repository_manager' + - '@netzmacht.contao_toolkit.contao.input_adapter' + tags: + - { name: 'netzmacht.contao_toolkit.component.content_element_factory' } + - { name: 'netzmacht.contao_toolkit.component.content_element', alias: 'leaflet', category: 'includes' } + + netzmacht.contao_leaflet.frontend.module_factory: + class: Netzmacht\Contao\Leaflet\Frontend\Module\MapModuleFactory + arguments: + - '@templating' + - '@translator' + - '@netzmacht.contao_leaflet.map.provider' + - '@netzmacht.contao_toolkit.repository_manager' + - '@netzmacht.contao_toolkit.contao.input_adapter' + tags: + - { name: 'netzmacht.contao_toolkit.component.frontend_module_factory' } + - { name: 'netzmacht.contao_toolkit.component.frontend_module', alias: 'leaflet', category: 'includes' } + + netzmacht.contao_leaflet.frontend.insert_tag: + class: Netzmacht\Contao\Leaflet\Frontend\InsertTag\LeafletInsertTagParser + public: true + arguments: + - '@netzmacht.contao_leaflet.map.provider' + - '%kernel.debug%' + tags: + - { name: 'contao.hook', hook: 'replaceInsertTags', method: 'replace' } + + netzmacht.contao_leaflet.frontend.data_controller: + class: Netzmacht\Contao\Leaflet\Frontend\DataController + arguments: + - '@netzmacht.contao_leaflet.filter_factory' + - '%kernel.debug%' diff --git a/src/Bundle/Resources/contao/config/config.php b/src/Bundle/Resources/contao/config/config.php new file mode 100644 index 0000000..29595b8 --- /dev/null +++ b/src/Bundle/Resources/contao/config/config.php @@ -0,0 +1,67 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +/* + * Backend module. + */ + +array_insert( + $GLOBALS['BE_MOD'], + 1, + [ + 'leaflet' => [ + 'leaflet_map' => [ + 'tables' => [ + 'tl_leaflet_map', + 'tl_leaflet_control', + ], + 'icon' => 'bundles/netzmachtcontaoleaflet/img/map.png', + 'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/backend.css', + ], + 'leaflet_layer' => [ + 'tables' => [ + 'tl_leaflet_layer', + 'tl_leaflet_marker', + 'tl_leaflet_vector', + 'tl_leaflet_icon', + 'tl_leaflet_style', + 'tl_leaflet_popup', + ], + 'icon' => 'bundles/netzmachtcontaoleaflet/img/layers.png', + 'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/backend.css', + 'javascript' => 'bundles/netzmachtcontaoleaflet/js/backend.js', + ], + 'leaflet_about' => [ + 'callback' => Netzmacht\Contao\Leaflet\Backend\About::class, + 'icon' => 'bundles/netzmachtcontaoleaflet/img/about.png', + 'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/about.css', + ], + ], + ] +); + +if (TL_MODE === 'BE') { + $GLOBALS['TL_CSS'][] = 'bundles/netzmachtcontaoleaflet/css/backend_global.css'; +} + +/* + * Models. + */ + +$GLOBALS['TL_MODELS']['tl_leaflet_control'] = \Netzmacht\Contao\Leaflet\Model\ControlModel::class; +$GLOBALS['TL_MODELS']['tl_leaflet_icon'] = \Netzmacht\Contao\Leaflet\Model\IconModel::class; +$GLOBALS['TL_MODELS']['tl_leaflet_layer'] = \Netzmacht\Contao\Leaflet\Model\LayerModel::class; +$GLOBALS['TL_MODELS']['tl_leaflet_map'] = \Netzmacht\Contao\Leaflet\Model\MapModel::class; +$GLOBALS['TL_MODELS']['tl_leaflet_marker'] = \Netzmacht\Contao\Leaflet\Model\MarkerModel::class; +$GLOBALS['TL_MODELS']['tl_leaflet_popup'] = \Netzmacht\Contao\Leaflet\Model\PopupModel::class; +$GLOBALS['TL_MODELS']['tl_leaflet_style'] = \Netzmacht\Contao\Leaflet\Model\StyleModel::class; +$GLOBALS['TL_MODELS']['tl_leaflet_vector'] = \Netzmacht\Contao\Leaflet\Model\VectorModel::class; diff --git a/src/Bundle/Resources/contao/dca/tl_content.php b/src/Bundle/Resources/contao/dca/tl_content.php new file mode 100644 index 0000000..8c922c5 --- /dev/null +++ b/src/Bundle/Resources/contao/dca/tl_content.php @@ -0,0 +1,85 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_DCA']['tl_content']['metapalettes']['leaflet'] = [ + 'type' => ['type', 'headline'], + 'leaflet' => ['leaflet_map', 'leaflet_mapId', 'leaflet_width', 'leaflet_height'], + 'templates' => [':hide', 'customTpl', 'leaflet_template'], + 'protected' => [':hide', 'protected'], + 'expert' => [':hide', 'guests', 'cssID', 'space'], + 'invisible' => [':hide', 'invisible', 'start', 'start'], +]; + +$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_map'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_map'], + 'inputType' => 'select', + 'exclude' => true, + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.frontend_integration', 'getMaps'], + 'wizard' => [ + ['netzmacht.contao_leaflet.listeners.dca.frontend_integration', 'getEditMapLink'], + ], + 'eval' => [ + 'tl_class' => 'w50 wizard', + 'chosen' => true, + ], + 'sql' => "int(10) unsigned NOT NULL default '0'", +]; + +$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_mapId'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_mapId'], + 'inputType' => 'text', + 'exclude' => true, + 'eval' => [ + 'tl_class' => 'w50', + 'chosen' => true, + 'maxlength' => 16, + ], + 'sql' => "varchar(16) NOT NULL default ''", +]; + +$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_width'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_width'], + 'inputType' => 'inputUnit', + 'options' => ['px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'], + 'search' => false, + 'exclude' => true, + 'eval' => ['rgxp' => 'digit', 'tl_class' => 'clr w50'], + 'sql' => "varchar(64) NOT NULL default ''", +]; + + +$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_height'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_height'], + 'inputType' => 'inputUnit', + 'options' => ['px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'], + 'search' => false, + 'exclude' => true, + 'eval' => ['rgxp' => 'digit', 'tl_class' => 'w50'], + 'sql' => "varchar(64) NOT NULL default ''", +]; + +$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_template'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_template'], + 'inputType' => 'select', + 'exclude' => true, + 'options_callback' => ['netzmacht.contao_toolkit.dca.listeners.template_options', 'handleOptionsCallback'], + 'eval' => [ + 'tl_class' => 'w50', + 'chosen' => true, + ], + 'toolkit' => [ + 'template_options' => [ + 'prefix' => 'leaflet_map_js', + ], + ], + 'sql' => "varchar(64) NOT NULL default ''", +]; diff --git a/src/Bundle/Resources/contao/dca/tl_leaflet_control.php b/src/Bundle/Resources/contao/dca/tl_leaflet_control.php new file mode 100644 index 0000000..b5403f1 --- /dev/null +++ b/src/Bundle/Resources/contao/dca/tl_leaflet_control.php @@ -0,0 +1,409 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_DCA']['tl_leaflet_control'] = [ + 'config' => [ + 'dataContainer' => 'Table', + 'enableVersioning' => true, + 'ptable' => 'tl_leaflet_map', + 'sql' => [ + 'keys' => [ + 'id' => 'primary', + 'pid' => 'index', + ], + ], + 'onload_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'loadLanguageFile'], + ], + 'onsubmit_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + + // List configuration + 'list' => [ + 'sorting' => [ + 'mode' => 4, + 'fields' => ['sorting'], + 'headerFields' => ['title'], + 'flag' => 1, + 'sorting' => 2, + 'panelLayout' => 'filter,sort;search,limit', + 'child_record_callback' => ['netzmacht.contao_leaflet.listeners.dca.control', 'generateRow'], + ], + 'label' => [ + 'fields' => ['title'], + 'format' => '%s', + ], + 'global_operations' => [ + 'all' => [ + 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], + 'href' => 'act=select', + 'class' => 'header_edit_all', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"', + ], + ], + 'operations' => [ + 'edit' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['edit'], + 'href' => 'act=edit', + 'icon' => 'header.gif', + ], + 'copy' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['copy'], + 'href' => 'act=copy', + 'icon' => 'copy.gif', + ], + 'delete' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['delete'], + 'href' => 'act=delete', + 'icon' => 'delete.gif', + 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] + . '\'))return false;Backend.getScrollOffset()"', + ], + 'toggle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['toggle'], + 'icon' => 'visible.gif', + 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', + 'button_callback' => [ + 'netzmacht.contao_toolkit.dca.listeners.state_button_callback', + 'handleButtonCallback', + ], + 'toolkit' => [ + 'state_button' => [ + 'stateColumn' => 'active', + ], + ], + ], + 'show' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['show'], + 'href' => 'act=show', + 'icon' => 'show.gif', + ], + ], + ], + + 'palettes' => [ + '__selector__' => ['type'], + ], + + 'metapalettes' => [ + 'default' => [ + 'name' => ['title', 'alias', 'type', 'position'], + 'config' => [], + 'active' => ['active'], + ], + 'zoom extends default' => [ + 'config' => ['zoomInText', 'zoomOutText', 'zoomInTitle', 'zoomOutTitle'], + ], + 'layers extends default' => [ + 'config' => ['layers', 'collapsed', 'autoZIndex'], + ], + 'scale extends default' => [ + 'config' => ['maxWidth', 'metric', 'imperial', 'updateWhenIdle'], + ], + 'attribution extends default' => [ + 'config' => ['attributions', 'prefix', 'disableDefault'], + ], + 'loading extends default' => [ + 'config' => ['separate', 'zoomControl', 'spinjs'], + ], + 'fullscreen extends default' => [ + 'config' => ['buttonTitle', 'separate', 'simulateFullScreen'], + ], + ], + + 'metasubpalettes' => [ + 'spinjs' => ['spin'], + ], + + 'fields' => [ + 'id' => [ + 'sql' => 'int(10) unsigned NOT NULL auto_increment', + ], + 'pid' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'tstamp' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'sorting' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + 'sorting' => true, + ], + 'title' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['title'], + 'exclude' => true, + 'inputType' => 'text', + 'sorting' => true, + 'search' => true, + 'flag' => 1, + 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'alias' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['alias'], + 'exclude' => true, + 'inputType' => 'text', + 'search' => true, + 'save_callback' => [ + ['netzmacht.contao_toolkit.dca.listeners.alias_generator', 'handleSaveCallback'], + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateAlias'], + ], + 'eval' => [ + 'mandatory' => false, + 'maxlength' => 255, + 'tl_class' => 'w50', + 'nullIfEmpty' => true, + ], + 'toolkit' => [ + 'alias_generator' => [ + 'factory' => 'netzmacht.contao_leaflet.definition.alias_generator.factory_parent', + 'fields' => ['title'], + ], + ], + 'sql' => 'varchar(255) NULL', + ], + 'type' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['type'], + 'exclude' => true, + 'inputType' => 'select', + 'filter' => true, + 'sorting' => true, + 'eval' => [ + 'mandatory' => true, + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'submitOnChange' => true, + 'chosen' => true, + 'helpwizard' => true, + ], + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.control', 'getControlTypes'], + 'reference' => &$GLOBALS['TL_LANG']['leaflet_control'], + 'sql' => "varchar(32) NOT NULL default ''", + ], + 'position' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['position'], + 'exclude' => true, + 'inputType' => 'select', + 'filter' => true, + 'sorting' => true, + 'options' => ['topleft', 'topright', 'bottomleft', 'bottomright'], + 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_control'], + 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50', 'helpwizard' => true], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'active' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['active'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'filter' => true, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + 'zoomInText' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInText'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'zoomOutText' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInText'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'zoomInTitle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInTitle'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'zoomOutTitle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomOutTitle'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'collapsed' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['collapsed'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => '1', + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'autoZIndex' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['autoZIndex'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => '1', + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'layers' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['layers'], + 'exclude' => true, + 'inputType' => 'multiColumnWizard', + 'load_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.control', 'loadLayerRelations'], + ], + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.control', 'saveLayerRelations'], + ], + 'eval' => [ + 'tl_class' => 'leaflet-mcw leaflet-mcw-control-layers', + 'columnFields' => [ + 'layer' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['layer'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.control', 'getLayers'], + 'eval' => [ + 'style' => 'width: 300px', + 'chosen' => true, + 'includeBlankOption' => true, + ], + ], + 'mode' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['layerMode'], + 'exclude' => true, + 'inputType' => 'select', + 'options' => ['base', 'overlay'], + 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_control'], + 'eval' => [ + 'style' => 'width: 200px', + 'helpwizard' => true, + ], + ], + ], + ], + 'sql' => 'mediumblob NULL', + ], + 'maxWidth' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['maxWidth'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => 100, + 'eval' => ['tl_class' => 'w50', 'rgxp' => 'digit'], + 'sql' => "int(5) NOT NULL default '100'", + ], + 'metric' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['metric'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => '1', + 'eval' => ['tl_class' => 'w50 clr'], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'imperial' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['imperial'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => '1', + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'updateWhenIdle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['updateWhenIdle'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'prefix' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['prefix'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'attributions' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['attributions'], + 'exclude' => true, + 'inputType' => 'listWizard', + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'clr', 'allowHtml' => true], + 'sql' => 'mediumblob NULL', + ], + 'separate' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['separate'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => ['tl_class' => 'w50 m12'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'zoomControl' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomControl'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.control', 'getZoomControls'], + 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_control'], + 'eval' => [ + 'mandatory' => false, + 'tl_class' => 'w50', + 'chosen' => true, + 'includeBlankOption' => true, + ], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'spinjs' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['spinjs'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'spin' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['spin'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => [ + 'style' => 'height:60px', + 'preserveTags' => true, + 'decodeEntities' => true, + 'allowHtml' => true, + 'rte' => 'ace|json', + 'tl_class' => 'clr', + ], + 'sql' => 'mediumtext NULL', + ], + 'simulateFullScreen' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['simulateFullScreen'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => ['tl_class' => 'w50 m12'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'buttonTitle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['buttonTitle'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'disableDefault' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['disableDefault'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50 m12'], + 'sql' => "char(1) NOT NULL default ''", + ], + ], +]; diff --git a/src/Bundle/Resources/contao/dca/tl_leaflet_control_layer.php b/src/Bundle/Resources/contao/dca/tl_leaflet_control_layer.php new file mode 100644 index 0000000..4322636 --- /dev/null +++ b/src/Bundle/Resources/contao/dca/tl_leaflet_control_layer.php @@ -0,0 +1,44 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_DCA']['tl_leaflet_control_layer'] = [ + 'config' => [ + 'dataContainer' => 'Table', + 'sql' => [ + 'keys' => [ + 'id' => 'primary', + 'cid,lid' => 'unique', + ], + ], + ], + + 'fields' => [ + 'id' => [ + 'sql' => 'int(10) unsigned NOT NULL auto_increment', + ], + 'tstamp' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'sorting' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'cid' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'lid' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'mode' => [ + 'sql' => "varchar(16) NOT NULL default ''", + ], + ], +]; diff --git a/src/Bundle/Resources/contao/dca/tl_leaflet_icon.php b/src/Bundle/Resources/contao/dca/tl_leaflet_icon.php new file mode 100644 index 0000000..3e99465 --- /dev/null +++ b/src/Bundle/Resources/contao/dca/tl_leaflet_icon.php @@ -0,0 +1,418 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_DCA']['tl_leaflet_icon'] = [ + 'config' => [ + 'dataContainer' => 'Table', + 'enableVersioning' => true, + 'sql' => [ + 'keys' => [ + 'id' => 'primary', + 'alias' => 'unique', + ], + ], + 'onsubmit_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + + 'list' => [ + 'sorting' => [ + 'mode' => 1, + 'fields' => ['title'], + 'flag' => 1, + 'panelLayout' => 'limit', + 'headerFields' => ['title', 'type'], + ], + 'label' => [ + 'fields' => ['title', 'type'], + 'format' => '%s [%s]', + ], + 'global_operations' => [ + 'layers' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['layersBtn'], + 'href' => 'table=tl_leaflet_layer', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/layers.png', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"', + ], + 'styles' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['styles'], + 'href' => 'table=tl_leaflet_style', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/style.png', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + 'popups' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['popups'], + 'href' => 'table=tl_leaflet_popup', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + 'all' => [ + 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], + 'href' => 'act=select', + 'class' => 'header_edit_all', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"', + ], + ], + 'operations' => [ + 'edit' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['edit'], + 'href' => 'act=edit', + 'icon' => 'edit.gif', + ], + 'copy' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['copy'], + 'href' => 'act=copy', + 'icon' => 'copy.gif', + ], + 'delete' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['delete'], + 'href' => 'act=delete', + 'icon' => 'delete.gif', + 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] + . '\'))return false;Backend.getScrollOffset()"', + ], + 'toggle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['toggle'], + 'icon' => 'visible.gif', + 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', + 'button_callback' => [ + 'netzmacht.contao_toolkit.dca.listeners.state_button_callback', + 'handleButtonCallback', + ], + 'toolkit' => [ + 'state_button' => [ + 'stateColumn' => 'active', + ], + ], + ], + 'show' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['show'], + 'href' => 'act=show', + 'icon' => 'show.gif', + ], + ], + ], + + 'palettes' => [ + '__selector__' => ['type'], + ], + + 'metapalettes' => [ + 'default' => [ + 'title' => ['title', 'alias', 'type'], + ], + 'image extends default' => [ + 'config' => [ + 'iconImage', + 'iconRetinaImage', + 'iconAnchor', + 'popupAnchor', + 'className', + ], + 'shadow' => [ + 'shadowImage', + 'shadowRetinaImage', + 'shadowAnchor', + ], + 'active' => [ + 'active', + ], + ], + + 'div extends default' => [ + 'config' => [ + 'html', + 'iconSize', + 'iconAnchor', + 'popupAnchor', + 'className', + ], + 'active' => [ + 'active', + ], + ], + + 'extra extends default' => [ + 'config' => [ + 'icon', + 'prefix', + 'shape', + 'markerColor', + 'number', + 'iconColor', + ], + 'active' => [ + 'active', + ], + ], + ], + + 'fields' => [ + 'id' => [ + 'sql' => 'int(10) unsigned NOT NULL auto_increment', + ], + 'tstamp' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'title' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['title'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'alias' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['alias'], + 'exclude' => true, + 'inputType' => 'text', + 'save_callback' => [ + ['netzmacht.contao_toolkit.dca.listeners.alias_generator', 'handleSaveCallback'], + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateAlias'], + ], + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true], + 'toolkit' => [ + 'alias_generator' => [ + 'factory' => 'netzmacht.contao_leaflet.definition.alias_generator.factory_default', + 'fields' => ['title'], + ], + ], + 'sql' => 'varchar(255) NULL', + ], + 'type' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['type'], + 'exclude' => true, + 'inputType' => 'select', + 'eval' => [ + 'mandatory' => true, + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'submitOnChange' => true, + 'chosen' => true, + ], + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.icon', 'getIconOptions'], + 'reference' => &$GLOBALS['TL_LANG']['leaflet_icon'], + 'sql' => "varchar(32) NOT NULL default ''", + ], + 'active' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['active'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + 'iconImage' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['iconImage'], + 'exclude' => true, + 'inputType' => 'fileTree', + 'eval' => [ + 'filesOnly' => true, + 'fieldType' => 'radio', + 'mandatory' => true, + 'tl_class' => 'clr', + 'extensions' => 'gif,png,svg,jpg', + ], + 'sql' => 'binary(16) NULL', + ], + 'iconRetinaImage' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['iconRetinaImage'], + 'exclude' => true, + 'inputType' => 'fileTree', + 'eval' => [ + 'filesOnly' => true, + 'fieldType' => 'radio', + 'mandatory' => false, + 'tl_class' => 'clr', + 'extensions' => 'gif,png,svg,jpg', + ], + 'sql' => 'binary(16) NULL', + ], + 'shadowImage' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['shadowImage'], + 'exclude' => true, + 'inputType' => 'fileTree', + 'eval' => [ + 'filesOnly' => true, + 'fieldType' => 'radio', + 'mandatory' => false, + 'tl_class' => 'clr', + 'extensions' => 'gif,png,svg,jpg', + ], + 'sql' => 'binary(16) NULL', + ], + 'shadowRetinaImage' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['shadowRetinaImage'], + 'exclude' => true, + 'inputType' => 'fileTree', + 'eval' => [ + 'filesOnly' => true, + 'fieldType' => 'radio', + 'mandatory' => false, + 'tl_class' => 'clr', + 'extensions' => 'gif,png,svg,jpg', + ], + 'sql' => 'binary(16) NULL', + ], + 'iconAnchor' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['iconAnchor'], + 'exclude' => true, + 'inputType' => 'text', + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateCoordinates'], + ], + 'eval' => [ + 'maxlength' => 255, + 'tl_class' => 'w50', + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(255) NULL', + ], + 'shadowAnchor' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['shadowAnchor'], + 'exclude' => true, + 'inputType' => 'text', + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateCoordinates'], + ], + 'eval' => [ + 'maxlength' => 255, + 'tl_class' => 'w50', + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(255) NULL', + ], + 'popupAnchor' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['popupAnchor'], + 'exclude' => true, + 'inputType' => 'text', + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateCoordinates'], + ], + 'eval' => [ + 'maxlength' => 255, + 'tl_class' => 'w50', + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(255) NULL', + ], + 'className' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['className'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 64, 'tl_class' => 'w50'], + 'sql' => "varchar(64) NOT NULL default ''", + ], + 'iconSize' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['iconSize'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => [ + 'maxlength' => 64, + 'tl_class' => 'w50', + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(64) NULL', + ], + 'html' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['html'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => [ + 'style' => 'height:60px', + 'preserveTags' => true, + 'decodeEntities' => true, + 'allowHtml' => true, + 'rte' => 'ace|html', + 'tl_class' => 'clr', + ], + 'sql' => 'mediumtext NULL', + ], + 'icon' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['icon'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => [ + 'maxlength' => 64, + 'tl_class' => 'w50', + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(64) NULL', + ], + 'prefix' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['prefix'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => [ + 'maxlength' => 64, + 'tl_class' => 'w50', + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(64) NULL', + ], + 'shape' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['shape'], + 'exclude' => true, + 'inputType' => 'select', + 'default' => 'circle', + 'options' => ['circle', 'square', 'star', 'penta'], + 'eval' => [ + 'tl_class' => 'w50', + ], + 'sql' => 'varchar(64) NULL', + ], + 'iconColor' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['iconColor'], + 'exclude' => true, + 'inputType' => 'text', + 'wizard' => [ + ['netzmacht.contao_toolkit.dca.listeners.color_picker', 'handleWizardCallback'], + ], + 'eval' => [ + 'maxlength' => 64, + 'tl_class' => 'w50 wizard', + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(16) NULL', + ], + 'markerColor' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['markerColor'], + 'exclude' => true, + 'inputType' => 'select', + 'default' => 'circle', + 'options' => [ + 'blue', + 'red', + 'orange-dark', + 'orange', + 'yellow', + 'blue-dark', + 'cyan', + 'purple', + 'violet', + 'pink', + 'green-dark', + 'green', + 'green-light', + 'black', + 'white', + ], + 'eval' => [ + 'tl_class' => 'w50', + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(16) NULL', + ], + ], +]; diff --git a/src/Bundle/Resources/contao/dca/tl_leaflet_layer.php b/src/Bundle/Resources/contao/dca/tl_leaflet_layer.php new file mode 100644 index 0000000..789aa2d --- /dev/null +++ b/src/Bundle/Resources/contao/dca/tl_leaflet_layer.php @@ -0,0 +1,900 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_DCA']['tl_leaflet_layer'] = [ + 'config' => [ + 'dataContainer' => 'Table', + 'enableVersioning' => true, + 'ctable' => ['tl_leaflet_vector', 'tl_leaflet_marker'], + 'ondelete_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.layer', 'deleteRelations'], + ], + 'sql' => [ + 'keys' => [ + 'id' => 'primary', + 'pid' => 'index', + 'alias' => 'unique', + ], + ], + 'onload_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'loadLanguageFile'], + ], + 'onsubmit_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + 'list' => [ + 'sorting' => [ + 'mode' => 5, + 'fields' => ['title'], + 'flag' => 1, + 'icon' => 'bundles/netzmachtcontaoleaflet/img/layers.png', + 'panelLayout' => 'filter;search,limit', + 'paste_button_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'getPasteButtons'], + ], + 'label' => [ + 'fields' => ['title'], + 'format' => '%s', + 'label_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'generateRow'], + ], + 'global_operations' => [ + 'styles' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['styles'], + 'href' => 'table=tl_leaflet_style', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/style.png', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + 'icons' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['icons'], + 'href' => 'table=tl_leaflet_icon', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/icons.png', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + 'popups' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['popups'], + 'href' => 'table=tl_leaflet_popup', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + 'all' => [ + 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], + 'href' => 'act=select', + 'class' => 'header_edit_all', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + ], + 'operations' => [ + 'markers' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['markers'], + 'href' => 'table=tl_leaflet_marker', + 'icon' => 'edit.gif', + 'button_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'generateMarkersButton'], + ], + 'vectors' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['vectors'], + 'href' => 'table=tl_leaflet_vector', + 'icon' => 'edit.gif', + 'button_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'generateVectorsButton'], + ], + 'edit' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['edit'], + 'href' => 'act=edit', + 'icon' => 'header.gif', + ], + 'copy' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['copy'], + 'href' => 'act=copy', + 'icon' => 'copy.gif', + ], + 'cut' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['cut'], + 'href' => 'act=paste&mode=cut', + 'icon' => 'cut.gif', + 'attributes' => 'onclick="Backend.getScrollOffset()"', + ], + 'delete' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['delete'], + 'href' => 'act=delete', + 'icon' => 'delete.gif', + 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] + . '\'))return false;Backend.getScrollOffset()"', + ], + 'toggle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['toggle'], + 'icon' => 'visible.gif', + 'attributes' => 'onclick="Backend.getScrollOffset(); + return ContaoLeafletAjaxRequest.toggleVisibility(this,%s)"', + 'button_callback' => [ + 'netzmacht.contao_toolkit.dca.listeners.state_button_callback', + 'handleButtonCallback', + ], + 'toolkit' => [ + 'state_button' => [ + 'stateColumn' => 'active', + ], + ], + ], + 'show' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['show'], + 'href' => 'act=show', + 'icon' => 'show.gif', + ], + ], + ], + + 'palettes' => [ + '__selector__' => ['type'], + ], + + 'metapalettes' => [ + 'default' => [ + 'title' => ['title', 'alias', 'type'], + 'config' => [], + 'style' => [], + 'expert' => [':hide'], + 'active' => ['active'], + ], + 'markers extends default' => [ + '+expert' => ['pointToLayer'], + '+config' => ['boundsMode', 'deferred'], + ], + 'group extends default' => [ + '+title' => ['groupType'], + '+active' => ['boundsMode'], + ], + 'vectors extends default' => [ + '+expert' => ['onEachFeature', 'pointToLayer'], + '+config' => ['boundsMode', 'deferred'], + ], + 'reference extends default' => [ + '+title' => ['reference', 'standalone'], + ], + 'markercluster extends default' => [ + 'config' => [ + 'showCoverageOnHover', + 'zoomToBoundsOnClick', + 'removeOutsideVisibleBounds', + 'animateAddingMarkers', + 'spiderfyOnMaxZoom', + 'disableClusteringAtZoom', + 'maxClusterRadius', + 'singleMarkerMode', + ], + '+expert' => [ + 'polygonOptions', + 'iconCreateFunction', + 'disableDefaultStyle', + ], + ], + 'tile extends default' => [ + 'config' => [ + 'tileUrl', + 'subdomains', + 'attribution', + 'minZoom', + 'maxZoom', + ], + '+expert' => [ + 'errorTileUrl', + 'tileSize', + 'tms', + 'continuousWorld', + 'noWrap', + 'zoomReverse', + 'zoomOffset', + 'maxNativeZoom', + 'opacity', + 'zIndex', + 'unloadvisibleTiles', + 'updateWhenIdle', + 'detectRetina', + 'reuseTiles', + 'bounds', + ], + ], + 'overpass extends default' => [ + 'config' => [ + 'overpassQuery', + 'boundsMode', + 'minZoom', + 'overpassEndpoint', + 'overpassPopup', + ], + 'style' => [ + 'amenityIcons', + ], + '+expert' => [ + 'onEachFeature', + 'pointToLayer', + ], + ], + + 'file extends default' => [ + '+config' => ['boundsMode', 'fileFormat'], + '+expert' => [ + 'onEachFeature', + 'pointToLayer', + ], + ], + ], + + 'metasubselectpalettes' => [ + 'type' => [ + 'provider' => ['tile_provider', 'tile_provider_variant'], + ], + 'tile_provider' => [ + 'MapBox' => ['tile_provider_key'], + 'HERE' => ['tile_provider_key', 'tile_provider_code'], + ], + 'fileFormat' => [ + '!' => ['file'] + ] + ], + + 'metasubpalettes' => [ + 'spiderfyOnMaxZoom' => ['spiderfyDistanceMultiplier'], + 'deferred' => ['cache'], + 'cache' => ['cacheLifeTime'], + ], + + 'fields' => [ + 'id' => [ + 'sql' => 'int(10) unsigned NOT NULL auto_increment', + ], + 'pid' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'sorting' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'tstamp' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'title' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['title'], + 'exclude' => true, + 'inputType' => 'text', + 'search' => true, + 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'alias' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['alias'], + 'exclude' => true, + 'inputType' => 'text', + 'search' => true, + 'save_callback' => [ + ['netzmacht.contao_toolkit.dca.listeners.alias_generator', 'handleSaveCallback'], + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateAlias'], + ], + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true], + 'toolkit' => [ + 'alias_generator' => [ + 'factory' => 'netzmacht.contao_leaflet.definition.alias_generator.factory_default', + 'fields' => ['title'], + ], + ], + 'sql' => 'varchar(255) NULL', + ], + 'type' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['type'], + 'exclude' => true, + 'inputType' => 'select', + 'filter' => true, + 'eval' => [ + 'mandatory' => true, + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'submitOnChange' => true, + 'chosen' => true, + 'helpwizard' => true, + ], + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'getLayerOptions'], + 'reference' => &$GLOBALS['TL_LANG']['leaflet_layer'], + 'sql' => "varchar(32) NOT NULL default ''", + ], + 'active' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['active'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'filter' => true, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + 'tile_provider' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider'], + 'exclude' => true, + 'inputType' => 'select', + 'eval' => [ + 'mandatory' => true, + 'tl_class' => 'w50 clr', + 'includeBlankOption' => true, + 'submitOnChange' => true, + 'chosen' => true, + ], + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'getProviderOptions'], + 'sql' => "varchar(32) NOT NULL default ''", + ], + 'tile_provider_variant' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider_variant'], + 'exclude' => true, + 'inputType' => 'select', + 'eval' => [ + 'mandatory' => false, + 'tl_class' => 'w50', + 'submitOnChange' => true, + 'chosen' => false, + ], + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'getVariants'], + 'sql' => "varchar(32) NOT NULL default ''", + ], + 'tile_provider_key' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider_key'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'clr w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'tile_provider_code' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider_code'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'deferred' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['deferred'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50 m12', 'submitOnChange' => true, 'isBoolean' => true], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'groupType' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupType'], + 'exclude' => true, + 'inputType' => 'select', + 'eval' => [ + 'mandatory' => true, + 'tl_class' => 'w50', + 'submitOnChange' => true, + 'helpwizard' => true, + ], + 'default' => 'layer', + 'options' => ['layer', 'feature'], + 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes'], + 'sql' => "varchar(32) NOT NULL default ''", + ], + 'reference' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['reference'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'getLayers'], + 'eval' => [ + 'mandatory' => true, + 'tl_class' => 'w50', + 'chosen' => true, + 'includeBlankOption' => true, + ], + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'standalone' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['standalone'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'onEachFeature' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['onEachFeature'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => [ + 'preserveTags' => true, + 'decodeEntities' => true, + 'allowHtml' => true, + 'rte' => 'ace|javascript', + 'tl_class' => 'clr', + ], + 'sql' => 'mediumtext NULL', + ], + 'pointToLayer' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['pointToLayer'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => [ + 'preserveTags' => true, + 'decodeEntities' => true, + 'allowHtml' => true, + 'rte' => 'ace|javascript', + 'tl_class' => 'clr', + ], + 'sql' => 'mediumtext NULL', + ], + 'showCoverageOnHover' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['showCoverageOnHover'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'zoomToBoundsOnClick' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['zoomToBoundsOnClick'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'spiderfyOnMaxZoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['spiderfyOnMaxZoom'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50 m12', 'submitOnChange' => true, 'isBoolean' => true], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'removeOutsideVisibleBounds' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['removeOutsideVisibleBounds'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'animateAddingMarkers' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['animateAddingMarkers'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'disableClusteringAtZoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['disableClusteringAtZoom'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'getZoomLevels'], + 'default' => null, + 'eval' => [ + 'maxlength' => 4, + 'rgxp' => 'digit', + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true, + ], + 'sql' => 'int(4) NULL', + ], + 'maxClusterRadius' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['maxClusterRadius'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => null, + 'eval' => ['maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true], + 'sql' => 'int(5) NULL', + ], + 'singleMarkerMode' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['singleMarkerMode'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50 m12', 'submitOnChange' => false, 'isBoolean' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'polygonOptions' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['polygonOptions'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => [ + 'preserveTags' => true, + 'decodeEntities' => true, + 'allowHtml' => true, + 'rte' => 'ace|json', + 'tl_class' => 'clr', + ], + 'sql' => 'mediumtext NULL', + ], + 'spiderfyDistanceMultiplier' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['spiderfyDistanceMultiplier'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => null, + 'eval' => ['maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true], + 'sql' => 'int(5) NULL', + ], + 'iconCreateFunction' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['iconCreateFunction'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => [ + 'preserveTags' => true, + 'decodeEntities' => true, + 'allowHtml' => true, + 'rte' => 'ace|javascript', + 'tl_class' => 'clr', + ], + 'sql' => 'mediumtext NULL', + ], + 'disableDefaultStyle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['disableDefaultStyle'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'boundsMode' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['boundsMode'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'getBoundsModes'], + 'eval' => ['tl_class' => 'w50', 'includeBlankOption' => true], + 'sql' => "varchar(6) NOT NULL default ''", + ], + 'tileUrl' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tileUrl'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => '', + 'eval' => ['maxlength' => 255, 'tl_class' => 'w50', 'mandatory' => true], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'minZoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['minZoom'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'getZoomLevels'], + 'eval' => [ + 'maxlength' => 4, + 'rgxp' => 'digit', + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true, + ], + 'sql' => 'int(4) NULL', + ], + 'maxZoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['maxZoom'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'getZoomLevels'], + 'eval' => [ + 'maxlength' => 4, + 'rgxp' => 'digit', + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true, + ], + 'sql' => 'int(4) NULL', + ], + 'maxNativeZoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['maxNativeZoom'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'getZoomLevels'], + 'eval' => [ + 'maxlength' => 4, + 'rgxp' => 'digit', + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true, + ], + 'sql' => 'int(4) NULL', + ], + 'tileSize' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tileSize'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => null, + 'eval' => ['maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true], + 'sql' => 'int(5) NULL', + ], + 'subdomains' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['subdomains'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => '', + 'eval' => ['maxlength' => 16, 'tl_class' => 'w50'], + 'sql' => "varchar(16) NOT NULL default ''", + ], + 'errorTileUrl' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['errorTileUrl'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => '', + 'eval' => ['maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'attribution' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['attribution'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => '', + 'eval' => ['maxlength' => 255, 'tl_class' => 'long', 'allowHtml' => true], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'tms' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tms'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'continuousWorld' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['continuousWorld'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'noWrap' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['noWrap'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'zoomOffset' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['zoomOffset'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => null, + 'eval' => ['maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true], + 'sql' => 'int(5) NULL', + ], + 'zoomReverse' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['zoomReverse'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'opacity' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['opacity'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => '1.0', + 'eval' => ['mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50 clr'], + 'sql' => "varchar(4) NOT NULL default ''", + ], + 'zIndex' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['zIndex'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => null, + 'eval' => ['maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true], + 'sql' => 'int(5) NULL', + ], + 'unloadvisibleTiles' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['unloadvisibleTiles'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'updateWhenIdle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['updateWhenIdle'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'detectRetina' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['detectRetina'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'reuseTiles' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['reuseTiles'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'bounds' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['bounds'], + 'exclude' => true, + 'inputType' => 'leaflet_geocode', + 'save_callback' => [ + ], + 'eval' => [ + 'maxlength' => 255, + 'multiple' => true, + 'size' => 2, + 'tl_class' => 'clr', + 'nullIfEmpty' => true, + ], + 'sql' => 'mediumblob NULL', + ], + 'cache' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['cache'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50 m12', 'submitOnChange' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'cacheLifeTime' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['cacheLifeTime'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => 0, + 'eval' => ['maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50'], + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'overpassQuery' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['overpassQuery'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => [ + 'preserveTags' => true, + 'decodeEntities' => true, + 'allowHtml' => true, + 'rte' => 'ace', + 'tl_class' => 'clr', + ], + 'sql' => 'mediumtext NULL', + ], + 'overpassEndpoint' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['overpassEndpoint'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => '', + 'eval' => ['tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'overpassCallback' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['overpassCallback'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => [ + 'preserveTags' => true, + 'decodeEntities' => true, + 'allowHtml' => true, + 'rte' => 'ace|javascript', + 'tl_class' => 'clr', + ], + 'sql' => 'mediumtext NULL', + ], + 'minZoomIndicatorPosition' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['minZoomIndicatorPosition'], + 'exclude' => true, + 'inputType' => 'select', + 'filter' => true, + 'sorting' => true, + 'options' => ['topleft', 'topright', 'bottomleft', 'bottomright'], + 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_layer'], + 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50', 'helpwizard' => true], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'minZoomIndicatorMessage' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['minZoomIndicatorMessage'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => '', + 'eval' => ['tl_class' => 'clr w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'minZoomIndicatorMessageNoLayer' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['minZoomIndicatorMessageNoLayer'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => '', + 'eval' => ['tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'debug' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['debug'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50 m12'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'amenityIcons' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['amenityIcons'], + 'exclude' => true, + 'inputType' => 'multiColumnWizard', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'getIcons'], + 'eval' => [ + 'tl_class' => 'leaflet-mcw leaflet-mcw-amenity-icons', + 'columnFields' => [ + 'amenity' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['amenity'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'getAmenities'], + 'eval' => [ + 'mandatory' => true, + 'tl_class' => 'w50', + 'style' => 'width: 200px', + 'chosen' => true, + ], + ], + 'icon' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['amenityIcon'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'getIcons'], + 'eval' => [ + 'mandatory' => true, + 'tl_class' => 'w50', + 'style' => 'width: 200px', + 'chosen' => true, + ], + ], + ], + ], + 'sql' => 'blob NULL', + ], + 'overpassPopup' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['overpassPopup'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => [ + 'preserveTags' => true, + 'decodeEntities' => true, + 'allowHtml' => true, + 'rte' => 'ace|javascript', + 'tl_class' => 'clr', + ], + 'sql' => 'mediumtext NULL', + ], + 'fileFormat' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormat'], + 'exclude' => true, + 'inputType' => 'select', + 'filter' => true, + 'eval' => [ + 'mandatory' => true, + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'submitOnChange' => true, + 'chosen' => true, + 'helpwizard' => true, + ], + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'getFileFormats'], + 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats'], + 'sql' => "varchar(32) NOT NULL default ''", + ], + 'file' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['file'], + 'exclude' => true, + 'inputType' => 'fileTree', + 'load_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.layer', 'prepareFileWidget'], + ], + 'eval' => [ + 'filesOnly' => true, + 'fieldType' => 'radio', + 'mandatory' => true, + 'tl_class' => 'clr', + ], + 'sql' => 'binary(16) NULL', + ], + ], +]; diff --git a/src/Bundle/Resources/contao/dca/tl_leaflet_map.php b/src/Bundle/Resources/contao/dca/tl_leaflet_map.php new file mode 100644 index 0000000..6b701f2 --- /dev/null +++ b/src/Bundle/Resources/contao/dca/tl_leaflet_map.php @@ -0,0 +1,533 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_DCA']['tl_leaflet_map'] = [ + 'config' => [ + 'dataContainer' => 'Table', + 'enableVersioning' => true, + 'ctable' => ['tl_leaflet_control'], + 'sql' => [ + 'keys' => [ + 'id' => 'primary', + 'alias' => 'unique', + ], + ], + 'onload_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'loadLanguageFile'], + ], + 'onsubmit_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + + 'list' => [ + 'sorting' => [ + 'mode' => 1, + 'fields' => ['title'], + 'panelLayout' => 'search,limit', + 'flag' => 1, + ], + 'label' => [ + 'fields' => ['title', 'alias'], + 'format' => '%s [%s]', + ], + 'global_operations' => [ + 'all' => [ + 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], + 'href' => 'act=select', + 'class' => 'header_edit_all', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"', + ], + ], + 'operations' => [ + 'edit' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['edit'], + 'href' => 'act=edit', + 'icon' => 'header.gif', + ], + 'controls' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['controls'], + 'href' => 'table=tl_leaflet_control', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/control.png', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"', + ], + 'copy' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['copy'], + 'href' => 'act=copy', + 'icon' => 'copy.gif', + ], + 'delete' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['delete'], + 'href' => 'act=delete', + 'icon' => 'delete.gif', + 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] + . '\'))return false;Backend.getScrollOffset()"', + ], + 'show' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['show'], + 'href' => 'act=show', + 'icon' => 'show.gif', + ], + ], + ], + + 'metapalettes' => [ + 'default' => [ + 'title' => ['title', 'alias'], + 'zoom' => ['center', 'zoom', 'adjustZoomExtra', 'adjustBounds', 'dynamicLoad', 'boundsPadding'], + 'locate' => ['locate'], + 'layers' => ['layers'], + 'interaction' => [ + 'dragging', + 'touchZoom', + 'scrollWheelZoom', + 'doubleClickZoom', + 'boxZoom', + 'tap', + 'keyboard', + ], + 'behaviour' => [ + 'zoomControl', + 'trackResize', + 'closeOnClick', + 'bounceAtZoomLimits', + ], + 'expert' => [ + 'options', + 'cache', + ], + ], + ], + 'metasubpalettes' => [ + 'keyboard' => [ + 'keyboardPanOffset', + 'keyboardZoomOffset', + ], + 'adjustZoomExtra' => [ + 'minZoom', + 'maxZoom', + 'zoomSnap', + 'zoomDelta', + ], + 'locate' => [ + ':hide', + 'locateWatch', + 'locateSetView', + 'locateMaxZoom', + 'locateTimeout', + 'locateMaximumAge', + 'enableHighAccuracy', + ], + 'cache' => [ + 'cacheLifeTime', + ], + ], + + 'fields' => [ + 'id' => [ + 'sql' => 'int(10) unsigned NOT NULL auto_increment', + ], + 'tstamp' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'title' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['title'], + 'exclude' => true, + 'inputType' => 'text', + 'search' => true, + 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'alias' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['alias'], + 'exclude' => true, + 'inputType' => 'text', + 'search' => true, + 'save_callback' => [ + ['netzmacht.contao_toolkit.dca.listeners.alias_generator', 'handleSaveCallback'], + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateAlias'], + ], + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true], + 'toolkit' => [ + 'alias_generator' => [ + 'factory' => 'netzmacht.contao_leaflet.definition.alias_generator.factory_default', + 'fields' => ['title'], + ], + ], + 'sql' => 'varchar(255) NULL', + ], + 'center' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['center'], + 'exclude' => true, + 'inputType' => 'text', + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateCoordinates'], + ], + 'wizard' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'getGeocoder'], + ], + 'eval' => [ + 'maxlength' => 255, + 'tl_class' => 'long clr', + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(255) NULL', + ], + 'layers' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['layers'], + 'exclude' => true, + 'inputType' => 'multiColumnWizard', + 'load_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.map', 'loadLayerRelations'], + ], + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.map', 'saveLayerRelations'], + ], + 'eval' => [ + 'multiple' => true, + 'doNotSaveEmpty' => true, + 'tl_class' => 'leaflet-mcw leaflet-mcw-map-layers', + 'columnFields' => [ + 'reference' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['reference'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.map', 'getLayers'], + 'eval' => [ + 'mandatory' => false, + 'tl_class' => 'w50', + 'chosen' => true, + 'includeBlankOption' => true, + ], + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + ], + 'flatArray' => true, + ], + 'sql' => 'mediumblob NULL', + ], + 'zoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoom'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'getZoomLevels'], + 'default' => null, + 'eval' => [ + 'maxlength' => 4, + 'rgxp' => 'digit', + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true, + ], + 'sql' => 'int(4) NULL', + ], + 'adjustZoomExtra' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustZoomExtra'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50 m12', 'submitOnChange' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'minZoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['minZoom'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'getZoomLevels'], + 'eval' => [ + 'maxlength' => 4, + 'rgxp' => 'digit', + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true, + ], + 'sql' => 'int(4) NULL', + ], + 'maxZoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['maxZoom'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'getZoomLevels'], + 'eval' => [ + 'maxlength' => 4, + 'rgxp' => 'digit', + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true, + ], + 'sql' => 'int(4) NULL', + ], + 'zoomSnap' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomSnap'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => [ + 'maxlength' => 4, + 'rgxp' => 'digit', + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(4) NULL', + ], + 'zoomDelta' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomDelta'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => [ + 'maxlength' => 4, + 'rgxp' => 'digit', + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(4) NULL', + ], + 'dragging' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['dragging'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'touchZoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['touchZoom'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'scrollWheelZoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['scrollWheelZoom'], + 'exclude' => true, + 'inputType' => 'select', + 'options' => ['1', 'center'], + 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'], + 'default' => true, + 'eval' => [ + 'tl_class' => 'w50', + 'helpwizard' => true, + 'includeBlankOption' => true, + 'blankOptionLabel' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'][''][0], + ], + 'sql' => "char(6) NOT NULL default ''", + ], + 'doubleClickZoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['doubleClickZoom'], + 'exclude' => true, + 'inputType' => 'select', + 'options' => ['1', 'center'], + 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'], + 'default' => true, + 'eval' => [ + 'tl_class' => 'w50', + 'helpwizard' => true, + 'includeBlankOption' => true, + 'blankOptionLabel' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'][''][0], + ], + 'sql' => "char(6) NOT NULL default ''", + ], + 'boxZoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['boxZoom'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'tap' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['tap'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'trackResize' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['trackResize'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'bounceAtZoomLimits' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['bounceAtZoomLimits'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'closeOnClick' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['closeOnClick'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'keyboard' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboard'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'keyboardPanOffset' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardPanOffset'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => 80, + 'eval' => ['mandatory' => true, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'clr w50'], + 'sql' => "int(4) NOT NULL default '80'", + ], + 'keyboardZoomOffset' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardZoomOffset'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => 1, + 'eval' => ['mandatory' => true, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'], + 'sql' => "int(4) NOT NULL default '1'", + ], + 'zoomControl' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomControl'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'options' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['options'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => [ + 'tl_class' => 'clr lng', + 'allowHtml' => true, + 'style' => 'min-height: 40px;', + 'rte' => 'ace|json', + ], + 'sql' => 'text NULL', + ], + 'adjustBounds' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBounds'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'options' => ['load', 'deferred'], + 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions'], + 'eval' => ['tl_class' => 'clr w50', 'multiple' => true, 'helpwizard' => true], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'dynamicLoad' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['dynamicLoad'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'clr w50', 'submitOnChange' => false], + 'sql' => "char(1) NOT NULL default ''", + ], + 'boundsPadding' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['boundsPadding'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => [ + 'maxlength' => 32, + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(32) NULL', + ], + 'locate' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['locate'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'locateWatch' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['locateWatch'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'locateSetView' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['locateSetView'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => false], + 'sql' => "char(1) NOT NULL default ''", + ], + 'locateTimeout' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['locateTimeout'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => null, + 'eval' => ['maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true], + 'sql' => 'int(9) NULL', + ], + 'locateMaximumAge' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaximumAge'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => null, + 'eval' => ['maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true], + 'sql' => 'int(9) NULL', + ], + 'enableHighAccuracy' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['enableHighAccuracy'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50 m12'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'locateMaxZoom' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaxZoom'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'getZoomLevels'], + 'eval' => [ + 'maxlength' => 4, + 'rgxp' => 'digit', + 'tl_class' => 'clr w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true, + ], + 'sql' => 'int(4) NULL', + ], + 'cache' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['cache'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50 m12', 'submitOnChange' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'cacheLifeTime' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['cacheLifeTime'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => 0, + 'eval' => ['maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50'], + 'sql' => "int(9) NOT NULL default '0'", + ], + ], +]; diff --git a/src/Bundle/Resources/contao/dca/tl_leaflet_map_layer.php b/src/Bundle/Resources/contao/dca/tl_leaflet_map_layer.php new file mode 100644 index 0000000..6cb18f9 --- /dev/null +++ b/src/Bundle/Resources/contao/dca/tl_leaflet_map_layer.php @@ -0,0 +1,41 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_DCA']['tl_leaflet_map_layer'] = [ + 'config' => [ + 'dataContainer' => 'Table', + 'sql' => [ + 'keys' => [ + 'id' => 'primary', + 'mid,lid' => 'unique', + ], + ], + ], + + 'fields' => [ + 'id' => [ + 'sql' => 'int(10) unsigned NOT NULL auto_increment', + ], + 'tstamp' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'sorting' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'mid' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'lid' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + ], +]; diff --git a/src/Bundle/Resources/contao/dca/tl_leaflet_marker.php b/src/Bundle/Resources/contao/dca/tl_leaflet_marker.php new file mode 100644 index 0000000..0b24991 --- /dev/null +++ b/src/Bundle/Resources/contao/dca/tl_leaflet_marker.php @@ -0,0 +1,342 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_DCA']['tl_leaflet_marker'] = [ + 'config' => [ + 'dataContainer' => 'Table', + 'enableVersioning' => true, + 'ptable' => 'tl_leaflet_layer', + 'sql' => [ + 'keys' => [ + 'id' => 'primary', + 'pid' => 'index', + 'alias' => 'unique', + ], + ], + 'onload_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'loadLanguageFile'], + ], + 'onsubmit_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + + 'list' => [ + 'sorting' => [ + 'mode' => 4, + 'fields' => ['sorting'], + 'flag' => 1, + 'panelLayout' => 'sort,filter;search,limit', + 'headerFields' => ['title', 'type'], + 'child_record_callback' => ['netzmacht.contao_leaflet.listeners.dca.marker', 'generateRow'], + ], + 'label' => [ + 'fields' => ['title'], + 'format' => '%s', + ], + 'global_operations' => [ + 'icons' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['icons'], + 'href' => 'table=tl_leaflet_icon&id=', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/icons.png', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"', + ], + 'popups' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['popups'], + 'href' => 'table=tl_leaflet_popup', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + 'all' => [ + 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], + 'href' => 'act=select', + 'class' => 'header_edit_all', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"', + ], + ], + 'operations' => [ + 'edit' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['edit'], + 'href' => 'act=edit', + 'icon' => 'edit.gif', + ], + 'copy' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['copy'], + 'href' => 'act=copy', + 'icon' => 'copy.gif', + ], + 'delete' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['delete'], + 'href' => 'act=delete', + 'icon' => 'delete.gif', + 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] + . '\'))return false;Backend.getScrollOffset()"', + ], + 'toggle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['toggle'], + 'icon' => 'visible.gif', + 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', + 'button_callback' => [ + 'netzmacht.contao_toolkit.dca.listeners.state_button_callback', + 'handleButtonCallback', + ], + 'toolkit' => [ + 'state_button' => [ + 'stateColumn' => 'active', + ], + ], + ], + 'show' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['show'], + 'href' => 'act=show', + 'icon' => 'show.gif', + ], + ], + ], + + 'metapalettes' => [ + 'default' => [ + 'title' => ['title', 'alias', 'coordinates'], + 'content' => ['tooltip', 'alt', 'addPopup'], + 'config' => [ + ':hide', + 'clickable', + 'draggable', + 'keyboard', + 'zIndexOffset', + 'opacity', + 'riseOnHover', + 'riseOffset', + 'customIcon', + ], + 'expert' => [':hide', 'featureData'], + 'active' => ['active', 'ignoreForBounds'], + ], + ], + 'metasubpalettes' => [ + 'addPopup' => ['popup', 'popupContent'], + 'customIcon' => ['icon'], + ], + + 'fields' => [ + 'id' => [ + 'sql' => 'int(10) unsigned NOT NULL auto_increment', + ], + 'tstamp' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'sorting' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + 'sorting' => true, + ], + 'pid' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'title' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['title'], + 'exclude' => true, + 'search' => true, + 'sorting' => true, + 'flag' => 1, + 'inputType' => 'text', + 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'alias' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['alias'], + 'exclude' => true, + 'inputType' => 'text', + 'search' => true, + 'save_callback' => [ + ['netzmacht.contao_toolkit.dca.listeners.alias_generator', 'handleSaveCallback'], + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateAlias'], + ], + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true], + 'toolkit' => [ + 'alias_generator' => [ + 'factory' => 'netzmacht.contao_leaflet.definition.alias_generator.factory_default', + 'fields' => ['title'], + ], + ], + 'sql' => 'varchar(255) NULL', + ], + 'coordinates' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['coordinates'], + 'exclude' => true, + 'inputType' => 'text', + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateCoordinates'], + ['netzmacht.contao_leaflet.listeners.dca.marker', 'saveCoordinates'], + ], + 'load_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.marker', 'loadCoordinates'], + ], + 'wizard' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'getGeocoder'], + ], + 'eval' => [ + 'maxlength' => 255, + 'tl_class' => 'long clr', + 'nullIfEmpty' => true, + 'doNotSaveEmpty' => true, + ], + ], + 'latitude' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['latitude'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => 'decimal(10,8) NULL', + ], + 'longitude' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['longitude'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => 'decimal(11,8) NULL', + ], + 'altitude' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['altitude'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => 'float NULL', + ], + 'active' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['active'], + 'exclude' => true, + 'filter' => true, + 'sorting' => true, + 'flag' => 12, + 'inputType' => 'checkbox', + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + 'tooltip' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['tooltip'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'alt' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['alt'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'addPopup' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['addPopup'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'filter' => true, + 'eval' => ['tl_class' => 'w50 m12', 'submitOnChange' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'popup' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['popup'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.marker', 'getPopups'], + 'eval' => [ + 'mandatory' => false, + 'tl_class' => 'w50', + 'chosen' => true, + 'includeBlankOption' => true, + ], + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'popupContent' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['popupContent'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => true, 'rte' => 'tinyMCE', 'helpwizard' => true, 'tl_class' => 'clr'], + 'explanation' => 'insertTags', + 'sql' => 'mediumtext NULL', + ], + 'customIcon' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['customIcon'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => ['tl_class' => 'clr w50 m12', 'submitOnChange' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'icon' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['icon'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.marker', 'getIcons'], + 'eval' => [ + 'mandatory' => true, + 'tl_class' => 'w50', + 'chosen' => true, + ], + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'draggable' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['draggable'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'clickable' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['clickable'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'keyboard' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['keyboard'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'zIndexOffset' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['zIndexOffset'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => 0, + 'eval' => ['maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'clr w50', 'nullIfEmpty' => true], + 'sql' => 'int(5) NULL', + ], + 'ignoreForBounds' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['ignoreForBounds'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'featureData' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['featureData'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => [ + 'tl_class' => 'clr lng', + 'allowHtml' => true, + 'style' => 'min-height: 40px;', + 'rte' => 'ace|json', + ], + 'sql' => 'text NULL', + ], + ], +]; diff --git a/src/Bundle/Resources/contao/dca/tl_leaflet_popup.php b/src/Bundle/Resources/contao/dca/tl_leaflet_popup.php new file mode 100644 index 0000000..b40f21d --- /dev/null +++ b/src/Bundle/Resources/contao/dca/tl_leaflet_popup.php @@ -0,0 +1,276 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_DCA']['tl_leaflet_popup'] = [ + 'config' => [ + 'dataContainer' => 'Table', + 'enableVersioning' => true, + 'sql' => [ + 'keys' => [ + 'id' => 'primary', + 'alias' => 'unique', + ], + ], + 'onsubmit_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + + 'list' => [ + 'sorting' => [ + 'mode' => 1, + 'fields' => ['title'], + 'flag' => 1, + 'panelLayout' => 'limit', + 'headerFields' => ['title', 'type'], + ], + 'label' => [ + 'fields' => ['title', 'type'], + 'format' => '%s [%s]', + ], + 'global_operations' => [ + 'layers' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['layersBtn'], + 'href' => 'table=tl_leaflet_layer', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/layers.png', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"', + ], + 'styles' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['styles'], + 'href' => 'table=tl_leaflet_style', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/style.png', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + 'icons' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['icons'], + 'href' => 'table=tl_leaflet_icon', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/icons.png', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + 'all' => [ + 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], + 'href' => 'act=select', + 'class' => 'header_edit_all', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"', + ], + ], + 'operations' => [ + 'edit' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['edit'], + 'href' => 'act=edit', + 'icon' => 'edit.gif', + ], + 'copy' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['copy'], + 'href' => 'act=copy', + 'icon' => 'copy.gif', + ], + 'delete' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['delete'], + 'href' => 'act=delete', + 'icon' => 'delete.gif', + 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] + . '\'))return false;Backend.getScrollOffset()"', + ], + 'toggle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['toggle'], + 'icon' => 'visible.gif', + 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', + 'button_callback' => [ + 'netzmacht.contao_toolkit.dca.listeners.state_button_callback', + 'handleButtonCallback', + ], + 'toolkit' => [ + 'state_button' => [ + 'stateColumn' => 'active', + ], + ], + ], + 'show' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['show'], + 'href' => 'act=show', + 'icon' => 'show.gif', + ], + ], + ], + + 'palettes' => [ + '__selector__' => ['type'], + ], + + 'metapalettes' => [ + 'default' => [ + 'title' => ['title', 'alias'], + 'size' => ['maxWidth', 'minWidth', 'maxHeight'], + 'config' => [ + ':hide', + 'closeButton', + 'keepInView', + 'closeOnClick', + 'zoomAnimation', + 'offset', + 'className', + 'autoPan', + ], + 'active' => ['active'], + ], + ], + + 'metasubpalettes' => [ + 'autoPan' => ['autoPanPadding'], + ], + + 'fields' => [ + 'id' => [ + 'sql' => 'int(10) unsigned NOT NULL auto_increment', + ], + 'tstamp' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'title' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['title'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'alias' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['alias'], + 'exclude' => true, + 'inputType' => 'text', + 'save_callback' => [ + ['netzmacht.contao_toolkit.dca.listeners.alias_generator', 'handleSaveCallback'], + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateAlias'], + ], + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true], + 'toolkit' => [ + 'alias_generator' => [ + 'factory' => 'netzmacht.contao_leaflet.definition.alias_generator.factory_default', + 'fields' => ['title'], + ], + ], + 'sql' => 'varchar(255) NULL', + ], + 'maxWidth' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['maxWidth'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => null, + 'eval' => ['mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'], + 'sql' => 'int(4) NULL', + ], + 'minWidth' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['minWidth'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => null, + 'eval' => ['mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'], + 'sql' => 'int(4) NULL', + ], + 'maxHeight' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['maxHeight'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => null, + 'eval' => ['mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'], + 'sql' => 'int(4) NULL', + ], + 'autoPan' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['autoPan'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50 m12', 'submitOnChange' => true], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'keepInView' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['keepInView'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => false], + 'sql' => "char(1) NOT NULL default ''", + ], + 'closeButton' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['closeButton'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => false], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'offset' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['offset'], + 'exclude' => true, + 'inputType' => 'text', + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateCoordinates'], + ], + 'eval' => [ + 'maxlength' => 255, + 'tl_class' => 'w50', + 'nullIfEmpty' => true, + ], + 'sql' => 'varchar(255) NULL', + ], + 'autoPanPadding' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['autoPanPadding'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => [ + 'maxlength' => 255, + 'tl_class' => 'w50', + 'nullIfEmpty' => true, + 'multiple' => true, + 'size' => 2, + ], + 'sql' => 'varchar(255) NULL', + ], + 'zoomAnimation' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['zoomAnimation'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => false], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'closeOnClick' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['closeOnClick'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => false], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'className' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['className'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 64, 'tl_class' => 'w50'], + 'sql' => "varchar(64) NOT NULL default ''", + ], + 'active' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['active'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'filter' => true, + 'sorting' => true, + 'search' => false, + 'flag' => 12, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + ], +]; diff --git a/src/Bundle/Resources/contao/dca/tl_leaflet_style.php b/src/Bundle/Resources/contao/dca/tl_leaflet_style.php new file mode 100644 index 0000000..8a10177 --- /dev/null +++ b/src/Bundle/Resources/contao/dca/tl_leaflet_style.php @@ -0,0 +1,284 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_DCA']['tl_leaflet_style'] = [ + 'config' => [ + 'dataContainer' => 'Table', + 'enableVersioning' => true, + 'sql' => [ + 'keys' => [ + 'id' => 'primary', + 'alias' => 'unique', + ], + ], + 'onsubmit_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + + 'list' => [ + 'sorting' => [ + 'mode' => 1, + 'fields' => ['title'], + 'flag' => 1, + 'panelLayout' => 'limit', + 'headerFields' => ['title', 'type'], + ], + 'label' => [ + 'fields' => ['title', 'type'], + 'format' => '%s [%s]', + ], + 'global_operations' => [ + 'layers' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['layersBtn'], + 'href' => 'table=tl_leaflet_layer', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/layers.png', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"', + ], + 'icons' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['icons'], + 'href' => 'table=tl_leaflet_icon', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/icons.png', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + 'popups' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['popups'], + 'href' => 'table=tl_leaflet_popup', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + 'all' => [ + 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], + 'href' => 'act=select', + 'class' => 'header_edit_all', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"', + ], + ], + 'operations' => [ + 'edit' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['edit'], + 'href' => 'act=edit', + 'icon' => 'edit.gif', + ], + 'copy' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['copy'], + 'href' => 'act=copy', + 'icon' => 'copy.gif', + ], + 'delete' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['delete'], + 'href' => 'act=delete', + 'icon' => 'delete.gif', + 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] + . '\'))return false;Backend.getScrollOffset()"', + ], + 'toggle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['toggle'], + 'icon' => 'visible.gif', + 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', + 'button_callback' => [ + 'netzmacht.contao_toolkit.dca.listeners.state_button_callback', + 'handleButtonCallback', + ], + 'toolkit' => [ + 'state_button' => [ + 'stateColumn' => 'active', + ], + ], + ], + 'show' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['show'], + 'href' => 'act=show', + 'icon' => 'show.gif', + ], + ], + ], + + 'palettes' => [ + '__selector__' => ['type'], + ], + + 'metapalettes' => [ + 'default' => [ + 'title' => ['title', 'alias', 'type'], + 'config' => [], + 'active' => ['active'], + ], + 'fixed extends default' => [ + 'config' => ['stroke', 'fill'], + ], + ], + + 'metasubpalettes' => [ + 'stroke' => ['color', 'weight', 'opacity', 'dashArray', 'lineCap', 'lineJoin'], + 'fill' => ['fillColor', 'fillOpacity',], + ], + + 'fields' => [ + 'id' => [ + 'sql' => 'int(10) unsigned NOT NULL auto_increment', + ], + 'tstamp' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'title' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['title'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'alias' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['alias'], + 'exclude' => true, + 'inputType' => 'text', + 'save_callback' => [ + ['netzmacht.contao_toolkit.dca.listeners.alias_generator', 'handleSaveCallback'], + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateAlias'], + ], + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true], + 'toolkit' => [ + 'alias_generator' => [ + 'factory' => 'netzmacht.contao_leaflet.definition.alias_generator.factory_default', + 'fields' => ['title'], + ], + ], + 'sql' => 'varchar(255) NULL', + ], + 'type' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['type'], + 'exclude' => true, + 'inputType' => 'select', + 'eval' => [ + 'mandatory' => true, + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'submitOnChange' => true, + 'chosen' => true, + ], + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.style', 'getStyleOptions'], + 'reference' => &$GLOBALS['TL_LANG']['leaflet_style'], + 'sql' => "varchar(32) NOT NULL default ''", + ], + 'stroke' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['stroke'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'w50', 'submitOnChange' => true], + 'sql' => "char(1) NOT NULL default '1'", + ], + 'color' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['color'], + 'exclude' => true, + 'inputType' => 'text', + 'wizard' => [ + ['netzmacht.contao_toolkit.dca.listeners.color_picker', 'handleWizardCallback'], + ], + 'eval' => [ + 'tl_class' => 'w50 wizard clr', + 'maxlength' => 7, + 'decodeEntities' => true, + ], + 'sql' => "varchar(8) NOT NULL default ''", + ], + 'weight' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['weight'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => 5, + 'eval' => ['mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'], + 'sql' => "int(4) NOT NULL default '5'", + ], + 'opacity' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['opacity'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => '0.5', + 'eval' => ['mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'], + 'sql' => "varchar(4) NOT NULL default '0.5'", + ], + 'fill' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['fill'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => ['tl_class' => 'clr w50', 'submitOnChange' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'fillColor' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['fillColor'], + 'exclude' => true, + 'inputType' => 'text', + 'wizard' => [ + ['netzmacht.contao_toolkit.dca.listeners.color_picker', 'handleWizardCallback'], + ], + 'eval' => [ + 'tl_class' => 'clr w50 wizard', + 'maxlength' => 7, + 'decodeEntities' => true, + ], + 'sql' => "varchar(8) NOT NULL default ''", + ], + 'fillOpacity' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['fillOpacity'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => '0.2', + 'eval' => ['mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'], + 'sql' => "varchar(4) NOT NULL default '0.2'", + ], + 'dashArray' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['dashArray'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 32, 'tl_class' => 'w50'], + 'sql' => "varchar(32) NOT NULL default ''", + ], + 'lineCap' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['lineCap'], + 'exclude' => true, + 'inputType' => 'select', + 'options' => ['butt', 'round', 'square', 'inherit'], + 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['lineCaps'], + 'eval' => [ + 'mandatory' => false, + 'tl_class' => 'w50 clr', + 'includeBlankOption' => true, + 'helpwizard' => true, + ], + 'sql' => "varchar(8) NOT NULL default ''", + ], + 'lineJoin' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['lineJoin'], + 'exclude' => true, + 'inputType' => 'select', + 'options' => ['miter', 'round', 'bevel', 'inherit'], + 'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['lineJoins'], + 'eval' => ['mandatory' => false, 'tl_class' => 'w50', 'includeBlankOption' => true, 'helpwizard'], + 'sql' => "varchar(8) NOT NULL default ''", + ], + 'active' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['active'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'filter' => true, + 'sorting' => true, + 'search' => false, + 'flag' => 12, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + ], +]; diff --git a/src/Bundle/Resources/contao/dca/tl_leaflet_vector.php b/src/Bundle/Resources/contao/dca/tl_leaflet_vector.php new file mode 100644 index 0000000..4e2fe66 --- /dev/null +++ b/src/Bundle/Resources/contao/dca/tl_leaflet_vector.php @@ -0,0 +1,382 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_DCA']['tl_leaflet_vector'] = [ + 'config' => [ + 'dataContainer' => 'Table', + 'enableVersioning' => true, + 'ptable' => 'tl_leaflet_layer', + 'sql' => [ + 'keys' => [ + 'id' => 'primary', + 'pid' => 'index', + 'alias' => 'unique', + ], + ], + 'onload_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'loadLanguageFile'], + ], + 'onsubmit_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + + 'list' => [ + 'sorting' => [ + 'mode' => 4, + 'fields' => ['sorting'], + 'flag' => 1, + 'panelLayout' => 'sort,filter;search,limit', + 'headerFields' => ['title', 'type'], + 'child_record_callback' => ['netzmacht.contao_leaflet.listeners.dca.vector', 'generateRow'], + ], + 'label' => [ + 'fields' => ['title'], + 'format' => '%s', + ], + 'global_operations' => [ + 'styles' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['styles'], + 'href' => 'table=tl_leaflet_style', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/style.png', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + 'popups' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popups'], + 'href' => 'table=tl_leaflet_popup', + 'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png', + 'attributes' => 'onclick="Backend.getScrollOffset();"', + ], + 'all' => [ + 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], + 'href' => 'act=select', + 'class' => 'header_edit_all', + 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"', + ], + ], + 'operations' => [ + 'edit' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['edit'], + 'href' => 'act=edit', + 'icon' => 'edit.gif', + ], + 'copy' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['copy'], + 'href' => 'act=copy', + 'icon' => 'copy.gif', + ], + 'cut' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['cut'], + 'href' => 'act=paste&mode=cut', + 'icon' => 'cut.gif', + 'attributes' => 'onclick="Backend.getScrollOffset()"', + ], + 'delete' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['delete'], + 'href' => 'act=delete', + 'icon' => 'delete.gif', + 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] + . '\'))return false;Backend.getScrollOffset()"', + ], + 'toggle' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['toggle'], + 'icon' => 'visible.gif', + 'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"', + 'button_callback' => [ + 'netzmacht.contao_toolkit.dca.listeners.state_button_callback', + 'handleButtonCallback', + ], + 'toolkit' => [ + 'state_button' => [ + 'stateColumn' => 'active', + ], + ], + ], + 'show' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['show'], + 'href' => 'act=show', + 'icon' => 'show.gif', + ], + ], + ], + + 'palettes' => [ + '__selector__' => ['type'], + ], + + 'metapalettes' => [ + 'default' => [ + 'title' => ['title', 'alias', 'type'], + 'data' => [], + 'popup' => [':hide', 'addPopup'], + 'config' => [':hide', 'style', 'className', 'clickable'], + 'expert' => [':hide', 'featureData'], + 'active' => ['active', 'ignoreForBounds'], + ], + + 'polyline extends default' => [ + '+config' => ['smoothFactor', 'noClip'], + 'data' => ['data'], + ], + + 'multiPolyline extends polyline' => [ + 'data' => ['multiData'], + ], + + 'polygon extends polyline' => [], + + 'multiPolygon extends multiPolyline' => [ + ], + + 'rectangle extends polygon' => [ + 'data' => ['bounds'], + ], + + 'circle extends default' => [ + '+data' => ['coordinates', 'radius'], + ], + + 'circleMarker extends circle' => [], + ], + 'metasubpalettes' => [ + 'addPopup' => ['popup', 'popupContent'], + ], + + 'fields' => [ + 'id' => [ + 'sql' => 'int(10) unsigned NOT NULL auto_increment', + ], + 'tstamp' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'pid' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'sorting' => [ + 'sql' => "int(10) unsigned NOT NULL default '0'", + 'sorting' => true, + ], + 'title' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['title'], + 'exclude' => true, + 'inputType' => 'text', + 'filter' => false, + 'sorting' => true, + 'search' => true, + 'flag' => 1, + 'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", + ], + 'alias' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['alias'], + 'exclude' => true, + 'inputType' => 'text', + 'search' => true, + 'save_callback' => [ + ['netzmacht.contao_toolkit.dca.listeners.alias_generator', 'handleSaveCallback'], + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateAlias'], + ], + 'eval' => ['mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true], + 'toolkit' => [ + 'alias_generator' => [ + 'factory' => 'netzmacht.contao_leaflet.definition.alias_generator.factory_default', + 'fields' => ['title'], + ], + ], + 'sql' => 'varchar(255) NULL', + ], + 'type' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['type'], + 'exclude' => true, + 'inputType' => 'select', + 'filter' => true, + 'sorting' => true, + 'search' => false, + 'flag' => 1, + 'eval' => [ + 'mandatory' => true, + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'submitOnChange' => true, + 'chosen' => true, + 'helpwizard' => true, + ], + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.vector', 'getVectorOptions'], + 'reference' => &$GLOBALS['TL_LANG']['leaflet_vector'], + 'sql' => "varchar(32) NOT NULL default ''", + ], + 'active' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['active'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'filter' => true, + 'sorting' => true, + 'search' => false, + 'flag' => 12, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'], + ], + ], + 'addPopup' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['addPopup'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'filter' => true, + 'eval' => ['tl_class' => 'w50 m12', 'submitOnChange' => true], + 'sql' => "char(1) NOT NULL default ''", + ], + 'popup' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popup'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.vector', 'getPopups'], + 'eval' => [ + 'mandatory' => false, + 'tl_class' => 'w50', + 'chosen' => true, + 'includeBlankOption' => true, + ], + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'popupContent' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popupContent'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => true, 'rte' => 'tinyMCE', 'helpwizard' => true, 'tl_class' => 'clr'], + 'explanation' => 'insertTags', + 'sql' => 'mediumtext NULL', + ], + 'style' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['style'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.vector', 'getStyles'], + 'eval' => [ + 'mandatory' => false, + 'tl_class' => 'w50', + 'chosen' => true, + 'includeBlankOption' => true, + ], + 'sql' => "int(10) unsigned NOT NULL default '0'", + ], + 'clickable' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['clickable'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => ['tl_class' => 'm12 w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'className' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['className'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => ['mandatory' => false, 'maxlength' => 64, 'tl_class' => 'w50'], + 'sql' => "varchar(64) NOT NULL default ''", + ], + 'coordinates' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['coordinates'], + 'exclude' => true, + 'inputType' => 'text', + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateCoordinates'], + ], + 'wizard' => [ + ['netzmacht.contao_leaflet.listeners.dca.leaflet', 'getGeocoder'], + ], + 'eval' => [ + 'maxlength' => 255, + 'tl_class' => 'long clr', + 'nullIfEmpty' => true, + 'mandatory' => true, + ], + 'sql' => 'varchar(255) NULL', + ], + 'radius' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['radius'], + 'exclude' => true, + 'inputType' => 'text', + 'default' => 5, + 'eval' => ['mandatory' => false, 'maxlength' => 10, 'rgxp' => 'digit', 'tl_class' => 'clr w50'], + 'sql' => "int(10) NOT NULL default '5'", + ], + 'data' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['data'], + 'inputType' => 'textarea', + 'search' => false, + 'eval' => ['mandatory' => true, 'alwaysSave' => true], + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateMultipleCoordinates'], + ], + 'sql' => 'longblob NULL', + ], + 'multiData' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['multiData'], + 'inputType' => 'multiColumnWizard', + 'search' => false, + 'eval' => [ + 'tl_class' => 'leaflet-mcw', + 'mandatory' => true, + 'alwaysSave' => true, + 'flatArray' => true, + 'columnFields' => [ + 'data' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['data'], + 'inputType' => 'textarea', + 'search' => false, + 'eval' => ['alwaysSave' => true, 'style' => 'width:600px'], + ], + ], + ], + 'save_callback' => [ + ['netzmacht.contao_leaflet.listeners.dca.validator', 'validateMultipleCoordinateSets'], + ], + 'sql' => 'longblob NULL', + ], + 'bounds' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['bounds'], + 'exclude' => true, + 'inputType' => 'leaflet_geocode', + 'save_callback' => [], + 'eval' => [ + 'maxlength' => 255, + 'multiple' => true, + 'size' => 2, + 'tl_class' => 'clr', + 'nullIfEmpty' => true, + ], + 'sql' => 'mediumblob NULL', + ], + 'ignoreForBounds' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['ignoreForBounds'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => false, + 'eval' => ['tl_class' => 'w50'], + 'sql' => "char(1) NOT NULL default ''", + ], + 'featureData' => [ + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['featureData'], + 'exclude' => true, + 'inputType' => 'textarea', + 'eval' => [ + 'tl_class' => 'clr lng', + 'allowHtml' => true, + 'style' => 'min-height: 40px;', + 'rte' => 'ace|json', + ], + 'sql' => 'text NULL', + ], + ], +]; diff --git a/src/Bundle/Resources/contao/dca/tl_module.php b/src/Bundle/Resources/contao/dca/tl_module.php new file mode 100644 index 0000000..b4c9dd1 --- /dev/null +++ b/src/Bundle/Resources/contao/dca/tl_module.php @@ -0,0 +1,85 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_DCA']['tl_module']['metapalettes']['leaflet'] = [ + 'type' => ['name', 'type', 'headline'], + 'leaflet' => ['leaflet_map', 'leaflet_mapId', 'leaflet_width', 'leaflet_height', 'leaflet_template'], + 'templates' => [':hide', 'customTpl'], + 'protected' => [':hide', 'protected'], + 'expert' => [':hide', 'guests', 'cssID', 'space'], + 'invisible' => [':hide', 'invisible', 'start', 'start'], +]; + +$GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_map'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_map'], + 'inputType' => 'select', + 'exclude' => true, + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.frontend_integration', 'getMaps'], + 'wizard' => [ + ['netzmacht.contao_leaflet.listeners.dca.frontend_integration', 'getEditMapLink'], + ], + 'eval' => [ + 'tl_class' => 'w50 wizard', + 'chosen' => true, + ], + 'sql' => "int(10) unsigned NOT NULL default '0'", +]; + +$GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_mapId'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_mapId'], + 'inputType' => 'text', + 'exclude' => true, + 'eval' => [ + 'tl_class' => 'w50', + 'chosen' => true, + 'maxlength' => 16, + ], + 'sql' => "varchar(16) NOT NULL default ''", +]; + +$GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_width'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_width'], + 'inputType' => 'inputUnit', + 'options' => ['px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'], + 'search' => false, + 'exclude' => true, + 'eval' => ['rgxp' => 'digit', 'tl_class' => 'clr w50'], + 'sql' => "varchar(64) NOT NULL default ''", +]; + + +$GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_height'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_height'], + 'inputType' => 'inputUnit', + 'options' => ['px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'], + 'search' => false, + 'exclude' => true, + 'eval' => ['rgxp' => 'digit', 'tl_class' => 'w50'], + 'sql' => "varchar(64) NOT NULL default ''", +]; + +$GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_template'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_template'], + 'inputType' => 'select', + 'exclude' => true, + 'options_callback' => ['netzmacht.contao_toolkit.dca.listeners.template_options', 'handleOptionsCallback'], + 'eval' => [ + 'tl_class' => 'w50', + 'chosen' => true, + ], + 'toolkit' => [ + 'template_options' => [ + 'prefix' => 'leaflet_map_js', + ], + ], + 'sql' => "varchar(64) NOT NULL default ''", +]; diff --git a/module/languages/de/leaflet.php b/src/Bundle/Resources/contao/languages/de/leaflet.php similarity index 96% rename from module/languages/de/leaflet.php rename to src/Bundle/Resources/contao/languages/de/leaflet.php index 8bbaeb8..8103170 100644 --- a/module/languages/de/leaflet.php +++ b/src/Bundle/Resources/contao/languages/de/leaflet.php @@ -3,17 +3,18 @@ * Translations are managed using Transifex. To create a new translation * or to help to maintain an existing one, please register at transifex.com. * - * @link http://help.transifex.com/intro/translating.html - * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ + * @link http://help.transifex.com/intro/translating.html + * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ * * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL * - * last-updated: 2016-10-06T15:54:30+02:00 + * last-updated: 2017-10-17T16:04:08+00:00 */ $GLOBALS['TL_LANG']['leaflet']['applyPosition'] = 'Position anwenden'; $GLOBALS['TL_LANG']['leaflet']['invalidAlias'] = 'Ein ungültiger Alias wurde angegeben. Ein Alias darf nicht leer sein, mit einer Zahl beginnen oder Sonderzeichen enthalten (Unterstriche sind erlaubt).'; $GLOBALS['TL_LANG']['leaflet']['invalidCoordinates'] = 'Ungültige Koordinatenwerte vorhanden.'; +$GLOBALS['TL_LANG']['leaflet']['searchPosition'] = 'Standort suchen'; $GLOBALS['TL_LANG']['leaflet_control']['attribution']['0'] = 'Copyright-Leiste'; $GLOBALS['TL_LANG']['leaflet_control']['attribution']['1'] = 'Das Kontrollelement zur Namensnennung erlaubt es, Urheber in einer kleinen Textbox auf der Karte anzuzeigen. Lesen Sie für weitere Details die Leaflet-Dokumentation.'; $GLOBALS['TL_LANG']['leaflet_control']['fullscreen']['0'] = 'Fullscreen-Kontrollelement'; diff --git a/module/languages/de/modules.php b/src/Bundle/Resources/contao/languages/de/modules.php similarity index 91% rename from module/languages/de/modules.php rename to src/Bundle/Resources/contao/languages/de/modules.php index 1e72d97..84f21aa 100644 --- a/module/languages/de/modules.php +++ b/src/Bundle/Resources/contao/languages/de/modules.php @@ -3,8 +3,8 @@ * Translations are managed using Transifex. To create a new translation * or to help to maintain an existing one, please register at transifex.com. * - * @link http://help.transifex.com/intro/translating.html - * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ + * @link http://help.transifex.com/intro/translating.html + * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ * * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL * diff --git a/module/languages/de/tl_content.php b/src/Bundle/Resources/contao/languages/de/tl_content.php similarity index 91% rename from module/languages/de/tl_content.php rename to src/Bundle/Resources/contao/languages/de/tl_content.php index 7d8f63e..5681a37 100644 --- a/module/languages/de/tl_content.php +++ b/src/Bundle/Resources/contao/languages/de/tl_content.php @@ -3,8 +3,8 @@ * Translations are managed using Transifex. To create a new translation * or to help to maintain an existing one, please register at transifex.com. * - * @link http://help.transifex.com/intro/translating.html - * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ + * @link http://help.transifex.com/intro/translating.html + * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ * * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL * diff --git a/module/languages/de/tl_leaflet_control.php b/src/Bundle/Resources/contao/languages/de/tl_leaflet_control.php similarity index 95% rename from module/languages/de/tl_leaflet_control.php rename to src/Bundle/Resources/contao/languages/de/tl_leaflet_control.php index 2b477aa..8dd0c3b 100644 --- a/module/languages/de/tl_leaflet_control.php +++ b/src/Bundle/Resources/contao/languages/de/tl_leaflet_control.php @@ -3,12 +3,12 @@ * Translations are managed using Transifex. To create a new translation * or to help to maintain an existing one, please register at transifex.com. * - * @link http://help.transifex.com/intro/translating.html - * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ + * @link http://help.transifex.com/intro/translating.html + * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ * * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL * - * last-updated: 2016-10-04T13:07:35+02:00 + * last-updated: 2017-10-17T16:04:09+00:00 */ $GLOBALS['TL_LANG']['tl_leaflet_control']['active']['0'] = 'Kontrollelement aktivieren'; @@ -21,6 +21,7 @@ $GLOBALS['TL_LANG']['tl_leaflet_control']['attributions']['1'] = 'Hier kö $GLOBALS['TL_LANG']['tl_leaflet_control']['autoZIndex']['0'] = 'Automatischer Z-Index'; $GLOBALS['TL_LANG']['tl_leaflet_control']['autoZIndex']['1'] = 'Falls aktiviert wird das Kontrollelement zu allen Layern in aufsteigender Reihenfolge einen z-index hinzufügen, damit die Reihenfolge auch beim an- und abschalten von Layern erhalten bleibt.'; $GLOBALS['TL_LANG']['tl_leaflet_control']['base']['0'] = 'Basislayer'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['base']['1'] = 'Basis-Layer werden mit Radio-Buttons umgeschaltet. Beachten Sie, dass alle Basis-Layer als Basis-Layer-Objekte übergeben werden sollten, aber nur ein einziger für die Initialisierung der Karte benutzt werden soll.'; $GLOBALS['TL_LANG']['tl_leaflet_control']['bottomleft']['0'] = 'Links unten'; $GLOBALS['TL_LANG']['tl_leaflet_control']['bottomleft']['1'] = 'Linker unterer Bereich der Karte'; $GLOBALS['TL_LANG']['tl_leaflet_control']['bottomright']['0'] = 'Rechts unten'; diff --git a/module/languages/de/tl_leaflet_icon.php b/src/Bundle/Resources/contao/languages/de/tl_leaflet_icon.php similarity index 88% rename from module/languages/de/tl_leaflet_icon.php rename to src/Bundle/Resources/contao/languages/de/tl_leaflet_icon.php index f25261d..3ff38fa 100644 --- a/module/languages/de/tl_leaflet_icon.php +++ b/src/Bundle/Resources/contao/languages/de/tl_leaflet_icon.php @@ -3,12 +3,12 @@ * Translations are managed using Transifex. To create a new translation * or to help to maintain an existing one, please register at transifex.com. * - * @link http://help.transifex.com/intro/translating.html - * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ + * @link http://help.transifex.com/intro/translating.html + * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ * * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL * - * last-updated: 2016-10-04T13:07:35+02:00 + * last-updated: 2017-10-17T16:04:07+00:00 */ $GLOBALS['TL_LANG']['tl_leaflet_icon']['active']['0'] = 'Aktivieren Sie das Icon.'; @@ -30,6 +30,7 @@ $GLOBALS['TL_LANG']['tl_leaflet_icon']['edit']['1'] = 'Icon ID %s b $GLOBALS['TL_LANG']['tl_leaflet_icon']['icon']['0'] = 'Icon-CSS-Klasse'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['icon']['1'] = 'Icon-CSS-Klasse, beispielsweise fa-envelope'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['iconAnchor']['0'] = 'Icon-Anker'; +$GLOBALS['TL_LANG']['tl_leaflet_icon']['iconAnchor']['1'] = 'Die Koordinaten der "Spitze" des Schattens (relativ zu seiner oberen linken Ecke).'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['iconColor']['0'] = 'Iconfarbe'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['iconColor']['1'] = 'Definieren Sie hier eine Farbe für den Icon-Marker'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['iconImage']['0'] = 'Icon-Bild'; @@ -48,7 +49,10 @@ $GLOBALS['TL_LANG']['tl_leaflet_icon']['popupAnchor']['0'] = 'Popup-Anker' $GLOBALS['TL_LANG']['tl_leaflet_icon']['popupAnchor']['1'] = 'Geben Sie die Koordinaten des Punktes an, von dem aus sich das Popup "öffnet". Die Koordinaten werden relativ zum Anker des Icons benutzt.'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['popups']['0'] = 'Popups verwalten'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['popups']['1'] = 'Popup-Icons verwalten'; +$GLOBALS['TL_LANG']['tl_leaflet_icon']['prefix']['0'] = 'Iconpräfix Klasse'; +$GLOBALS['TL_LANG']['tl_leaflet_icon']['prefix']['1'] = 'Iconpräfix Klasse, z.B. fa'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['shadowAnchor']['0'] = 'Schatten-Anker'; +$GLOBALS['TL_LANG']['tl_leaflet_icon']['shadowAnchor']['1'] = 'Die Koordinaten der "Spitze" des Schattens (relativ zu seiner oberen linken Ecke) (das gleiche wie der Symbol Anker, wenn nicht angegeben).'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['shadowImage']['0'] = 'Schatten-Bild'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['shadowImage']['1'] = 'Wählen Sie ein Bild für den Schatten aus.'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['shadowRetinaImage']['0'] = 'Retina-Schattenbild'; diff --git a/module/languages/de/tl_leaflet_layer.php b/src/Bundle/Resources/contao/languages/de/tl_leaflet_layer.php similarity index 98% rename from module/languages/de/tl_leaflet_layer.php rename to src/Bundle/Resources/contao/languages/de/tl_leaflet_layer.php index 044f407..0815d93 100644 --- a/module/languages/de/tl_leaflet_layer.php +++ b/src/Bundle/Resources/contao/languages/de/tl_leaflet_layer.php @@ -3,8 +3,8 @@ * Translations are managed using Transifex. To create a new translation * or to help to maintain an existing one, please register at transifex.com. * - * @link http://help.transifex.com/intro/translating.html - * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ + * @link http://help.transifex.com/intro/translating.html + * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ * * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL * diff --git a/module/languages/de/tl_leaflet_map.php b/src/Bundle/Resources/contao/languages/de/tl_leaflet_map.php similarity index 93% rename from module/languages/de/tl_leaflet_map.php rename to src/Bundle/Resources/contao/languages/de/tl_leaflet_map.php index 65f5080..52d31c2 100644 --- a/module/languages/de/tl_leaflet_map.php +++ b/src/Bundle/Resources/contao/languages/de/tl_leaflet_map.php @@ -3,16 +3,17 @@ * Translations are managed using Transifex. To create a new translation * or to help to maintain an existing one, please register at transifex.com. * - * @link http://help.transifex.com/intro/translating.html - * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ + * @link http://help.transifex.com/intro/translating.html + * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ * * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL * - * last-updated: 2016-10-06T15:54:30+02:00 + * last-updated: 2017-10-17T16:04:07+00:00 */ $GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBounds']['0'] = 'Grenzen festlegen'; $GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBounds']['1'] = 'Falls aktiviert passt sich die karten an den Bereich der Datenlayer an, für die Auswirkungen auf die Kartengrenzen zugelassen sind.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions']['deferred']['0'] = 'Nach dem Laden des verzögerten Features'; $GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions']['deferred']['1'] = 'Bestimmt ob die Kartengrenzen neu berechnet werden wenn ein Feature verzögert geladen wird.'; $GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions']['load']['0'] = 'bei Karteninitialisierung'; $GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions']['load']['1'] = 'Grenzen berechnen, wenn die Karte initialisiert wird. Alle statischen und bereits geladenen Features werden mit einbezogen.'; @@ -23,6 +24,7 @@ $GLOBALS['TL_LANG']['tl_leaflet_map']['alias']['1'] = $GLOBALS['TL_LANG']['tl_leaflet_map']['behaviour_legend'] = 'Verhalten'; $GLOBALS['TL_LANG']['tl_leaflet_map']['bounceAtZoomLimits']['0'] = 'Zurückfedern bei Erreichen des Zoom-Limits'; $GLOBALS['TL_LANG']['tl_leaflet_map']['bounceAtZoomLimits']['1'] = 'Deaktivieren Sie diese Einstellung, falls Sie verhindern möchten, dass außerhalb liegende Elemente der Karte beim Zoomen über die festgelegten minimalen / maximalen Zoomstufen hinaus angezeigt werden wenn mit zwei Fingern gezoomt wird.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['boundsPadding']['1'] = 'Padding wird verwendet, um Grenzen zu setzen. Verwenden Sie kommagetrennte Werte. Wenn 2 Werte angegeben werden, ist die Padding-Option eingestellt. Wenn 4 Werte angegeben werden, ist paddingTopLeft und paddingBottomRight gesetzt.'; $GLOBALS['TL_LANG']['tl_leaflet_map']['boxZoom']['0'] = 'Zoomen durch Markierung'; $GLOBALS['TL_LANG']['tl_leaflet_map']['boxZoom']['1'] = 'legen Sie fest ob der Kartenausschnitt vergrößert werden kann indem Benutzer die Maus mit gedrückter Umschalttaste über die Karte ziehen.'; $GLOBALS['TL_LANG']['tl_leaflet_map']['cache']['0'] = 'Cache aktivieren'; @@ -62,6 +64,8 @@ $GLOBALS['TL_LANG']['tl_leaflet_map']['layers']['1'] = $GLOBALS['TL_LANG']['tl_leaflet_map']['layers_legend'] = 'Standardlayer'; $GLOBALS['TL_LANG']['tl_leaflet_map']['locate']['0'] = 'Nutzerposition ermitteln'; $GLOBALS['TL_LANG']['tl_leaflet_map']['locate']['1'] = 'Initialer Kartenzoom. Diese Funktion versucht, den Benutzer mittels Geolocation-API zu orten.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaxZoom']['0'] = 'Lokalisieren Sie den maximalen Zoom'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaxZoom']['1'] = 'Max-Zoom bei der Aktualisierung der Kartenansicht.'; $GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaximumAge']['0'] = 'Maximale Gültigkeit der Benutzerposition'; $GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaximumAge']['1'] = 'Maximales Alter der Daten zum Aufenthaltsort in Millisekunden. Ansonsten wird der zwischengespeicherte Wert benutzt.'; $GLOBALS['TL_LANG']['tl_leaflet_map']['locateSetView']['0'] = 'Kartenmitte aktualisieren'; diff --git a/module/languages/de/tl_leaflet_marker.php b/src/Bundle/Resources/contao/languages/de/tl_leaflet_marker.php similarity index 87% rename from module/languages/de/tl_leaflet_marker.php rename to src/Bundle/Resources/contao/languages/de/tl_leaflet_marker.php index d98e0bc..f3fbfcf 100644 --- a/module/languages/de/tl_leaflet_marker.php +++ b/src/Bundle/Resources/contao/languages/de/tl_leaflet_marker.php @@ -3,12 +3,12 @@ * Translations are managed using Transifex. To create a new translation * or to help to maintain an existing one, please register at transifex.com. * - * @link http://help.transifex.com/intro/translating.html - * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ + * @link http://help.transifex.com/intro/translating.html + * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ * * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL * - * last-updated: 2016-10-06T15:54:30+02:00 + * last-updated: 2017-10-17T16:04:07+00:00 */ $GLOBALS['TL_LANG']['tl_leaflet_marker']['active']['0'] = 'Marker aktivieren'; @@ -44,6 +44,7 @@ $GLOBALS['TL_LANG']['tl_leaflet_marker']['icon']['1'] = 'Individuelle $GLOBALS['TL_LANG']['tl_leaflet_marker']['icons']['0'] = 'Icons verwalten'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['icons']['1'] = 'Marker-Icons verwalten'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['ignoreForBounds']['0'] = 'Von Grenzen-Berechnung ausschließen.'; +$GLOBALS['TL_LANG']['tl_leaflet_marker']['ignoreForBounds']['1'] = 'Fügen Sie dieses Element nicht in die Berechnung ein.'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['keyboard']['0'] = 'Tatstaturnavigation'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['keyboard']['1'] = 'Legen Sie fest ob der Marker über die Tabulatortaste erreicht und mit der Eingabetaste geklickt werden kann.'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['new']['0'] = 'Marker erstellen'; @@ -62,5 +63,7 @@ $GLOBALS['TL_LANG']['tl_leaflet_marker']['title_legend'] = 'Titel und Ty $GLOBALS['TL_LANG']['tl_leaflet_marker']['toggle']['0'] = 'Aktivierung umschalten'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['toggle']['1'] = 'Aktivierung von Marker ID %s umschalten'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['tooltip']['0'] = 'Tooltip'; +$GLOBALS['TL_LANG']['tl_leaflet_marker']['tooltip']['1'] = 'Marker-Tooltip als Titelattribut gerendert.'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['zIndexOffset']['0'] = 'Z-Index-Offset'; +$GLOBALS['TL_LANG']['tl_leaflet_marker']['zIndexOffset']['1'] = 'Standardmäßig werden Markerbilder z-Index automatisch auf Grundlage der geografischen Breite festgelegt. Verwenden Sie diese Option, wenn Sie den Marker über allen anderen (oder darunter) platzieren möchten und einen hohen Wert wie 1000 (bzw. einen hohen negativen Wert) angeben.'; diff --git a/module/languages/de/tl_leaflet_popup.php b/src/Bundle/Resources/contao/languages/de/tl_leaflet_popup.php similarity index 97% rename from module/languages/de/tl_leaflet_popup.php rename to src/Bundle/Resources/contao/languages/de/tl_leaflet_popup.php index e7e0249..e3f782b 100644 --- a/module/languages/de/tl_leaflet_popup.php +++ b/src/Bundle/Resources/contao/languages/de/tl_leaflet_popup.php @@ -3,8 +3,8 @@ * Translations are managed using Transifex. To create a new translation * or to help to maintain an existing one, please register at transifex.com. * - * @link http://help.transifex.com/intro/translating.html - * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ + * @link http://help.transifex.com/intro/translating.html + * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ * * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL * diff --git a/module/languages/de/tl_leaflet_style.php b/src/Bundle/Resources/contao/languages/de/tl_leaflet_style.php similarity index 75% rename from module/languages/de/tl_leaflet_style.php rename to src/Bundle/Resources/contao/languages/de/tl_leaflet_style.php index 32a1b0d..4a771dc 100644 --- a/module/languages/de/tl_leaflet_style.php +++ b/src/Bundle/Resources/contao/languages/de/tl_leaflet_style.php @@ -3,22 +3,24 @@ * Translations are managed using Transifex. To create a new translation * or to help to maintain an existing one, please register at transifex.com. * - * @link http://help.transifex.com/intro/translating.html - * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ + * @link http://help.transifex.com/intro/translating.html + * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ * * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL * - * last-updated: 2016-10-04T13:07:35+02:00 + * last-updated: 2017-10-17T16:04:07+00:00 */ $GLOBALS['TL_LANG']['tl_leaflet_style']['active_legend'] = 'Aktivierung'; $GLOBALS['TL_LANG']['tl_leaflet_style']['alias']['0'] = 'Alias'; $GLOBALS['TL_LANG']['tl_leaflet_style']['alias']['1'] = 'Alias des Stils.'; $GLOBALS['TL_LANG']['tl_leaflet_style']['color']['0'] = 'Linienfarbe'; +$GLOBALS['TL_LANG']['tl_leaflet_style']['color']['1'] = 'Eigene Linienfarbe. Wenn dieses Feld leer ist wird die Standard-Linienfarbe benutzt. Erwartete Werte sind vollständige Hex-Codes (mit #).'; $GLOBALS['TL_LANG']['tl_leaflet_style']['config_legend'] = 'Konfiguration'; $GLOBALS['TL_LANG']['tl_leaflet_style']['copy']['0'] = 'Stil kopieren'; $GLOBALS['TL_LANG']['tl_leaflet_style']['copy']['1'] = 'Stil ID %s kopieren'; $GLOBALS['TL_LANG']['tl_leaflet_style']['dashArray']['0'] = 'Linienmuster'; +$GLOBALS['TL_LANG']['tl_leaflet_style']['dashArray']['1'] = 'Geben Sie einen String ein, der für die Linienart benutzt werden soll.'; $GLOBALS['TL_LANG']['tl_leaflet_style']['delete']['0'] = 'Stil löschen'; $GLOBALS['TL_LANG']['tl_leaflet_style']['delete']['1'] = 'Stil ID %s löschen'; $GLOBALS['TL_LANG']['tl_leaflet_style']['edit']['0'] = 'Stil bearbeiten'; @@ -26,6 +28,7 @@ $GLOBALS['TL_LANG']['tl_leaflet_style']['edit']['1'] = 'Stil ID %s bearbe $GLOBALS['TL_LANG']['tl_leaflet_style']['fill']['0'] = 'Vektor füllen'; $GLOBALS['TL_LANG']['tl_leaflet_style']['fill']['1'] = 'Bestimmen Sie, ob der Pfad gefüllt dargestellt werden soll.'; $GLOBALS['TL_LANG']['tl_leaflet_style']['fillColor']['0'] = 'Füllfarbe'; +$GLOBALS['TL_LANG']['tl_leaflet_style']['fillColor']['1'] = 'Eigene Linienfarbe. Wenn dieses Feld leer ist wird die Standard-Linienfarbe benutzt. Erwartete Werte sind vollständige Hex-Codes (mit #).'; $GLOBALS['TL_LANG']['tl_leaflet_style']['fillOpacity']['0'] = 'Transparenz der Füllung'; $GLOBALS['TL_LANG']['tl_leaflet_style']['fillOpacity']['1'] = 'Die Transparenz der Füllung kann einen Wert zwischen 0 und 1 annehmen.'; $GLOBALS['TL_LANG']['tl_leaflet_style']['icons']['0'] = 'Icons verwalten'; @@ -35,6 +38,7 @@ $GLOBALS['TL_LANG']['tl_leaflet_style']['layersBtn']['1'] = 'Leaflet-Layer ver $GLOBALS['TL_LANG']['tl_leaflet_style']['lineCap']['0'] = 'Linienenden'; $GLOBALS['TL_LANG']['tl_leaflet_style']['lineCap']['1'] = 'Geben Sie einen Wert ein, der für die Enden der Linie benutzt werden soll,'; $GLOBALS['TL_LANG']['tl_leaflet_style']['lineJoin']['0'] = 'Linienverbindung'; +$GLOBALS['TL_LANG']['tl_leaflet_style']['lineJoin']['1'] = 'Geben Sie einen String ein, der die Form der Ecken definiert.'; $GLOBALS['TL_LANG']['tl_leaflet_style']['new']['0'] = 'Stil erstellen'; $GLOBALS['TL_LANG']['tl_leaflet_style']['new']['1'] = 'Neuen Stil erstellen'; $GLOBALS['TL_LANG']['tl_leaflet_style']['opacity']['0'] = 'Linientransparenz'; @@ -44,6 +48,7 @@ $GLOBALS['TL_LANG']['tl_leaflet_style']['popups']['1'] = 'Popup-Icons verwa $GLOBALS['TL_LANG']['tl_leaflet_style']['show']['0'] = 'Details anzeigen'; $GLOBALS['TL_LANG']['tl_leaflet_style']['show']['1'] = 'Details des Stils ID %s anzeigen'; $GLOBALS['TL_LANG']['tl_leaflet_style']['stroke']['0'] = 'Linie ziehen'; +$GLOBALS['TL_LANG']['tl_leaflet_style']['stroke']['1'] = 'Legt fest, ob eine Linie entlang des Pfades dargestellt werden soll. Deaktivieren Sie diese Einstellung um die Grenzen von Polygonen oder Kreisen unsichtbar zu schalten.'; $GLOBALS['TL_LANG']['tl_leaflet_style']['title']['0'] = 'Titel'; $GLOBALS['TL_LANG']['tl_leaflet_style']['title']['1'] = 'Titel des Stils.'; $GLOBALS['TL_LANG']['tl_leaflet_style']['title_legend'] = 'Titel und Typ'; diff --git a/module/languages/de/tl_leaflet_vector.php b/src/Bundle/Resources/contao/languages/de/tl_leaflet_vector.php similarity index 97% rename from module/languages/de/tl_leaflet_vector.php rename to src/Bundle/Resources/contao/languages/de/tl_leaflet_vector.php index 81a76ad..5d1424e 100644 --- a/module/languages/de/tl_leaflet_vector.php +++ b/src/Bundle/Resources/contao/languages/de/tl_leaflet_vector.php @@ -3,8 +3,8 @@ * Translations are managed using Transifex. To create a new translation * or to help to maintain an existing one, please register at transifex.com. * - * @link http://help.transifex.com/intro/translating.html - * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ + * @link http://help.transifex.com/intro/translating.html + * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ * * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL * diff --git a/module/languages/de/tl_module.php b/src/Bundle/Resources/contao/languages/de/tl_module.php similarity index 91% rename from module/languages/de/tl_module.php rename to src/Bundle/Resources/contao/languages/de/tl_module.php index 4cbe8f3..2e4f5f4 100644 --- a/module/languages/de/tl_module.php +++ b/src/Bundle/Resources/contao/languages/de/tl_module.php @@ -3,8 +3,8 @@ * Translations are managed using Transifex. To create a new translation * or to help to maintain an existing one, please register at transifex.com. * - * @link http://help.transifex.com/intro/translating.html - * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ + * @link http://help.transifex.com/intro/translating.html + * @link https://www.transifex.com/projects/p/contao-leaflet-maps/language/de/ * * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL * diff --git a/module/languages/en/leaflet.php b/src/Bundle/Resources/contao/languages/en/leaflet.php similarity index 92% rename from module/languages/en/leaflet.php rename to src/Bundle/Resources/contao/languages/en/leaflet.php index bcd3324..a268eec 100644 --- a/module/languages/en/leaflet.php +++ b/src/Bundle/Resources/contao/languages/en/leaflet.php @@ -1,5 +1,15 @@ + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + $GLOBALS['TL_LANG']['leaflet_control']['zoom'][0] = 'Zoom control'; $GLOBALS['TL_LANG']['leaflet_control']['zoom'][1] = 'A basic zoom control. For more details read the Leaflet documentation.'; $GLOBALS['TL_LANG']['leaflet_control']['attribution'][0] = 'Attribution control'; @@ -29,6 +39,8 @@ $GLOBALS['TL_LANG']['leaflet_layer']['tile'][0] = 'Tile layer'; $GLOBALS['TL_LANG']['leaflet_layer']['tile'][1] = 'Tile layer with full config options.'; $GLOBALS['TL_LANG']['leaflet_layer']['overpass'][0] = 'Overpass API'; $GLOBALS['TL_LANG']['leaflet_layer']['overpass'][1] = 'Overpass API data layer.'; +$GLOBALS['TL_LANG']['leaflet_layer']['file'][0] = 'File'; +$GLOBALS['TL_LANG']['leaflet_layer']['file'][1] = 'Geo data from a file (gpx,kml,wkt).'; $GLOBALS['TL_LANG']['leaflet_vector']['polyline'][0] = 'Polyline'; $GLOBALS['TL_LANG']['leaflet_vector']['polyline'][1] = 'Polyline overlay. For more details read the Leaflet documentation.'; diff --git a/module/languages/en/modules.php b/src/Bundle/Resources/contao/languages/en/modules.php similarity index 58% rename from module/languages/en/modules.php rename to src/Bundle/Resources/contao/languages/en/modules.php index 178e11a..f2b1520 100644 --- a/module/languages/en/modules.php +++ b/src/Bundle/Resources/contao/languages/en/modules.php @@ -1,5 +1,15 @@ + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + $GLOBALS['TL_LANG']['MOD']['leaflet'][0] = 'Leaflet'; $GLOBALS['TL_LANG']['MOD']['leaflet'][1] = 'Leaflet extension for Contao'; $GLOBALS['TL_LANG']['MOD']['leaflet_map'][0] = 'Leaflet Maps'; @@ -15,8 +25,8 @@ $GLOBALS['TL_LANG']['MOD']['tl_leaflet_icon'] = 'Icons'; $GLOBALS['TL_LANG']['MOD']['tl_leaflet_marker'] = 'Markers'; $GLOBALS['TL_LANG']['MOD']['tl_leaflet_control'] = 'Controls'; -$GLOBALS['TL_LANG']['FMD']['leaflet'][0] = 'Leaflet Map'; -$GLOBALS['TL_LANG']['FMD']['leaflet'][1] = 'Integrate leaflet map as frontend module.'; +$GLOBALS['TL_LANG']['FMD']['leaflet'][0] = 'Leaflet Map'; +$GLOBALS['TL_LANG']['FMD']['leaflet'][1] = 'Integrate leaflet map as frontend module.'; -$GLOBALS['TL_LANG']['CTE']['leaflet'][0] = 'Leaflet Map'; -$GLOBALS['TL_LANG']['CTE']['leaflet'][1] = 'Integrate leaflet map as content element.'; +$GLOBALS['TL_LANG']['CTE']['leaflet'][0] = 'Leaflet Map'; +$GLOBALS['TL_LANG']['CTE']['leaflet'][1] = 'Integrate leaflet map as content element.'; diff --git a/module/languages/en/tl_content.php b/src/Bundle/Resources/contao/languages/en/tl_content.php similarity index 76% rename from module/languages/en/tl_content.php rename to src/Bundle/Resources/contao/languages/en/tl_content.php index 6ebd1f0..6adc2ac 100644 --- a/module/languages/en/tl_content.php +++ b/src/Bundle/Resources/contao/languages/en/tl_content.php @@ -1,5 +1,15 @@ + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + $GLOBALS['TL_LANG']['tl_content']['leaflet_legend'] = 'Leaflet map configuration'; $GLOBALS['TL_LANG']['tl_content']['leaflet_map'][0] = 'Leaflet Map'; $GLOBALS['TL_LANG']['tl_content']['leaflet_map'][1] = 'Choose a Leaflet Map'; diff --git a/module/languages/en/tl_leaflet_control.php b/src/Bundle/Resources/contao/languages/en/tl_leaflet_control.php similarity index 94% rename from module/languages/en/tl_leaflet_control.php rename to src/Bundle/Resources/contao/languages/en/tl_leaflet_control.php index 358eb6f..c295e58 100644 --- a/module/languages/en/tl_leaflet_control.php +++ b/src/Bundle/Resources/contao/languages/en/tl_leaflet_control.php @@ -1,5 +1,15 @@ + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + $GLOBALS['TL_LANG']['tl_leaflet_control']['name_legend'] = 'Title and type'; $GLOBALS['TL_LANG']['tl_leaflet_control']['config_legend'] = 'Configuration'; $GLOBALS['TL_LANG']['tl_leaflet_control']['active_legend'] = 'Activation'; @@ -89,5 +99,5 @@ $GLOBALS['TL_LANG']['tl_leaflet_control']['topright'][1] = 'Top right of the $GLOBALS['TL_LANG']['tl_leaflet_control']['base'][0] = 'Base layer'; $GLOBALS['TL_LANG']['tl_leaflet_control']['base'][1] = 'Base layers will be switched with radio buttons. Note that all base layers should be passed in the base layers object, but only one should be added to the map during map instantiation'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['overlay'][0] = 'Overlay'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['overlay'][1] = 'Overlays will be switched with checkboxes.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['overlay'][0] = 'Overlay'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['overlay'][1] = 'Overlays will be switched with checkboxes.'; diff --git a/module/languages/en/tl_leaflet_icon.php b/src/Bundle/Resources/contao/languages/en/tl_leaflet_icon.php similarity index 94% rename from module/languages/en/tl_leaflet_icon.php rename to src/Bundle/Resources/contao/languages/en/tl_leaflet_icon.php index cd63188..086b1d6 100644 --- a/module/languages/en/tl_leaflet_icon.php +++ b/src/Bundle/Resources/contao/languages/en/tl_leaflet_icon.php @@ -1,5 +1,15 @@ + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + $GLOBALS['TL_LANG']['tl_leaflet_icon']['title_legend'] = 'Title'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['config_legend'] = 'Configuration'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['shadow_legend'] = 'Shadow'; diff --git a/module/languages/en/tl_leaflet_layer.php b/src/Bundle/Resources/contao/languages/en/tl_leaflet_layer.php similarity index 87% rename from module/languages/en/tl_leaflet_layer.php rename to src/Bundle/Resources/contao/languages/en/tl_leaflet_layer.php index 08c9cbd..19935ee 100644 --- a/module/languages/en/tl_leaflet_layer.php +++ b/src/Bundle/Resources/contao/languages/en/tl_leaflet_layer.php @@ -1,5 +1,15 @@ + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + $GLOBALS['TL_LANG']['tl_leaflet_layer']['title_legend'] = 'Layer'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['active_legend'] = 'Activation'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['expert_legend'] = 'Expert settings'; @@ -135,12 +145,27 @@ $GLOBALS['TL_LANG']['tl_leaflet_layer']['amenity'][0] = 'Amen $GLOBALS['TL_LANG']['tl_leaflet_layer']['amenity'][1] = 'OSM amenity.'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['amenityIcon'][1] = 'Icon'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['amenityIcon'][0] = 'Icon style'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormat'][0] = 'File formats'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormat'][1] = 'Choose which file format is used.'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['file'][0] = 'File'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['file'][1] = 'Choose a file containing geodata. Supported formats are: %s.'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['layer'][0] = 'Layer group'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['layer'][1] = 'Basic layer group.
See http://leafletjs.com/reference.html#layergroup'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['feature'][0] = 'Feature group'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['feature'][1] = 'Extended layer group with events and popup support.
See http://leafletjs.com/reference.html#featuregroup'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['gpx'][0] = 'GPX'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['gpx'][1] = 'GPS Exchange format. Read the documentation for more information.'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['kml'][0] = 'KML'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['kml'][1] = 'Keyhole Markup Language. Read the documentation for more information.'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['wkt'][0] = 'WKT'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['wkt'][1] = 'Well-known text Read the documentation for more information.'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['topojson'][0] = 'TopoJSON'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['topojson'][1] = 'TopoJSON is a topological geospatial data interchange format based on GeoJSON. Read the documentation for more information.'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['geojson'][0] = 'GeoJSON'; +$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['geojson'][1] = 'GeoJSON is a format for encoding a variety of geographic data structures. Read the documentation for more information.'; + $GLOBALS['TL_LANG']['tl_leaflet_layer']['pasteinto'][1] = 'Paste into layer %s'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['pasteafter'][1] = 'Paste after layer %s'; diff --git a/src/Bundle/Resources/contao/languages/en/tl_leaflet_map.php b/src/Bundle/Resources/contao/languages/en/tl_leaflet_map.php new file mode 100644 index 0000000..e1cc78c --- /dev/null +++ b/src/Bundle/Resources/contao/languages/en/tl_leaflet_map.php @@ -0,0 +1,117 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +$GLOBALS['TL_LANG']['tl_leaflet_map']['title_legend'] = 'Title'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['interaction_legend'] = 'Interaction controls'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoom_legend'] = 'Center and zoom'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locate_legend'] = 'Locate user position'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['layers_legend'] = 'Default layers'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['expert_legend'] = 'Expert settings'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['behaviour_legend'] = 'Behaviour'; + +$GLOBALS['TL_LANG']['tl_leaflet_map']['new'][0] = 'Create map'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['new'][1] = 'Create new map'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['edit'][0] = 'Edit map'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['edit'][1] = 'Edit map ID %s'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['copy'][0] = 'Copy map'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['copy'][1] = 'Copy map ID %s'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['controls'][0] = 'Manage controls'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['controls'][1] = 'Manage controls of map ID %s'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['delete'][0] = 'Delete map'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['delete'][1] = 'Delete map ID %s'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['show'][0] = 'Show details'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['show'][1] = 'Show map ID %s details'; + +$GLOBALS['TL_LANG']['tl_leaflet_map']['title'][0] = 'Title'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['title'][1] = 'Title of the map.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['alias'][0] = 'Alias'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['alias'][1] = 'Alias of the map.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['center'][0] = 'Center'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['center'][1] = 'Initial geographical center of the map. Comma separated coordinates.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['dragging'][0] = 'Dragging'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['dragging'][1] = 'Whether the map be draggable with mouse/touch or not.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['touchZoom'][0] = 'Touch zoom'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['touchZoom'][1] = 'Whether the map can be zoomed by touch-dragging with two fingers.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['scrollWheelZoom'][0] = 'Scroll wheel zoom'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['scrollWheelZoom'][1] = 'Whether the map can be zoomed by using the mouse wheel.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['doubleClickZoom'][0] = 'Double click zoom'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['doubleClickZoom'][1] = 'Whether the map can be zoomed in by double clicking on it and zoomed out by double clicking while holding shift.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['boxZoom'][0] = 'Box zoom'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['boxZoom'][1] = 'Whether the map can be zoomed to a rectangular area specified by dragging the mouse while pressing shift.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['tap'][0] = 'Instant taps'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['tap'][1] = 'Enables mobile hacks for supporting instant taps.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['trackResize'][0] = 'Track window resize'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['trackResize'][1] = 'Whether the map automatically handles browser window resize to update itself.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['closeOnClick'][0] = 'Close popup on click'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['closeOnClick'][1] = 'Disable if you don\'t want popups to close when user clicks the map'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboard'][0] = 'Keyboard navigation'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboard'][1] = 'Makes the map focusable and allows users to navigate the map with keyboard arrows and +/- keys'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardPanOffset'][0] = 'Keyboard pan offset'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardPanOffset'][1] = 'Amount of pixels to pan when pressing an arrow key.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardZoomOffset'][0] = 'Keyboard zoom offset'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardZoomOffset'][1] = 'Number of zoom levels to change when pressing + or - key.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoom'][0] = 'Zoom level'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoom'][1] = 'Initial map zoom.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['minZoom'][0] = 'Minimum zoom level'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['minZoom'][1] = 'Minimum zoom level of the map. Overrides any minZoom set on map layers.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['maxZoom'][0] = 'Maximum zoom level'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['maxZoom'][1] = 'Maximum zoom level of the map. This overrides any maxZoom set on map layers.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomSnap'][0] = 'Zoom snap'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomSnap'][1] = 'Forces the map\'s zoom level to always be a multiple of the number. Default is 1.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomDelta'][0] = 'Zoom delta'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomDelta'][1] = 'Controls how much the map\'s zoom level will change after zoom in or zoom out.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomControl'][0] = 'Add default zoom control'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomControl'][1] = 'Whether the zoom control is added to the map by default.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['bounceAtZoomLimits'][0] = 'Bounce at zoom limits'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['bounceAtZoomLimits'][1] = 'Disable if you don\'t want the map to zoom beyond min/max zoom and then bounce back when pinch-zooming'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['options'][0] = 'Extra options'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['options'][1] = 'Add extra map options as valid json. See http://leafletjs.com/reference.html#map-options'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustZoomExtra'][0] = 'Adjust extra zoom settings'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustZoomExtra'][1] = 'Enable if you want to adjust minimum and maximum zoom as well'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['layers'][0] = 'Default layers'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['layers'][1] = 'Inital visible layers of the map. For optional layers use the layers control.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBounds'][0] = 'Adjust bounds'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBounds'][1] = 'If enabled the map will fit into bounds of data layers which are marked to affect the map bounds.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locate'][0] = 'Locate user position'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locate'][1] = 'Initial map zoom.Tries to locate the user using the Geolocation API.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locateWatch'][0] = 'Watch continuously'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locateWatch'][1] = 'If true, starts continous watching of location changes '; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locateSetView'][0] = 'Update map center'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locateSetView'][1] = 'If enabled, automatically sets the map view to the user location. Otherwise only the locationfound event is triggered.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaxZoom'][0] = 'Locate max zoom'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaxZoom'][1] = 'Max zoom when setting updating map view.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locateTimeout'][0] = 'Locate timeout'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locateTimeout'][1] = 'Number of milliseconds to wait for a response from geolocation.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['enableHighAccuracy'][0] = 'High accuracy'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['enableHighAccuracy'][1] = 'Enables high accuracy, see description in the W3C spec.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaximumAge'][0] = 'Locate maximum age'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['locateMaximumAge'][1] = 'Maximum age of detected location in milliseconds. Use cached value if time has not passed.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['dynamicLoad'][0] = 'Load data dynamically in bounds'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['dynamicLoad'][1] = 'If enabled the map requests data from the layers for the current bounds only and make a new request if bounds has changed.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['boundsPadding'][0] = 'Bounds padding'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['boundsPadding'][1] = 'Padding being used then applying bounds. Use comma separated values. If 2 values are given the padding option is set. If 4 values are given paddingTopLeft and paddingBottomRight is set.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['cache'][0] = 'Enable cache'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['cache'][1] = 'If enabled the generated map javascript is cached.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['cacheLifeTime'][0] = 'Cache lifetime'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['cacheLifeTime'][1] = 'Indicates how long a cache entry is valid in seconds.'; + +$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions']['load'][0] = 'At map initialization'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions']['load'][1] = 'Calculate bounds when the map is initialized. All static and already loaded deferred featured are included.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions']['deferred'][0] = 'After loading deferred feature'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustBoundsOptions']['deferred'][1] = 'Recalculate bounds when a deferred feature is load.'; + +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'][''][0] = 'Disable'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'][''][1] = 'Disable zoom function.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['1'][0] = 'Enable'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['1'][1] = 'Enable zoom function.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['center'][0] = 'Center'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['center'][1] = 'If passed \'center\', it will zoom to the center of the view regardless of where the mouse was.'; diff --git a/module/languages/en/tl_leaflet_marker.php b/src/Bundle/Resources/contao/languages/en/tl_leaflet_marker.php similarity index 92% rename from module/languages/en/tl_leaflet_marker.php rename to src/Bundle/Resources/contao/languages/en/tl_leaflet_marker.php index fde43f2..03e0398 100644 --- a/module/languages/en/tl_leaflet_marker.php +++ b/src/Bundle/Resources/contao/languages/en/tl_leaflet_marker.php @@ -1,10 +1,20 @@ + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + $GLOBALS['TL_LANG']['tl_leaflet_marker']['title_legend'] = 'Title and type'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['content_legend'] = 'Content'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['config_legend'] = 'Configuration'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['active_legend'] = 'Activation'; -$GLOBALS['TL_LANG']['tl_leaflet_marker']['expert_legend'] = 'Expert settings'; +$GLOBALS['TL_LANG']['tl_leaflet_marker']['expert_legend'] = 'Expert settings'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['new'][0] = 'Create marker'; diff --git a/module/languages/en/tl_leaflet_popup.php b/src/Bundle/Resources/contao/languages/en/tl_leaflet_popup.php similarity index 93% rename from module/languages/en/tl_leaflet_popup.php rename to src/Bundle/Resources/contao/languages/en/tl_leaflet_popup.php index a4af8c7..a2bc878 100644 --- a/module/languages/en/tl_leaflet_popup.php +++ b/src/Bundle/Resources/contao/languages/en/tl_leaflet_popup.php @@ -1,5 +1,15 @@ + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + $GLOBALS['TL_LANG']['tl_leaflet_popup']['title_legend'] = 'Title'; $GLOBALS['TL_LANG']['tl_leaflet_popup']['config_legend'] = 'Configuration'; $GLOBALS['TL_LANG']['tl_leaflet_popup']['size_legend'] = 'Popup size'; diff --git a/module/languages/en/tl_leaflet_style.php b/src/Bundle/Resources/contao/languages/en/tl_leaflet_style.php similarity index 93% rename from module/languages/en/tl_leaflet_style.php rename to src/Bundle/Resources/contao/languages/en/tl_leaflet_style.php index 44f7592..d360310 100644 --- a/module/languages/en/tl_leaflet_style.php +++ b/src/Bundle/Resources/contao/languages/en/tl_leaflet_style.php @@ -1,5 +1,15 @@ + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + $GLOBALS['TL_LANG']['tl_leaflet_style']['title_legend'] = 'Title and type'; $GLOBALS['TL_LANG']['tl_leaflet_style']['active_legend'] = 'Activation'; $GLOBALS['TL_LANG']['tl_leaflet_style']['config_legend'] = 'Configuration'; diff --git a/module/languages/en/tl_leaflet_vector.php b/src/Bundle/Resources/contao/languages/en/tl_leaflet_vector.php similarity index 93% rename from module/languages/en/tl_leaflet_vector.php rename to src/Bundle/Resources/contao/languages/en/tl_leaflet_vector.php index c89189f..5244899 100644 --- a/module/languages/en/tl_leaflet_vector.php +++ b/src/Bundle/Resources/contao/languages/en/tl_leaflet_vector.php @@ -1,11 +1,21 @@ + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + $GLOBALS['TL_LANG']['tl_leaflet_vector']['title_legend'] = 'Title and type'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['active_legend'] = 'Activation'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['config_legend'] = 'Configuration'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['data_legend'] = 'Vector data'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['popup_legend'] = 'Popup'; -$GLOBALS['TL_LANG']['tl_leaflet_vector']['expert_legend'] = 'Expert settings'; +$GLOBALS['TL_LANG']['tl_leaflet_vector']['expert_legend'] = 'Expert settings'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['new'][0] = 'Create vector'; diff --git a/module/languages/en/tl_module.php b/src/Bundle/Resources/contao/languages/en/tl_module.php similarity index 76% rename from module/languages/en/tl_module.php rename to src/Bundle/Resources/contao/languages/en/tl_module.php index a81965e..9949922 100644 --- a/module/languages/en/tl_module.php +++ b/src/Bundle/Resources/contao/languages/en/tl_module.php @@ -1,5 +1,15 @@ + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + $GLOBALS['TL_LANG']['tl_module']['leaflet_legend'] = 'Leaflet map configuration'; $GLOBALS['TL_LANG']['tl_module']['leaflet_map'][0] = 'Leaflet Map'; $GLOBALS['TL_LANG']['tl_module']['leaflet_map'][1] = 'Choose a Leaflet Map'; diff --git a/module/assets/.htaccess b/src/Bundle/Resources/contao/public/.htaccess similarity index 100% rename from module/assets/.htaccess rename to src/Bundle/Resources/contao/public/.htaccess diff --git a/src/Bundle/Resources/contao/templates/be_leaflet_about.html5 b/src/Bundle/Resources/contao/templates/be_leaflet_about.html5 new file mode 100644 index 0000000..dfa1178 --- /dev/null +++ b/src/Bundle/Resources/contao/templates/be_leaflet_about.html5 @@ -0,0 +1,140 @@ +
+
+

headline; ?> + version; ?> +

+
+ +
+

About

+
+

+ The Leaflet maps integration for Contao CMS is an Open Source Software license under the LGPL 3.0. + This extension is only exists because of great other Open Source Software which it heavenly depends on. +

+

+ This software ships with an visible attribution to netzmacht creative in the map attribution + control. + If you want to remove this attribution, you have to purchase a commercial license. + For more details visit the project + website. +

+
+
+ > + +

+ netzmacht
+ David Molineus
+

+

+ DAB Bank München
+ IBAN: DE52701204008354237003
+ BIC: DABBDEMMXXX +

+
+ + + + +
+
+
+ +
+

Support Contao Leaflet

+ +
+
+

Report issues

+

If you found a bug, got some troubles or have a feature request - feel free to open an issue.

+

Issue + tracker

+
+
+

Contribute

+

There are many ways you can con­tribute. Translations, + docu­mentation or code contributions are welcome. +

+

Contribute +

+
+
+

Fund a feature

+

Contao Leaflet is not feature complete. Have a look at the list of planned feature and support + them.

+

Planned + features

+
+
+
+ +
+

Individual development

+

If you have special requirements you can hire me for an individual development.

+

Contact

+
+
+

Commercial license

+

If you want to remove the attribution in the attribution control, you can purchase a commercial + license.

+

Purchase + license

+
+
+
+ +
+

Credits

+ + + + + + + + libraries): ?> + + + + + libraries as $library): ?> + + + + + + + + + + + + + + + + + + + + + + + dependencies): ?> + + + + + dependencies as $dep): ?> + + + + + + + +
NameVersionLicenseHomepage
Libraries
Graphics
Farm Fresh-Web Icons3.9.2CC BY 3.0 USfatcow.com/free-icons
Web Blog Icons by SEM Labs3.9.2CC BY 4.0semlabs.co.uk
Dependencies
+
+
diff --git a/module/templates/be_leaflet_geocode.html5 b/src/Bundle/Resources/contao/templates/be_leaflet_geocode.html5 similarity index 88% rename from module/templates/be_leaflet_geocode.html5 rename to src/Bundle/Resources/contao/templates/be_leaflet_geocode.html5 index 842d1f5..6375db0 100644 --- a/module/templates/be_leaflet_geocode.html5 +++ b/src/Bundle/Resources/contao/templates/be_leaflet_geocode.html5 @@ -10,21 +10,21 @@ L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); - var element = $('field; ?>'); + var element = $('field; ?>'); var geocoder = L.Control.geocoder({ defaultMarkGeocode: false, collapsed: false, placeholder: '' }).addTo(map); - geocoder.on('markgeocode', function(event) { + geocoder.on('markgeocode', function (event) { var container = document.createElement('div'); - var link = document.createElement('button'); - var result = event.geocode; + var link = document.createElement('button'); + var result = event.geocode; link.set('style', 'margin-left: 10px;'); link.appendText(''); - link.addEvent('click', function(e) { + link.addEvent('click', function (e) { e.stop(); element.set('value', result.center.lat + ',' + result.center.lng); @@ -37,7 +37,7 @@ map.removeLayer(this._geocodeMarker); } - map.fitBounds(result.bbox, { padding: [0, 70]}); + map.fitBounds(result.bbox, {padding: [0, 70]}); map.panTo(result.center); this._geocodeMarker = new L.Marker(result.center, {draggable: true}) diff --git a/module/templates/ce_leaflet_map.html5 b/src/Bundle/Resources/contao/templates/ce_leaflet_map.html5 similarity index 84% rename from module/templates/ce_leaflet_map.html5 rename to src/Bundle/Resources/contao/templates/ce_leaflet_map.html5 index 61563ff..d62880d 100644 --- a/module/templates/ce_leaflet_map.html5 +++ b/src/Bundle/Resources/contao/templates/ce_leaflet_map.html5 @@ -9,5 +9,5 @@ -' . $this->javascript .''; ?> +' . $this->javascript . ''; ?> diff --git a/src/Bundle/Resources/contao/templates/leaflet_map_html.html5 b/src/Bundle/Resources/contao/templates/leaflet_map_html.html5 new file mode 100644 index 0000000..8624e3d --- /dev/null +++ b/src/Bundle/Resources/contao/templates/leaflet_map_html.html5 @@ -0,0 +1,7 @@ +
+ diff --git a/src/Bundle/Resources/contao/templates/leaflet_map_js.html5 b/src/Bundle/Resources/contao/templates/leaflet_map_js.html5 new file mode 100644 index 0000000..31ca758 --- /dev/null +++ b/src/Bundle/Resources/contao/templates/leaflet_map_js.html5 @@ -0,0 +1,5 @@ +L.contao.addMap('mapId ?>', function() { +javascript ?> + +return { map: map, layers: layers, controls: controls, icons: icons }; +}()); diff --git a/module/templates/mod_leaflet_map.html5 b/src/Bundle/Resources/contao/templates/mod_leaflet_map.html5 similarity index 84% rename from module/templates/mod_leaflet_map.html5 rename to src/Bundle/Resources/contao/templates/mod_leaflet_map.html5 index e0138dd..6c7ffbd 100644 --- a/module/templates/mod_leaflet_map.html5 +++ b/src/Bundle/Resources/contao/templates/mod_leaflet_map.html5 @@ -9,4 +9,4 @@ -' . $this->javascript .''; ?> +' . $this->javascript . ''; ?> diff --git a/module/assets/css/about.css b/src/Bundle/Resources/public/css/about.css similarity index 96% rename from module/assets/css/about.css rename to src/Bundle/Resources/public/css/about.css index 0e71c71..87f8827 100644 --- a/module/assets/css/about.css +++ b/src/Bundle/Resources/public/css/about.css @@ -3,7 +3,6 @@ padding: 15px; } - .netzmacht-leaflet-credits a { color: #669A00; } @@ -17,7 +16,7 @@ .netzmacht-leaflet-credits h1 { color: #fff; font-size: 1.4em; - text-shadow: 0 -1px 1px rgba(0,0,0,0.35); + text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.35); } .netzmacht-leaflet-credits .row:after { diff --git a/src/Bundle/Resources/public/css/backend.css b/src/Bundle/Resources/public/css/backend.css new file mode 100644 index 0000000..09d7686 --- /dev/null +++ b/src/Bundle/Resources/public/css/backend.css @@ -0,0 +1,60 @@ + +.tl_listing_container.tree_view ul > li.tl_file { + background: url('./../img/fol-placeholder.gif') no-repeat 6px 4px; +} + +.tl_listing_container.tree_view ul > li.tl_file > div { + line-height: 18px; +} + +.tl_listing_container.tree_view > ul > li.tl_file { + padding-left: 26px; +} + +.tl_listing_container.tree_view ul > li.parent > ul { + padding-left: 20px; +} + +.tl_listing_container.tree_view ul > li > .tl_left > a { + margin-left: -20px; +} + +.tl_listing_container.tree_view ul[class="level_1"] li.tl_file > .tl_left { + padding-left: 20px !important; +} + +.long .tl_text_2 { + width: 325px; +} + +.leaflet-mcw { + clear: both; +} + +.leaflet-mcw .tl_modulewizard { + width: 100%; +} + +.leaflet-mcw .multicolumnwizard textarea, +.leaflet-mcw .multicolumnwizard .tl_select { + width: 100% !important; +} + +.leaflet-mcw .tl_modulewizard td:first-child { + width: auto; +} + +@media screen and (min-width: 768px) { + .leaflet-mcw .tl_modulewizard { + max-width: 75%; + } + + .leaflet-mcw-map-layers .tl_modulewizard { + max-width: 45%; + } + + .leaflet-mcw-amenity-icons td:nth-child(1), + .leaflet-mcw-control-layers td:nth-child(2) { + width: 35%; + } +} diff --git a/src/Bundle/Resources/public/css/backend_global.css b/src/Bundle/Resources/public/css/backend_global.css new file mode 100644 index 0000000..ffc55e7 --- /dev/null +++ b/src/Bundle/Resources/public/css/backend_global.css @@ -0,0 +1,8 @@ + +#tl_navigation .tl_level_1_group .group-leaflet { + background: url(/bundles/netzmachtcontaoleaflet/img/leaflet.svg) 3px 2px no-repeat; +} + +.tl_help_table a { + text-decoration: underline; +} diff --git a/module/assets/img/about.png b/src/Bundle/Resources/public/img/about.png similarity index 100% rename from module/assets/img/about.png rename to src/Bundle/Resources/public/img/about.png diff --git a/module/assets/img/cluster.png b/src/Bundle/Resources/public/img/cluster.png similarity index 100% rename from module/assets/img/cluster.png rename to src/Bundle/Resources/public/img/cluster.png diff --git a/module/assets/img/cluster_1.png b/src/Bundle/Resources/public/img/cluster_1.png similarity index 100% rename from module/assets/img/cluster_1.png rename to src/Bundle/Resources/public/img/cluster_1.png diff --git a/module/assets/img/control.png b/src/Bundle/Resources/public/img/control.png similarity index 100% rename from module/assets/img/control.png rename to src/Bundle/Resources/public/img/control.png diff --git a/src/Bundle/Resources/public/img/file.png b/src/Bundle/Resources/public/img/file.png new file mode 100644 index 0000000..7a7227e Binary files /dev/null and b/src/Bundle/Resources/public/img/file.png differ diff --git a/src/Bundle/Resources/public/img/file_1.png b/src/Bundle/Resources/public/img/file_1.png new file mode 100644 index 0000000..502668d Binary files /dev/null and b/src/Bundle/Resources/public/img/file_1.png differ diff --git a/module/assets/img/fol-placeholder.gif b/src/Bundle/Resources/public/img/fol-placeholder.gif similarity index 100% rename from module/assets/img/fol-placeholder.gif rename to src/Bundle/Resources/public/img/fol-placeholder.gif diff --git a/module/assets/img/group.png b/src/Bundle/Resources/public/img/group.png similarity index 100% rename from module/assets/img/group.png rename to src/Bundle/Resources/public/img/group.png diff --git a/module/assets/img/group_1.png b/src/Bundle/Resources/public/img/group_1.png similarity index 100% rename from module/assets/img/group_1.png rename to src/Bundle/Resources/public/img/group_1.png diff --git a/module/assets/img/icons.png b/src/Bundle/Resources/public/img/icons.png similarity index 100% rename from module/assets/img/icons.png rename to src/Bundle/Resources/public/img/icons.png diff --git a/module/assets/img/layers.png b/src/Bundle/Resources/public/img/layers.png similarity index 100% rename from module/assets/img/layers.png rename to src/Bundle/Resources/public/img/layers.png diff --git a/src/Bundle/Resources/public/img/leaflet.svg b/src/Bundle/Resources/public/img/leaflet.svg new file mode 100644 index 0000000..f499944 --- /dev/null +++ b/src/Bundle/Resources/public/img/leaflet.svg @@ -0,0 +1,72 @@ + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/module/assets/img/logo.png b/src/Bundle/Resources/public/img/logo.png similarity index 100% rename from module/assets/img/logo.png rename to src/Bundle/Resources/public/img/logo.png diff --git a/module/assets/img/map.png b/src/Bundle/Resources/public/img/map.png similarity index 100% rename from module/assets/img/map.png rename to src/Bundle/Resources/public/img/map.png diff --git a/module/assets/img/markers.png b/src/Bundle/Resources/public/img/markers.png similarity index 100% rename from module/assets/img/markers.png rename to src/Bundle/Resources/public/img/markers.png diff --git a/module/assets/img/markers_1.png b/src/Bundle/Resources/public/img/markers_1.png similarity index 100% rename from module/assets/img/markers_1.png rename to src/Bundle/Resources/public/img/markers_1.png diff --git a/module/assets/img/overpass.png b/src/Bundle/Resources/public/img/overpass.png similarity index 100% rename from module/assets/img/overpass.png rename to src/Bundle/Resources/public/img/overpass.png diff --git a/module/assets/img/popup.png b/src/Bundle/Resources/public/img/popup.png similarity index 100% rename from module/assets/img/popup.png rename to src/Bundle/Resources/public/img/popup.png diff --git a/module/assets/img/provider.png b/src/Bundle/Resources/public/img/provider.png similarity index 100% rename from module/assets/img/provider.png rename to src/Bundle/Resources/public/img/provider.png diff --git a/module/assets/img/provider_1.png b/src/Bundle/Resources/public/img/provider_1.png similarity index 100% rename from module/assets/img/provider_1.png rename to src/Bundle/Resources/public/img/provider_1.png diff --git a/module/assets/img/reference.png b/src/Bundle/Resources/public/img/reference.png similarity index 100% rename from module/assets/img/reference.png rename to src/Bundle/Resources/public/img/reference.png diff --git a/module/assets/img/reference_1.png b/src/Bundle/Resources/public/img/reference_1.png similarity index 100% rename from module/assets/img/reference_1.png rename to src/Bundle/Resources/public/img/reference_1.png diff --git a/module/assets/img/style.png b/src/Bundle/Resources/public/img/style.png similarity index 100% rename from module/assets/img/style.png rename to src/Bundle/Resources/public/img/style.png diff --git a/module/assets/img/tile.png b/src/Bundle/Resources/public/img/tile.png similarity index 100% rename from module/assets/img/tile.png rename to src/Bundle/Resources/public/img/tile.png diff --git a/module/assets/img/tile_1.png b/src/Bundle/Resources/public/img/tile_1.png similarity index 100% rename from module/assets/img/tile_1.png rename to src/Bundle/Resources/public/img/tile_1.png diff --git a/module/assets/img/vectors.png b/src/Bundle/Resources/public/img/vectors.png similarity index 100% rename from module/assets/img/vectors.png rename to src/Bundle/Resources/public/img/vectors.png diff --git a/module/assets/img/vectors_1.png b/src/Bundle/Resources/public/img/vectors_1.png similarity index 100% rename from module/assets/img/vectors_1.png rename to src/Bundle/Resources/public/img/vectors_1.png diff --git a/src/Bundle/Resources/public/js/backend.js b/src/Bundle/Resources/public/js/backend.js new file mode 100644 index 0000000..94c802d --- /dev/null +++ b/src/Bundle/Resources/public/js/backend.js @@ -0,0 +1,64 @@ +/** + * Contao Open Source CMS + * + * Copyright (c) 2005-2017 Leo Feyer + * + * @license LGPL-3.0+ + */ + + +/** + * Provide methods to handle Ajax requests. + * + * @author Leo Feyer + */ +var ContaoLeafletAjaxRequest = { + /** + * Toggle the visibility of an element + * + * @param {object} el The DOM element + * @param {string} id The ID of the target element + * @param {string} table The table name + * + * @returns {boolean} + */ + toggleVisibility: function (el, id, table) { + el.blur(); + + var img = null, + image = $(el).getFirst('img'), + published = (image.get('data-state') == 1), + div = el.getParent('div'), + index, next, icon, icond, pa; + img = div.getParent('li').getFirst('.tl_left img.list-icon'); + + // Change the icon + if (img !== null && img.nodeName.toLowerCase() == 'img') { + icon = img.get('data-icon'); + icond = img.get('data-icon-disabled'); + + img.src = !published ? icon : icond; + } + + // Send request + if (!published) { + image.src = AjaxRequest.themePath + 'icons/visible.svg'; + image.set('data-state', 1); + new Request.Contao({'url': window.location.href, 'followRedirects': false}).get({ + 'tid': id, + 'state': 1, + 'rt': Contao.request_token + }); + } else { + image.src = AjaxRequest.themePath + 'icons/invisible.svg'; + image.set('data-state', 0); + new Request.Contao({'url': window.location.href, 'followRedirects': false}).get({ + 'tid': id, + 'state': 0, + 'rt': Contao.request_token + }); + } + + return false; + } +}; diff --git a/src/Bundle/Resources/public/js/contao-leaflet.js b/src/Bundle/Resources/public/js/contao-leaflet.js new file mode 100644 index 0000000..e26d02d --- /dev/null +++ b/src/Bundle/Resources/public/js/contao-leaflet.js @@ -0,0 +1 @@ +L.Contao=L.Evented.extend({statics:{ATTRIBUTION:' | netzmacht'},maps:{},icons:{},initialize:function(){L.Icon.Default.imagePath="assets/leaflet/libs/leaflet/images/",this.setGeoJsonListeners(L.GeoJSON)},addMap:function(t,o){return this.maps[t]=o,this.fire("map:added",{id:t,map:o}),this},getMap:function(t){return void 0===this.maps[t]?null:this.maps[t]},addIcon:function(t,o){return this.icons[t]=o,this.fire("icon:added",{id:t,icon:o}),this},loadIcons:function(t){for(var o=0;o=200&&t<300||304===t}function i(){void 0===a.status||n(a.status)?o.call(a,null,a):o.call(a,a,null)}var s=!1;if(void 0===window.XMLHttpRequest)return o(Error("Browser not supported"));if(void 0===e){var r=t.match(/^\s*https?:\/\/[^\/]*/);e=r&&r[0]!==location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}var a=new window.XMLHttpRequest;if(e&&!("withCredentials"in a)){a=new window.XDomainRequest;var p=o;o=function(){if(s)p.apply(this,arguments);else{var t=this,o=arguments;setTimeout(function(){p.apply(t,o)},0)}}}return"onload"in a?a.onload=i:a.onreadystatechange=function(){4===a.readyState&&i()},a.onerror=function(t){o.call(this,t||!0,null),o=function(){}},a.onprogress=function(){},a.ontimeout=function(t){o.call(this,t,null),o=function(){}},a.onabort=function(t){o.call(this,t,null),o=function(){}},a.open("GET",t,!0),a.send(null),s=!0,a}}); \ No newline at end of file diff --git a/src/Netzmacht/Contao/Leaflet/Definition/Layer/OverpassLayer.php b/src/Definition/Layer/OverpassLayer.php similarity index 94% rename from src/Netzmacht/Contao/Leaflet/Definition/Layer/OverpassLayer.php rename to src/Definition/Layer/OverpassLayer.php index 15e8139..b120d5b 100644 --- a/src/Netzmacht/Contao/Leaflet/Definition/Layer/OverpassLayer.php +++ b/src/Definition/Layer/OverpassLayer.php @@ -1,11 +1,13 @@ - * @copyright 2016 netzmacht David Molineus. All rights reserved. - * @filesource + * Leaflet maps for Contao CMS. * + * @package contao-leaflet-maps + * @author David Molineus + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource */ namespace Netzmacht\Contao\Leaflet\Definition\Layer; diff --git a/src/Netzmacht/Contao/Leaflet/Definition/Style.php b/src/Definition/Style.php similarity index 74% rename from src/Netzmacht/Contao/Leaflet/Definition/Style.php rename to src/Definition/Style.php index 3631ef2..e7e07a4 100644 --- a/src/Netzmacht/Contao/Leaflet/Definition/Style.php +++ b/src/Definition/Style.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Definition; diff --git a/src/Netzmacht/Contao/Leaflet/Definition/Style/FixedStyle.php b/src/Definition/Style/FixedStyle.php similarity index 97% rename from src/Netzmacht/Contao/Leaflet/Definition/Style/FixedStyle.php rename to src/Definition/Style/FixedStyle.php index a6a37ff..13db1c4 100644 --- a/src/Netzmacht/Contao/Leaflet/Definition/Style/FixedStyle.php +++ b/src/Definition/Style/FixedStyle.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Definition\Style; diff --git a/src/Netzmacht/Contao/Leaflet/ContaoAssets.php b/src/Encoder/ContaoAssets.php similarity index 91% rename from src/Netzmacht/Contao/Leaflet/ContaoAssets.php rename to src/Encoder/ContaoAssets.php index bc5e907..902b21d 100644 --- a/src/Netzmacht/Contao/Leaflet/ContaoAssets.php +++ b/src/Encoder/ContaoAssets.php @@ -1,15 +1,16 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ -namespace Netzmacht\Contao\Leaflet; +namespace Netzmacht\Contao\Leaflet\Encoder; use Netzmacht\Contao\Toolkit\View\Assets\AssetsManager; use Netzmacht\LeafletPHP\Assets; @@ -43,7 +44,7 @@ class ContaoAssets implements Assets private $cache = [ 'stylesheets' => [], 'javascripts' => [], - 'map' => [] + 'map' => [], ]; /** diff --git a/src/Encoder/EncoderFactory.php b/src/Encoder/EncoderFactory.php new file mode 100644 index 0000000..30a7df1 --- /dev/null +++ b/src/Encoder/EncoderFactory.php @@ -0,0 +1,63 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Encoder; + +use Netzmacht\JavascriptBuilder\Encoder; +use Netzmacht\JavascriptBuilder\Encoder\ChainEncoder; +use Netzmacht\JavascriptBuilder\Output; +use Netzmacht\JavascriptBuilder\Symfony\EventDispatchingEncoder; +use Symfony\Component\EventDispatcher\EventDispatcherInterface as EventDispatcher; + +/** + * Class EncoderFactory. + * + * @package Netzmacht\Contao\Leaflet\Encoder + */ +final class EncoderFactory +{ + /** + * Definition builder event dispatcher. + * + * @var EventDispatcher + */ + private $dispatcher; + + /** + * EncoderFactory constructor. + * + * @param EventDispatcher $dispatcher Definition builder event dispatcher. + */ + public function __construct(EventDispatcher $dispatcher) + { + $this->dispatcher = $dispatcher; + } + + /** + * Create the encoder. + * + * @param Output $output Output object. + * + * @return Encoder + */ + public function __invoke(Output $output): Encoder + { + $encoder = (new ChainEncoder()) + ->register(new Encoder\MultipleObjectsEncoder()) + ->register(new EventDispatchingEncoder($this->dispatcher)) + ->register(new Encoder\JavascriptEncoder($output, JSON_UNESCAPED_SLASHES)); + + return $encoder; + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php b/src/Encoder/Subscriber/EncoderSubscriber.php similarity index 82% rename from src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php rename to src/Encoder/Subscriber/EncoderSubscriber.php index 4f380c0..55fe1eb 100644 --- a/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php +++ b/src/Encoder/Subscriber/EncoderSubscriber.php @@ -1,22 +1,22 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ -namespace Netzmacht\Contao\Leaflet\Subscriber; +namespace Netzmacht\Contao\Leaflet\Encoder\Subscriber; use Netzmacht\Contao\Leaflet\Frontend\RequestUrl; -use Netzmacht\JavascriptBuilder\Encoder; -use Netzmacht\JavascriptBuilder\Flags; -use Netzmacht\JavascriptBuilder\Symfony\Event\EncodeValueEvent; -use Netzmacht\JavascriptBuilder\Symfony\Event\EncodeReferenceEvent; use Netzmacht\JavascriptBuilder\Exception\EncodeValueFailed; +use Netzmacht\JavascriptBuilder\Flags; +use Netzmacht\JavascriptBuilder\Symfony\Event\EncodeReferenceEvent; +use Netzmacht\JavascriptBuilder\Symfony\Event\EncodeValueEvent; use Netzmacht\LeafletPHP\Definition\Type\Icon; use Netzmacht\LeafletPHP\Plugins\Omnivore\OmnivoreLayer; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -33,13 +33,13 @@ class EncoderSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array( - EncodeValueEvent::NAME => array( - array('encodeIcons', 1000), - array('loadLayer', 100), - ), - EncodeReferenceEvent::NAME => array('referenceIcon', 100), - ); + return [ + EncodeValueEvent::NAME => [ + ['encodeIcons', 1000], + ['loadLayer', 100], + ], + EncodeReferenceEvent::NAME => ['referenceIcon', 100], + ]; } /** @@ -89,16 +89,15 @@ class EncoderSubscriber implements EventSubscriberInterface { $value = $event->getValue(); $encoder = $event->getEncoder(); - $template = 'L.contao.load(%s, %s, %s, %s, map);'; + $template = 'L.contao.%s(%s, %s, %s, %s, map);'; + $method = 'loadFile'; if ($value instanceof OmnivoreLayer) { $url = $value->getUrl(); if ($url instanceof RequestUrl) { - $url = $url->getHash(); - } elseif (strpos($url, '/') !== false) { - // Slash found, not a Contao leaflet hash, do not replace encoding. - return; + $url = $url->getHash(); + $method = 'load'; } if ($value->getCustomLayer()) { @@ -111,6 +110,7 @@ class EncoderSubscriber implements EventSubscriberInterface $event->addLine( sprintf( $template, + $method, $encoder->encodeValue($url), $encoder->encodeValue(strtolower(str_replace('Omnivore.', '', $value->getType()))), $encoder->encodeArray($value->getOptions(), JSON_FORCE_OBJECT), diff --git a/src/Netzmacht/Contao/Leaflet/Event/BuildDefinitionEvent.php b/src/Event/BuildDefinitionEvent.php similarity index 62% rename from src/Netzmacht/Contao/Leaflet/Event/BuildDefinitionEvent.php rename to src/Event/BuildDefinitionEvent.php index c7cbbe1..e0aa7f3 100644 --- a/src/Netzmacht/Contao/Leaflet/Event/BuildDefinitionEvent.php +++ b/src/Event/BuildDefinitionEvent.php @@ -1,18 +1,20 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Event; +use Contao\Model; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\LeafletPHP\Definition; -use Netzmacht\LeafletPHP\Value\LatLngBounds; use Symfony\Component\EventDispatcher\Event; /** @@ -22,7 +24,7 @@ use Symfony\Component\EventDispatcher\Event; */ class BuildDefinitionEvent extends Event { - const NAME = 'leaflet.mapper.definition'; + const NAME = 'netzmacht.contao_leaflet.mapper.build_definition'; /** * The leaflet object definition. @@ -39,24 +41,24 @@ class BuildDefinitionEvent extends Event private $model; /** - * Optional bounds where elements should be in. + * Building request. * - * @var LatLngBounds + * @var Request|null */ - private $bounds; + private $request; /** * Construct. * * @param Definition $definition The leaflet definition. - * @param \Model $model The definition model. - * @param LatLngBounds $bounds Optional bounds where elements should be in. + * @param Model $model The definition model. + * @param Request|null $request Building request. */ - public function __construct(Definition $definition, \Model $model, LatLngBounds $bounds = null) + public function __construct(Definition $definition, Model $model, Request $request = null) { $this->definition = $definition; $this->model = $model; - $this->bounds = $bounds; + $this->request = $request; } /** @@ -82,10 +84,10 @@ class BuildDefinitionEvent extends Event /** * Get the bounds. * - * @return LatLngBounds|null + * @return Request|null */ - public function getBounds() + public function getRequest() { - return $this->bounds; + return $this->request; } } diff --git a/src/Netzmacht/Contao/Leaflet/Event/ConvertToGeoJsonEvent.php b/src/Event/ConvertToGeoJsonEvent.php similarity index 86% rename from src/Netzmacht/Contao/Leaflet/Event/ConvertToGeoJsonEvent.php rename to src/Event/ConvertToGeoJsonEvent.php index 8bf6d80..de71b21 100644 --- a/src/Netzmacht/Contao/Leaflet/Event/ConvertToGeoJsonEvent.php +++ b/src/Event/ConvertToGeoJsonEvent.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Event; @@ -22,7 +23,7 @@ use Symfony\Component\EventDispatcher\Event; */ class ConvertToGeoJsonEvent extends Event { - const NAME = 'leaflet.mapper.convert-to-geojson'; + const NAME = 'netzmacht.contao_leaflet.mapper.convert_to_geojson'; /** * The definition. diff --git a/src/Netzmacht/Contao/Leaflet/Event/GetHashEvent.php b/src/Event/GetHashEvent.php similarity index 83% rename from src/Netzmacht/Contao/Leaflet/Event/GetHashEvent.php rename to src/Event/GetHashEvent.php index c9961c4..fac4a51 100644 --- a/src/Netzmacht/Contao/Leaflet/Event/GetHashEvent.php +++ b/src/Event/GetHashEvent.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Event; @@ -20,7 +21,7 @@ use Symfony\Component\EventDispatcher\Event; */ class GetHashEvent extends Event { - const NAME = 'leaflet.get-hash'; + const NAME = 'netzmacht.contao_leaflet.get_hash'; /** * The data. diff --git a/src/Netzmacht/Contao/Leaflet/Event/GetJavascriptEvent.php b/src/Event/GetJavascriptEvent.php similarity index 82% rename from src/Netzmacht/Contao/Leaflet/Event/GetJavascriptEvent.php rename to src/Event/GetJavascriptEvent.php index fca1b4f..52099a0 100644 --- a/src/Netzmacht/Contao/Leaflet/Event/GetJavascriptEvent.php +++ b/src/Event/GetJavascriptEvent.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Event; @@ -21,7 +22,7 @@ use Symfony\Component\EventDispatcher\Event; */ class GetJavascriptEvent extends Event { - const NAME = 'leaflet.service.get-javascript'; + const NAME = 'netzmacht.contao_leaflet.get_javascript'; /** * The generated javascript. diff --git a/src/Netzmacht/Contao/Leaflet/Filter/BboxFilter.php b/src/Filter/BboxFilter.php similarity index 83% rename from src/Netzmacht/Contao/Leaflet/Filter/BboxFilter.php rename to src/Filter/BboxFilter.php index 6ec6ed6..4b637e8 100644 --- a/src/Netzmacht/Contao/Leaflet/Filter/BboxFilter.php +++ b/src/Filter/BboxFilter.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Filter; @@ -67,7 +68,7 @@ class BboxFilter implements Filter */ public function getValues() { - return array('bounds' => $this->bounds); + return ['bounds' => $this->bounds]; } /** diff --git a/src/Netzmacht/Contao/Leaflet/Filter/DistanceFilter.php b/src/Filter/DistanceFilter.php similarity index 86% rename from src/Netzmacht/Contao/Leaflet/Filter/DistanceFilter.php rename to src/Filter/DistanceFilter.php index f730545..6c062e3 100644 --- a/src/Netzmacht/Contao/Leaflet/Filter/DistanceFilter.php +++ b/src/Filter/DistanceFilter.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Filter; @@ -87,9 +88,9 @@ class DistanceFilter implements Filter */ public function getValues() { - return array( + return [ 'radius' => $this->radius, - 'center' => $this->center - ); + 'center' => $this->center, + ]; } } diff --git a/src/Netzmacht/Contao/Leaflet/Filter/Filter.php b/src/Filter/Filter.php similarity index 83% rename from src/Netzmacht/Contao/Leaflet/Filter/Filter.php rename to src/Filter/Filter.php index 0715dfd..6cd4e17 100644 --- a/src/Netzmacht/Contao/Leaflet/Filter/Filter.php +++ b/src/Filter/Filter.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Filter; diff --git a/src/Filter/FilterFactory.php b/src/Filter/FilterFactory.php new file mode 100644 index 0000000..62b27f8 --- /dev/null +++ b/src/Filter/FilterFactory.php @@ -0,0 +1,59 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Filter; + +/** + * Class FilterFactory. + * + * @package Netzmacht\Contao\Leaflet\Filter + */ +final class FilterFactory +{ + /** + * Map of filter classes. + * + * @var array + */ + private $filters; + + /** + * FilterFactory constructor. + * + * @param array $filters Map of filter classes. + */ + public function __construct(array $filters) + { + $this->filters = $filters; + } + + /** + * Create a filter. + * + * @param string $filter Filter name. + * @param string $values Filter values. + * + * @return Filter + * + * @throws \RuntimeException When filter is not supported. + */ + public function create(string $filter, string $values): Filter + { + if (isset($this->filters[$filter])) { + return call_user_func([$filter, 'fromRequest'], $values); + } + + throw new \RuntimeException(sprintf('Creating filter failed. Unsupported filter "%s"', $filter)); + } +} diff --git a/src/Frontend/AbstractMapHybrid.php b/src/Frontend/AbstractMapHybrid.php new file mode 100644 index 0000000..71d23b1 --- /dev/null +++ b/src/Frontend/AbstractMapHybrid.php @@ -0,0 +1,155 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Frontend; + +use Contao\Database\Result; +use Contao\Input; +use Contao\Model; +use Contao\Model\Collection; +use Netzmacht\Contao\Leaflet\MapProvider; +use Netzmacht\Contao\Leaflet\Model\MapModel; +use Netzmacht\Contao\Toolkit\Component\Hybrid\AbstractHybrid; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Symfony\Component\Templating\EngineInterface as TemplateEngine; +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Class HybridTrait provides method required by the frontend module and content element the same time. + * + * @package Netzmacht\Contao\Leaflet\Frontend + */ +abstract class AbstractMapHybrid extends AbstractHybrid +{ + /** + * The map provider. + * + * @var MapProvider + */ + private $mapProvider; + + /** + * The user input. + * + * @var Input + */ + private $input; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * HybridTrait constructor. + * + * @param Result|Model|Collection $model Component model. + * @param TemplateEngine $templateEngine Template engine. + * @param Translator $translator Translator. + * @param MapProvider $mapProvider Map provider. + * @param RepositoryManager $repositoryManager Repository manager. + * @param Input $input Request Input. + * @param string $column Column in which the element appears. + */ + public function __construct( + $model, + TemplateEngine $templateEngine, + Translator $translator, + MapProvider $mapProvider, + RepositoryManager $repositoryManager, + $input, + $column = null + ) { + parent::__construct($model, $templateEngine, $translator, $column); + + $this->mapProvider = $mapProvider; + $this->input = $input; + $this->repositoryManager = $repositoryManager; + } + + /** + * Do the frontend integration generation. + * + * @return string + */ + public function generate(): string + { + $this->mapProvider->handleAjaxRequest($this->getIdentifier()); + + if (TL_MODE === 'BE') { + $repository = $this->repositoryManager->getRepository(MapModel::class); + $model = $repository->find((int) $this->get('leaflet_map')); + $parameters = [ + 'title' => $this->get('headline'), + ]; + + if ($model) { + $href = 'contao/main.php?do=leaflet&table=tl_leaflet_map&act=edit&id=' . $model->id; + + $parameters['wildcard'] = '### LEAFLET MAP ' . $model->title . ' ###'; + $parameters['id'] = $model->id; + $parameters['link'] = $model->title; + $parameters['href'] = $href; + } + + return $this->render('toolkit:be:be_wildcard.html5', $parameters); + } + + return parent::generate(); + } + + /** + * {@inheritdoc} + * + * @throws \Exception If map could not be created. + */ + protected function prepareTemplateData(array $data): array + { + try { + $template = $this->get('leaflet_template') ?: 'leaflet_map_js'; + $mapId = $this->getIdentifier(); + $map = $this->mapProvider->generate($this->get('leaflet_map'), null, $mapId, $template); + + $data['javascript'] = $map; + $data['mapId'] = $mapId; + + $style = ''; + $height = deserialize($this->get('leaflet_height'), true); + $width = deserialize($this->get('leaflet_width'), true); + + if (!empty($width['value'])) { + $style .= 'width:' . $width['value'] . $width['unit'] . ';'; + } + + if (!empty($height['value'])) { + $style .= 'height:' . $height['value'] . $height['unit'] . ';'; + } + + $data['mapStyle'] = $style; + } catch (\Exception $e) { + throw $e; + } + + return $data; + } + + /** + * Get the component identifier which is used as unique name. + * + * @return string + */ + abstract protected function getIdentifier(): string; +} diff --git a/src/Frontend/Assets/LibrariesConfiguration.php b/src/Frontend/Assets/LibrariesConfiguration.php new file mode 100644 index 0000000..54929d8 --- /dev/null +++ b/src/Frontend/Assets/LibrariesConfiguration.php @@ -0,0 +1,102 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Frontend\Assets; + +use Contao\CoreBundle\Framework\ContaoFrameworkInterface as ContaoFramework; + +/** + * Class LibrariesConfiguration. + * + * @package Netzmacht\Contao\Leaflet\Frontend\Assets + */ +class LibrariesConfiguration implements \IteratorAggregate, \ArrayAccess +{ + /** + * Contao framework. + * + * @var ContaoFramework + */ + private $framework; + + /** + * LibrariesConfiguration constructor. + * + * @param ContaoFramework $framework Contao framework. + */ + public function __construct(ContaoFramework $framework) + { + $this->framework = $framework; + } + + /** + * {@inheritdoc} + * + * @SuppressWarnings(PHPMD.Superglobals) + */ + public function getIterator() + { + $this->framework->initialize(); + + return new \ArrayIterator($GLOBALS['LEAFLET_LIBRARIES']); + } + + /** + * {@inheritdoc} + * + * @SuppressWarnings(PHPMD.Superglobals) + */ + public function offsetExists($offset) + { + $this->framework->initialize(); + + return isset($GLOBALS['LEAFLET_LIBRARIES'][$offset]); + } + + /** + * {@inheritdoc} + * + * @SuppressWarnings(PHPMD.Superglobals) + */ + public function offsetGet($offset) + { + $this->framework->initialize(); + + return $GLOBALS['LEAFLET_LIBRARIES'][$offset]; + } + + /** + * {@inheritdoc} + * + * @SuppressWarnings(PHPMD.Superglobals) + */ + public function offsetSet($offset, $value) + { + $this->framework->initialize(); + + $GLOBALS['LEAFLET_LIBRARIES'][$offset] = $value; + } + + /** + * {@inheritdoc} + * + * @SuppressWarnings(PHPMD.Superglobals) + */ + public function offsetUnset($offset) + { + $this->framework->initialize(); + + unset($GLOBALS['LEAFLET_LIBRARIES'][$offset]); + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/MapElement.php b/src/Frontend/ContentElement/MapElement.php similarity index 59% rename from src/Netzmacht/Contao/Leaflet/Frontend/MapElement.php rename to src/Frontend/ContentElement/MapElement.php index 0ae08f1..9b9b723 100644 --- a/src/Netzmacht/Contao/Leaflet/Frontend/MapElement.php +++ b/src/Frontend/ContentElement/MapElement.php @@ -1,15 +1,20 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ -namespace Netzmacht\Contao\Leaflet\Frontend; +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Frontend\ContentElement; + +use Netzmacht\Contao\Leaflet\Frontend\AbstractMapHybrid; /** * The content element for the leaflet map. @@ -30,10 +35,10 @@ class MapElement extends AbstractMapHybrid * * @return string */ - protected function getIdentifier() + protected function getIdentifier(): string { if ($this->get('leaflet_mapId')) { - return $this->get('leaflet_mapId'); + return (string) $this->get('leaflet_mapId'); } if ($this->get('cssID')[0]) { diff --git a/src/Frontend/ContentElement/MapElementFactory.php b/src/Frontend/ContentElement/MapElementFactory.php new file mode 100644 index 0000000..6b8da7f --- /dev/null +++ b/src/Frontend/ContentElement/MapElementFactory.php @@ -0,0 +1,115 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Frontend\ContentElement; + +use Contao\Config; +use Contao\CoreBundle\Framework\Adapter; +use Contao\Input; +use Netzmacht\Contao\Leaflet\MapProvider; +use Netzmacht\Contao\Toolkit\Component\Component; +use Netzmacht\Contao\Toolkit\Component\ComponentFactory; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Symfony\Component\Templating\EngineInterface as TemplateEngine; +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Class MapElementFactory + * + * @package Netzmacht\Contao\Leaflet\Frontend\ContentElement + */ +class MapElementFactory implements ComponentFactory +{ + /** + * Template engine. + * + * @var TemplateEngine + */ + private $templating; + + /** + * Translator. + * + * @var Translator + */ + private $translator; + + /** + * Map provider. + * + * @var MapProvider + */ + private $mapProvider; + + /** + * Input adapter. + * + * @var Input|Adapter + */ + private $input; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * MapElementFactory constructor. + * + * @param TemplateEngine $engine Template engine. + * @param Translator $translator Translator. + * @param MapProvider $mapProvider Map provider. + * @param RepositoryManager $repositoryManager Repository manager. + * @param Input|Adapter $input Input adapter. + */ + public function __construct( + TemplateEngine $engine, + Translator $translator, + MapProvider $mapProvider, + RepositoryManager $repositoryManager, + $input + ) { + $this->templating = $engine; + $this->translator = $translator; + $this->mapProvider = $mapProvider; + $this->input = $input; + $this->repositoryManager = $repositoryManager; + } + + /** + * {@inheritDoc} + */ + public function supports($model): bool + { + return $model->type === 'leaflet'; + } + + /** + * {@inheritDoc} + */ + public function create($model, string $column): Component + { + return new MapElement( + $model, + $this->templating, + $this->translator, + $this->mapProvider, + $this->repositoryManager, + $this->input, + $column + ); + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/DataController.php b/src/Frontend/DataController.php similarity index 50% rename from src/Netzmacht/Contao/Leaflet/Frontend/DataController.php rename to src/Frontend/DataController.php index c7c957b..c5dd4cc 100644 --- a/src/Netzmacht/Contao/Leaflet/Frontend/DataController.php +++ b/src/Frontend/DataController.php @@ -1,17 +1,19 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Frontend; use Netzmacht\Contao\Leaflet\Filter\Filter; +use Netzmacht\Contao\Leaflet\Filter\FilterFactory; use Netzmacht\Contao\Leaflet\MapProvider; /** @@ -21,78 +23,69 @@ use Netzmacht\Contao\Leaflet\MapProvider; */ class DataController { - /** - * The map provider. - * - * @var MapProvider - */ - private $mapProvider; - /** * The user input data. * * @var array */ - private $input = array( + private $input = [ 'format' => 'geojson', 'type' => 'layer', 'id' => null, 'filter' => null, - 'values' => null - ); - - /** - * Filters configuration. - * - * @var array - */ - private $filters; + 'values' => null, + ]; /** - * Display errors. + * Debug mode. * * @var bool */ - private $displayErrors; + private $debugMode; + + /** + * Filter factory. + * + * @var FilterFactory + */ + private $filterFactory; /** * Construct. * - * @param MapProvider $mapProvider The map provider. - * @param array $filters Filters configuration. - * @param bool $displayErrors Display errors. + * @param FilterFactory $filterFactory Filter factory. + * @param bool $debugMode Debug mode. */ - public function __construct(MapProvider $mapProvider, array $filters, $displayErrors) + public function __construct(FilterFactory $filterFactory, $debugMode) { - $this->mapProvider = $mapProvider; - $this->filters = $filters; - $this->displayErrors = $displayErrors; + $this->debugMode = $debugMode; + $this->filterFactory = $filterFactory; } /** * Execute the controller and create the data response. * - * @param array $input The user input as array. + * @param array $input The user input as array. + * @param MapProvider $mapProvider Map provider. * * @return void - * * @throws \Exception If anything went wrong. */ - public function execute(array $input) + public function execute(array $input, MapProvider $mapProvider) { $input = array_merge($this->input, $input); try { if ($input['filter']) { - $filter = $this->createFilter($input); + $filter = $this->filterFactory->create($input['filter'], $input['values']); } else { $filter = null; } - list($data, $error) = $this->loadData($input['type'], $input['id'], $filter); + list($data, $error) = $this->loadData($mapProvider, $input['type'], $input['id'], $filter); $this->encodeData($input['format'], $data); } catch (\Exception $e) { - if ($this->displayErrors) { + if ($this->debugMode) { throw $e; } $error = true; @@ -127,50 +120,29 @@ class DataController /** * Load the data. * - * @param string $type The data type. - * @param mixed $dataId The data id. - * @param Filter $filter Optional request filter. + * @param MapProvider $mapProvider Map provider. + * @param string $type The data type. + * @param mixed $dataId The data id. + * @param Filter $filter Optional request filter. * * @return array */ - public function loadData($type, $dataId, Filter $filter = null) + public function loadData(MapProvider $mapProvider, $type, $dataId, Filter $filter = null) { $error = false; $data = null; switch ($type) { case 'layer': - $data = $this->mapProvider->getFeatureCollection($dataId, $filter); + $data = $mapProvider->getFeatureCollection($dataId, $filter); break; default: $error = true; - return array($data, $error); + return [$data, $error]; } - return array($data, $error); - } - - /** - * Create a filter. - * - * @param array $input The user input as array. - * - * @return Filter - * @throws \RuntimeException If the filter is not defined. - * - * @SuppressWarnings(PHPMD.Superglobals) - */ - private function createFilter($input) - { - if (!isset($this->filters[$input['filter']])) { - throw new \RuntimeException(sprintf('Undefined filter "%s".', $input['filter'])); - } - - /** @var Filter $filter */ - $filter = $this->filters[$input['filter']]; - - return $filter::fromRequest($input['values']); + return [$data, $error]; } } diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/InsertTag/LeafletInsertTagParser.php b/src/Frontend/InsertTag/LeafletInsertTagParser.php similarity index 61% rename from src/Netzmacht/Contao/Leaflet/Frontend/InsertTag/LeafletInsertTagParser.php rename to src/Frontend/InsertTag/LeafletInsertTagParser.php index fb2c35b..1c05b03 100644 --- a/src/Netzmacht/Contao/Leaflet/Frontend/InsertTag/LeafletInsertTagParser.php +++ b/src/Frontend/InsertTag/LeafletInsertTagParser.php @@ -1,18 +1,23 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ +declare(strict_types=1); + namespace Netzmacht\Contao\Leaflet\Frontend\InsertTag; use Netzmacht\Contao\Leaflet\MapProvider; -use Netzmacht\Contao\Toolkit\InsertTag\Parser; +use Netzmacht\Contao\Toolkit\InsertTag\AbstractSingleInsertTagParser; +use Netzmacht\Contao\Toolkit\InsertTag\ArgumentParser; +use Netzmacht\Contao\Toolkit\InsertTag\ArgumentParserPlugin; /** * LeafletInsertTagParser parses the leaflet insert tag. @@ -26,8 +31,17 @@ use Netzmacht\Contao\Toolkit\InsertTag\Parser; * * @package Netzmacht\Contao\Leaflet\Frontend\InsertTag */ -class LeafletInsertTagParser implements Parser +final class LeafletInsertTagParser extends AbstractSingleInsertTagParser { + use ArgumentParserPlugin; + + /** + * Insert tag name. + * + * @var string + */ + protected $tagName = 'leaflet'; + /** * The map service. * @@ -57,34 +71,24 @@ class LeafletInsertTagParser implements Parser /** * {@inheritDoc} */ - public static function getTags() + protected function parseTag(array $arguments, string $tag, string $raw) { - return ['leaflet']; - } - - /** - * {@inheritDoc} - */ - public function supports($tag) - { - return in_array($tag, static::getTags()); - } - - /** - * {@inheritDoc} - */ - public function parse($raw, $tag, $params = null, $cache = true) - { - $parts = explode('::', $params); - - if (empty($parts[0])) { - return false; + if (empty($arguments['mapId'])) { + return ''; } - $style = empty($parts[1]) ? 'width:400px;height:300px' : $parts[1]; - $template = empty($parts[2]) ? 'leaflet_map_html' : $parts[2]; + $style = empty($arguments['style']) ? 'width:400px;height:300px' : $arguments['style']; + $template = empty($arguments['template']) ? 'leaflet_map_html' : $arguments['template']; - return $this->generateMap($parts[0], $template, $style); + return $this->generateMap($arguments['mapId'], $template, $style); + } + + /** + * {@inheritDoc} + */ + protected function createArgumentParser(): ArgumentParser + { + return ArgumentParser::create()->splitBy('::', ['mapId', 'style', 'template']); } /** @@ -98,7 +102,7 @@ class LeafletInsertTagParser implements Parser * * @throws \Exception If debug mode is enabled and something went wrong. */ - private function generateMap($mapId, $template, $style) + private function generateMap($mapId, string $template, string $style) { try { return $this->mapProvider->generate($mapId, null, $mapId, $template, $style); diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/MapModule.php b/src/Frontend/Module/MapModule.php similarity index 60% rename from src/Netzmacht/Contao/Leaflet/Frontend/MapModule.php rename to src/Frontend/Module/MapModule.php index 3819d8e..e356b3d 100644 --- a/src/Netzmacht/Contao/Leaflet/Frontend/MapModule.php +++ b/src/Frontend/Module/MapModule.php @@ -1,15 +1,20 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ -namespace Netzmacht\Contao\Leaflet\Frontend; +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Frontend\Module; + +use Netzmacht\Contao\Leaflet\Frontend\AbstractMapHybrid; /** * The frontend module for the Leaflet map. @@ -30,10 +35,10 @@ class MapModule extends AbstractMapHybrid * * @return string */ - protected function getIdentifier() + protected function getIdentifier(): string { if ($this->get('leaflet_mapId')) { - return $this->get('leaflet_mapId'); + return (string) $this->get('leaflet_mapId'); } if ($this->get('cssID')[0]) { diff --git a/src/Frontend/Module/MapModuleFactory.php b/src/Frontend/Module/MapModuleFactory.php new file mode 100644 index 0000000..53e255d --- /dev/null +++ b/src/Frontend/Module/MapModuleFactory.php @@ -0,0 +1,115 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Frontend\Module; + +use Contao\Config; +use Contao\CoreBundle\Framework\Adapter; +use Contao\Input; +use Netzmacht\Contao\Leaflet\MapProvider; +use Netzmacht\Contao\Toolkit\Component\Component; +use Netzmacht\Contao\Toolkit\Component\ComponentFactory; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Symfony\Component\Templating\EngineInterface as TemplateEngine; +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Class MapElementFactory + * + * @package Netzmacht\Contao\Leaflet\Frontend\ContentElement + */ +class MapModuleFactory implements ComponentFactory +{ + /** + * Template engine. + * + * @var TemplateEngine + */ + private $templating; + + /** + * Translator. + * + * @var Translator + */ + private $translator; + + /** + * Map provider. + * + * @var MapProvider + */ + private $mapProvider; + + /** + * Input adapter. + * + * @var Input|Adapter + */ + private $input; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * MapElementFactory constructor. + * + * @param TemplateEngine $engine Template engine. + * @param Translator $translator Translator. + * @param MapProvider $mapProvider Map provider. + * @param RepositoryManager $repositoryManager Repository manager. + * @param Input|Adapter $input Input adapter. + */ + public function __construct( + TemplateEngine $engine, + Translator $translator, + MapProvider $mapProvider, + RepositoryManager $repositoryManager, + $input + ) { + $this->templating = $engine; + $this->translator = $translator; + $this->mapProvider = $mapProvider; + $this->input = $input; + $this->repositoryManager = $repositoryManager; + } + + /** + * {@inheritDoc} + */ + public function supports($model): bool + { + return $model->type === 'leaflet'; + } + + /** + * {@inheritDoc} + */ + public function create($model, string $column): Component + { + return new MapModule( + $model, + $this->templating, + $this->translator, + $this->mapProvider, + $this->repositoryManager, + $this->input, + $column + ); + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/RequestUrl.php b/src/Frontend/RequestUrl.php similarity index 69% rename from src/Netzmacht/Contao/Leaflet/Frontend/RequestUrl.php rename to src/Frontend/RequestUrl.php index cd37039..8603a9d 100644 --- a/src/Netzmacht/Contao/Leaflet/Frontend/RequestUrl.php +++ b/src/Frontend/RequestUrl.php @@ -1,17 +1,19 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Frontend; use Netzmacht\Contao\Leaflet\Filter\Filter; +use Netzmacht\Contao\Leaflet\Mapper\Request; /** * Class RequestUrl creates the request url. @@ -20,13 +22,6 @@ use Netzmacht\Contao\Leaflet\Filter\Filter; */ class RequestUrl implements \JsonSerializable { - /** - * The for param is the identifier to the responsible frontend module or content element. - * - * @var string - */ - private static $for; - /** * The leaflet hash. * @@ -53,44 +48,33 @@ class RequestUrl implements \JsonSerializable * * It combines the params and creates an hash for it. * - * @param int $dataId The data object id. - * @param string|null $type Object type. If empty it assumes a layer. - * @param string|null $format Data format. If empty it assumes geojson. - * @param Filter $filter Optional filter. + * @param int $dataId The data object id. + * @param string|null $type Object type. If empty it assumes a layer. + * @param string|null $format Data format. If empty it assumes geojson. + * @param Request $request Optional building request. * * @return RequestUrl */ - public static function create($dataId, $type = null, $format = null, Filter $filter = null) + public static function create($dataId, $type = null, $format = null, Request $request = null) { - $params = array( - 'for' => static::$for, + $params = [ + 'for' => $request ? $request->getMapIdentifier() : null, 'type' => $type != 'layer' ? $type : null, 'id' => $dataId, - 'format' => $format != 'geojson' ? $format : null - ); + 'format' => $format != 'geojson' ? $format : null, + ]; $hash = base64_encode(implode(',', $params)); $query = 'leaflet=' . $hash; - if ($filter) { + if ($request && $request->getFilter()) { + $filter = $request->getFilter(); $query .= '&f=' . $filter->getName() . '&v=' . $filter->toRequest(); } $url = \Config::get('websitePath') . '/' . \Frontend::addToUrl($query, false); - return new static($url, $hash, $filter); - } - - /** - * Set the for param. - * - * @param string $for The identifier which has the responsibility listen to the request. - * - * @return void - */ - public static function setFor($for) - { - static::$for = $for; + return new static($url, $hash, $request); } /** diff --git a/src/Frontend/ValueFilter.php b/src/Frontend/ValueFilter.php new file mode 100644 index 0000000..7efe103 --- /dev/null +++ b/src/Frontend/ValueFilter.php @@ -0,0 +1,78 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +namespace Netzmacht\Contao\Leaflet\Frontend; + +use Contao\CoreBundle\Framework\ContaoFrameworkInterface as ContaoFramework; +use Contao\InsertTags; + +/** + * Class ValueFilter is a service class which can be used to filter values before passing them to an definition object. + * + * @package Netzmacht\Contao\Leaflet\Frontend + */ +class ValueFilter +{ + /** + * Contao framework. + * + * @var ContaoFramework + */ + private $framework; + + /** + * Insert tags. + * + * @var InsertTags + */ + private $replacer; + + /** + * ValueFilter constructor. + * + * @param ContaoFramework $framework Contao framework. + */ + public function __construct(ContaoFramework $framework) + { + $this->framework = $framework; + } + + /** + * Get the replacer. + * + * @return InsertTags + */ + private function getReplacer(): InsertTags + { + if ($this->replacer === null) { + $this->framework->initialize(); + $this->replacer = $this->framework->createInstance(InsertTags::class); + } + + return $this->replacer; + } + + /** + * Filter a value so it can be passed to the frontend. + * + * The idea behind this extra method is that we just have to change one place if anything else than the + * insert tags has to be replaced. + * + * @param string $value The given value. + * + * @return string + */ + public function filter($value) + { + return $this->getReplacer()->replace($value); + } +} diff --git a/src/Listener/Dca/ControlDcaListener.php b/src/Listener/Dca/ControlDcaListener.php new file mode 100644 index 0000000..af820d5 --- /dev/null +++ b/src/Listener/Dca/ControlDcaListener.php @@ -0,0 +1,225 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +namespace Netzmacht\Contao\Leaflet\Listener\Dca; + +use Contao\StringUtil; +use Doctrine\DBAL\Connection; +use Netzmacht\Contao\Leaflet\Model\ControlModel; +use Netzmacht\Contao\Leaflet\Model\LayerModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Netzmacht\Contao\Toolkit\Dca\Listener\AbstractListener; +use Netzmacht\Contao\Toolkit\Dca\Manager; +use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder; + +/** + * Class Control is the helper for the tl_leaflet_control dca. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ +class ControlDcaListener extends AbstractListener +{ + /** + * Name of the data container. + * + * @var string + */ + protected static $name = 'tl_leaflet_control'; + + /** + * The database connection. + * + * @var Connection + */ + private $connection; + + /** + * Control types. + * + * @var array + */ + private $types; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Construct. + * + * @param Manager $manager Data container manager. + * @param Connection $connection Database connection. + * @param RepositoryManager $repositoryManager Repository manager. + * @param array $types Control types. + */ + public function __construct( + Manager $manager, + Connection $connection, + RepositoryManager $repositoryManager, + array $types + ) { + parent::__construct($manager); + + $this->connection = $connection; + $this->types = $types; + $this->repositoryManager = $repositoryManager; + } + + /** + * Get control types. + * + * @return array + */ + public function getControlTypes(): array + { + return $this->types; + } + + /** + * Generate a row. + * + * @param array $row The data row. + * + * @return string + */ + public function generateRow($row) + { + return sprintf( + '%s [%s]', + $row['title'], + $row['type'] + ); + } + + /** + * Get layers for the layers control. + * + * @return array + */ + public function getLayers() + { + $repository = $this->repositoryManager->getRepository(LayerModel::class); + $collection = $repository->findAll(); + + return OptionsBuilder::fromCollection($collection, 'title') + ->asTree() + ->getOptions(); + } + + /** + * Get the zoom controls for the reference value of the loading control. + * + * @return array + */ + public function getZoomControls() + { + $repository = $this->repositoryManager->getRepository(ControlModel::class); + $collection = $repository->findBy(['type=?'], ['zoom'], ['order' => 'title']); + + return OptionsBuilder::fromCollection($collection, 'title')->getOptions(); + } + + /** + * Load layer relations. + * + * @param mixed $value The actual value. + * @param \DataContainer $dataContainer The data container driver. + * + * @return array + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function loadLayerRelations($value, $dataContainer) + { + $query = 'SELECT lid As layer, mode FROM tl_leaflet_control_layer WHERE cid=:cid ORDER BY sorting'; + $statement = $this->connection->prepare($query); + + $statement->bindValue('cid', $dataContainer->id); + $statement->execute(); + + return $statement->fetchAll(); + } + + /** + * Save layer relations. + * + * @param mixed $layers The layer id values. + * @param \DataContainer $dataContainer The dataContainer driver. + * + * @return null + */ + public function saveLayerRelations($layers, $dataContainer) + { + $new = StringUtil::deserialize($layers, true); + $values = []; + $query = 'SELECT * FROM tl_leaflet_control_layer WHERE cid=:cid order BY sorting'; + $statement = $this->connection->prepare($query); + $statement->bindValue('cid', $dataContainer->id); + $statement->execute(); + + while ($row = $statement->fetch()) { + $values[$row['lid']] = $row; + } + + $sorting = 0; + + foreach ($new as $layer) { + if (!isset($values[$layer['layer']])) { + $data = [ + 'tstamp' => time(), + 'lid' => $layer['layer'], + 'cid' => $dataContainer->id, + 'mode' => $layer['mode'], + 'sorting' => $sorting, + ]; + + $this->connection->insert('tl_leaflet_control_layer', $data); + $sorting += 128; + } else { + $this->connection->update( + 'tl_leaflet_control_layer', + [ + 'tstamp' => time(), + 'sorting' => $sorting, + 'mode' => $layer['mode'], + ], + [ + 'id' => $values[$layer['layer']]['id'], + ] + ); + + $sorting += 128; + unset($values[$layer['layer']]); + } + } + + $ids = array_map( + function ($item) { + return $item['id']; + }, + $values + ); + + if ($ids) { + $this->connection->executeUpdate( + 'DELETE FROM tl_leaflet_control_layer WHERE id IN(?)', + [$ids], + [Connection::PARAM_INT_ARRAY] + ); + } + + return null; + } +} diff --git a/src/Listener/Dca/FrontendIntegrationListener.php b/src/Listener/Dca/FrontendIntegrationListener.php new file mode 100644 index 0000000..8a4f4c9 --- /dev/null +++ b/src/Listener/Dca/FrontendIntegrationListener.php @@ -0,0 +1,112 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Listener\Dca; + +use Contao\Image; +use Contao\RequestToken; +use Contao\StringUtil; +use Netzmacht\Contao\Leaflet\Model\MapModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder; +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Class Module is the helper for the tl_module dca. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ +final class FrontendIntegrationListener +{ + /** + * Translator. + * + * @var Translator + */ + private $translator; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * FrontendIntegration constructor. + * + * @param RepositoryManager $repositoryManager Repository manager. + * @param Translator $translator Translator. + */ + public function __construct(RepositoryManager $repositoryManager, Translator $translator) + { + $this->translator = $translator; + $this->repositoryManager = $repositoryManager; + } + + /** + * Get all leaflet maps. + * + * @return array + */ + public function getMaps(): array + { + $repository = $this->repositoryManager->getRepository(MapModel::class); + $collection = $repository->findAll(['order' => 'title']); + + return OptionsBuilder::fromCollection($collection, 'title')->getOptions(); + } + + /** + * Get edit map link wizard. + * + * @param \DataContainer $dataContainer The dataContainer driver. + * + * @return string + */ + public function getEditMapLink($dataContainer): string + { + if ($dataContainer->value < 1) { + return ''; + } + + $pattern = 'title="%s" style="padding-left: 3px" onclick="Backend.openModalIframe('; + $pattern .= '{\'width\':768,\'title\':\'%s\',\'url\':this.href});return false"'; + + return sprintf( + '%s', + 'contao/main.php?do=leaflet_map&table=tl_leaflet_map&act=edit&id=', + $dataContainer->value, + RequestToken::get(), + sprintf( + $pattern, + StringUtil::specialchars( + $this->translator->trans('editalias.1', [$dataContainer->value], 'contao_tl_content') + ), + StringUtil::specialchars( + str_replace( + "'", + "\\'", + sprintf($this->translator->trans('editalias.1', [$dataContainer->value], 'contao_tl_content')) + ) + ) + ), + Image::getHtml( + 'alias.gif', + $this->translator->trans('editalias.0', [$dataContainer->value], 'contao_tl_content'), + 'style="vertical-align:top"' + ) + ); + } +} diff --git a/src/Listener/Dca/IconDcaListener.php b/src/Listener/Dca/IconDcaListener.php new file mode 100644 index 0000000..ae82090 --- /dev/null +++ b/src/Listener/Dca/IconDcaListener.php @@ -0,0 +1,50 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Listener\Dca; + +/** + * Class IconDcaListener. + * + * @package Netzmacht\Contao\Leaflet\Listener\Dca + */ +class IconDcaListener +{ + /** + * Icon type options. + * + * @var array + */ + private $icons; + + /** + * IconDcaListener constructor. + * + * @param array $icons Icon type options. + */ + public function __construct(array $icons) + { + $this->icons = $icons; + } + + /** + * Get icon options. + * + * @return array + */ + public function getIconOptions(): array + { + return $this->icons; + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Dca/LayerCallbacks.php b/src/Listener/Dca/LayerDcaListener.php similarity index 50% rename from src/Netzmacht/Contao/Leaflet/Dca/LayerCallbacks.php rename to src/Listener/Dca/LayerDcaListener.php index 5831d0b..b0a8fde 100644 --- a/src/Netzmacht/Contao/Leaflet/Dca/LayerCallbacks.php +++ b/src/Listener/Dca/LayerDcaListener.php @@ -1,28 +1,38 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ -namespace Netzmacht\Contao\Leaflet\Dca; +namespace Netzmacht\Contao\Leaflet\Listener\Dca; -use ContaoCommunityAlliance\Translator\TranslatorInterface as Translator; -use Netzmacht\Contao\Toolkit\Dca\Callback\Callbacks; +use Contao\Backend; +use Contao\CoreBundle\Framework\Adapter; +use Contao\DataContainer; +use Contao\Image; +use Contao\StringUtil; +use Doctrine\DBAL\Connection; +use Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\LayerLabelRenderer; +use Netzmacht\Contao\Leaflet\Model\IconModel; +use Netzmacht\Contao\Leaflet\Model\LayerModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Netzmacht\Contao\Toolkit\Dca\Listener\AbstractListener; use Netzmacht\Contao\Toolkit\Dca\Manager; use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder; -use Netzmacht\Contao\Leaflet\Model\LayerModel; +use Symfony\Component\Translation\TranslatorInterface as Translator; /** * Class Layer is the helper class for the tl_leaflet_layer dca. * * @package Netzmacht\Contao\Leaflet\Dca */ -class LayerCallbacks extends Callbacks +class LayerDcaListener extends AbstractListener { /** * Name of the data container. @@ -31,13 +41,6 @@ class LayerCallbacks extends Callbacks */ protected static $name = 'tl_leaflet_layer'; - /** - * Helper service name. - * - * @var string - */ - protected static $serviceName = 'leaflet.dca.layer-callbacks'; - /** * Layers definition. * @@ -48,13 +51,20 @@ class LayerCallbacks extends Callbacks /** * The database connection. * - * @var \Database + * @var Connection */ - private $database; - + private $connection; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + /** * Tile providers configuration. - * + * * @var array */ private $tileProviders; @@ -73,33 +83,86 @@ class LayerCallbacks extends Callbacks */ private $amenities; + /** + * Layer label renderer. + * + * @var LayerLabelRenderer + */ + private $labelRenderer; + + /** + * File formats. + * + * @var array + */ + private $fileFormats; + + /** + * Backend adapter. + * + * @var Backend|Adapter + */ + private $backendAdapter; + /** * Construct. * - * @param Manager $manager Data container manager. - * @param \Database $database Database connection. - * @param Translator $translator Translator. - * @param array $layers Leaflet layer configuration. - * @param array $tileProviders Tile providers. - * @param array $amenities OSM amenities. + * @param Manager $manager Data container manager. + * @param Connection $connection Database connection. + * @param RepositoryManager $repositoryManager Repository manager. + * @param Translator $translator Translator. + * @param LayerLabelRenderer $labelRenderer Layer label renderer. + * @param Adapter|Backend $backendAdapter Backend adapter. + * @param array $layers Leaflet layer configuration. + * @param array $tileProviders Tile providers. + * @param array $amenities OSM amenities. + * @param array $fileFormats File formats. + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( Manager $manager, - \Database $database, + Connection $connection, + RepositoryManager $repositoryManager, Translator $translator, + LayerLabelRenderer $labelRenderer, + $backendAdapter, array $layers, array $tileProviders, - array $amenities + array $amenities, + array $fileFormats ) { parent::__construct($manager); - \Controller::loadLanguageFile('leaflet_layer'); + $this->connection = $connection; + $this->layers = $layers; + $this->tileProviders = $tileProviders; + $this->translator = $translator; + $this->amenities = $amenities; + $this->labelRenderer = $labelRenderer; + $this->fileFormats = $fileFormats; + $this->repositoryManager = $repositoryManager; + $this->backendAdapter = $backendAdapter; + } - $this->database = $database; - $this->layers = $layers; - $this->tileProviders = $tileProviders; - $this->translator = $translator; - $this->amenities = $amenities; + /** + * Get layer options. + * + * @return array + */ + public function getLayerOptions(): array + { + return array_keys($this->layers); + } + + /** + * Get tile provider options. + * + * @return array + */ + public function getProviderOptions(): array + { + return array_keys($this->tileProviders); } /** @@ -118,7 +181,7 @@ class LayerCallbacks extends Callbacks return $this->tileProviders[$dataContainer->activeRecord->tile_provider]['variants']; } - return array(); + return []; } /** @@ -133,21 +196,27 @@ class LayerCallbacks extends Callbacks { if (!empty($this->layers[$row['type']]['icon'])) { $src = $this->layers[$row['type']]['icon']; - } else { $src = 'iconPLAIN.gif'; } + $activeIcon = $src; + $disabledIcon = preg_replace('/(\.[^\.]+)$/', '_1$1', $src); + if (!$row['active']) { - $src = preg_replace('/(\.[^\.]+)$/', '_1$1', $src); + $src = $disabledIcon; } - $alt = $this->getFormatter()->formatValue('type', $row['type']); - $icon = \Image::getHtml($src, $alt, sprintf('title="%s"', strip_tags($alt))); + $alt = $this->getFormatter()->formatValue('type', $row['type']); + $attributes = sprintf( + 'class="list-icon" title="%s" data-icon="%s" data-icon-disabled="%s"', + StringUtil::specialchars(strip_tags($alt)), + $activeIcon, + $disabledIcon + ); - if (!empty($this->layers[$row['type']]['label'])) { - $label = $this->layers[$row['type']]['label']($row, $label); - } + $icon = Image::getHtml($src, $alt, $attributes); + $label = $this->labelRenderer->render($row, $label, $this->translator); return $icon . ' ' . $label; } @@ -168,7 +237,8 @@ class LayerCallbacks extends Callbacks ) ); - $collection = LayerModel::findMultipleByTypes($types); + $repository = $this->repositoryManager->getRepository(LayerModel::class); + $collection = $repository->findMultipleByTypes($types); $builder = OptionsBuilder::fromCollection( $collection, 'id', @@ -195,43 +265,42 @@ class LayerCallbacks extends Callbacks */ public function getPasteButtons($dataContainer, $row, $table, $whatever, $children) { - $pasteAfterUrl = \Controller::addToUrl( - 'act='.$children['mode'].'&mode=1&pid='.$row['id'] - .(!is_array($children['id']) ? '&id='.$children['id'] : '') + $pasteAfterUrl = $this->backendAdapter->addToUrl( + 'act=' . $children['mode'] . '&mode=1&pid=' . $row['id'] + . (!is_array($children['id']) ? '&id=' . $children['id'] : '') ); $buffer = sprintf( '%s ', $pasteAfterUrl, - specialchars($this->translator->translate('pasteafter.1', $table, [$row['id']])), - \Image::getHtml( + StringUtil::specialchars($this->translator->trans('pasteafter.1', [$row['id']], 'contao_' . $table)), + Image::getHtml( 'pasteafter.gif', - $this->translator->translate('pasteafter.1', $table, [$row['id']]) + $this->translator->trans('pasteafter.1', [$row['id']], 'contao_' . $table) ) ); if (!empty($this->layers[$row['type']]['children'])) { - $pasteIntoUrl = \Controller::addToUrl( + $pasteIntoUrl = $this->backendAdapter->addToUrl( sprintf( 'act=%s&mode=2&pid=%s%s', $children['mode'], $row['id'], - !is_array($children['id']) ? '&id='.$children['id'] : '' + !is_array($children['id']) ? '&id=' . $children['id'] : '' ) ); $buffer .= sprintf( '%s ', $pasteIntoUrl, - specialchars($this->translator->translate('pasteinto.1', $table, [$row['id']])), - \Image::getHtml( + StringUtil::specialchars($this->translator->trans('pasteinto.1', [$row['id']], 'contao_' . $table)), + Image::getHtml( 'pasteinto.gif', - $this->translator->translate('pasteinto.1', $table, [$row['id']]) + $this->translator->trans('pasteinto.1', [$row['id']], 'contao_' . $table) ) ); - } elseif ($row['id'] > 0) { - $buffer .= \Image::getHtml('pasteinto_.gif'); + $buffer .= Image::getHtml('pasteinto_.gif'); } return $buffer; @@ -290,42 +359,33 @@ class LayerCallbacks extends Callbacks public function deleteRelations($dataContainer, $undoId) { if ($undoId) { - $undo = $this->database - ->prepare('SELECT * FROM tl_undo WHERE id=?') - ->limit(1) - ->execute($undoId) - ->row(); + $statement = $this->connection->prepare('SELECT * FROM tl_undo WHERE id=:id LIMIT 0,1'); + $statement->bindValue('id', $undoId); + $statement->execute(); - $result = $this->database - ->prepare('SELECT * FROM tl_leaflet_map_layer WHERE lid=?') - ->execute($dataContainer->id); + $undo = $statement->fetch(); - $undo['data'] = deserialize($undo['data'], true); + $statement = $this->connection->prepare('SELECT * FROM tl_leaflet_map_layer WHERE lid=:lid'); + $statement->bindValue('lid', $dataContainer->id); + $statement->execute(); - while ($result->next()) { - $undo['data']['tl_leaflet_map_layer'][] = $result->row(); + $undo['data'] = StringUtil::deserialize($undo['data'], true); + + while ($row = $statement->fetch()) { + $undo['data']['tl_leaflet_map_layer'][] = $row; } - $result = $this->database - ->prepare('SELECT * FROM tl_leaflet_control_layer WHERE lid=?') - ->execute($dataContainer->id); + $statement = $this->connection->prepare('SELECT * FROM tl_leaflet_control_layer WHERE lid=:lid'); + $statement->bindValue('lid', $dataContainer->id); + $statement->execute(); - while ($result->next()) { - $undo['data']['tl_leaflet_control_layer'][] = $result->row(); - } + $undo['data']['tl_leaflet_control_layer'] = $statement->fetchAll(); - $this->database->prepare('UPDATE tl_undo %s WHERE id=?') - ->set(array('data' => $undo['data'])) - ->execute($undo['id']); + $this->connection->update('tl_undo', ['data' => $undo['data']], ['id' => $undo['id']]); } - $this->database - ->prepare('DELETE FROM tl_leaflet_map_layer WHERE lid=?') - ->execute($dataContainer->id); - - $this->database - ->prepare('DELETE FROM tl_leaflet_control_layer WHERE lid=?') - ->execute($dataContainer->id); + $this->connection->delete('tl_leaflet_map_layer', ['lid' => $dataContainer->id]); + $this->connection->delete('tl_leaflet_control_layer', ['lid' => $dataContainer->id]); } /** @@ -337,7 +397,7 @@ class LayerCallbacks extends Callbacks */ public function getBoundsModes($dataContainer) { - $options = array(); + $options = []; if ($dataContainer->activeRecord && !empty($this->layers[$dataContainer->activeRecord->type]['boundsMode'])) { foreach ($this->layers[$dataContainer->activeRecord->type]['boundsMode'] as $mode => $enabled) { @@ -361,7 +421,8 @@ class LayerCallbacks extends Callbacks */ public function getLayers($dataContainer) { - $collection = LayerModel::findBy('id !', $dataContainer->id); + $repository = $this->repositoryManager->getRepository(LayerModel::class); + $collection = $repository->findBy(['tl_leaflet_layer.id!=?'], [$dataContainer->id]); return OptionsBuilder::fromCollection($collection, 'title') ->asTree() @@ -378,6 +439,68 @@ class LayerCallbacks extends Callbacks return $this->amenities; } + /** + * Get all icons. + * + * @return array + */ + public function getIcons() + { + $repository = $this->repositoryManager->getRepository(IconModel::class); + $collection = $repository->findAll(['order' => 'title']); + $builder = OptionsBuilder::fromCollection( + $collection, + function ($model) { + return sprintf('%s [%s]', $model['title'], $model['type']); + } + ); + + return $builder->getOptions(); + } + + /** + * Get the file formats. + * + * @return array + */ + public function getFileFormats(): array + { + return array_keys($this->fileFormats); + } + + /** + * Prepare the file widget. + * + * @param mixed $value Given value. + * @param DataContainer $dataContainer Data container driver. + * + * @return mixed + */ + public function prepareFileWidget($value, $dataContainer) + { + if ($dataContainer->activeRecord) { + $fileFormat = $dataContainer->activeRecord->fileFormat; + + if (isset($this->fileFormats[$fileFormat])) { + $definition = $this->getDefinition(); + $definition->set( + ['fields', $dataContainer->field, 'eval', 'extensions'], + implode(',', $this->fileFormats[$fileFormat]) + ); + + $definition->set( + ['fields', $dataContainer->field, 'label', 1], + sprintf( + $definition->get(['fields', $dataContainer->field, 'label', 1]), + implode(', ', $this->fileFormats[$fileFormat]) + ) + ); + } + } + + return $value; + } + /** * Generate a button. * diff --git a/src/Listener/Dca/LeafletDcaListener.php b/src/Listener/Dca/LeafletDcaListener.php new file mode 100644 index 0000000..a8737ee --- /dev/null +++ b/src/Listener/Dca/LeafletDcaListener.php @@ -0,0 +1,163 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +namespace Netzmacht\Contao\Leaflet\Listener\Dca; + +use Contao\CoreBundle\Framework\Adapter; +use Contao\DataContainer; +use Contao\System; +use Netzmacht\Contao\Leaflet\Model\LayerModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Netzmacht\LeafletPHP\Value\LatLng; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Templating\EngineInterface as TemplateEngine; + +/** + * Class Leaflet is the base helper providing different methods. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ +class LeafletDcaListener +{ + /** + * File system. + * + * @var Filesystem + */ + private $fileSystem; + + /** + * Cache dir. + * + * @var string + */ + private $cacheDir; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Template engine. + * + * @var TemplateEngine + */ + private $templateEngine; + + /** + * System adapter. + * + * @var Adapter|System + */ + private $systemAdapter; + + /** + * LeafletCallbacks constructor. + * + * @param RepositoryManager $repositoryManager Repository manager. + * @param TemplateEngine $templateEngine Template engine. + * @param Filesystem $fileSystem File system. + * @param Adapter|System $systemAdapter Contao system adapter. + * @param string $cacheDir Cache dir. + */ + public function __construct( + RepositoryManager $repositoryManager, + TemplateEngine $templateEngine, + Filesystem $fileSystem, + $systemAdapter, + string $cacheDir + ) { + $this->repositoryManager = $repositoryManager; + $this->templateEngine = $templateEngine; + $this->fileSystem = $fileSystem; + $this->systemAdapter = $systemAdapter; + $this->cacheDir = $cacheDir; + } + + /** + * Load the language files. + * + * @return void + */ + public function loadLanguageFile() + { + $this->systemAdapter->loadLanguageFile('leaflet'); + } + + /** + * Create the zoom range. + * + * @return array + */ + public function getZoomLevels() + { + return range(1, 20); + } + + /** + * Get the geocoder wizard. + * + * @param DataContainer $dataContainer The dataContainer driver. + * + * @return string + */ + public function getGeocoder($dataContainer) + { + $data['field'] = 'ctrl_' . $dataContainer->field; + + try { + $latLng = LatLng::fromString($dataContainer->value); + $data['marker'] = json_encode($latLng); + } catch (\Exception $e) { + // LatLng throws an exception of value could not be created. Just let the value empty when. + } + + return $this->templateEngine->render('toolkit:be:be_leaflet_geocode.html5', $data); + } + + /** + * Get all layers. + * + * @return array + */ + public function getLayers() + { + $options = []; + $repository = $this->repositoryManager->getRepository(LayerModel::class); + $collection = $repository->findBy(['pid=?'], ['0'], ['order' => 'title']); + + if ($collection) { + foreach ($collection as $model) { + $options[$model->id] = $model->title; + } + } + + return $options; + } + + /** + * Clear the leaflet cache. + * + * @param mixed $value Value when used as save_callback. + * + * @return mixed + */ + public function clearCache($value = null) + { + $this->fileSystem->remove($this->cacheDir); + + return $value; + } +} diff --git a/src/Listener/Dca/MapDcaListener.php b/src/Listener/Dca/MapDcaListener.php new file mode 100644 index 0000000..2a4077e --- /dev/null +++ b/src/Listener/Dca/MapDcaListener.php @@ -0,0 +1,174 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Listener\Dca; + +use Contao\DataContainer; +use Contao\StringUtil; +use Doctrine\DBAL\Connection; +use Netzmacht\Contao\Leaflet\Model\LayerModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Netzmacht\Contao\Toolkit\Dca\Listener\AbstractListener; +use Netzmacht\Contao\Toolkit\Dca\Manager; +use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder; +use PDO; + +/** + * Class Map is the helper class for the tl_leaflet_map dca. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ +class MapDcaListener extends AbstractListener +{ + /** + * Name of the data container. + * + * @var string + */ + protected static $name = 'tl_leaflet_map'; + + /** + * The database connection. + * + * @var Connection + */ + private $connection; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Construct. + * + * @param Manager $manager Data container manager. + * @param Connection $connection Database connection. + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(Manager $manager, Connection $connection, RepositoryManager $repositoryManager) + { + parent::__construct($manager); + + $this->connection = $connection; + $this->repositoryManager = $repositoryManager; + } + + /** + * Load layer relations. + * + * @param mixed $value The actual value. + * @param DataContainer $dataContainer The data container driver. + * + * @return array + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function loadLayerRelations($value, $dataContainer): array + { + $statement = $this->connection->prepare('SELECT lid FROM tl_leaflet_map_layer WHERE mid=:mid ORDER BY sorting'); + $statement->bindValue('mid', $dataContainer->id); + + if ($statement->execute()) { + return $statement->fetchAll(PDO::FETCH_COLUMN, 0); + } + + return []; + } + + /** + * Save layer relations. + * + * @param mixed $layerId The layer id values. + * @param DataContainer $dataContainer The dataContainer driver. + * + * @return null + */ + public function saveLayerRelations($layerId, $dataContainer) + { + $new = array_filter(StringUtil::deserialize($layerId, true)); + $values = []; + $statement = $this->connection->prepare('SELECT * FROM tl_leaflet_map_layer WHERE mid=:mid order BY sorting'); + + $statement->bindValue('mid', $dataContainer->id); + $statement->execute(); + + while ($row = $statement->fetch()) { + $values[$row['lid']] = $row; + } + + $sorting = 0; + + foreach ($new as $layerId) { + if (!isset($values[$layerId])) { + $data = [ + 'tstamp' => time(), + 'lid' => $layerId, + 'mid' => $dataContainer->id, + 'sorting' => $sorting, + ]; + + $this->connection->insert('tl_leaflet_map_layer', $data); + $sorting += 128; + } else { + if ($values[$layerId]['sorting'] <= ($sorting - 128) + || $values[$layerId]['sorting'] >= ($sorting + 128) + ) { + $this->connection->update( + 'tl_leaflet_map_layer', + ['tstamp' => time(), 'sorting' => $sorting], + ['id' => $values[$layerId]['id']] + ); + } + + $sorting += 128; + unset($values[$layerId]); + } + } + + $ids = array_map( + function ($item) { + return $item['id']; + }, + $values + ); + + if ($ids) { + $this->connection->executeUpdate( + 'DELETE FROM tl_leaflet_map_layer WHERE id IN(?)', + [$ids], + [Connection::PARAM_INT_ARRAY] + ); + } + + return null; + } + + /** + * Get all layers except of the current layer. + * + * @return array + */ + public function getLayers() + { + $repository = $this->repositoryManager->getRepository(LayerModel::class); + $collection = $repository->findAll(['order' => 'title']); + + return OptionsBuilder::fromCollection($collection, 'title') + ->asTree() + ->getOptions(); + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Dca/MarkerCallbacks.php b/src/Listener/Dca/MarkerDcaListener.php similarity index 54% rename from src/Netzmacht/Contao/Leaflet/Dca/MarkerCallbacks.php rename to src/Listener/Dca/MarkerDcaListener.php index 0b9aa40..916f7fa 100644 --- a/src/Netzmacht/Contao/Leaflet/Dca/MarkerCallbacks.php +++ b/src/Listener/Dca/MarkerDcaListener.php @@ -1,27 +1,57 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ -namespace Netzmacht\Contao\Leaflet\Dca; +namespace Netzmacht\Contao\Leaflet\Listener\Dca; -use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder; +use Contao\Controller; +use Doctrine\DBAL\Connection; use Netzmacht\Contao\Leaflet\Model\IconModel; use Netzmacht\Contao\Leaflet\Model\PopupModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder; /** * Class Marker is the dca helper class for the tl_leaflet_marker dca. * * @package Netzmacht\Contao\Leaflet\Dca */ -class MarkerCallbacks +class MarkerDcaListener { + /** + * Database connection. + * + * @var Connection + */ + private $connection; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * MarkerDcaListener constructor. + * + * @param Connection $connection Database connection. + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(Connection $connection, RepositoryManager $repositoryManager) + { + $this->connection = $connection; + $this->repositoryManager = $repositoryManager; + } + /** * Generate the row label. * @@ -41,7 +71,8 @@ class MarkerCallbacks */ public function getIcons() { - $collection = IconModel::findAll(array('order' => 'title')); + $repository = $this->repositoryManager->getRepository(IconModel::class); + $collection = $repository->findAll(['order' => 'title']); $builder = OptionsBuilder::fromCollection( $collection, function ($model) { @@ -59,7 +90,8 @@ class MarkerCallbacks */ public function getPopups() { - $collection = PopupModel::findAll(array('order' => 'title')); + $repository = $this->repositoryManager->getRepository(PopupModel::class); + $collection = $repository->findAll(['order' => 'title']); $builder = OptionsBuilder::fromCollection($collection, 'title'); return $builder->getOptions(); @@ -75,11 +107,11 @@ class MarkerCallbacks */ public function saveCoordinates($value, $dataContainer) { - $combined = array( + $combined = [ 'latitude' => null, 'longitude' => null, - 'altitude' => null - ); + 'altitude' => null, + ]; $values = trimsplit(',', $value); $keys = array_keys($combined); @@ -91,10 +123,7 @@ class MarkerCallbacks } } - \Database::getInstance() - ->prepare('UPDATE tl_leaflet_marker %s WHERE id=?') - ->set($combined) - ->execute($dataContainer->id); + $this->connection->update('tl_leaflet_marker', $combined, ['id' => $dataContainer->id]); return null; } @@ -111,21 +140,23 @@ class MarkerCallbacks */ public function loadCoordinates($value, $dataContainer) { - $result = \Database::getInstance() - ->prepare('SELECT latitude, longitude, altitude FROM tl_leaflet_marker WHERE id=?') - ->execute($dataContainer->id); + $query = 'SELECT latitude, longitude, altitude FROM tl_leaflet_marker WHERE id=:id'; + $statement = $this->connection->prepare($query); + $statement->bindValue('id', $dataContainer->id); - if ($result->numRows) { - $buffer = $result->latitude; + $statement->execute(); - if ($buffer && $result->longitude) { - $buffer .= ',' . $result->longitude; + if ($row = $statement->fetch()) { + $buffer = $row['latitude']; + + if ($buffer && $row['longitude']) { + $buffer .= ',' . $row['longitude']; } else { return $buffer; } - if ($buffer && $result->altitude) { - $buffer .= ',' . $result->longitude; + if ($buffer && $row['altitude']) { + $buffer .= ',' . $row['altitude']; } return $buffer; diff --git a/src/Listener/Dca/StyleDcaListener.php b/src/Listener/Dca/StyleDcaListener.php new file mode 100644 index 0000000..95e276c --- /dev/null +++ b/src/Listener/Dca/StyleDcaListener.php @@ -0,0 +1,50 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Listener\Dca; + +/** + * Class StyleDcaListener. + * + * @package Netzmacht\Contao\Leaflet\Listener\Dca + */ +class StyleDcaListener +{ + /** + * Style type options. + * + * @var array + */ + private $icons; + + /** + * StyleDcaListener constructor. + * + * @param array $styles Styles options. + */ + public function __construct(array $styles) + { + $this->icons = $styles; + } + + /** + * Get style options. + * + * @return array + */ + public function getStyleOptions(): array + { + return $this->icons; + } +} diff --git a/src/Listener/Dca/Validator.php b/src/Listener/Dca/Validator.php new file mode 100644 index 0000000..89ad56e --- /dev/null +++ b/src/Listener/Dca/Validator.php @@ -0,0 +1,163 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +namespace Netzmacht\Contao\Leaflet\Listener\Dca; + +use Contao\DataContainer; +use Netzmacht\Contao\Toolkit\Dca\Manager; +use Netzmacht\LeafletPHP\Value\LatLng; +use Symfony\Component\Translation\TranslatorInterface as Translator; + +/** + * Class Validator. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ +class Validator +{ + /** + * Translator. + * + * @var Translator; + */ + private $translator; + + /** + * Data container manager. + * + * @var Manager + */ + private $dcaManager; + + /** + * Validator constructor. + * + * @param Manager $dcaManager Data container manager. + * @param Translator $translator Translator. + */ + public function __construct(Manager $dcaManager, Translator $translator) + { + $this->translator = $translator; + $this->dcaManager = $dcaManager; + } + + /** + * Validate coordinates. + * + * @param mixed $value Given value. + * @param DataContainer $dataContainer Data container driver. + * + * @return mixed + * + * @throws \InvalidArgumentException When invalid coordinates given. + */ + public function validateCoordinates($value, $dataContainer) + { + if (!$value && !$this->isRequired($dataContainer)) { + return $value; + } + + try { + LatLng::fromString($value); + } catch (\Exception $e) { + throw new \InvalidArgumentException( + $this->translator->trans('invalidCoordinates', [$value], 'contao_leaflet'), + 0, + $e + ); + } + + return $value; + } + + /** + * Validate multiple coordinates. + * + * @param mixed $values Given value. + * @param DataContainer $dataContainer Data container driver. + * + * @return mixed + * + * @throws \InvalidArgumentException When invalid coordinates given. + */ + public function validateMultipleCoordinates($values, $dataContainer) + { + if (!is_array($values)) { + $lines = explode("\n", $values); + } else { + $lines = $values; + } + + foreach ($lines as $coordinate) { + $this->validateCoordinates($coordinate, $dataContainer); + } + + return $values; + } + + /** + * Validate multiple coordinate sets. + * + * @param mixed $values Given value. + * @param DataContainer $dataContainer Data container driver. + * + * @return mixed + * + * @throws \InvalidArgumentException When invalid coordinates given. + */ + public function validateMultipleCoordinateSets($values, $dataContainer) + { + $sets = deserialize($values, true); + foreach ($sets as $lines) { + $this->validateMultipleCoordinates($lines, $dataContainer); + } + + return $values; + } + + /** + * Validate an alias. + * + * @param string $value Given value. + * + * @return string + * @throws \InvalidArgumentException When invalid value given. + */ + public function validateAlias($value) + { + if (preg_match('/^[A-Za-z_]+[A-Za-z0-9_]+$/', $value) !== 1) { + throw new \InvalidArgumentException( + $this->translator->trans('invalidAlias', [], 'contao_leaflet') + ); + } + + return $value; + } + + /** + * Check if value is required. + * + * @param DataContainer $dataContainer Data container driver. + * + * @return bool + */ + private function isRequired($dataContainer): bool + { + $definition = $this->dcaManager->getDefinition($dataContainer->table); + + if ($definition->get(['fields', $dataContainer->field, 'eval', 'mandatory'])) { + return true; + } + + return false; + } +} diff --git a/src/Listener/Dca/VectorDcaListener.php b/src/Listener/Dca/VectorDcaListener.php new file mode 100644 index 0000000..34f234d --- /dev/null +++ b/src/Listener/Dca/VectorDcaListener.php @@ -0,0 +1,117 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +namespace Netzmacht\Contao\Leaflet\Listener\Dca; + +use Netzmacht\Contao\Leaflet\Model\PopupModel; +use Netzmacht\Contao\Leaflet\Model\StyleModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Netzmacht\Contao\Toolkit\Dca\Listener\AbstractListener; +use Netzmacht\Contao\Toolkit\Dca\Manager; +use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder; + +/** + * Helper class for the tl_leaflet_vector dca. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ +class VectorDcaListener extends AbstractListener +{ + /** + * Name of the data container. + * + * @var string + */ + protected static $name = 'tl_leaflet_vector'; + + /** + * Vector options. + * + * @var array + */ + private $vectors; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Construct. + * + * @param Manager $dcaManager Data container manager. + * @param RepositoryManager $repositoryManager Repository manager. + * @param array $vectors Vectors. + */ + public function __construct(Manager $dcaManager, RepositoryManager $repositoryManager, array $vectors) + { + parent::__construct($dcaManager); + + $this->vectors = $vectors; + $this->repositoryManager = $repositoryManager; + } + + /** + * Get the vector options. + * + * @return array + */ + public function getVectorOptions(): array + { + return $this->vectors; + } + + /** + * Generate the row label. + * + * @param array $row Current data row. + * + * @return string + */ + public function generateRow($row) + { + return sprintf( + '%s (%s)', + $row['title'], + $this->getFormatter()->formatValue('type', $row['type']) + ); + } + + /** + * Get all styles. + * + * @return array + */ + public function getStyles() + { + $repository = $this->repositoryManager->getRepository(StyleModel::class); + $collection = $repository->findAll(['order' => 'title']); + + return OptionsBuilder::fromCollection($collection, 'title')->getOptions(); + } + + /** + * Get all popups. + * + * @return array + */ + public function getPopups() + { + $repository = $this->repositoryManager->getRepository(PopupModel::class); + $collection = $repository->findAll(['order' => 'title']); + $builder = OptionsBuilder::fromCollection($collection, 'title'); + + return $builder->getOptions(); + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Subscriber/GeoJsonSubscriber.php b/src/Listener/GeoJsonListener.php similarity index 63% rename from src/Netzmacht/Contao/Leaflet/Subscriber/GeoJsonSubscriber.php rename to src/Listener/GeoJsonListener.php index 4b9d819..4c64914 100644 --- a/src/Netzmacht/Contao/Leaflet/Subscriber/GeoJsonSubscriber.php +++ b/src/Listener/GeoJsonListener.php @@ -1,32 +1,39 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ -namespace Netzmacht\Contao\Leaflet\Subscriber; +declare(strict_types=1); -use Netzmacht\Contao\Leaflet\Dca\VectorCallbacks; +namespace Netzmacht\Contao\Leaflet\Listener; + +use Contao\FilesModel; +use Contao\Model; use Netzmacht\Contao\Leaflet\Event\ConvertToGeoJsonEvent; use Netzmacht\Contao\Leaflet\Model\LayerModel; -use Netzmacht\LeafletPHP\Value\GeoJson\Feature; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Netzmacht\LeafletPHP\Definition as LeafletDefinition; use Netzmacht\LeafletPHP\Definition\HasPopup; use Netzmacht\LeafletPHP\Definition\UI\Marker; +use Netzmacht\LeafletPHP\Definition\Vector; use Netzmacht\LeafletPHP\Definition\Vector\Circle; use Netzmacht\LeafletPHP\Definition\Vector\CircleMarker; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Netzmacht\LeafletPHP\Value\GeoJson\Feature; +use Netzmacht\LeafletPHP\Value\GeoJson\GeoJsonObject; /** * Class GeoJsonSubscriber provides subscribers when a definition is converted to a geo json feature. * * @package Netzmacht\Contao\Leaflet\Subscriber */ -class GeoJsonSubscriber implements EventSubscriberInterface +final class GeoJsonListener { /** * Property mapping between models and features. @@ -35,43 +42,54 @@ class GeoJsonSubscriber implements EventSubscriberInterface */ private $featureModelProperties; + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + /** * GeoJsonSubscriber constructor. * - * @param array $featureModelProperties Property mapping between models and features. + * @param RepositoryManager $repositoryManager Repository manager. + * @param array $featureModelProperties Property mapping between models and features. */ - public function __construct(array $featureModelProperties) + public function __construct(RepositoryManager $repositoryManager, array $featureModelProperties) { + $this->repositoryManager = $repositoryManager; $this->featureModelProperties = $featureModelProperties; } /** - * {@inheritdoc} + * Handle the event. + * + * @param ConvertToGeoJsonEvent $event The event. + * + * @return void */ - public static function getSubscribedEvents() + public function handle(ConvertToGeoJsonEvent $event) { - return array( - ConvertToGeoJsonEvent::NAME => array( - array('addPopup'), - array('enrichObjects'), - array('enrichCircle'), - array('setModelData') - ) - ); + $feature = $event->getGeoJson(); + $definition = $event->getDefinition(); + $model = $event->getModel(); + + $this->addPopup($feature, $definition); + $this->enrichObjects($feature, $definition, $model); + $this->enrichCircle($feature, $definition); + $this->setModelData($feature, $model); } /** * Add popup property for definitions with an popup. * - * @param ConvertToGeoJsonEvent $event The subscribed event. + * @param GeoJsonObject $feature The geojson feature object. + * @param LeafletDefinition $definition The definition. * * @return void */ - public function addPopup(ConvertToGeoJsonEvent $event) + public function addPopup(GeoJsonObject $feature, LeafletDefinition $definition) { - $feature = $event->getGeoJson(); - $definition = $event->getDefinition(); - if ($definition instanceof HasPopup && $feature instanceof Feature) { if ($definition->getPopup()) { $feature->setProperty('popup', $definition->getPopup()); @@ -90,17 +108,15 @@ class GeoJsonSubscriber implements EventSubscriberInterface /** * Enrich map object with feature data and bounds information. * - * @param ConvertToGeoJsonEvent $event The subscribed event. + * @param GeoJsonObject $feature The geojson feature object. + * @param LeafletDefinition $definition The definition. + * @param Model|object $model The data model. * * @return void */ - public function enrichObjects(ConvertToGeoJsonEvent $event) + public function enrichObjects(GeoJsonObject $feature, LeafletDefinition $definition, $model) { - $feature = $event->getGeoJson(); - $definition = $event->getDefinition(); - $model = $event->getModel(); - - if (($definition instanceof Marker || $definition instanceof VectorCallbacks) + if (($definition instanceof Marker || $definition instanceof Vector) && $model instanceof \Model && $feature instanceof Feature) { $this->setDataProperty($model, $feature); $this->setBoundsInformation($model, $feature); @@ -110,32 +126,28 @@ class GeoJsonSubscriber implements EventSubscriberInterface /** * Enrich the the circle with constructor arguments. * - * @param ConvertToGeoJsonEvent $event The subscribed events. + * @param GeoJsonObject $feature The geojson feature object. + * @param LeafletDefinition $definition The definition. * * @return void */ - public function enrichCircle(ConvertToGeoJsonEvent $event) + public function enrichCircle(GeoJsonObject $feature, LeafletDefinition $definition) { - $feature = $event->getGeoJson(); - $definition = $event->getDefinition(); - if ($definition instanceof Circle && !$definition instanceof CircleMarker && $feature instanceof Feature) { - $feature->setProperty('arguments', array($definition->getLatLng(), $definition->getRadius())); + $feature->setProperty('arguments', [$definition->getLatLng(), $definition->getRadius()]); } } /** * Pass configured properties on an model to the properties.model key. * - * @param ConvertToGeoJsonEvent $event The subscribed events. + * @param GeoJsonObject $feature The geojson feature object. + * @param Model|object $model The data model. * * @return void */ - public function setModelData(ConvertToGeoJsonEvent $event) + public function setModelData(GeoJsonObject $feature, $model) { - $feature = $event->getGeoJson(); - $model = $event->getModel(); - if (!$model instanceof \Model || !$feature instanceof Feature || empty($this->featureModelProperties[$model->getTable()])) { return; @@ -175,17 +187,19 @@ class GeoJsonSubscriber implements EventSubscriberInterface break; case 'file': - $file = \FilesModel::findByUuid($value); - $value = $file->path; + $repository = $this->repositoryManager->getRepository(FilesModel::class); + $file = $repository->findByUuid($value); + $value = $file->path; break; case 'files': - $collection = \FilesModel::findMultipleByUuids(deserialize($value, true)); + $repository = $this->repositoryManager->getRepository(FilesModel::class); + $collection = $repository->findMultipleByUuids(deserialize($value, true)); if ($collection) { $value = $collection->fetchEach('path'); } else { - $value = array(); + $value = []; } break; @@ -212,7 +226,8 @@ class GeoJsonSubscriber implements EventSubscriberInterface if ($model->ignoreForBounds) { $feature->setProperty('ignoreForBounds', true); } else { - $parent = LayerModel::findByPk($model->pid); + $repository = $this->repositoryManager->getRepository(LayerModel::class); + $parent = $repository->find((int) $model->pid); if ($parent && $parent->boundsMode !== 'extend') { $feature->setProperty('ignoreForBounds', true); diff --git a/src/Netzmacht/Contao/Leaflet/Subscriber/HashSubscriber.php b/src/Listener/HashSubscriber.php similarity index 78% rename from src/Netzmacht/Contao/Leaflet/Subscriber/HashSubscriber.php rename to src/Listener/HashSubscriber.php index 65a1883..ba375c0 100644 --- a/src/Netzmacht/Contao/Leaflet/Subscriber/HashSubscriber.php +++ b/src/Listener/HashSubscriber.php @@ -1,15 +1,16 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ -namespace Netzmacht\Contao\Leaflet\Subscriber; +namespace Netzmacht\Contao\Leaflet\Listener; use Netzmacht\Contao\Leaflet\Event\GetHashEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -26,12 +27,12 @@ class HashSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array( - GetHashEvent::NAME => array( - array('getModelHash'), - array('getFallback', -100) - ) - ); + return [ + GetHashEvent::NAME => [ + ['getModelHash'], + ['getFallback', -100], + ], + ]; } /** diff --git a/src/Listener/LoadAssetsListener.php b/src/Listener/LoadAssetsListener.php new file mode 100644 index 0000000..79715f8 --- /dev/null +++ b/src/Listener/LoadAssetsListener.php @@ -0,0 +1,155 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Listener; + +use Netzmacht\Contao\Leaflet\Encoder\ContaoAssets; +use Netzmacht\Contao\Leaflet\Frontend\Assets\LibrariesConfiguration; +use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Model\IconModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Netzmacht\LeafletPHP\Assets; +use Netzmacht\LeafletPHP\Definition\Type\Icon; +use Netzmacht\LeafletPHP\Definition\Type\ImageIcon; + +/** + * Class LoadAssetsListener. + * + * @package Netzmacht\Contao\Leaflet\Listener + */ +class LoadAssetsListener +{ + /** + * Assets. + * + * @var Assets + */ + private $assets; + + /** + * Definition mapper. + * + * @var DefinitionMapper + */ + private $definitionMapper; + + /** + * Libraries. + * + * @var LibrariesConfiguration + */ + private $libraries; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * LoadAssetsListener constructor. + * + * @param Assets $assets Assets. + * @param DefinitionMapper $definitionMapper Definition mapper. + * @param RepositoryManager $repositoryManager Repository manager. + * @param LibrariesConfiguration $libraries Libraries. + */ + public function __construct( + Assets $assets, + DefinitionMapper $definitionMapper, + RepositoryManager $repositoryManager, + LibrariesConfiguration $libraries + ) { + $this->assets = $assets; + $this->definitionMapper = $definitionMapper; + $this->libraries = $libraries; + $this->repositoryManager = $repositoryManager; + } + + /** + * Handle the get javascript event. + * + * @return void + */ + public function onGetJavascriptEvent() + { + $this->assets->addJavascript( + 'bundles/netzmachtcontaoleaflet/js/contao-leaflet.js', + ContaoAssets::TYPE_FILE + ); + + $repository = $this->repositoryManager->getRepository(IconModel::class); + $collection = $repository->findBy(['active=?'], [true]); + + if ($collection) { + $buffer = ''; + $icons = []; + + foreach ($collection as $model) { + /** @var ImageIcon $icon */ + $icon = $this->definitionMapper->handle($model); + $icons[] = [ + 'id' => $icon->getId(), + 'type' => lcfirst($icon->getType()), + 'options' => $icon->getOptions(), + ]; + + $this->loadIconsLibraries($icon); + } + + if ($icons) { + $buffer = sprintf('L.contao.loadIcons(%s);', json_encode($icons)); + } + + // @codingStandardsIgnoreStart + // TODO: Cache it. + // codingStandardsIgnoreEnd + + $file = new \File('assets/leaflet/js/icons.js'); + $file->write($buffer); + $file->close(); + + $this->assets->addJavascript('assets/leaflet/js/icons.js', ContaoAssets::TYPE_FILE); + } + } + + /** + * Load all libraries for an icon. + * + * @param Icon $icon Icon definition. + * + * @return void + */ + protected function loadIconsLibraries($icon) + { + foreach ($icon::getRequiredLibraries() as $library) { + if (!isset($this->libraries[$library])) { + continue; + } + + $assets = $this->libraries[$library]; + + if (!empty($assets['css'])) { + list ($source, $type) = (array) $assets['css']; + $this->assets->addStylesheet($source, $type ?: Assets::TYPE_FILE); + } + + if (!empty($assets['javascript'])) { + list ($source, $type) = (array) $assets['javascript']; + $this->assets->addJavascript($source, $type ?: Assets::TYPE_FILE); + } + } + } +} diff --git a/src/Listener/RegisterLibrariesListener.php b/src/Listener/RegisterLibrariesListener.php new file mode 100644 index 0000000..96fbc85 --- /dev/null +++ b/src/Listener/RegisterLibrariesListener.php @@ -0,0 +1,72 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Listener; + +use Netzmacht\Contao\Leaflet\Frontend\Assets\LibrariesConfiguration; +use Netzmacht\LeafletPHP\Assets; +use Netzmacht\LeafletPHP\Leaflet; + +/** + * Class RegisterLibrariesListener. + * + * @package Netzmacht\Contao\Leaflet\Listener + */ +final class RegisterLibrariesListener +{ + /** + * Libraries configuration. + * + * @var LibrariesConfiguration + */ + private $libraries; + + /** + * Leaflet builder. + * + * @var Leaflet + */ + private $leaflet; + + /** + * RegisterLibrariesListener constructor. + * + * @param LibrariesConfiguration $libraries Libraries configuration. + * @param Leaflet $leaflet Leaflet builder. + */ + public function __construct(LibrariesConfiguration $libraries, Leaflet $leaflet) + { + $this->libraries = $libraries; + $this->leaflet = $leaflet; + } + + /** + * Handle the on initialize system hook. + * + * @return void + */ + public function onInitializeSystem() + { + foreach ($this->libraries as $name => $assets) { + if (!empty($assets['css'])) { + list ($source, $type) = (array) $assets['css']; + $this->leaflet->registerStylesheet($name, $source, $type ?: Assets::TYPE_FILE); + } + if (!empty($assets['javascript'])) { + list ($source, $type) = (array) $assets['javascript']; + $this->leaflet->registerJavascript($name, $source, $type ?: Assets::TYPE_FILE); + } + } + } +} diff --git a/src/Netzmacht/Contao/Leaflet/MapProvider.php b/src/MapProvider.php similarity index 70% rename from src/Netzmacht/Contao/Leaflet/MapProvider.php rename to src/MapProvider.php index 01293bb..d630dcf 100644 --- a/src/Netzmacht/Contao/Leaflet/MapProvider.php +++ b/src/MapProvider.php @@ -1,28 +1,34 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet; +use Contao\Input; use Doctrine\Common\Cache\Cache; +use Netzmacht\Contao\Leaflet\Encoder\ContaoAssets; use Netzmacht\Contao\Leaflet\Event\GetJavascriptEvent; use Netzmacht\Contao\Leaflet\Filter\Filter; use Netzmacht\Contao\Leaflet\Frontend\DataController; -use Netzmacht\Contao\Leaflet\Frontend\RequestUrl; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\LayerModel; use Netzmacht\Contao\Leaflet\Model\MapModel; -use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Netzmacht\Contao\Toolkit\View\Template\TemplateReference; use Netzmacht\LeafletPHP\Definition\Map; use Netzmacht\LeafletPHP\Leaflet; +use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection; use Symfony\Component\EventDispatcher\EventDispatcherInterface as EventDispatcher; +use Symfony\Component\Templating\EngineInterface as TemplateEngine; /** * Class MapProvider. @@ -66,20 +72,6 @@ class MapProvider */ private $assets; - /** - * Request filters configuration. - * - * @var array - */ - private $filters; - - /** - * Display errors setting. - * - * @var bool - */ - private $displayErrors; - /** * Cache. * @@ -87,36 +79,60 @@ class MapProvider */ private $cache; + /** + * Data controller. + * + * @var DataController + */ + private $dataController; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Template engine. + * + * @var TemplateEngine + */ + private $templateEngine; + /** * Construct. * - * @param DefinitionMapper $mapper The definition mapper. - * @param Leaflet $leaflet The Leaflet instance. - * @param EventDispatcher $eventDispatcher The Contao event dispatcher. - * @param \Input $input Thw request input. - * @param ContaoAssets $assets Assets handler. - * @param Cache $cache Cache. - * @param array $filters Request filters configuration. - * @param bool $displayErrors Display errors setting. + * @param DefinitionMapper $mapper The definition mapper. + * @param Leaflet $leaflet The Leaflet instance. + * @param EventDispatcher $eventDispatcher The Contao event dispatcher. + * @param Input $input Thw request input. + * @param ContaoAssets $assets Assets handler. + * @param Cache $cache Cache. + * @param DataController $dataController Data controller. + * @param RepositoryManager $repositoryManager Repository manager. + * @param TemplateEngine $templateEngine Template engine. */ public function __construct( DefinitionMapper $mapper, Leaflet $leaflet, EventDispatcher $eventDispatcher, - \Input $input, + $input, ContaoAssets $assets, Cache $cache, - array $filters, - $displayErrors + DataController $dataController, + RepositoryManager $repositoryManager, + TemplateEngine $templateEngine ) { - $this->mapper = $mapper; - $this->leaflet = $leaflet; - $this->eventDispatcher = $eventDispatcher; - $this->input = $input; - $this->assets = $assets; - $this->filters = $filters; - $this->displayErrors = $displayErrors; - $this->cache = $cache; + $this->mapper = $mapper; + $this->leaflet = $leaflet; + $this->eventDispatcher = $eventDispatcher; + $this->input = $input; + $this->assets = $assets; + $this->cache = $cache; + $this->dataController = $dataController; + $this->repositoryManager = $repositoryManager; + $this->templateEngine = $templateEngine; } /** @@ -137,9 +153,8 @@ class MapProvider $model = $this->getModel($mapId); } - RequestUrl::setFor($elementId ?: $mapId); - $definition = $this->mapper->reset()->handle($model, $filter, $elementId); - RequestUrl::setFor(null); + $request = new Request($elementId ?: $mapId, $filter); + $definition = $this->mapper->reset()->handle($model, $request, $elementId); return $definition; } @@ -155,7 +170,8 @@ class MapProvider */ public function getModel($mapId) { - $model = MapModel::findByIdOrAlias($mapId); + $repository = $this->repositoryManager->getRepository(MapModel::class); + $model = $repository->findByIdOrAlias($mapId); if ($model === null) { throw new \InvalidArgumentException(sprintf('Model "%s" not found', $mapId)); @@ -201,14 +217,14 @@ class MapProvider } } - $buffer = $this->doGenerate($mapId, $filter, $elementId, $template, $model, $style); + $buffer = $this->doGenerate($model, $filter, $elementId, $template, $style); if ($model->cache) { $this->cache->save( $cacheKey, [ - 'assets' => $this->assets->toArray(), - 'javascript' => $buffer + 'assets' => $this->assets->toArray(), + 'javascript' => $buffer, ], (int) $model->cacheLifeTime ); @@ -232,15 +248,18 @@ class MapProvider if ($layerId instanceof LayerModel) { $model = $layerId; } else { - $model = LayerModel::findByPK($layerId); + $repository = $this->repositoryManager->getRepository(LayerModel::class); + $model = $repository->find((int) $layerId); } if (!$model || !$model->active) { throw new \InvalidArgumentException(sprintf('Could not find layer "%s"', $layerId)); } + $request = new Request('', $filter); + if (!$model->cache) { - return $this->mapper->handleGeoJson($model, $filter); + return $this->mapper->handleGeoJson($model, $request); } $cacheKey = 'feature_layer_' . $model->id; @@ -252,7 +271,7 @@ class MapProvider return $this->cache->fetch($cacheKey); } - $collection = $this->mapper->handleGeoJson($model, $filter); + $collection = $this->mapper->handleGeoJson($model, $request); $this->cache->save($cacheKey, $collection, $model->cacheLifeTime); return $collection; @@ -283,15 +302,14 @@ class MapProvider throw new \RuntimeException('Bad request. Could not resolve query params'); } - $data = array_combine(array('for', 'type', 'id', 'format', 'filter', 'values'), $data); + $data = array_combine(['for', 'type', 'id', 'format', 'filter', 'values'], $data); $data = array_filter($data); if (empty($data['for']) || $data['for'] != $identifier) { return; } - $controller = new DataController($this, $this->filters, $this->displayErrors); - $controller->execute($data); + $this->dataController->execute($data, $this); if ($exit) { exit; @@ -350,19 +368,21 @@ class MapProvider protected function doGenerate($model, $filter, $elementId, $template, $style) { $definition = $this->getDefinition($model, $filter, $elementId); - $template = \Controller::getTemplate($template); - - // @codingStandardsIgnoreStart - Set for the template. $javascript = $this->leaflet->build($definition, $this->assets); $mapId = $definition->getId(); - // @codingStandardsIgnoreEnd - ob_start(); - include $template; - $content = ob_get_contents(); - ob_end_clean(); + $templateReference = new TemplateReference($template, 'html5', TemplateReference::SCOPE_FRONTEND); + $parameters = [ + 'definition' => $definition, + 'model' => $model, + 'elementId' => $elementId, + 'style' => $style, + 'javascript' => $javascript, + 'mapId' => $mapId, + ]; - $event = new GetJavascriptEvent($definition, $content); + $content = $this->templateEngine->render($templateReference, $parameters); + $event = new GetJavascriptEvent($definition, $content); $this->eventDispatcher->dispatch($event::NAME, $event); $buffer = $event->getJavascript(); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php b/src/Mapper/AbstractMapper.php similarity index 69% rename from src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php rename to src/Mapper/AbstractMapper.php index a02f9cf..511da9d 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php +++ b/src/Mapper/AbstractMapper.php @@ -1,17 +1,18 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\LeafletPHP\Definition; /** @@ -62,14 +63,14 @@ abstract class AbstractMapper implements Mapper public function handle( $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null, Definition $parent = null ) { - $definition = $this->createInstance($model, $mapper, $filter, $elementId); + $definition = $this->createInstance($model, $mapper, $request, $elementId); $this->optionsBuilder->build($definition, $model); - $this->build($definition, $model, $mapper, $filter, $parent); + $this->build($definition, $model, $mapper, $request, $parent); return $definition; } @@ -77,7 +78,7 @@ abstract class AbstractMapper implements Mapper /** * {@inheritdoc} */ - public function match($model, Filter $filter = null) + public function match($model, Request $request = null) { $modelClass = static::$modelClass; @@ -97,9 +98,9 @@ abstract class AbstractMapper implements Mapper * Use for specific build methods. * * @param Definition $definition The definition being built. - * @param \Model $model The model. + * @param Model $model The model. * @param DefinitionMapper $mapper The definition mapper. - * @param Filter|null $filter Optional request filter. + * @param Request $request Optional building request. * @param Definition|null $parent The parent object. * * @return void @@ -108,9 +109,9 @@ abstract class AbstractMapper implements Mapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { } @@ -118,21 +119,21 @@ abstract class AbstractMapper implements Mapper /** * Create a new definition instance. * - * @param \Model $model The model. + * @param Model $model The model. * @param DefinitionMapper $mapper The definition mapper. - * @param Filter $filter Optional request filter. + * @param Request $request Optional building request. * @param string|null $elementId Optional element id. * * @return Definition */ protected function createInstance( - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null ) { - $reflector = new \ReflectionClass($this->getClassName($model, $mapper, $filter)); - $instance = $reflector->newInstanceArgs($this->buildConstructArguments($model, $mapper, $filter, $elementId)); + $reflector = new \ReflectionClass($this->getClassName($model, $mapper, $request)); + $instance = $reflector->newInstanceArgs($this->buildConstructArguments($model, $mapper, $request, $elementId)); return $instance; } @@ -140,9 +141,9 @@ abstract class AbstractMapper implements Mapper /** * Get construct arguments. * - * @param \Model $model The model. + * @param Model $model The model. * @param DefinitionMapper $mapper The definition mapper. - * @param Filter $filter Optional request filter. + * @param Request $request Optional building request. * @param string|null $elementId Optional element id. * * @return array @@ -150,28 +151,28 @@ abstract class AbstractMapper implements Mapper * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function buildConstructArguments( - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null ) { - return array( - $this->getElementId($model, $elementId) - ); + return [ + $this->getElementId($model, $elementId), + ]; } /** * Get definition class name. * - * @param \Model $model The model. - * @param DefinitionMapper $mapper The definition mapper. - * @param Filter $filter Optional request filter. + * @param Model $model The model. + * @param DefinitionMapper $mapper The definition mapper. + * @param Request $request Optional building request. * * @return string * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null) + protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null) { return static::$definitionClass; } @@ -179,12 +180,12 @@ abstract class AbstractMapper implements Mapper /** * Create element id for the model. * - * @param \Model $model The model being passed. + * @param Model $model The model being passed. * @param string|null $elementId Optional forced id. * * @return string */ - protected function getElementId(\Model $model, $elementId = null) + protected function getElementId(Model $model, $elementId = null) { if ($elementId) { return $elementId; diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractTypeMapper.php b/src/Mapper/AbstractTypeMapper.php similarity index 70% rename from src/Netzmacht/Contao/Leaflet/Mapper/AbstractTypeMapper.php rename to src/Mapper/AbstractTypeMapper.php index f3dfa05..e2deb54 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractTypeMapper.php +++ b/src/Mapper/AbstractTypeMapper.php @@ -1,18 +1,17 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper; -use Netzmacht\Contao\Leaflet\Filter\Filter; - /** * Class AbstractTypeMapper is the base mapper for tables containing different types of definitins. * @@ -30,7 +29,7 @@ abstract class AbstractTypeMapper extends AbstractMapper /** * {@inheritdoc} */ - public function match($model, Filter $filter = null) + public function match($model, Request $request = null) { return parent::match($model) && $model->type === static::$type; } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/AbstractControlMapper.php b/src/Mapper/Control/AbstractControlMapper.php similarity index 68% rename from src/Netzmacht/Contao/Leaflet/Mapper/Control/AbstractControlMapper.php rename to src/Mapper/Control/AbstractControlMapper.php index 3c21f08..10a3720 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Control/AbstractControlMapper.php +++ b/src/Mapper/Control/AbstractControlMapper.php @@ -1,17 +1,19 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Control; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; +use Netzmacht\Contao\Leaflet\Model\ControlModel; /** * Class AbstractControlMapper is the base mapper for the control model. @@ -25,7 +27,7 @@ class AbstractControlMapper extends AbstractTypeMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\ControlModel'; + protected static $modelClass = ControlModel::class; /** * {@inheritdoc} diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/AttributionControlMapper.php b/src/Mapper/Control/AttributionControlMapper.php similarity index 80% rename from src/Netzmacht/Contao/Leaflet/Mapper/Control/AttributionControlMapper.php rename to src/Mapper/Control/AttributionControlMapper.php index 7f940ae..c06f0a0 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Control/AttributionControlMapper.php +++ b/src/Mapper/Control/AttributionControlMapper.php @@ -1,18 +1,20 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Control; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Control\Attribution; use Netzmacht\LeafletPHP\Definition\Map; @@ -29,7 +31,7 @@ class AttributionControlMapper extends AbstractControlMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Attribution'; + protected static $definitionClass = Attribution::class; /** * Layer type. @@ -53,9 +55,9 @@ class AttributionControlMapper extends AbstractControlMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { if (!$definition instanceof Attribution) { diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/FullscreenControlMapper.php b/src/Mapper/Control/FullscreenControlMapper.php similarity index 73% rename from src/Netzmacht/Contao/Leaflet/Mapper/Control/FullscreenControlMapper.php rename to src/Mapper/Control/FullscreenControlMapper.php index 0bbbb3b..c81d7ca 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Control/FullscreenControlMapper.php +++ b/src/Mapper/Control/FullscreenControlMapper.php @@ -1,17 +1,18 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Control; -use Netzmacht\LeafletPHP\Definition; +use Netzmacht\LeafletPHP\Plugins\FullScreen\FullScreenControl; /** * Class FullscreenControlMapper. @@ -25,7 +26,7 @@ class FullscreenControlMapper extends AbstractControlMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Plugins\FullScreen\FullScreenControl'; + protected static $definitionClass = FullScreenControl::class; /** * Layer type. diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/LayersControlMapper.php b/src/Mapper/Control/LayersControlMapper.php similarity index 63% rename from src/Netzmacht/Contao/Leaflet/Mapper/Control/LayersControlMapper.php rename to src/Mapper/Control/LayersControlMapper.php index b9242e9..f9222be 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Control/LayersControlMapper.php +++ b/src/Mapper/Control/LayersControlMapper.php @@ -1,19 +1,22 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Control; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\ControlModel; +use Netzmacht\LeafletPHP\Definition\Control\Layers; /** * Class LayersControlMapper maps the control model to the layers control definition. @@ -27,7 +30,7 @@ class LayersControlMapper extends AbstractControlMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Layers'; + protected static $definitionClass = Layers::class; /** * Layer type. @@ -40,14 +43,14 @@ class LayersControlMapper extends AbstractControlMapper * {@inheritdoc} */ protected function buildConstructArguments( - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null ) { - $arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId); - $arguments[1] = array(); - $arguments[2] = array(); + $arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId); + $arguments[1] = []; + $arguments[2] = []; /** @var ControlModel $model */ $collection = $model->findActiveLayers(); @@ -56,10 +59,20 @@ class LayersControlMapper extends AbstractControlMapper foreach ($collection as $layer) { $argument = ($layer->controlMode === 'overlay') ? 2 : 1; - $arguments[$argument][] = $mapper->handle($layer, $filter); + $arguments[$argument][] = $mapper->handle($layer, $request); } } return $arguments; } + + /** + * {@inheritDoc} + */ + protected function initialize() + { + parent::initialize(); + + $this->optionsBuilder->addOptions(['collapsed', 'autoZIndex']); + } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/LoadingControlMapper.php b/src/Mapper/Control/LoadingControlMapper.php similarity index 62% rename from src/Netzmacht/Contao/Leaflet/Mapper/Control/LoadingControlMapper.php rename to src/Mapper/Control/LoadingControlMapper.php index 881fd70..0b35ba2 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Control/LoadingControlMapper.php +++ b/src/Mapper/Control/LoadingControlMapper.php @@ -1,19 +1,22 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Control; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\ControlModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Control\Zoom; use Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl; @@ -33,16 +36,35 @@ class LoadingControlMapper extends AbstractControlMapper */ protected static $type = 'loading'; + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Construct. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + + parent::__construct(); + } + /** * {@inheritdoc} */ - protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null) + protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null) { if ($model->spinjs) { - return 'Netzmacht\LeafletPHP\Plugins\Loading\SpinJsLoadingControl'; + return SpinJsLoadingControl::class; } - return 'Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl'; + return LoadingControl::class; } /** @@ -60,12 +82,12 @@ class LoadingControlMapper extends AbstractControlMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { - parent::build($definition, $model, $mapper, $filter); + parent::build($definition, $model, $mapper, $request); if ($definition instanceof SpinJsLoadingControl && $model->spin) { $config = json_decode($model->spin, true); @@ -77,9 +99,10 @@ class LoadingControlMapper extends AbstractControlMapper if ($definition instanceof LoadingControl && !$definition->isSeparate() && $model->zoomControl) { // Only assign if zoom control is activated and part of the map. - $control = ControlModel::findOneBy( - array('active=1', 'type=?', 'pid=?', 'id=?'), - array('zoom', $model->pid, $model->zoomControl) + $repository = $this->repositoryManager->getRepository(ControlModel::class); + $control = $repository->findOneBy( + ['active=1', 'type=?', 'pid=?', 'id=?'], + ['zoom', $model->pid, $model->zoomControl] ); if ($control) { diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/ScaleControlMapper.php b/src/Mapper/Control/ScaleControlMapper.php similarity index 72% rename from src/Netzmacht/Contao/Leaflet/Mapper/Control/ScaleControlMapper.php rename to src/Mapper/Control/ScaleControlMapper.php index d2c33c5..0fc61a3 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Control/ScaleControlMapper.php +++ b/src/Mapper/Control/ScaleControlMapper.php @@ -1,16 +1,19 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Control; +use Netzmacht\LeafletPHP\Definition\Control\Scale; + /** * Class ScaleControlMapper maps the database item of the type "scale" to the scale control. * @@ -23,7 +26,7 @@ class ScaleControlMapper extends AbstractControlMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Scale'; + protected static $definitionClass = Scale::class; /** * Layer type. diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/ZoomControlMapper.php b/src/Mapper/Control/ZoomControlMapper.php similarity index 75% rename from src/Netzmacht/Contao/Leaflet/Mapper/Control/ZoomControlMapper.php rename to src/Mapper/Control/ZoomControlMapper.php index c62c7d7..9c1aeb5 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Control/ZoomControlMapper.php +++ b/src/Mapper/Control/ZoomControlMapper.php @@ -1,16 +1,19 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Control; +use Netzmacht\LeafletPHP\Definition\Control\Zoom; + /** * Class ZoomControlMapper maps the zoom database definition to the zoom control. * @@ -23,7 +26,7 @@ class ZoomControlMapper extends AbstractControlMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Zoom'; + protected static $definitionClass = Zoom::class; /** * Layer type. diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/DefinitionMapper.php b/src/Mapper/DefinitionMapper.php similarity index 86% rename from src/Netzmacht/Contao/Leaflet/Mapper/DefinitionMapper.php rename to src/Mapper/DefinitionMapper.php index 100cf6e..331e4fe 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/DefinitionMapper.php +++ b/src/Mapper/DefinitionMapper.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper; @@ -14,7 +15,6 @@ namespace Netzmacht\Contao\Leaflet\Mapper; use Netzmacht\Contao\Leaflet\Event\BuildDefinitionEvent; use Netzmacht\Contao\Leaflet\Event\ConvertToGeoJsonEvent; use Netzmacht\Contao\Leaflet\Event\GetHashEvent; -use Netzmacht\Contao\Leaflet\Filter\Filter; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Value\GeoJson\ConvertsToGeoJsonFeature; use Netzmacht\LeafletPHP\Value\GeoJson\Feature; @@ -34,7 +34,7 @@ class DefinitionMapper * * @var Mapper[][] */ - private $mappers = array(); + private $mappers = []; /** * The event dispatcher. @@ -48,7 +48,7 @@ class DefinitionMapper * * @var array */ - private $mapped = array(); + private $mapped = []; /** * Construct. @@ -84,7 +84,7 @@ class DefinitionMapper */ public function reset() { - $this->mapped = array(); + $this->mapped = []; return $this; } @@ -93,24 +93,24 @@ class DefinitionMapper * Build a model. * * @param mixed $model The definition model. - * @param Filter $filter Optional request filter. - * @param string $elementId Optional element id. If none given the mapId or alias is used. + * @param Request|null $request The map request. + * @param string|null $elementId Optional element id. If none given the model id or alias is used. * @param Definition|null $parent Optional pass the parent object. * * @return Definition|null * * @throws \RuntimeException If model could not be mapped to a definition. */ - public function handle($model, Filter $filter = null, $elementId = null, $parent = null) + public function handle($model, Request $request = null, $elementId = null, $parent = null) { $hash = $this->hash($model, $elementId); if (!isset($this->mapped[$hash])) { $mapper = $this->getMapper($model); - $definition = $mapper->handle($model, $this, $filter, $elementId, $parent); + $definition = $mapper->handle($model, $this, $request, $elementId, $parent); if ($definition) { - $event = new BuildDefinitionEvent($definition, $model, $filter); + $event = new BuildDefinitionEvent($definition, $model, $request); $this->eventDispatcher->dispatch($event::NAME, $event); } @@ -123,19 +123,19 @@ class DefinitionMapper /** * Build a model. * - * @param mixed $model The definition model. - * @param Filter $filter Optional request filter. + * @param mixed $model The definition model. + * @param Request $request Optional building request. * * @return FeatureCollection|Feature|null * * @throws \RuntimeException If a model could not be mapped to the GeoJSON representation. */ - public function handleGeoJson($model, Filter $filter = null) + public function handleGeoJson($model, Request $request = null) { $mapper = $this->getMapper($model); if ($mapper instanceof GeoJsonMapper) { - return $mapper->handleGeoJson($model, $this, $filter); + return $mapper->handleGeoJson($model, $this, $request); } throw new \RuntimeException( diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/GeoJsonMapper.php b/src/Mapper/GeoJsonMapper.php similarity index 50% rename from src/Netzmacht/Contao/Leaflet/Mapper/GeoJsonMapper.php rename to src/Mapper/GeoJsonMapper.php index 1d29354..f7cf7f7 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/GeoJsonMapper.php +++ b/src/Mapper/GeoJsonMapper.php @@ -1,17 +1,18 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\LeafletPHP\Value\GeoJson\GeoJsonFeature; /** @@ -24,11 +25,11 @@ interface GeoJsonMapper /** * Hanle the GeoJSON creation. * - * @param \Model $model The model being mapped. - * @param DefinitionMapper $mapper The definition mapper. - * @param Filter $filter Optional request filter. + * @param Model $model The model being mapped. + * @param DefinitionMapper $mapper The definition mapper. + * @param Request $request Optional building request. * * @return GeoJsonFeature|null */ - public function handleGeoJson(\Model $model, DefinitionMapper $mapper, Filter $filter = null); + public function handleGeoJson(Model $model, DefinitionMapper $mapper, Request $request = null); } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/AbstractLayerMapper.php b/src/Mapper/Layer/AbstractLayerMapper.php similarity index 69% rename from src/Netzmacht/Contao/Leaflet/Mapper/Layer/AbstractLayerMapper.php rename to src/Mapper/Layer/AbstractLayerMapper.php index f16d1c8..20bc61b 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/AbstractLayerMapper.php +++ b/src/Mapper/Layer/AbstractLayerMapper.php @@ -1,17 +1,19 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; +use Netzmacht\Contao\Leaflet\Model\LayerModel; /** * Class AbstractLayerMapper is the base mapper for the layer model. @@ -25,7 +27,7 @@ class AbstractLayerMapper extends AbstractTypeMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\LayerModel'; + protected static $modelClass = LayerModel::class; /** * {@inheritdoc} diff --git a/src/Mapper/Layer/FileLayerMapper.php b/src/Mapper/Layer/FileLayerMapper.php new file mode 100644 index 0000000..17a1687 --- /dev/null +++ b/src/Mapper/Layer/FileLayerMapper.php @@ -0,0 +1,170 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Mapper\Layer; + +use Contao\FilesModel; +use Contao\Model; +use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; +use Netzmacht\JavascriptBuilder\Type\Expression; +use Netzmacht\LeafletPHP\Definition; +use Netzmacht\LeafletPHP\Definition\Group\FeatureGroup; +use Netzmacht\LeafletPHP\Definition\Group\GeoJson; +use Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson as OmnivoreGeoJson; +use Netzmacht\LeafletPHP\Plugins\Omnivore\Gpx; +use Netzmacht\LeafletPHP\Plugins\Omnivore\Kml; +use Netzmacht\LeafletPHP\Plugins\Omnivore\OmnivoreLayer; +use Netzmacht\LeafletPHP\Plugins\Omnivore\TopoJson; +use Netzmacht\LeafletPHP\Plugins\Omnivore\Wkt; + +/** + * Class FileLayerMapper. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Layer + */ +class FileLayerMapper extends AbstractLayerMapper +{ + /** + * The definition type. + * + * @var string + */ + protected static $type = 'file'; + + /** + * Class of the model being build. + * + * @var string + */ + protected static $definitionClass = FeatureGroup::class; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Construct. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + + parent::__construct(); + } + + /** + * {@inheritDoc} + */ + public function handle( + $model, + DefinitionMapper $mapper, + Request $request = null, + $elementId = null, + Definition $parent = null + ) { + $repository = $this->repositoryManager->getRepository(FilesModel::class); + $fileModel = $repository->findByPk($model->file); + $definition = $this->createInstance($model, $mapper, $request, $elementId, $fileModel); + + $this->optionsBuilder->build($definition, $model); + $this->build($definition, $model, $mapper, $request, $parent); + + return $definition; + } + + /** + * {@inheritDoc} + */ + protected function createInstance( + Model $model, + DefinitionMapper $mapper, + Request $request = null, + $elementId = null, + FilesModel $fileModel = null + ) { + $layerId = $this->getElementId($model, $elementId); + + if ($fileModel instanceof FilesModel && $fileModel->type === 'file') { + switch ($model->fileFormat) { + case 'gpx': + $layer = new Gpx($layerId, $fileModel->path); + break; + + case 'kml': + $layer = new Kml($layerId, $fileModel->path); + break; + + case 'wkt': + $layer = new Wkt($layerId, $fileModel->path); + break; + + case 'geojson': + $layer = new OmnivoreGeoJson($layerId, $fileModel->path); + break; + + case 'topojson': + $layer = new TopoJson($layerId, $fileModel->path); + break; + + default: + return parent::createInstance($model, $mapper, $request, $elementId); + } + + $customLayer = new GeoJson($layerId); + + $layer->setCustomLayer($customLayer); + + return $layer; + } + + return parent::createInstance($model, $mapper, $request, $elementId); + } + + /** + * {@inheritDoc} + */ + protected function build( + Definition $definition, + Model $model, + DefinitionMapper $mapper, + Request $request = null, + Definition $parent = null + ) { + if (!$definition instanceof OmnivoreLayer) { + return; + } + + $customLayer = $definition->getCustomLayer(); + if ($customLayer instanceof GeoJson) { + if ($model->boundsMode) { + $customLayer->setOption('boundsMode', $model->boundsMode); + } + + if ($model->pointToLayer) { + $customLayer->setPointToLayer(new Expression($model->pointToLayer)); + } + + if ($model->onEachFeature) { + $customLayer->setOnEachFeature(new Expression($model->onEachFeature)); + } + } + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/GroupLayerMapper.php b/src/Mapper/Layer/GroupLayerMapper.php similarity index 52% rename from src/Netzmacht/Contao/Leaflet/Mapper/Layer/GroupLayerMapper.php rename to src/Mapper/Layer/GroupLayerMapper.php index 3dbb302..00b8822 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/GroupLayerMapper.php +++ b/src/Mapper/Layer/GroupLayerMapper.php @@ -1,20 +1,24 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\LayerModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; use Netzmacht\LeafletPHP\Definition; +use Netzmacht\LeafletPHP\Definition\Group\FeatureGroup; use Netzmacht\LeafletPHP\Definition\Group\LayerGroup; use Netzmacht\LeafletPHP\Definition\Layer; @@ -32,16 +36,35 @@ class GroupLayerMapper extends AbstractLayerMapper */ protected static $type = 'group'; + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Construct. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + + parent::__construct(); + } + /** * {@inheritdoc} */ - protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null) + protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null) { if ($model->groupType === 'feature') { - return 'Netzmacht\LeafletPHP\Definition\Group\FeatureGroup'; + return FeatureGroup::class; } - return 'Netzmacht\LeafletPHP\Definition\Group\LayerGroup'; + return LayerGroup::class; } /** @@ -49,19 +72,20 @@ class GroupLayerMapper extends AbstractLayerMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { if (!$definition instanceof LayerGroup) { return; } - $collection = LayerModel::findBy( - array('pid=?', 'active=1'), - array($model->id), - array('order' => 'sorting') + $repository = $this->repositoryManager->getRepository(LayerModel::class); + $collection = $repository->findBy( + ['pid=?', 'active=1'], + [$model->id], + ['order' => 'sorting'] ); if ($collection) { diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkerClusterLayerMapper.php b/src/Mapper/Layer/MarkerClusterLayerMapper.php similarity index 71% rename from src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkerClusterLayerMapper.php rename to src/Mapper/Layer/MarkerClusterLayerMapper.php index 329f3d6..9cb4cf0 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkerClusterLayerMapper.php +++ b/src/Mapper/Layer/MarkerClusterLayerMapper.php @@ -1,21 +1,23 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; -use Netzmacht\Contao\Leaflet\ContaoAssets; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; +use Netzmacht\Contao\Leaflet\Encoder\ContaoAssets; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\LayerModel; -use Netzmacht\Contao\Toolkit\View\Assets\AssetsManager; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; use Netzmacht\JavascriptBuilder\Type\AnonymousFunction; use Netzmacht\JavascriptBuilder\Type\Expression; use Netzmacht\LeafletPHP\Definition; @@ -35,7 +37,7 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Plugins\MarkerCluster\MarkerClusterGroup'; + protected static $definitionClass = MarkerClusterGroup::class; /** * Layer type. @@ -52,15 +54,24 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper private $assets; /** - * MarkerClusterLayerMapper constructor. + * Repository manager. * - * @param ContaoAssets $assets Assets manager. + * @var RepositoryManager */ - public function __construct(ContaoAssets $assets) - { - parent::__construct(); + private $repositoryManager; - $this->assets = $assets; + /** + * Construct. + * + * @param ContaoAssets $assets Assets manager. + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(ContaoAssets $assets, RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + $this->assets = $assets; + + parent::__construct(); } /** @@ -85,12 +96,12 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { - parent::build($definition, $model, $mapper, $filter, $parent); + parent::build($definition, $model, $mapper, $request, $parent); /** @var MarkerClusterGroup $definition */ @@ -106,10 +117,11 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper $this->assets->addStylesheet('assets/leaflet/libs/leaflet-markercluster/MarkerCluster.Default.css'); } - $collection = LayerModel::findBy( - array('pid=?', 'active=1'), - array($model->id), - array('order' => 'sorting') + $repository = $this->repositoryManager->getRepository(LayerModel::class); + $collection = $repository->findBy( + ['pid=?', 'active=1'], + [$model->id], + ['order' => 'sorting'] ); if ($collection) { diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php b/src/Mapper/Layer/MarkersLayerMapper.php similarity index 64% rename from src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php rename to src/Mapper/Layer/MarkersLayerMapper.php index fdb9b75..e402bac 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php +++ b/src/Mapper/Layer/MarkersLayerMapper.php @@ -1,25 +1,29 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; +use Netzmacht\Contao\Leaflet\Frontend\RequestUrl; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\MarkerModel; -use Netzmacht\Contao\Leaflet\Frontend\RequestUrl; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; use Netzmacht\JavascriptBuilder\Type\Expression; use Netzmacht\LeafletPHP\Definition; -use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection; use Netzmacht\LeafletPHP\Definition\Group\GeoJson; +use Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson as OmnivoreGeoJson; +use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection; /** * Class MarkersLayerMapper maps the layer model to the markers definition. @@ -35,25 +39,44 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper */ protected static $type = 'markers'; + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Construct. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + + parent::__construct(); + } + /** * {@inheritdoc} */ - protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null) + protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null) { if ($model->deferred) { - return 'Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson'; + return OmnivoreGeoJson::class; } - return 'Netzmacht\LeafletPHP\Definition\Group\GeoJson'; + return GeoJson::class; } /** * {@inheritdoc} */ protected function buildConstructArguments( - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null ) { if ($model->deferred) { @@ -68,21 +91,21 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper $layer->setOption('boundsMode', $model->boundsMode); } - return array( + return [ $this->getElementId($model, $elementId), - RequestUrl::create($model->id, null, null, $filter), - array(), - $layer - ); + RequestUrl::create($model->id, null, null, $request), + [], + $layer, + ]; } - return array( + return [ $this->getElementId($model, $elementId), - RequestUrl::create($model->id, null, null, $filter) - ); + RequestUrl::create($model->id, null, null, $request), + ]; } - return parent::buildConstructArguments($model, $mapper, $filter, $elementId); + return parent::buildConstructArguments($model, $mapper, $request, $elementId); } /** @@ -90,9 +113,9 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { if ($definition instanceof GeoJson) { @@ -122,10 +145,10 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper /** * {@inheritdoc} */ - public function handleGeoJson(\Model $model, DefinitionMapper $mapper, Filter $filter = null) + public function handleGeoJson(Model $model, DefinitionMapper $mapper, Request $request = null) { $feature = new FeatureCollection(); - $collection = $this->loadMarkerModels($model, $filter); + $collection = $this->loadMarkerModels($model, $request); if ($collection) { foreach ($collection as $item) { @@ -144,17 +167,19 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper /** * Load all layer markers. * - * @param \Model $model The layer model. - * @param Filter $filter The request filter. + * @param Model $model The layer model. + * @param Request $request Optional building request. * * @return \Model\Collection|null */ - protected function loadMarkerModels(\Model $model, Filter $filter = null) + protected function loadMarkerModels(Model $model, Request $request = null) { + $repository = $this->repositoryManager->getRepository(MarkerModel::class); + if ($model->boundsMode == 'fit') { - return MarkerModel::findByFilter($model->id, $filter); + return $repository->findByFilter($model->id, $request->getFilter()); } - return MarkerModel::findByFilter($model->id); + return $repository->findByFilter($model->id); } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/OverpassLayerMapper.php b/src/Mapper/Layer/OverpassLayerMapper.php similarity index 76% rename from src/Netzmacht/Contao/Leaflet/Mapper/Layer/OverpassLayerMapper.php rename to src/Mapper/Layer/OverpassLayerMapper.php index 74d9bec..a2a8743 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/OverpassLayerMapper.php +++ b/src/Mapper/Layer/OverpassLayerMapper.php @@ -1,20 +1,23 @@ - * @copyright 2016 netzmacht David Molineus. All rights reserved. - * @filesource + * Leaflet maps for Contao CMS. * + * @package contao-leaflet-maps + * @author David Molineus + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource */ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; -use Model; +use Contao\Model; use Netzmacht\Contao\Leaflet\Definition\Layer\OverpassLayer; -use Netzmacht\Contao\Leaflet\Filter\Filter; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\IconModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; use Netzmacht\JavascriptBuilder\Type\Expression; use Netzmacht\LeafletPHP\Definition; @@ -37,7 +40,26 @@ class OverpassLayerMapper extends AbstractLayerMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\Contao\Leaflet\Definition\Layer\OverpassLayer'; + protected static $definitionClass = OverpassLayer::class; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Construct. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + + parent::__construct(); + } /** * {@inheritdoc} @@ -60,7 +82,7 @@ class OverpassLayerMapper extends AbstractLayerMapper Definition $definition, Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { if (!$definition instanceof OverpassLayer) { @@ -95,7 +117,8 @@ class OverpassLayerMapper extends AbstractLayerMapper $amenityIconsMap = $this->filterAmenityIconsConfig($model->amenityIcons); if ($amenityIconsMap) { - $collection = IconModel::findMultipleByIds(array_unique($amenityIconsMap)); + $repository = $this->repositoryManager->getRepository(IconModel::class); + $collection = $repository->findMultipleByIds(array_unique($amenityIconsMap)); $icons = []; if ($collection) { diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php b/src/Mapper/Layer/ProviderLayerMapper.php similarity index 74% rename from src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php rename to src/Mapper/Layer/ProviderLayerMapper.php index 28d72ca..4b52a5d 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php +++ b/src/Mapper/Layer/ProviderLayerMapper.php @@ -1,20 +1,23 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Mapper\OptionsBuilder; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\LeafletPHP\Definition; +use Netzmacht\LeafletPHP\Plugins\LeafletProviders\Provider; /** * Class ProviderLayerMapper maps the layer model to the tile provider definition. @@ -52,13 +55,13 @@ class ProviderLayerMapper extends AbstractLayerMapper /** * {@inheritdoc} */ - protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null) + protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null) { if (isset($this->providers[$model->tile_provider]['class'])) { return $this->providers[$model->tile_provider]['class']; } - return 'Netzmacht\LeafletPHP\Plugins\LeafletProviders\Provider'; + return Provider::class; } /** @@ -66,9 +69,9 @@ class ProviderLayerMapper extends AbstractLayerMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { if (!empty($this->providers[$model->tile_provider]['options'])) { @@ -84,15 +87,15 @@ class ProviderLayerMapper extends AbstractLayerMapper * {@inheritdoc} */ protected function buildConstructArguments( - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null ) { - return array( + return [ $model->alias ?: ('layer_' . $model->id), $model->tile_provider, - $model->tile_provider_variant ?: null - ); + $model->tile_provider_variant ?: null, + ]; } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ReferenceLayerMapper.php b/src/Mapper/Layer/ReferenceLayerMapper.php similarity index 51% rename from src/Netzmacht/Contao/Leaflet/Mapper/Layer/ReferenceLayerMapper.php rename to src/Mapper/Layer/ReferenceLayerMapper.php index a0eef6c..e3c3c9d 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ReferenceLayerMapper.php +++ b/src/Mapper/Layer/ReferenceLayerMapper.php @@ -1,19 +1,21 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; -use Netzmacht\Contao\Leaflet\Filter\Filter; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\LayerModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; use Netzmacht\LeafletPHP\Definition; /** @@ -30,17 +32,37 @@ class ReferenceLayerMapper extends AbstractLayerMapper */ protected static $type = 'reference'; + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Construct. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + + parent::__construct(); + } + /** * {@inheritdoc} */ public function handle( $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null, Definition $parent = null ) { - $reference = LayerModel::findByPk($model->reference); + $repository = $this->repositoryManager->getRepository(LayerModel::class); + $reference = $repository->findByPk($model->reference); if (!$reference || !$reference->active) { return null; @@ -48,6 +70,6 @@ class ReferenceLayerMapper extends AbstractLayerMapper $elementId = $model->standalone ? $this->getElementId($model, $elementId) : null; - return $mapper->handle($reference, $filter, $elementId); + return $mapper->handle($reference, $request, $elementId); } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/TileLayerMapper.php b/src/Mapper/Layer/TileLayerMapper.php similarity index 72% rename from src/Netzmacht/Contao/Leaflet/Mapper/Layer/TileLayerMapper.php rename to src/Mapper/Layer/TileLayerMapper.php index 9709528..c695c9e 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/TileLayerMapper.php +++ b/src/Mapper/Layer/TileLayerMapper.php @@ -1,18 +1,21 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; +use Contao\StringUtil; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Raster\TileLayer; use Netzmacht\LeafletPHP\Value\LatLngBounds; @@ -29,7 +32,7 @@ class TileLayerMapper extends AbstractLayerMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Raster\TileLayer'; + protected static $definitionClass = TileLayer::class; /** * The layer type. @@ -63,12 +66,12 @@ class TileLayerMapper extends AbstractLayerMapper * {@inheritdoc} */ protected function buildConstructArguments( - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null ) { - $arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId); + $arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId); $arguments[] = $model->tileUrl; @@ -80,26 +83,26 @@ class TileLayerMapper extends AbstractLayerMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { - parent::build($definition, $model, $mapper, $filter, $parent); + parent::build($definition, $model, $mapper, $request, $parent); /** @var TileLayer $definition */ - $filter = deserialize($model->bounds); + $bounds = StringUtil::deserialize($model->bounds); - if ($filter[0] && $filter[1]) { - $filter = array_map( + if ($request[0] && $request[1]) { + $bounds = array_map( function ($value) { return explode(',', $value, 3); }, - $filter + $bounds ); - $filter = LatLngBounds::fromArray($filter); - $definition->setBounds($filter); + $bounds = LatLngBounds::fromArray($bounds); + $definition->setBounds($bounds); } } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php b/src/Mapper/Layer/VectorsLayerMapper.php similarity index 69% rename from src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php rename to src/Mapper/Layer/VectorsLayerMapper.php index 5605753..bd587d3 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php +++ b/src/Mapper/Layer/VectorsLayerMapper.php @@ -1,26 +1,30 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; +use Contao\Model\Collection; +use Netzmacht\Contao\Leaflet\Frontend\RequestUrl; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\VectorModel; -use Netzmacht\Contao\Leaflet\Frontend\RequestUrl; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; use Netzmacht\JavascriptBuilder\Type\Expression; use Netzmacht\LeafletPHP\Definition; -use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection; use Netzmacht\LeafletPHP\Definition\Group\GeoJson; -use Netzmacht\LeafletPHP\Definition\Vector; +use Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson as OmnivoreGeoJson; +use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection; /** * Class VectorsLayerMapper maps the layer model for the Vectors layer definition. @@ -36,29 +40,48 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper */ protected static $type = 'vectors'; + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Construct. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + + parent::__construct(); + } + /** * {@inheritdoc} */ - protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null) + protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null) { if ($model->deferred) { - return 'Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson'; + return OmnivoreGeoJson::class; } - return 'Netzmacht\LeafletPHP\Definition\Group\GeoJson'; + return GeoJson::class; } /** * {@inheritdoc} */ protected function buildConstructArguments( - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null ) { if ($model->deferred) { - $options = array(); + $options = []; if ($model->pointToLayer) { $options['pointToLayer'] = new Expression($model->pointToLayer); @@ -76,21 +99,21 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper $layer = new GeoJson($this->getElementId($model, $elementId)); $layer->setOptions($options); - return array( + return [ $this->getElementId($model, $elementId), - RequestUrl::create($model->id, null, null, $filter), - array(), - $layer - ); + RequestUrl::create($model->id, null, null, $request), + [], + $layer, + ]; } - return array( + return [ $this->getElementId($model, $elementId), - RequestUrl::create($model->id, null, null, $filter) - ); + RequestUrl::create($model->id, null, null, $request), + ]; } - return parent::buildConstructArguments($model, $mapper, $filter, $elementId); + return parent::buildConstructArguments($model, $mapper, $request, $elementId); } /** @@ -98,9 +121,9 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { if ($definition instanceof GeoJson) { @@ -128,7 +151,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper /** * {@inheritdoc} */ - public function handleGeoJson(\Model $model, DefinitionMapper $mapper, Filter $filter = null) + public function handleGeoJson(Model $model, DefinitionMapper $mapper, Request $request = null) { $definition = new FeatureCollection(); $collection = $this->loadVectorModels($model); @@ -150,13 +173,15 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper /** * Load vector models. * - * @param \Model $model The layer model. + * @param Model $model The layer model. * - * @return \Model\Collection|null + * @return Collection|null */ - protected function loadVectorModels(\Model $model) + protected function loadVectorModels(Model $model) { - return VectorModel::findActiveBy('pid', $model->id, array('order' => 'sorting')); + $repository = $this->repositoryManager->getRepository(VectorModel::class); + + return $repository->findActiveBy(['pid=?'], [$model->id], ['order' => 'sorting']); } /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php b/src/Mapper/MapMapper.php similarity index 69% rename from src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php rename to src/Mapper/MapMapper.php index 1fa132e..441ad8d 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php +++ b/src/Mapper/MapMapper.php @@ -1,20 +1,21 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Model\ControlModel; use Netzmacht\Contao\Leaflet\Model\MapModel; -use Netzmacht\JavascriptBuilder\Type\Expression; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Control; use Netzmacht\LeafletPHP\Definition\Layer; @@ -32,14 +33,33 @@ class MapMapper extends AbstractMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\MapModel'; + protected static $modelClass = MapModel::class; /** * Class of the definition being created. * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Map'; + protected static $definitionClass = Map::class; + + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Construct. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + + parent::__construct(); + } /** * {@inheritdoc} @@ -50,8 +70,8 @@ class MapMapper extends AbstractMapper ->addOptions('center', 'zoom', 'zoomControl') ->addOptions('dragging', 'touchZoom', 'scrollWheelZoom', 'doubleClickZoom', 'boxZoom', 'tap', 'keyboard') ->addOptions('trackResize', 'closeOnClick', 'bounceAtZoomLimits') - ->addConditionalOptions('adjustZoomExtra', array('minZoom', 'maxZoom', 'zoomSnap', 'zoomDelta')) - ->addConditionalOptions('keyboard', array('keyboardPanOffset', 'keyboardZoomOffset')); + ->addConditionalOptions('adjustZoomExtra', ['minZoom', 'maxZoom', 'zoomSnap', 'zoomDelta']) + ->addConditionalOptions('keyboard', ['keyboardPanOffset', 'keyboardZoomOffset']); } /** @@ -59,15 +79,15 @@ class MapMapper extends AbstractMapper */ protected function build( Definition $map, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { if ($map instanceof Map && $model instanceof MapModel) { $this->buildCustomOptions($map, $model); - $this->buildControls($map, $model, $mapper, $filter); - $this->buildLayers($map, $model, $mapper, $filter); + $this->buildControls($map, $model, $mapper, $request); + $this->buildLayers($map, $model, $mapper, $request); $this->buildBoundsCalculation($map, $model); $this->buildLocate($map, $model); } @@ -77,15 +97,15 @@ class MapMapper extends AbstractMapper * {@inheritdoc} */ protected function buildConstructArguments( - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null ) { - return array( + return [ $this->getElementId($model, $elementId), - $this->getElementId($model, $elementId) - ); + $this->getElementId($model, $elementId), + ]; } /** @@ -112,23 +132,24 @@ class MapMapper extends AbstractMapper /** * Build map controls. * - * @param Map $map The map being built. - * @param MapModel $model The map model. - * @param DefinitionMapper $mapper The definition mapper. - * @param Filter $filter Optional request filter. + * @param Map $map The map being built. + * @param MapModel $model The map model. + * @param DefinitionMapper $mapper The definition mapper. + * @param Request $request Optional building request. * * @return void */ - private function buildControls(Map $map, MapModel $model, DefinitionMapper $mapper, Filter $filter = null) + private function buildControls(Map $map, MapModel $model, DefinitionMapper $mapper, Request $request = null) { - $collection = ControlModel::findActiveBy('pid', $model->id, array('order' => 'sorting')); + $repository = $this->repositoryManager->getRepository(ControlModel::class); + $collection = $repository->findActiveBy(['pid=?'], [$model->id], ['order' => 'sorting']); if (!$collection) { return; } foreach ($collection as $control) { - $control = $mapper->handle($control, $filter, null, $map); + $control = $mapper->handle($control, $request, null, $map); if ($control instanceof Control) { $control->addTo($map); @@ -139,14 +160,14 @@ class MapMapper extends AbstractMapper /** * Build map layers. * - * @param Map $map The map being built. - * @param MapModel $model The map model. - * @param DefinitionMapper $mapper Definition mapper. - * @param Filter $filter Optional request filter. + * @param Map $map The map being built. + * @param MapModel $model The map model. + * @param DefinitionMapper $mapper Definition mapper. + * @param Request $request Optional building request. * * @return void */ - private function buildLayers(Map $map, MapModel $model, DefinitionMapper $mapper, Filter $filter = null) + private function buildLayers(Map $map, MapModel $model, DefinitionMapper $mapper, Request $request = null) { $collection = $model->findActiveLayers(); @@ -156,7 +177,7 @@ class MapMapper extends AbstractMapper continue; } - $layer = $mapper->handle($layer, $filter, null, $map); + $layer = $mapper->handle($layer, $request, null, $map); if ($layer instanceof Layer) { $layer->addTo($map); } @@ -196,7 +217,6 @@ class MapMapper extends AbstractMapper } } - /** * Build map bounds calculations. * @@ -208,13 +228,13 @@ class MapMapper extends AbstractMapper private function buildLocate(Map $map, MapModel $model) { if ($model->locate) { - $options = array(); + $options = []; - $mapping = array( + $mapping = [ 'setView' => 'locateSetView', 'watch' => 'locateWatch', 'enableHighAccuracy' => 'enableHighAccuracy', - ); + ]; foreach ($mapping as $option => $property) { if ($model->$property) { @@ -222,11 +242,11 @@ class MapMapper extends AbstractMapper } } - $mapping = array( + $mapping = [ 'maxZoom' => 'locateMaxZoom', 'timeout' => 'locateTimeout', 'maximumAge' => 'locateMaximumAge', - ); + ]; foreach ($mapping as $option => $property) { if ($model->$property) { diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Mapper.php b/src/Mapper/Mapper.php similarity index 63% rename from src/Netzmacht/Contao/Leaflet/Mapper/Mapper.php rename to src/Mapper/Mapper.php index 215cf00..cdfd9d3 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Mapper.php +++ b/src/Mapper/Mapper.php @@ -1,17 +1,18 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\LeafletPHP\Definition; /** @@ -24,9 +25,9 @@ interface Mapper /** * Map model to the definition. * - * @param \Model|mixed $model The model being built. Usually a contao model, but can be anything. + * @param Model|mixed $model The model being built. Usually a contao model, but can be anything. * @param DefinitionMapper $mapper The definition builder. - * @param Filter $filter Optional filter bounds. + * @param Request $request Optional building request. * @param string $elementId Optional element. * @param Definition|null $parent Optional passed parent. * @@ -35,7 +36,7 @@ interface Mapper public function handle( $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null, Definition $parent = null ); @@ -43,10 +44,10 @@ interface Mapper /** * Check if mapper is responsible for the model. * - * @param \Model $model The model being build. - * @param Filter $filter Optional filter bounds. + * @param Model $model The model being build. + * @param Request $request Optional building request. * * @return bool */ - public function match($model, Filter $filter = null); + public function match($model, Request $request = null); } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/OptionsBuilder.php b/src/Mapper/OptionsBuilder.php similarity index 95% rename from src/Netzmacht/Contao/Leaflet/Mapper/OptionsBuilder.php rename to src/Mapper/OptionsBuilder.php index 377e7f0..c6b307b 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/OptionsBuilder.php +++ b/src/Mapper/OptionsBuilder.php @@ -1,16 +1,18 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper; +use Contao\Model; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\HasOptions; @@ -29,14 +31,14 @@ class OptionsBuilder * * @var array */ - private $options = array(); + private $options = []; /** * Conditional option mapping. * * @var array */ - private $conditional = array(); + private $conditional = []; /** * Add a option mapping. @@ -199,7 +201,7 @@ class OptionsBuilder * * @param array $options The options. * @param Definition $definition The definition being built. - * @param \Model $model The model. + * @param Model $model The model. * * @return void */ @@ -252,7 +254,7 @@ class OptionsBuilder */ private static function getDefaultOption($option, $definition) { - $keys = array('has', 'is', 'get'); + $keys = ['has', 'is', 'get']; $suffix = ucfirst($option); foreach ($keys as $key) { diff --git a/src/Mapper/Request.php b/src/Mapper/Request.php new file mode 100644 index 0000000..e19bad6 --- /dev/null +++ b/src/Mapper/Request.php @@ -0,0 +1,71 @@ + + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE + * @filesource + */ + +declare(strict_types=1); + +namespace Netzmacht\Contao\Leaflet\Mapper; + +use Netzmacht\Contao\Leaflet\Filter\Filter; + +/** + * Class MapRequest + * + * @package Netzmacht\Contao\Leaflet\Request + */ +class Request +{ + /** + * Map identifier. + * + * @var string + */ + private $identifier; + + /** + * Request filter. + * + * @var Filter|null + */ + private $filter; + + /** + * Request constructor. + * + * @param string $identifier Map identifier. + * @param Filter|null $filter Filter. + */ + public function __construct($identifier, Filter $filter = null) + { + $this->identifier = $identifier; + $this->filter = $filter; + } + + /** + * Get the map identifier. + * + * @return string + */ + public function getMapIdentifier(): string + { + return $this->identifier; + } + + /** + * Get the filter. + * + * @return Filter|null + */ + public function getFilter() + { + return $this->filter; + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Style/AbstractStyleMapper.php b/src/Mapper/Style/AbstractStyleMapper.php similarity index 63% rename from src/Netzmacht/Contao/Leaflet/Mapper/Style/AbstractStyleMapper.php rename to src/Mapper/Style/AbstractStyleMapper.php index 7bed34a..8114a48 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Style/AbstractStyleMapper.php +++ b/src/Mapper/Style/AbstractStyleMapper.php @@ -1,17 +1,19 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Style; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; +use Netzmacht\Contao\Leaflet\Model\StyleModel; /** * Class AbstractStyleMapper is the base mapper for the style model. @@ -25,5 +27,5 @@ abstract class AbstractStyleMapper extends AbstractTypeMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\StyleModel'; + protected static $modelClass = StyleModel::class; } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Style/FixedStyleMapper.php b/src/Mapper/Style/FixedStyleMapper.php similarity index 71% rename from src/Netzmacht/Contao/Leaflet/Mapper/Style/FixedStyleMapper.php rename to src/Mapper/Style/FixedStyleMapper.php index bf312a1..5441374 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Style/FixedStyleMapper.php +++ b/src/Mapper/Style/FixedStyleMapper.php @@ -1,17 +1,18 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Style; -use Netzmacht\LeafletPHP\Definition; +use Netzmacht\Contao\Leaflet\Definition\Style\FixedStyle; /** * Class FixedStyleMapper maps the fixed style to the corresponding definition. @@ -25,7 +26,7 @@ class FixedStyleMapper extends AbstractStyleMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\Contao\Leaflet\Definition\Style\FixedStyle'; + protected static $definitionClass = FixedStyle::class; /** * Style type. @@ -47,7 +48,7 @@ class FixedStyleMapper extends AbstractStyleMapper ->addConditionalOption('lineCap') ->addConditionalOption('lineJoin') ->addConditionalOption('dashArray') - ->addConditionalOptions('fill', array('fillColor', 'fillOpacity')) + ->addConditionalOptions('fill', ['fillColor', 'fillOpacity']) ->addOption('fill'); } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Type/AbstractIconMapper.php b/src/Mapper/Type/AbstractIconMapper.php similarity index 68% rename from src/Netzmacht/Contao/Leaflet/Mapper/Type/AbstractIconMapper.php rename to src/Mapper/Type/AbstractIconMapper.php index 2ba7479..b49ad0a 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Type/AbstractIconMapper.php +++ b/src/Mapper/Type/AbstractIconMapper.php @@ -1,17 +1,19 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Type; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; +use Netzmacht\Contao\Leaflet\Model\IconModel; /** * Class AbstractIconMapper is the base mapper for the icon model. @@ -25,7 +27,7 @@ class AbstractIconMapper extends AbstractTypeMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\IconModel'; + protected static $modelClass = IconModel::class; /** * {@inheritdoc} diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Type/DivIconMapper.php b/src/Mapper/Type/DivIconMapper.php similarity index 73% rename from src/Netzmacht/Contao/Leaflet/Mapper/Type/DivIconMapper.php rename to src/Mapper/Type/DivIconMapper.php index fc1992a..783fea2 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Type/DivIconMapper.php +++ b/src/Mapper/Type/DivIconMapper.php @@ -1,18 +1,20 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Type; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\DivIcon; @@ -28,7 +30,7 @@ class DivIconMapper extends AbstractIconMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Type\DivIcon'; + protected static $definitionClass = DivIcon::class; /** * Layer type. @@ -52,12 +54,12 @@ class DivIconMapper extends AbstractIconMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { - parent::build($definition, $model, $mapper, $filter); + parent::build($definition, $model, $mapper, $request); if ($definition instanceof DivIcon && $model->iconSize) { $definition->setIconSize(explode(',', $model->iconSize, 2)); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Type/ExtraMarkersIconMapper.php b/src/Mapper/Type/ExtraMarkersIconMapper.php similarity index 71% rename from src/Netzmacht/Contao/Leaflet/Mapper/Type/ExtraMarkersIconMapper.php rename to src/Mapper/Type/ExtraMarkersIconMapper.php index a78aed7..d5608b5 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Type/ExtraMarkersIconMapper.php +++ b/src/Mapper/Type/ExtraMarkersIconMapper.php @@ -1,20 +1,23 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Type; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\DivIcon; +use Netzmacht\LeafletPHP\Plugins\ExtraMarkers\ExtraMarkersIcon; /** * Class DivIconMapper maps the icon model to the div icon definition. @@ -28,7 +31,7 @@ class ExtraMarkersIconMapper extends AbstractIconMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Plugins\ExtraMarkers\ExtraMarkersIcon'; + protected static $definitionClass = ExtraMarkersIcon::class; /** * Layer type. @@ -52,12 +55,12 @@ class ExtraMarkersIconMapper extends AbstractIconMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { - parent::build($definition, $model, $mapper, $filter); + parent::build($definition, $model, $mapper, $request); if ($definition instanceof DivIcon && $model->iconSize) { $definition->setIconSize(explode(',', $model->iconSize, 2)); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Type/ImageIconMapper.php b/src/Mapper/Type/ImageIconMapper.php similarity index 62% rename from src/Netzmacht/Contao/Leaflet/Mapper/Type/ImageIconMapper.php rename to src/Mapper/Type/ImageIconMapper.php index dacb96e..a846217 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Type/ImageIconMapper.php +++ b/src/Mapper/Type/ImageIconMapper.php @@ -1,19 +1,23 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Type; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\FilesModel; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\IconModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\ImageIcon; @@ -29,7 +33,7 @@ class ImageIconMapper extends AbstractIconMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Type\ImageIcon'; + protected static $definitionClass = ImageIcon::class; /** * Layer type. @@ -38,19 +42,39 @@ class ImageIconMapper extends AbstractIconMapper */ protected static $type = 'image'; + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + + /** + * Construct. + * + * @param RepositoryManager $repositoryManager Repository manager. + */ + public function __construct(RepositoryManager $repositoryManager) + { + $this->repositoryManager = $repositoryManager; + + parent::__construct(); + } + /** * {@inheritdoc} */ protected function buildConstructArguments( - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null ) { - $arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId); + $arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId); if ($model->iconImage) { - $file = \FilesModel::findByUuid($model->iconImage); + $repository = $this->repositoryManager->getRepository(FilesModel::class); + $file = $repository->findByUuid($model->iconImage); if ($file) { $arguments[] = $file->path; @@ -65,9 +89,9 @@ class ImageIconMapper extends AbstractIconMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { if ($definition instanceof ImageIcon) { @@ -86,21 +110,23 @@ class ImageIconMapper extends AbstractIconMapper */ private function addIcon(ImageIcon $definition, IconModel $model) { + $repository = $this->repositoryManager->getRepository(FilesModel::class); + if ($model->iconImage) { - $file = \FilesModel::findByUuid($model->iconImage); + $file = $repository->findByUuid($model->iconImage); if ($file) { $definition->setIconUrl($file->path); $file = new \File($file->path); - $definition->setIconSize(array($file->width, $file->height)); + $definition->setIconSize([$file->width, $file->height]); if (!$model->iconAnchor) { - $definition->setIconAnchor(array($file->width / 2, $file->height)); + $definition->setIconAnchor([($file->width / 2), $file->height]); } if (!$model->popupAnchor) { - $definition->setPopupAnchor(array(0, 8 - $file->height)); + $definition->setPopupAnchor([0, (8 - $file->height)]); } } } @@ -110,7 +136,7 @@ class ImageIconMapper extends AbstractIconMapper } if ($model->iconRetinaImage) { - $file = \FilesModel::findByUuid($model->iconRetinaImage); + $file = $repository->findByUuid($model->iconRetinaImage); if ($file) { $definition->setIconRetinaUrl($file->path); @@ -128,17 +154,19 @@ class ImageIconMapper extends AbstractIconMapper */ private function addShadow(ImageIcon $definition, $model) { + $repository = $this->repositoryManager->getRepository(FilesModel::class); + if ($model->shadowImage) { - $file = \FilesModel::findByUuid($model->shadowImage); + $file = $repository->findByUuid($model->shadowImage); if ($file) { $definition->setShadowUrl($file->path); $file = new \File($file->path); - $definition->setShadowSize(array($file->width, $file->height)); + $definition->setShadowSize([$file->width, $file->height]); if (!$model->shadowAnchor) { - $definition->setShadowAnchor(array($file->width / 2, $file->height)); + $definition->setShadowAnchor([($file->width / 2), $file->height]); } } } @@ -148,7 +176,7 @@ class ImageIconMapper extends AbstractIconMapper } if ($model->shadowRetinaImage) { - $file = \FilesModel::findByUuid($model->shadowRetinaImage); + $file = $repository->findByUuid($model->shadowRetinaImage); if ($file) { $definition->setShadowRetinaUrl($file->path); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/UI/MarkerMapper.php b/src/Mapper/UI/MarkerMapper.php similarity index 61% rename from src/Netzmacht/Contao/Leaflet/Mapper/UI/MarkerMapper.php rename to src/Mapper/UI/MarkerMapper.php index 0dfa4bb..8a9a060 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/UI/MarkerMapper.php +++ b/src/Mapper/UI/MarkerMapper.php @@ -1,22 +1,26 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\UI; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Frontend\ValueFilter; use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\IconModel; +use Netzmacht\Contao\Leaflet\Model\MarkerModel; use Netzmacht\Contao\Leaflet\Model\PopupModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\ImageIcon; use Netzmacht\LeafletPHP\Definition\UI\Marker; @@ -34,14 +38,14 @@ class MarkerMapper extends AbstractMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\MarkerModel'; + protected static $modelClass = MarkerModel::class; /** * Class of the definition being created. * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\UI\Marker'; + protected static $definitionClass = Marker::class; /** * Frontend filter. @@ -50,29 +54,38 @@ class MarkerMapper extends AbstractMapper */ protected $valueFilter; + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + /** * Construct. * - * @param ValueFilter $valueFilter Frontend filter. + * @param RepositoryManager $repositoryManager Repository manager. + * @param ValueFilter $valueFilter Frontend filter. */ - public function __construct(ValueFilter $valueFilter) + public function __construct(RepositoryManager $repositoryManager, ValueFilter $valueFilter) { - parent::__construct(); + $this->repositoryManager = $repositoryManager; + $this->valueFilter = $valueFilter; - $this->valueFilter = $valueFilter; + parent::__construct(); } /** * {@inheritdoc} */ protected function buildConstructArguments( - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null ) { - $arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId); - $arguments[] = array($model->latitude, $model->longitude, $model->altitude ?: null) ?: null; + $arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId); + $arguments[] = [$model->latitude, $model->longitude, $model->altitude ?: null] ?: null; return $arguments; } @@ -94,9 +107,9 @@ class MarkerMapper extends AbstractMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { if ($definition instanceof Marker) { @@ -105,10 +118,11 @@ class MarkerMapper extends AbstractMapper $content = $this->valueFilter->filter($model->popupContent); if ($model->popup) { - $popupModel = PopupModel::findActiveByPK($model->popup); + $popupRepository = $this->repositoryManager->getRepository(PopupModel::class); + $popupModel = $popupRepository->findActiveByPK($model->popup); if ($popupModel) { - $popup = $mapper->handle($popupModel, $filter, null, $definition); + $popup = $mapper->handle($popupModel, $request, null, $definition); } } @@ -120,10 +134,11 @@ class MarkerMapper extends AbstractMapper } if ($model->customIcon) { - $iconModel = IconModel::findBy( - array('id=?', 'active=1'), - array($model->icon), - array('return' => 'Model') + $iconRepository = $this->repositoryManager->getRepository(IconModel::class); + $iconModel = $iconRepository->findBy( + ['id=?', 'active=1'], + [$model->icon], + ['return' => 'Model'] ); if ($iconModel) { diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/UI/PopupMapper.php b/src/Mapper/UI/PopupMapper.php similarity index 85% rename from src/Netzmacht/Contao/Leaflet/Mapper/UI/PopupMapper.php rename to src/Mapper/UI/PopupMapper.php index 92886cf..24e1778 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/UI/PopupMapper.php +++ b/src/Mapper/UI/PopupMapper.php @@ -1,19 +1,21 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\UI; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\PopupModel; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\UI\Popup; @@ -30,14 +32,14 @@ class PopupMapper extends AbstractMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\UI\Popup'; + protected static $definitionClass = Popup::class; /** * The model class. * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\PopupModel'; + protected static $modelClass = PopupModel::class; /** * {@inheritdoc} @@ -59,12 +61,12 @@ class PopupMapper extends AbstractMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { - parent::build($definition, $model, $mapper, $filter, $parent); + parent::build($definition, $model, $mapper, $request, $parent); /** @var Popup $definition */ /** @var PopupModel $model */ diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/AbstractVectorMapper.php b/src/Mapper/Vector/AbstractVectorMapper.php similarity index 59% rename from src/Netzmacht/Contao/Leaflet/Mapper/Vector/AbstractVectorMapper.php rename to src/Mapper/Vector/AbstractVectorMapper.php index 3eceb65..3b38602 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/AbstractVectorMapper.php +++ b/src/Mapper/Vector/AbstractVectorMapper.php @@ -1,23 +1,27 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; +use Contao\Model; use Netzmacht\Contao\Leaflet\Definition\Style; -use Netzmacht\Contao\Leaflet\Filter\Filter; use Netzmacht\Contao\Leaflet\Frontend\ValueFilter; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\Contao\Leaflet\Model\PopupModel; use Netzmacht\Contao\Leaflet\Model\StyleModel; +use Netzmacht\Contao\Leaflet\Model\VectorModel; +use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\HasPopup; use Netzmacht\LeafletPHP\Definition\UI\Popup; @@ -35,7 +39,7 @@ class AbstractVectorMapper extends AbstractTypeMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\VectorModel'; + protected static $modelClass = VectorModel::class; /** * Frontend filter. @@ -44,16 +48,25 @@ class AbstractVectorMapper extends AbstractTypeMapper */ protected $valueFilter; + /** + * Repository manager. + * + * @var RepositoryManager + */ + private $repositoryManager; + /** * Construct. * - * @param ValueFilter $valueFilter Frontend filter. + * @param RepositoryManager $repositoryManager Repository manager. + * @param ValueFilter $valueFilter Frontend filter. */ - public function __construct(ValueFilter $valueFilter) + public function __construct(RepositoryManager $repositoryManager, ValueFilter $valueFilter) { - parent::__construct(); + $this->repositoryManager = $repositoryManager; + $this->valueFilter = $valueFilter; - $this->valueFilter = $valueFilter; + parent::__construct(); } /** @@ -61,15 +74,16 @@ class AbstractVectorMapper extends AbstractTypeMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { - parent::build($definition, $model, $mapper, $filter); + parent::build($definition, $model, $mapper, $request); if ($definition instanceof Path && $model->style) { - $styleModel = StyleModel::findActiveByPK($model->style); + $repository = $this->repositoryManager->getRepository(StyleModel::class); + $styleModel = $repository->findActiveByPK($model->style); if ($styleModel) { $style = $mapper->handle($styleModel); @@ -80,34 +94,35 @@ class AbstractVectorMapper extends AbstractTypeMapper } } - $this->buildPopup($definition, $model, $mapper, $filter); + $this->buildPopup($definition, $model, $mapper, $request); } /** * Build the popup. * * @param Definition $definition The definition. - * @param \Model $model The model. + * @param Model $model The model. * @param DefinitionMapper $mapper The definition mapper. - * @param Filter $filter The filter. + * @param Request $request Optional building request. * * @return void */ protected function buildPopup( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null + Request $request = null ) { if ($definition instanceof HasPopup && $model->addPopup) { $popup = null; $content = $this->valueFilter->filter($model->popupContent); if ($model->popup) { - $popupModel = PopupModel::findActiveByPK($model->popup); + $repository = $this->repositoryManager->getRepository(PopupModel::class); + $popupModel = $repository->findActiveByPK($model->popup); if ($popupModel) { - $popup = $mapper->handle($popupModel, $filter, null, $definition); + $popup = $mapper->handle($popupModel, $request, null, $definition); } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php b/src/Mapper/Vector/CircleMapper.php similarity index 74% rename from src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php rename to src/Mapper/Vector/CircleMapper.php index 069c38a..6ccb12f 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php +++ b/src/Mapper/Vector/CircleMapper.php @@ -1,22 +1,24 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\LeafletPHP\Definition; +use Netzmacht\LeafletPHP\Definition\Vector\Circle; use Netzmacht\LeafletPHP\Definition\Vector\CircleMarker; use Netzmacht\LeafletPHP\Value\LatLng; -use Netzmacht\LeafletPHP\Definition\Vector\Circle; /** * Class CircleMapper maps the database model to the circle definition. @@ -30,7 +32,7 @@ class CircleMapper extends AbstractVectorMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Circle'; + protected static $definitionClass = Circle::class; /** * Layer type. @@ -54,12 +56,12 @@ class CircleMapper extends AbstractVectorMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { - parent::build($definition, $model, $mapper, $filter); + parent::build($definition, $model, $mapper, $request); if ($definition instanceof CircleMarker) { $definition->setLatLng(LatLng::fromString($model->coordinates)); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMarkerMapper.php b/src/Mapper/Vector/CircleMarkerMapper.php similarity index 64% rename from src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMarkerMapper.php rename to src/Mapper/Vector/CircleMarkerMapper.php index d29c9f8..705de05 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMarkerMapper.php +++ b/src/Mapper/Vector/CircleMarkerMapper.php @@ -1,16 +1,19 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; +use Netzmacht\LeafletPHP\Definition\Vector\CircleMarker; + /** * Class CircleMarkerMapper maps the database model to the circle marker definition. * @@ -23,7 +26,7 @@ class CircleMarkerMapper extends CircleMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\CircleMarker'; + protected static $definitionClass = CircleMarker::class; /** * Layer type. diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolygonMapper.php b/src/Mapper/Vector/MultiPolygonMapper.php similarity index 70% rename from src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolygonMapper.php rename to src/Mapper/Vector/MultiPolygonMapper.php index b8a1099..881209a 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolygonMapper.php +++ b/src/Mapper/Vector/MultiPolygonMapper.php @@ -1,18 +1,20 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Vector\Polygon; @@ -28,7 +30,7 @@ class MultiPolygonMapper extends MultiPolylineMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Polygon'; + protected static $definitionClass = Polygon::class; /** * Layer type. @@ -42,12 +44,12 @@ class MultiPolygonMapper extends MultiPolylineMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { - parent::build($definition, $model, $mapper, $filter); + parent::build($definition, $model, $mapper, $request); if ($definition instanceof Polygon) { $this->createLatLngs($definition, $model); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolylineMapper.php b/src/Mapper/Vector/MultiPolylineMapper.php similarity index 73% rename from src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolylineMapper.php rename to src/Mapper/Vector/MultiPolylineMapper.php index 2b5dd9f..5147ccf 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolylineMapper.php +++ b/src/Mapper/Vector/MultiPolylineMapper.php @@ -1,18 +1,20 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Vector\Polyline; use Netzmacht\LeafletPHP\Value\LatLng; @@ -29,7 +31,7 @@ class MultiPolylineMapper extends AbstractVectorMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Polyline'; + protected static $definitionClass = Polyline::class; /** * Layer type. @@ -43,12 +45,12 @@ class MultiPolylineMapper extends AbstractVectorMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { - parent::build($definition, $model, $mapper, $filter); + parent::build($definition, $model, $mapper, $request); if ($definition instanceof Polyline) { $this->createLatLngs($definition, $model); @@ -59,11 +61,11 @@ class MultiPolylineMapper extends AbstractVectorMapper * Create lat lngs for the definition. * * @param Polyline $definition The multi polyline. - * @param \Model $model The definition model. + * @param Model $model The definition model. * * @return void */ - protected function createLatLngs(Polyline $definition, \Model $model) + protected function createLatLngs(Polyline $definition, Model $model) { foreach (deserialize($model->multiData, true) as $ring => $data) { $latLngs = array_map( diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolygonMapper.php b/src/Mapper/Vector/PolygonMapper.php similarity index 64% rename from src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolygonMapper.php rename to src/Mapper/Vector/PolygonMapper.php index de4ff20..0892a8d 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolygonMapper.php +++ b/src/Mapper/Vector/PolygonMapper.php @@ -1,16 +1,19 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; +use Netzmacht\LeafletPHP\Definition\Vector\Polygon; + /** * Class PolygonMapper maps the database model to the polygon definition. * @@ -23,7 +26,7 @@ class PolygonMapper extends PolylineMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Polygon'; + protected static $definitionClass = Polygon::class; /** * Layer type. diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolylineMapper.php b/src/Mapper/Vector/PolylineMapper.php similarity index 73% rename from src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolylineMapper.php rename to src/Mapper/Vector/PolylineMapper.php index 38117ce..8526cb9 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolylineMapper.php +++ b/src/Mapper/Vector/PolylineMapper.php @@ -1,21 +1,23 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\LeafletPHP\Definition; -use Netzmacht\LeafletPHP\Value\LatLng; use Netzmacht\LeafletPHP\Definition\Vector\Polyline; +use Netzmacht\LeafletPHP\Value\LatLng; /** * Class PolylineMapper maps the database model to the polyline definition. @@ -29,7 +31,7 @@ class PolylineMapper extends AbstractVectorMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Polyline'; + protected static $definitionClass = Polyline::class; /** * Layer type. @@ -43,12 +45,12 @@ class PolylineMapper extends AbstractVectorMapper */ protected function build( Definition $definition, - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, Definition $parent = null ) { - parent::build($definition, $model, $mapper, $filter); + parent::build($definition, $model, $mapper, $request); if ($definition instanceof Polyline) { array_map( diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/RectangleMapper.php b/src/Mapper/Vector/RectangleMapper.php similarity index 72% rename from src/Netzmacht/Contao/Leaflet/Mapper/Vector/RectangleMapper.php rename to src/Mapper/Vector/RectangleMapper.php index e72d96f..13307d4 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/RectangleMapper.php +++ b/src/Mapper/Vector/RectangleMapper.php @@ -1,19 +1,21 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; -use Netzmacht\Contao\Leaflet\Filter\Filter; +use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; -use Netzmacht\LeafletPHP\Definition; +use Netzmacht\Contao\Leaflet\Mapper\Request; +use Netzmacht\LeafletPHP\Definition\Vector\Rectangle; use Netzmacht\LeafletPHP\Value\LatLng; use Netzmacht\LeafletPHP\Value\LatLngBounds; @@ -29,7 +31,7 @@ class RectangleMapper extends AbstractVectorMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Rectangle'; + protected static $definitionClass = Rectangle::class; /** * Layer type. @@ -42,9 +44,9 @@ class RectangleMapper extends AbstractVectorMapper * {@inheritdoc} */ protected function buildConstructArguments( - \Model $model, + Model $model, DefinitionMapper $mapper, - Filter $filter = null, + Request $request = null, $elementId = null ) { $latLngs = array_map( @@ -54,7 +56,7 @@ class RectangleMapper extends AbstractVectorMapper deserialize($model->bounds, true) ); - $arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId); + $arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId); $arguments[] = new LatLngBounds($latLngs[0], $latLngs[1]); return $arguments; diff --git a/src/Netzmacht/Contao/Leaflet/Model/AbstractActiveModel.php b/src/Model/AbstractActiveModel.php similarity index 76% rename from src/Netzmacht/Contao/Leaflet/Model/AbstractActiveModel.php rename to src/Model/AbstractActiveModel.php index 029f3bc..c1b39cf 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/AbstractActiveModel.php +++ b/src/Model/AbstractActiveModel.php @@ -1,16 +1,19 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Model; +use Contao\Model\Collection; + /** * Class AbstractActiveModel is the base model for models with an active field. * @@ -26,7 +29,7 @@ abstract class AbstractActiveModel extends \Model * * @return \Model|null */ - public static function findActiveByPK($modelId, $options = array()) + public static function findActiveByPK($modelId, $options = []) { return static::findOneBy('active=1 AND id', $modelId, $options); } @@ -38,9 +41,9 @@ abstract class AbstractActiveModel extends \Model * @param mixed $value The column value. * @param array $options The options. * - * @return \Model|null + * @return Collection|null */ - public static function findActiveBy($column, $value, $options = array()) + public static function findActiveBy($column, $value, $options = []) { if (is_array($column)) { $column[] = 'active=1'; @@ -56,9 +59,9 @@ abstract class AbstractActiveModel extends \Model * * @param array $options The query options. * - * @return \Model\Collection|null + * @return Collection|null */ - public static function findActives($options = array()) + public static function findActives($options = []) { return static::findBy('active', '1', $options); } diff --git a/src/Netzmacht/Contao/Leaflet/Model/ControlModel.php b/src/Model/ControlModel.php similarity index 89% rename from src/Netzmacht/Contao/Leaflet/Model/ControlModel.php rename to src/Model/ControlModel.php index 6498618..0dd623b 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/ControlModel.php +++ b/src/Model/ControlModel.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Model; diff --git a/src/Netzmacht/Contao/Leaflet/Model/IconModel.php b/src/Model/IconModel.php similarity index 76% rename from src/Netzmacht/Contao/Leaflet/Model/IconModel.php rename to src/Model/IconModel.php index bf3ecfa..0931373 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/IconModel.php +++ b/src/Model/IconModel.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Model; diff --git a/src/Netzmacht/Contao/Leaflet/Model/LayerModel.php b/src/Model/LayerModel.php similarity index 82% rename from src/Netzmacht/Contao/Leaflet/Model/LayerModel.php rename to src/Model/LayerModel.php index 1c601a0..7164d09 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/LayerModel.php +++ b/src/Model/LayerModel.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Model; @@ -41,18 +42,18 @@ class LayerModel extends AbstractActiveModel * * @return Collection|null */ - public static function findMultipleByTypes(array $types, $options = array()) + public static function findMultipleByTypes(array $types, $options = []) { if (empty($types)) { return null; } - $options['column'] = array( + $options['column'] = [ sprintf( 'type IN (%s)', substr(str_repeat('?,', count($types)), 0, -1) - ) - ); + ), + ]; $options['value'] = $types; $options['return'] = 'Collection'; diff --git a/src/Netzmacht/Contao/Leaflet/Model/MapModel.php b/src/Model/MapModel.php similarity index 88% rename from src/Netzmacht/Contao/Leaflet/Model/MapModel.php rename to src/Model/MapModel.php index 1b401e0..8b9baf7 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/MapModel.php +++ b/src/Model/MapModel.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Model; diff --git a/src/Netzmacht/Contao/Leaflet/Model/MarkerModel.php b/src/Model/MarkerModel.php similarity index 76% rename from src/Netzmacht/Contao/Leaflet/Model/MarkerModel.php rename to src/Model/MarkerModel.php index f19f3f1..860bdd2 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/MarkerModel.php +++ b/src/Model/MarkerModel.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Model; @@ -40,7 +41,7 @@ class MarkerModel extends AbstractActiveModel public static function findByFilter($pid, Filter $filter = null) { if (!$filter) { - return static::findActiveBy('pid', $pid, array('order' => 'sorting')); + return static::findActiveBy('pid', $pid, ['order' => 'sorting']); } switch ($filter->getName()) { @@ -62,23 +63,23 @@ class MarkerModel extends AbstractActiveModel */ public static function findByBBoxFilter($pid, BboxFilter $filter) { - $columns = array( + $columns = [ 'active=1', 'pid=?', 'latitude > ? AND latitude < ?', - 'longitude > ? AND longitude < ?' - ); + 'longitude > ? AND longitude < ?', + ]; /** @var LatLngBounds $bounds */ $bounds = $filter->getValues()['bounds']; - $values = array( + $values = [ $pid, $bounds->getSouthWest()->getLatitude(), $bounds->getNorthEast()->getLatitude(), $bounds->getSouthWest()->getLongitude(), - $bounds->getNorthEast()->getLongitude() - ); + $bounds->getNorthEast()->getLongitude(), + ]; - return static::findBy($columns, $values, array('order' => 'sorting')); + return static::findBy($columns, $values, ['order' => 'sorting']); } } diff --git a/src/Netzmacht/Contao/Leaflet/Model/PopupModel.php b/src/Model/PopupModel.php similarity index 69% rename from src/Netzmacht/Contao/Leaflet/Model/PopupModel.php rename to src/Model/PopupModel.php index 5da81d1..b26f02a 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/PopupModel.php +++ b/src/Model/PopupModel.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Model; diff --git a/src/Netzmacht/Contao/Leaflet/Model/StyleModel.php b/src/Model/StyleModel.php similarity index 69% rename from src/Netzmacht/Contao/Leaflet/Model/StyleModel.php rename to src/Model/StyleModel.php index dbc852c..006106c 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/StyleModel.php +++ b/src/Model/StyleModel.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Model; diff --git a/src/Netzmacht/Contao/Leaflet/Model/VectorModel.php b/src/Model/VectorModel.php similarity index 69% rename from src/Netzmacht/Contao/Leaflet/Model/VectorModel.php rename to src/Model/VectorModel.php index 93651ca..2344e8b 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/VectorModel.php +++ b/src/Model/VectorModel.php @@ -1,12 +1,13 @@ - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 + * @copyright 2014-2017 netzmacht David Molineus. All rights reserved. + * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource - * */ namespace Netzmacht\Contao\Leaflet\Model; diff --git a/src/Netzmacht/Contao/Leaflet/Boot.php b/src/Netzmacht/Contao/Leaflet/Boot.php deleted file mode 100644 index a07590e..0000000 --- a/src/Netzmacht/Contao/Leaflet/Boot.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet; - -use Netzmacht\Contao\Leaflet\Event\InitializeDefinitionMapperEvent; -use Netzmacht\Contao\Leaflet\Event\InitializeEventDispatcherEvent; -use Netzmacht\Contao\Leaflet\Event\InitializeLeafletBuilderEvent; -use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; -use Netzmacht\LeafletPHP\Leaflet; -use Symfony\Component\EventDispatcher\EventDispatcherInterface as EventDispatcher; - -/** - * Class Boot initialize the leaflet map extension. - * - * @package Netzmacht\Contao\Leaflet - */ -class Boot -{ - /** - * The event dispatcher. - * - * @var EventDispatcher - */ - private $eventDispatcher; - - /** - * Construct. - * - * @param EventDispatcher $eventDispatcher The event dispatcher. - */ - public function __construct(EventDispatcher $eventDispatcher) - { - $this->eventDispatcher = $eventDispatcher; - } - - /** - * Initialize definition mapper. - * - * @param DefinitionMapper $definitionMapper The definition mapper. - * - * @return DefinitionMapper - */ - public function initializeDefinitionMapper(DefinitionMapper $definitionMapper) - { - $event = new InitializeDefinitionMapperEvent($definitionMapper); - $this->eventDispatcher->dispatch($event::NAME, $event); - - return $definitionMapper; - } - - /** - * Initialize the internal used event dispatcher of the leaflet encoding system. - * - * @param EventDispatcher $eventDispatcher The internal event dispatcher. - * - * @return EventDispatcher - */ - public function initializeEventDispatcher(EventDispatcher $eventDispatcher) - { - $event = new InitializeEventDispatcherEvent($eventDispatcher); - $this->eventDispatcher->dispatch($event::NAME, $event); - - return $eventDispatcher; - } - - /** - * Initialize the leaflet builder. - * - * @param Leaflet $leaflet The leaflet builder. - * - * @return Leaflet - */ - public function initializeLeafletBuilder(Leaflet $leaflet) - { - $event = new InitializeLeafletBuilderEvent($leaflet); - $this->eventDispatcher->dispatch($event::NAME, $event); - - return $leaflet; - } -} diff --git a/src/Netzmacht/Contao/Leaflet/Dca/ControlCallbacks.php b/src/Netzmacht/Contao/Leaflet/Dca/ControlCallbacks.php deleted file mode 100644 index 9b170ac..0000000 --- a/src/Netzmacht/Contao/Leaflet/Dca/ControlCallbacks.php +++ /dev/null @@ -1,190 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Dca; - -use Netzmacht\Contao\Toolkit\Dca\Callback\Callbacks; -use Netzmacht\Contao\Toolkit\Dca\Manager; -use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder; -use Netzmacht\Contao\Leaflet\Model\ControlModel; -use Netzmacht\Contao\Leaflet\Model\LayerModel; - -/** - * Class Control is the helper for the tl_leaflet_control dca. - * - * @package Netzmacht\Contao\Leaflet\Dca - */ -class ControlCallbacks extends Callbacks -{ - /** - * Name of the data container. - * - * @var string - */ - protected static $name = 'tl_leaflet_control'; - - /** - * Helper service name. - * - * @var string - */ - protected static $serviceName = 'leaflet.dca.control-callbacks'; - - /** - * The database connection. - * - * @var \Database - */ - private $database; - - /** - * Construct. - * - * @param Manager $manager Data container manager. - * @param \Database $database Database connection. - */ - public function __construct(Manager $manager, \Database $database) - { - parent::__construct($manager); - - $this->database = $database; - } - - /** - * Generate a row. - * - * @param array $row The data row. - * - * @return string - */ - public function generateRow($row) - { - return sprintf( - '%s [%s]', - $row['title'], - $row['type'] - ); - } - - /** - * Get layers for the layers control. - * - * @return array - */ - public function getLayers() - { - $collection = LayerModel::findAll(); - - return OptionsBuilder::fromCollection($collection, 'title') - ->asTree() - ->getOptions(); - } - - /** - * Get the zoom controls for the reference value of the loading control. - * - * @return array - */ - public function getZoomControls() - { - $collection = ControlModel::findBy('type', 'zoom', array('order' => 'title')); - - return OptionsBuilder::fromCollection($collection, 'title')->getOptions(); - } - - /** - * Load layer relations. - * - * @param mixed $value The actual value. - * @param \DataContainer $dataContainer The data container driver. - * - * @return array - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function loadLayerRelations($value, $dataContainer) - { - $result = $this->database - ->prepare('SELECT lid As layer, mode FROM tl_leaflet_control_layer WHERE cid=? ORDER BY sorting') - ->execute($dataContainer->id); - - return $result->fetchAllAssoc(); - } - - /** - * Save layer relations. - * - * @param $layers $layers The layer id values. - * @param \DataContainer $dataContainer The dataContainer driver. - * - * @return null - */ - public function saveLayerRelations($layers, $dataContainer) - { - $new = deserialize($layers, true); - $values = array(); - $result = $this->database - ->prepare('SELECT * FROM tl_leaflet_control_layer WHERE cid=? order BY sorting') - ->execute($dataContainer->id); - - while ($result->next()) { - $values[$result->lid] = $result->row(); - } - - $sorting = 0; - - foreach ($new as $layer) { - if (!isset($values[$layer['layer']])) { - $this->database - ->prepare('INSERT INTO tl_leaflet_control_layer %s') - ->set( - array( - 'tstamp' => time(), - 'lid' => $layer['layer'], - 'cid' => $dataContainer->id, - 'mode' => $layer['mode'], - 'sorting' => $sorting - ) - ) - ->execute(); - - $sorting += 128; - } else { - $this->database - ->prepare('UPDATE tl_leaflet_control_layer %s WHERE id=?') - ->set( - array( - 'tstamp' => time(), - 'sorting' => $sorting, - 'mode' => $layer['mode'] - ) - ) - ->execute($values[$layer['layer']]['id']); - - $sorting += 128; - unset ($values[$layer['layer']]); - } - } - - $ids = array_map( - function ($item) { - return $item['id']; - }, - $values - ); - - if ($ids) { - $this->database->query('DELETE FROM tl_leaflet_control_layer WHERE id IN(' . implode(',', $ids) . ')'); - } - - return null; - } -} diff --git a/src/Netzmacht/Contao/Leaflet/Dca/FrontendIntegration.php b/src/Netzmacht/Contao/Leaflet/Dca/FrontendIntegration.php deleted file mode 100644 index d97ce28..0000000 --- a/src/Netzmacht/Contao/Leaflet/Dca/FrontendIntegration.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Dca; - -use ContaoCommunityAlliance\Translator\TranslatorInterface as Translator; -use Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory; -use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder; -use Netzmacht\Contao\Leaflet\Model\MapModel; - -/** - * Class Module is the helper for the tl_module dca. - * - * @package Netzmacht\Contao\Leaflet\Dca - */ -class FrontendIntegration -{ - /** - * Translator. - * - * @var Translator - */ - private $translator; - - /** - * FrontendIntegration constructor. - * - * @param Translator $translator Translator. - */ - public function __construct(Translator $translator) - { - $this->translator = $translator; - } - - /** - * Generate the callback definition. - * - * @param string $methodName Callback method name. - * - * @return callable - */ - public static function callback($methodName) - { - return CallbackFactory::service('leaflet.dca.frontend-integration', $methodName); - } - - /** - * Get all leaflet maps. - * - * @return array - */ - public function getMaps() - { - $collection = MapModel::findAll(); - - return OptionsBuilder::fromCollection($collection, 'title')->getOptions(); - } - - /** - * Get edit map link wizard. - * - * @param \DataContainer $dataContainer The dataContainer driver. - * - * @return string - */ - public function getEditMapLink($dataContainer) - { - if ($dataContainer->value < 1) { - return ''; - } - - $pattern = 'title="%s" style="padding-left: 3px" onclick="Backend.openModalIframe('; - $pattern .= '{\'width\':768,\'title\':\'%s\',\'url\':this.href});return false"'; - - return sprintf( - '%s', - 'contao/main.php?do=leaflet_map&table=tl_leaflet_map&act=edit&id=', - $dataContainer->value, - \RequestToken::get(), - sprintf( - $pattern, - specialchars($this->translator->translate('editalias.1', 'tl_content', [$dataContainer->value])), - specialchars( - str_replace( - "'", - "\\'", - sprintf($this->translator->translate('editalias.1', 'tl_content', [$dataContainer->value])) - ) - ) - ), - \Image::getHtml( - 'alias.gif', - $this->translator->translate('editalias.0', 'tl_content', [$dataContainer->value]), - 'style="vertical-align:top"' - ) - ); - } -} diff --git a/src/Netzmacht/Contao/Leaflet/Dca/LeafletCallbacks.php b/src/Netzmacht/Contao/Leaflet/Dca/LeafletCallbacks.php deleted file mode 100644 index 3e97bf7..0000000 --- a/src/Netzmacht/Contao/Leaflet/Dca/LeafletCallbacks.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Dca; - -use Netzmacht\Contao\Leaflet\Model\LayerModel; -use Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory; -use Netzmacht\LeafletPHP\Value\LatLng; - -/** - * Class Leaflet is the base helper providing different methods. - * - * @package Netzmacht\Contao\Leaflet\Dca - */ -class LeafletCallbacks -{ - /** - * File system. - * - * @var \Files - */ - private $fileSystem; - - /** - * LeafletCallbacks constructor. - * - * @param \Files $fileSystem File system. - */ - public function __construct(\Files $fileSystem) - { - $this->fileSystem = $fileSystem; - } - - /** - * Generate the callback definition. - * - * @param string $methodName Callback method name. - * - * @return callable - */ - public static function callback($methodName) - { - return CallbackFactory::service('leaflet.dca.common', $methodName); - } - - /** - * Create the zoom range. - * - * @return array - */ - public function getZoomLevels() - { - return range(1, 20); - } - - /** - * Get the geocoder wizard. - * - * @param \DataContainer $dataContainer The dataContainer driver. - * - * @return string - */ - public function getGeocoder($dataContainer) - { - $template = new \BackendTemplate('be_leaflet_geocode'); - $template->field = 'ctrl_' . $dataContainer->field; - - try { - $latLng = LatLng::fromString($dataContainer->value); - $template->marker = json_encode($latLng); - } catch (\Exception $e) { - // LatLng throws an exeption of value could not be created. Just let the value empty when. - } - - - return $template->parse(); - } - - /** - * Get all layers. - * - * @return array - */ - public function getLayers() - { - $options = array(); - $collection = LayerModel::findBy('pid', '0', array('order' => 'title')); - - if ($collection) { - foreach ($collection as $model) { - $options[$model->id] = $model->title; - } - } - - return $options; - } - - /** - * Clear the leaflet cache. - * - * @param mixed $value Value when used as save_callback. - * - * @return mixed - */ - public function clearCache($value = null) - { - $this->fileSystem->rrdir('system/cache/leaflet', true); - - return $value; - } -} diff --git a/src/Netzmacht/Contao/Leaflet/Dca/MapCallbacks.php b/src/Netzmacht/Contao/Leaflet/Dca/MapCallbacks.php deleted file mode 100644 index ad5943b..0000000 --- a/src/Netzmacht/Contao/Leaflet/Dca/MapCallbacks.php +++ /dev/null @@ -1,159 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Dca; - -use Netzmacht\Contao\Leaflet\Model\LayerModel; -use Netzmacht\Contao\Toolkit\Dca\Callback\Callbacks; -use Netzmacht\Contao\Toolkit\Dca\Manager; -use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder; - -/** - * Class Map is the helper class for the tl_leaflet_map dca. - * - * @package Netzmacht\Contao\Leaflet\Dca - */ -class MapCallbacks extends Callbacks -{ - /** - * Name of the data container. - * - * @var string - */ - protected static $name = 'tl_leaflet_map'; - - /** - * Helper service name. - * - * @var string - */ - protected static $serviceName = 'leaflet.dca.map-callbacks'; - - /** - * The database connection. - * - * @var \Database - */ - private $database; - - /** - * Construct. - * - * @param Manager $manager Data container manager. - * @param \Database $database Database connection. - */ - public function __construct(Manager $manager, \Database $database) - { - parent::__construct($manager); - - $this->database = $database; - } - - /** - * Load layer relations. - * - * @param mixed $value The actual value. - * @param \DataContainer $dataContainer The data container driver. - * - * @return array - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function loadLayerRelations($value, $dataContainer) - { - $result = $this->database - ->prepare('SELECT lid FROM tl_leaflet_map_layer WHERE mid=? ORDER BY sorting') - ->execute($dataContainer->id); - - return $result->fetchEach('lid'); - } - - /** - * Save layer relations. - * - * @param mixed $layerId The layer id values. - * @param \DataContainer $dataContainer The dataContainer driver. - * - * @return null - */ - public function saveLayerRelations($layerId, $dataContainer) - { - $new = deserialize($layerId, true); - $values = array(); - $result = $this->database - ->prepare('SELECT * FROM tl_leaflet_map_layer WHERE mid=? order BY sorting') - ->execute($dataContainer->id); - - while ($result->next()) { - $values[$result->lid] = $result->row(); - } - - $sorting = 0; - - foreach ($new as $layerId) { - if (!isset($values[$layerId])) { - $this->database - ->prepare('INSERT INTO tl_leaflet_map_layer %s') - ->set( - array( - 'tstamp' => time(), - 'lid' => $layerId, - 'mid' => $dataContainer->id, - 'sorting' => $sorting - ) - ) - ->execute(); - - $sorting += 128; - } else { - if ($values[$layerId]['sorting'] <= ($sorting - 128) - || $values[$layerId]['sorting'] >= ($sorting + 128)) { - $this->database - ->prepare('UPDATE tl_leaflet_map_layer %s WHERE id=?') - ->set(array('tstamp' => time(), 'sorting' => $sorting)) - ->execute($values[$layerId]['id']); - } - - $sorting += 128; - unset ($values[$layerId]); - } - } - - $ids = array_map( - function ($item) { - return $item['id']; - }, - $values - ); - - if ($ids) { - $this->database->query('DELETE FROM tl_leaflet_map_layer WHERE id IN(' . implode(',', $ids) . ')'); - } - - return null; - } - - /** - * Get all layers except of the current layer. - * - * @param \DataContainer $dataContainer The dataContainer driver. - * - * @return array - */ - public function getLayers($dataContainer) - { - $collection = LayerModel::findBy('id !', $dataContainer->id); - - return OptionsBuilder::fromCollection($collection, 'title') - ->asTree() - ->getOptions(); - } -} diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Validator.php b/src/Netzmacht/Contao/Leaflet/Dca/Validator.php deleted file mode 100644 index 5da9c57..0000000 --- a/src/Netzmacht/Contao/Leaflet/Dca/Validator.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @copyright 2016 netzmacht David Molineus. All rights reserved. - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Dca; - -use ContaoCommunityAlliance\Translator\TranslatorInterface as Translator; -use Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory; -use Netzmacht\LeafletPHP\Value\LatLng; - -/** - * Class Validator. - * - * @package Netzmacht\Contao\Leaflet\Dca - */ -class Validator -{ - /** - * Translator. - * - * @var Translator; - */ - private $translator; - - /** - * Validator constructor. - * - * @param Translator $translator Translator. - */ - public function __construct(Translator $translator) - { - $this->translator = $translator; - } - - /** - * Generate the callback definition. - * - * @param string $methodName Callback method name. - * - * @return callable - */ - public static function callback($methodName) - { - return CallbackFactory::service('leaflet.dca.validator', $methodName); - } - - /** - * Validate coordinates. - * - * @param mixed $value Given value. - * - * @return mixed - * @throws \InvalidArgumentException When invalid coordinates give. - */ - public function validateCoordinates($value) - { - try { - LatLng::fromString($value); - } catch (\Exception $e) { - throw new \InvalidArgumentException( - $this->translator->translate('invalidCoordinates', 'leaflet', [$value]), - 0, - $e - ); - } - - return $value; - } - - /** - * Validate multiple coordinates. - * - * @param mixed $values Given value. - * - * @return mixed - */ - public function validateMultipleCoordinates($values) - { - if (!is_array($values)) { - $lines = explode("\n", $values); - } else { - $lines = $values; - } - - foreach ($lines as $coordinate) { - $this->validateCoordinates($coordinate); - } - - return $values; - } - - /** - * Validate multiple coordinate sets. - * - * @param mixed $values Given value. - * - * @return mixed - */ - public function validateMultipleCoordinateSets($values) - { - $sets = deserialize($values, true); - foreach ($sets as $lines) { - $this->validateMultipleCoordinates($lines); - } - - return $values; - } - - /** - * Validate an alias. - * - * @param string $value Given value. - * - * @return string - * @throws \InvalidArgumentException When invalid value given. - */ - public function validateAlias($value) - { - if (preg_match('/^[A-Za-z_]+[A-Za-z0-9_]+$/', $value) !== 1) { - throw new \InvalidArgumentException( - $this->translator->translate('invalidAlias', 'leaflet') - ); - } - - return $value; - } -} diff --git a/src/Netzmacht/Contao/Leaflet/Dca/VectorCallbacks.php b/src/Netzmacht/Contao/Leaflet/Dca/VectorCallbacks.php deleted file mode 100644 index d4ba594..0000000 --- a/src/Netzmacht/Contao/Leaflet/Dca/VectorCallbacks.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Dca; - -use Netzmacht\Contao\Toolkit\Dca\Callback\Callbacks; -use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder; -use Netzmacht\Contao\Leaflet\Model\StyleModel; - -/** - * Helper class for the tl_leaflet_vector dca. - * - * @package Netzmacht\Contao\Leaflet\Dca - */ -class VectorCallbacks extends Callbacks -{ - /** - * Name of the data container. - * - * @var string - */ - protected static $name = 'tl_leaflet_vector'; - - /** - * Helper service name. - * - * @var string - */ - protected static $serviceName = 'leaflet.dca.vector-callbacks'; - - /** - * Generate the row label. - * - * @param array $row Current data row. - * - * @return string - */ - public function generateRow($row) - { - return sprintf( - '%s (%s)', - $row['title'], - $this->getFormatter()->formatValue('type', $row['type']) - ); - } - - /** - * Get all styles. - * - * @return array - */ - public function getStyles() - { - $collection = StyleModel::findAll(array('order' => 'title')); - - return OptionsBuilder::fromCollection($collection, 'title')->getOptions(); - } -} diff --git a/src/Netzmacht/Contao/Leaflet/DependencyInjection/LeafletServices.php b/src/Netzmacht/Contao/Leaflet/DependencyInjection/LeafletServices.php deleted file mode 100644 index 4d3b2a6..0000000 --- a/src/Netzmacht/Contao/Leaflet/DependencyInjection/LeafletServices.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright 2016 netzmacht David Molineus. All rights reserved. - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\DependencyInjection; - -use Doctrine\Common\Cache\Cache; -use Netzmacht\Contao\Leaflet\Boot; -use Netzmacht\Contao\Leaflet\Frontend\ValueFilter; -use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; -use Netzmacht\Contao\Leaflet\MapProvider; -use Netzmacht\Contao\Toolkit\Data\Alias\AliasGenerator; -use Netzmacht\LeafletPHP\Assets; -use Netzmacht\LeafletPHP\Leaflet; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * Class LeafletServices describes services provided by the leaflet package. - * - * @package Netzmacht\Contao\Leaflet\DependencyInjection - */ -class LeafletServices -{ - /** - * Service name for the alias generator which creates valid js aliases. - * - * @return AliasGenerator - */ - const ALIAS_GENERATOR = 'leaflet.alias-generator.default'; - - /** - * Service name of the boot handler. - * - * @return Boot - */ - const BOOT = 'leaflet.boot'; - - /** - * Leaflet cache - * - * @return Cache - */ - const CACHE = 'leaflet.cache'; - - /** - * Service name of the definition builder. - * - * @return Leaflet - */ - const DEFINITION_BUILDER = 'leaflet.definition.builder'; - - /** - * Service name of the encoder factory used inside of the definition builder. - * - * @return \callable - */ - const DEFINITION_ENCODER_FACTORY = 'leaflet.definition.builder.encoder-factory'; - - /** - * Service name of the internal used event dispatcher of the definition builder. - * - * @return EventDispatcherInterface - */ - const DEFINITION_BUILDER_EVENT_DISPATCHER = 'leaflet.definition.builder.event-dispatcher'; - - /** - * Service name of the definition mapper. - * - * @return DefinitionMapper - */ - const DEFINITION_MAPPER = 'leaflet.definition.mapper'; - - /** - * Service name of the leaflet map provider. - * - * @return MapProvider - */ - const MAP_PROVIDER = 'leaflet.map.provider'; - - /** - * Service name of the map assets handler. - * - * @return Assets - */ - const MAP_ASSETS = 'leaflet.map.assets'; - - /** - * Service name of the frontend value filter. - * - * @return ValueFilter - */ - const FRONTEND_VALUE_FILTER = 'leaflet.frontend.value-filter'; - - /** - * Service name for the alias generator uses for rows being unique in the pid. - * - * @return AliasGenerator - */ - const PARENT_ALIAS_GENERATOR = 'leaflet.alias-generator.parent'; -} diff --git a/src/Netzmacht/Contao/Leaflet/Event/InitializeDefinitionMapperEvent.php b/src/Netzmacht/Contao/Leaflet/Event/InitializeDefinitionMapperEvent.php deleted file mode 100644 index 4b7a199..0000000 --- a/src/Netzmacht/Contao/Leaflet/Event/InitializeDefinitionMapperEvent.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Event; - -use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; -use Symfony\Component\EventDispatcher\Event; - -/** - * Class InitializeDefinitionMapperEvent is emitted when the definition mapper is created. - * - * @package Netzmacht\Contao\Leaflet\Event - */ -class InitializeDefinitionMapperEvent extends Event -{ - const NAME = 'leaflet.boot.initialize-definition-mapper'; - - /** - * The definitino mapper. - * - * @var DefinitionMapper - */ - private $definitionMapper; - - /** - * Construct. - * - * @param DefinitionMapper $definitionMapper The definition mapper. - */ - public function __construct(DefinitionMapper $definitionMapper) - { - $this->definitionMapper = $definitionMapper; - } - - /** - * Get the definition mapper. - * - * @return DefinitionMapper - */ - public function getDefinitionMapper() - { - return $this->definitionMapper; - } -} diff --git a/src/Netzmacht/Contao/Leaflet/Event/InitializeEventDispatcherEvent.php b/src/Netzmacht/Contao/Leaflet/Event/InitializeEventDispatcherEvent.php deleted file mode 100644 index 8be23e5..0000000 --- a/src/Netzmacht/Contao/Leaflet/Event/InitializeEventDispatcherEvent.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Event; - -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventDispatcherInterface as EventDispatcher; - -/** - * InitializeEventDispatcherEvent is emitted then the internal event dispatcher of the encoding system is initialized. - * - * @package Netzmacht\Contao\Leaflet\Event - */ -class InitializeEventDispatcherEvent extends Event -{ - const NAME = 'leaflet.boot.initialize-event-dispatcher'; - - /** - * The event dispatcher. - * - * @var EventDispatcher - */ - private $eventDispatcher; - - /** - * The event dispatcher. - * - * @param EventDispatcher $eventDispatcher The event dispatcher. - */ - public function __construct(EventDispatcher $eventDispatcher) - { - $this->eventDispatcher = $eventDispatcher; - } - - /** - * Get the event dispatcher. - * - * @return EventDispatcher - */ - public function getEventDispatcher() - { - return $this->eventDispatcher; - } -} diff --git a/src/Netzmacht/Contao/Leaflet/Event/InitializeLeafletBuilderEvent.php b/src/Netzmacht/Contao/Leaflet/Event/InitializeLeafletBuilderEvent.php deleted file mode 100644 index af933d9..0000000 --- a/src/Netzmacht/Contao/Leaflet/Event/InitializeLeafletBuilderEvent.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Event; - -use Netzmacht\LeafletPHP\Leaflet; -use Symfony\Component\EventDispatcher\Event; - -/** - * Class InitializeLeafletBuilderEvent is emitted when the leaflet builder is created. - * - * @package Netzmacht\Contao\Leaflet\Event - */ -class InitializeLeafletBuilderEvent extends Event -{ - const NAME = 'leaflet.boot.initialize-leaflet-builder'; - - /** - * The leaflet builder. - * - * @var Leaflet - */ - private $builder; - - /** - * Construct. - * - * @param Leaflet $builder The leaflet builder. - */ - public function __construct(Leaflet $builder) - { - $this->builder = $builder; - } - - /** - * Get the builder. - * - * @return Leaflet - */ - public function getBuilder() - { - return $this->builder; - } -} diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/AbstractMapHybrid.php b/src/Netzmacht/Contao/Leaflet/Frontend/AbstractMapHybrid.php deleted file mode 100644 index a69d87f..0000000 --- a/src/Netzmacht/Contao/Leaflet/Frontend/AbstractMapHybrid.php +++ /dev/null @@ -1,150 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Frontend; - -use ContaoCommunityAlliance\Translator\TranslatorInterface as Translator; -use Database\Result; -use Model\Collection; -use Netzmacht\Contao\Leaflet\MapProvider; -use Netzmacht\Contao\Leaflet\Model\MapModel; -use Netzmacht\Contao\Toolkit\Component\Hybrid\AbstractHybrid; -use Netzmacht\Contao\Toolkit\View\Template\TemplateFactory; - -/** - * Class HybridTrait provides method required by the frontend module and content element the same time. - * - * @package Netzmacht\Contao\Leaflet\Frontend - */ -abstract class AbstractMapHybrid extends AbstractHybrid -{ - /** - * The map provider. - * - * @var MapProvider - */ - private $mapProvider; - - /** - * The user input. - * - * @var \Input - */ - private $input; - - /** - * The Contao config. - * - * @var \Config - */ - private $config; - - /** - * HybridTrait constructor. - * - * @param Result|\Model|Collection $model Component model. - * @param TemplateFactory $templateFactory Template factory. - * @param Translator $translator Translator. - * @param MapProvider $mapProvider Map provider. - * @param \Input $input Request Input. - * @param \Config $config Config. - * @param string $column Column in which the element appears. - */ - public function __construct( - $model, - TemplateFactory $templateFactory, - Translator $translator, - MapProvider $mapProvider, - \Input $input, - \Config $config, - $column = null - ) { - parent::__construct($model, $templateFactory, $translator, $column); - - $this->mapProvider = $mapProvider; - $this->input = $input; - $this->config = $config; - } - - /** - * Do the frontend integration generation. - * - * @return string - */ - public function generate() - { - $this->mapProvider->handleAjaxRequest($this->getIdentifier()); - - if (TL_MODE === 'BE') { - $model = MapModel::findByPk($this->get('leaflet_map')); - - $template = $this->getTemplateFactory()->createBackendTemplate('be_wildcard'); - - if ($model) { - $href = 'contao/main.php?do=leaflet&table=tl_leaflet_map&act=edit&id=' . $model->id; - - $template->set('wildcard', '### LEAFLET MAP ' . $model->title . ' ###'); - $template->set('title', $this->get('headline')); - $template->set('id', $model->id); - $template->set('link', $model->title); - $template->set('href', $href); - } - - return $template->parse(); - } - - return parent::generate(); - } - - /** - * Do the frontend integration compiling. - * - * @return void - * - * @throws \Exception If the map could not be created. - * - * @SuppressWarnings(PHPMD.Superglobals) - */ - protected function compile() - { - try { - $template = $this->get('leaflet_template') ?: 'leaflet_map_js'; - $mapId = $this->getIdentifier(); - $map = $this->mapProvider->generate($this->get('leaflet_map'), null, $mapId, $template); - - $this->template->set('javascript', $map); - $this->template->set('mapId', $mapId); - - $style = ''; - $height = deserialize($this->get('leaflet_height'), true); - $width = deserialize($this->get('leaflet_width'), true); - - if (!empty($width['value'])) { - $style .= 'width:' . $width['value'] . $width['unit'] . ';'; - } - - if (!empty($height['value'])) { - $style .= 'height:' . $height['value'] . $height['unit'] . ';'; - } - - $this->template->set('mapStyle', $style); - } catch (\Exception $e) { - throw $e; - } - } - - /** - * Get the component identifier which is used as unique name. - * - * @return string - */ - abstract protected function getIdentifier(); -} diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/ValueFilter.php b/src/Netzmacht/Contao/Leaflet/Frontend/ValueFilter.php deleted file mode 100644 index 4885ba9..0000000 --- a/src/Netzmacht/Contao/Leaflet/Frontend/ValueFilter.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Frontend; - -use Netzmacht\Contao\Toolkit\InsertTag\Replacer; - -/** - * Class ValueFilter is a service class which can be used to filter values before passing them to an definition object. - * - * @package Netzmacht\Contao\Leaflet\Frontend - */ -class ValueFilter -{ - /** - * The insert tag replacer. - * - * @var Replacer - */ - private $insertTagReplacer; - - /** - * Construct. - * - * @param Replacer $replacer The insert tag replacer. - */ - public function __construct($replacer) - { - $this->insertTagReplacer = $replacer; - } - - /** - * Filter a value so it can be passed to the frontend. - * - * The idea behind this extra method is that we just have to change one place if anything else than the - * insert tags has to be replaced. - * - * @param string $value The given value. - * - * @return string - */ - public function filter($value) - { - return $this->insertTagReplacer->replace($value); - } -} diff --git a/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php b/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php deleted file mode 100644 index 9df111d..0000000 --- a/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php +++ /dev/null @@ -1,294 +0,0 @@ - - * @copyright 2014-2016 netzmacht David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Subscriber; - -use ContaoCommunityAlliance\Contao\EventDispatcher\EventDispatcherInitializer; -use Netzmacht\Contao\Leaflet\ContaoAssets; -use Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices; -use Netzmacht\Contao\Leaflet\Event\GetJavascriptEvent; -use Netzmacht\Contao\Leaflet\Event\InitializeDefinitionMapperEvent; -use Netzmacht\Contao\Leaflet\Event\InitializeEventDispatcherEvent; -use Netzmacht\Contao\Leaflet\Event\InitializeLeafletBuilderEvent; -use Netzmacht\Contao\Leaflet\Frontend\InsertTag\LeafletInsertTagParser; -use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; -use Netzmacht\Contao\Leaflet\Mapper\Mapper; -use Netzmacht\Contao\Leaflet\Model\IconModel; -use Netzmacht\Contao\Toolkit\Boot\Event\InitializeSystemEvent; -use Netzmacht\Contao\Toolkit\DependencyInjection\Services; -use Netzmacht\LeafletPHP\Assets; -use Netzmacht\LeafletPHP\Definition\Type\Icon; -use Netzmacht\LeafletPHP\Definition\Type\ImageIcon; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Class BootSubscriber provides handlers for leaflet boot process. - * - * @package Netzmacht\Contao\Leaflet\Subscriber - */ -class BootSubscriber implements EventSubscriberInterface -{ - /** - * Leaflet mapper configuration. - * - * @var array - */ - private $mappers; - - /** - * Leaflet encoder configuration. - * - * @var array - */ - private $encoders; - - /** - * Leaflet libraries configuration. - * - * @var array - */ - private $libraries; - - /** - * Assets manager. - * - * @var ContaoAssets - */ - private $assets; - - /** - * Definition mapper. - * - * @var DefinitionMapper - */ - private $definitionMapper; - - /** - * Flag for loading icon file. - * - * @var bool - */ - private $loadIconFile = false; - - /** - * BootSubscriber constructor. - * - * @param ContaoAssets $assets Leaflet assets manager. - * @param array $mappers Leaflet mapper configuration. - * @param array $encoders Leaflet encoder configuration. - * @param array $libraries Leaflet libraries configuration. - */ - public function __construct( - ContaoAssets $assets, - array $mappers, - array $encoders, - array $libraries - ) { - $this->assets = $assets; - $this->mappers = $mappers; - $this->encoders = $encoders; - $this->libraries = $libraries; - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() - { - return array( - InitializeSystemEvent::NAME => 'initializeInsertTagParser', - InitializeDefinitionMapperEvent::NAME => 'initializeDefinitionMapper', - InitializeEventDispatcherEvent::NAME => 'initializeEventDispatcher', - InitializeLeafletBuilderEvent::NAME => 'initializeLeafletBuilder', - GetJavascriptEvent::NAME => array(array('loadIcons'), array('loadAssets')), - ); - } - - /** - * Initialize the leaflet insert tag parser. - * - * @param InitializeSystemEvent $event The event. - * - * @return void - */ - public function initializeInsertTagParser(InitializeSystemEvent $event) - { - $container = $event->getContainer(); - $debugMode = $container->get(Services::CONFIG)->get('debugMode'); - $mapProvider = $container->get(LeafletServices::MAP_PROVIDER); - $parser = new LeafletInsertTagParser($mapProvider, $debugMode); - - $container->get(Services::INSERT_TAG_REPLACER)->registerParser($parser); - } - - /** - * Create and register all configured mappers. - * - * @param InitializeDefinitionMapperEvent $event The subscribed event. - * - * @return void - */ - public function initializeDefinitionMapper(InitializeDefinitionMapperEvent $event) - { - $mapper = $event->getDefinitionMapper(); - $this->definitionMapper = $mapper; - - foreach ($this->mappers as $className) { - if (is_array($className)) { - $mapper->register($this->createMapper($className[0]), $className[1]); - } else { - $mapper->register($this->createMapper($className)); - } - } - } - - /** - * Register all leaflet encoders. - * - * @param InitializeEventDispatcherEvent $event The subscribed event. - * - * @return void - */ - public function initializeEventDispatcher(InitializeEventDispatcherEvent $event) - { - $dispatcher = $event->getEventDispatcher(); - $initializer = new EventDispatcherInitializer(); - - $initializer->addSubscribers($dispatcher, $this->encoders); - } - - /** - * Register all libraries assets. - * - * @param InitializeLeafletBuilderEvent $event The subscribed event. - * - * @return void - */ - public function initializeLeafletBuilder(InitializeLeafletBuilderEvent $event) - { - $builder = $event->getBuilder(); - - foreach ($this->libraries as $name => $assets) { - if (!empty($assets['css'])) { - list ($source, $type) = (array) $assets['css']; - $builder->registerStylesheet($name, $source, $type ?: Assets::TYPE_FILE); - } - - if (!empty($assets['javascript'])) { - list ($source, $type) = (array) $assets['javascript']; - $builder->registerJavascript($name, $source, $type ?: Assets::TYPE_FILE); - } - } - } - - /** - * Load Contao leaflet assets. - * - * @return void - */ - public function loadAssets() - { - $this->assets->addJavascript('assets/leaflet/maps/contao-leaflet.js', ContaoAssets::TYPE_FILE); - - if ($this->loadIconFile) { - $this->assets->addJavascript('assets/leaflet/js/icons.js', ContaoAssets::TYPE_FILE); - } - } - - /** - * Load icons. - * - * @return void - */ - public function loadIcons() - { - if (!$this->definitionMapper) { - return; - } - - $collection = IconModel::findBy('active', true); - - if ($collection) { - $buffer = ''; - $icons = array(); - - foreach ($collection as $model) { - /** @var ImageIcon $icon */ - $icon = $this->definitionMapper->handle($model); - $icons[] = array( - 'id' => $icon->getId(), - 'type' => lcfirst($icon->getType()), - 'options' => $icon->getOptions(), - ); - - $this->loadIconsLibraries($icon); - } - - if ($icons) { - $buffer = sprintf('L.contao.loadIcons(%s);', json_encode($icons)); - } - - // @codingStandardsIgnoreStart - // TODO: Cache it. - // codingStandardsIgnoreEnd - - $file = new \File('assets/leaflet/js/icons.js'); - $file->write($buffer); - $file->close(); - - $this->loadIconFile = true; - } - } - - /** - * Create a new mapper. - * - * @param mixed $mapper The mapper class or callable factory. - * - * @return Mapper - */ - private function createMapper($mapper) - { - if (is_callable($mapper)) { - return $mapper(); - } - - return new $mapper; - } - - /** - * Load all libraries for an icon. - * - * @param Icon $icon Icon definition - * - * @return void. - */ - protected function loadIconsLibraries($icon) - { - foreach ($icon::getRequiredLibraries() as $library) { - if (!isset($this->libraries[$library])) { - continue; - } - - $assets = $this->libraries[$library]; - - if (!empty($assets['css'])) { - list ($source, $type) = (array)$assets['css']; - $this->assets->addStylesheet($source, $type ?: Assets::TYPE_FILE); - } - - if (!empty($assets['javascript'])) { - list ($source, $type) = (array)$assets['javascript']; - $this->assets->addJavascript($source, $type ?: Assets::TYPE_FILE); - } - } - } -}