90 Commits

Author SHA1 Message Date
David Molineus
c4feeb1b38 Add missing error block. 2019-01-10 16:41:03 +01:00
David Molineus
cb3e9bc8b4 Make controller public as it's required by Symfony 4. 2019-01-10 16:39:43 +01:00
David Molineus
6a88ed380b Update travis configuration for compatibility issues with phpcq v1.2.0. Test against PHP 7.3 as well. 2018-12-18 10:56:29 +01:00
David Molineus
4ea2adbb85 Merge tag '3.1.2' 2018-12-18 09:26:49 +01:00
David Molineus
dc5a0a081e Complete implementation of tile providers. 2018-12-18 09:23:47 +01:00
David Molineus
79f6efd9f3 Update leaflet providers. 2018-12-17 17:01:08 +01:00
David Molineus
e7bede78b1 Drop not required .htaccess folder. 2018-12-17 15:21:05 +01:00
David Molineus
997e16891b Add defined check. 2018-12-17 15:20:51 +01:00
David Molineus
d5407357d8 Merge tag '3.1.1' 2018-12-07 11:22:41 +01:00
David Molineus
1ba19f63b1 Prepare release. 2018-12-07 11:22:23 +01:00
David Molineus
878492c0b1 Fix Code style. 2018-12-07 11:22:16 +01:00
David Molineus
57ba63556a Ignore markers without defined coordinates. 2018-12-06 10:37:39 +01:00
David Molineus
0e2b8dd3cd Fix missing marker cluster icon. 2018-11-01 16:01:16 +01:00
David Molineus
91d3786187 Merge tag '3.1.0' 2018-11-01 15:37:04 +01:00
David Molineus
5e20b83503 Prepare release. 2018-11-01 15:36:35 +01:00
David Molineus
ca103521aa add url-polyfill to about page. 2018-11-01 15:34:58 +01:00
David Molineus
f422459be2 Gulp task improvement. 2018-11-01 11:37:32 +01:00
David Molineus
c661abb626 Fix dynamic data loading for new request url. 2018-11-01 10:26:38 +01:00
David Molineus
83226cdd80 Fix gulp watch task. 2018-11-01 10:25:54 +01:00
David Molineus
ed10175072 Add hint that zoom level is probably required (Close #56). 2018-10-30 13:00:52 +01:00
David Molineus
d2338332b4 Rewrite about page using own route (Close #48). 2018-10-30 12:38:46 +01:00
David Molineus
7aa4f38902 Update readme. 2018-10-30 10:53:44 +01:00
David Molineus
cb03dcfa41 Fix broken marker cluster (#60). 2018-10-30 10:52:47 +01:00
David Molineus
2108de32d9 Add support for distance filter for the marker layer. 2018-10-30 10:48:38 +01:00
David Molineus
314e2d21ee Update readme. 2018-10-30 09:53:12 +01:00
David Molineus
6faaa866ad Use minified scripts. 2018-10-30 09:38:38 +01:00
David Molineus
b22563b38c Prevent form submit on enter when using control geocoder and close popup when value is chosen. 2018-10-30 09:36:06 +01:00
David Molineus
a10e55a126 Fix: Do not cache insert tags as it would create esi tags. 2018-10-30 08:45:47 +01:00
David Molineus
e27ac21902 Also replace non cachable inserttags. 2018-10-29 16:24:07 +01:00
David Molineus
0ba725ed38 Implement custom route for data request to prevent partial rendering of the page and it's possible issues (f.e. form captcha changes) (Close #49). 2018-10-29 16:02:50 +01:00
David Molineus
7ec2ee0d96 Upgrade to gulp 4.0. 2018-10-29 15:46:38 +01:00
David Molineus
9e54f12555 Use TL_CSS_UNITS for with and height option (#59). 2018-10-19 16:37:49 +02:00
David Molineus
b323049f9d Merge tag '3.0.4' 2018-10-08 16:26:20 +02:00
David Molineus
873de89d7c Fix broken content element attributes (Missing class and custom id). 2018-10-08 16:26:04 +02:00
David Molineus
88927a3de8 Change format of changelog and add semver note. 2018-09-18 10:33:32 +02:00
David Molineus
8fdc7dab29 Make alias generator services public for Contao 4.6/Symfony 4.0 compatibility. 2018-09-18 10:26:38 +02:00
David Molineus
9a1b6dee01 Merge tag '3.0.2' 2018-08-23 14:50:34 +02:00
David Molineus
9e0f11ec18 Prevent cacheKey is not set. 2018-08-23 14:48:58 +02:00
David Molineus
f60ed1b7be Fix changelog versions. 2018-08-23 14:36:46 +02:00
David Molineus
3d45f6b2eb Run composer require checker and solve issues. 2018-08-23 14:35:25 +02:00
David Molineus
e73a4d4bdf Merge tag '3.0.1' 2018-06-20 08:30:50 +02:00
David Molineus
0322a87e94 Fix license. 2018-06-20 08:30:14 +02:00
David Molineus
f5e8701312 Update readme. 2018-06-20 08:25:47 +02:00
David Molineus
2d0221a90a Fix broken filter factory (Close #57). 2018-06-20 08:24:22 +02:00
David Molineus
9f0b34a53b Merge tag '3.0.0' 2018-01-05 17:11:39 +01:00
David Molineus
e5d336037f Prepare the release. 2018-01-05 17:11:21 +01:00
David Molineus
19614d305f Update requirements. 2018-01-05 17:04:14 +01:00
David Molineus
295d5385a0 Make services public which has to be required in Symfony 3.4. 2018-01-05 17:03:30 +01:00
David Molineus
bde761911f Update changelog. 2017-11-15 11:21:01 +01:00
David Molineus
b4947c1404 Update translations. 2017-11-15 11:18:42 +01:00
David Molineus
16e58f7f40 Register hook as tagged service. 2017-11-15 11:13:24 +01:00
David Molineus
27cef9b45b Add backend icon. 2017-11-13 13:13:14 +01:00
David Molineus
ef30de9698 Use the geocode widget for the boundaries. 2017-11-13 11:07:53 +01:00
David Molineus
db352a2df3 Fix counting of markers. 2017-11-13 10:12:39 +01:00
David Molineus
7db007bdab Remove double parameter. 2017-11-13 10:05:20 +01:00
David Molineus
a77c1b4039 Merge branch 'release/3.0.0' of github.com:netzmacht/contao-leaflet-maps into release/3.0.0 2017-11-13 10:03:16 +01:00
David Molineus
46e0661986 Use style dca listener. 2017-11-12 15:01:16 +01:00
David Molineus
ded5427afb Use same layer id for the geojson layer. 2017-11-12 14:59:11 +01:00
David Molineus
8b193a391a Add the missing repository manager dependency. 2017-11-12 14:48:56 +01:00
David Molineus
00da9f7b25 Adjust language path. 2017-10-27 13:36:44 +02:00
David Molineus
099cd6ca9d Update changelog. 2017-10-19 09:38:25 +02:00
David Molineus
86fb4f4e12 Update the readme. 2017-10-19 09:35:31 +02:00
David Molineus
ae4d9cec13 Update changelog. 2017-10-19 09:31:50 +02:00
David Molineus
08dea6e1da Code style. 2017-10-19 09:28:58 +02:00
David Molineus
ef7b493b2d Use the repository manager. 2017-10-19 08:45:39 +02:00
David Molineus
ce9de6ded3 Use template engine to render the map. 2017-10-18 17:01:03 +02:00
David Molineus
7498aef141 Fix query. 2017-10-18 16:48:16 +02:00
David Molineus
28adc54d36 Fix query. 2017-10-18 16:46:05 +02:00
David Molineus
451d13fe98 Work on repository manager usage. 2017-10-18 16:43:33 +02:00
David Molineus
a4192b4b1a Code style. 2017-10-18 16:36:36 +02:00
David Molineus
7741f44428 Use the repository manager. 2017-10-18 16:36:12 +02:00
David Molineus
0716354952 Work on service oriented listeners. 2017-10-18 16:26:27 +02:00
David Molineus
dd23d386eb Use latest Repository feature to replace static model calls. 2017-10-18 15:30:24 +02:00
David Molineus
edb4ac9eeb Support geojson and topojson as file types for the file layer. 2017-10-18 11:47:04 +02:00
David Molineus
5501887231 Refactor the factories so that they don't use the container. 2017-10-18 08:27:49 +02:00
David Molineus
60306459d2 Add the file path to the layer label. 2017-10-17 18:18:33 +02:00
David Molineus
c465b724f4 Convert array syntax and other minor code style adjustments. 2017-10-17 18:11:28 +02:00
David Molineus
6ded7441d9 Code style. 2017-10-17 18:03:49 +02:00
David Molineus
ae5fe11d20 Move Request to Mapper namespace. 2017-10-17 18:03:42 +02:00
David Molineus
8dbe464ca8 Move hash subscriber to the listener namespace. 2017-10-17 17:58:55 +02:00
David Molineus
d261e8b4ba Refactor GeoJsonSubscriber to an listener. 2017-10-17 17:57:40 +02:00
David Molineus
57fe57b8ea Move encoder subscriber to encoder namespace. 2017-10-17 17:48:14 +02:00
David Molineus
46e6dcc2fa Support bounds changing after files got loaded. 2017-10-17 17:43:12 +02:00
David Molineus
01b3962b78 Optimize use statements. 2017-10-17 17:11:35 +02:00
David Molineus
734aecf738 Add changelog. 2017-10-17 17:09:29 +02:00
David Molineus
50465e4026 Bypass filesystem cache in debug mode. 2017-10-17 17:09:00 +02:00
David Molineus
0abc4676f1 Merge branch 'feature/file-layer' into release/3.0.0 2017-10-17 16:51:10 +02:00
David Molineus
d1f26056e9 Implement a file layer for gpx,kml,wkt support. 2017-10-17 16:50:29 +02:00
David Molineus
31a5cc40a5 Optimize import statements. 2017-10-17 16:22:24 +02:00
David Molineus
59df74c3f9 Replace string class names with the ::class attribute. 2017-10-17 13:51:09 +02:00
140 changed files with 6226 additions and 951 deletions

View File

@@ -0,0 +1,11 @@
{
"symbol-whitelist": [
"null", "true", "false",
"static", "self", "parent",
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object",
"array_insert",
"Contao\\ManagerPlugin\\Bundle\\BundlePluginInterface",
"Contao\\ManagerPlugin\\Bundle\\Config\\BundleConfig",
"Contao\\ManagerPlugin\\Bundle\\Parser\\ParserInterface"
]
}

1
.gitignore vendored
View File

@@ -25,4 +25,3 @@ build.properties
# NPM
node_modules
package-lock.json

View File

@@ -1,11 +1,21 @@
dist: xenial
addons:
apt:
packages:
- ant-optional
language: php
php:
- "7.0"
- "7.3"
- "7.2"
- "7.1"
env:
- CONTAO_VERSION=contao/core-bundle ~4.4.0
- CONTAO_VERSION=contao/core-bundle ~4.5.0
- CONTAO_VERSION=contao/core-bundle ~4.6.0
matrix:
exclude:

134
CHANGELOG.md Normal file
View File

@@ -0,0 +1,134 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 3.1.3 - 2019-01-10
[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.1.2...3.1.3)
### Fixed
- Fix broken api routes in Contao 4.6/Symfony 4 (#69)
- Fix broken about.html.twig template. Error block was missing
## 3.1.2 - 2018-12-18
[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.1.1...3.1.2)
### Fixed
- Fix broken MapBox integration: Access token is now required
- Fix broken OpenWeatherMap integration: Api key is now required
- Fix broken Thunderforest integration: Api key is now required
### Added
- Add missing OpenPtMap of leaflet-providers
- Add missing OpenRailwayMap of leaflet-providers
- Add missing OpenFireMap of leaflet-providers
- Add missing SafeCast of leaflet-providers
- Add missing map types `normalNightTransit`, `normalNightTransitMobile`, `reducedDay`, `reducedNight`,
`hybridDayTransit` and `hybridDayGrey` of HERE provider
- Add missing map types `Voyager`, `VoyagerNoLabels`, `VoyagerOnlyLabels` and `VoyagerLabelsUnder` of CartoDB provider
- Add missing Wikimedia of leaflet-providers
- Add missing GeoportailFrance of leaflet-providers
- Add missing OneMapSG of leaflet-providers
## 3.1.1 - 2018-12-07
[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.1.0...3.1.1)
### Fixed
- Fix missing marker cluster icon.
- Ignore markers without coordinates to prevent uncaught exception caused by invalid coordinates.
## 3.1.0 - 2018-11-01
[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.0.4...3.1.0)
### Added
- Custom route to load map data.
- Add distance filter support for the marker layer (Bounds Mode "fit" has to be enabled).
- Add support for relative css units for map size definition (#59).
- Add hint that zoom level is probably required (#56).
### Deprecated
- Deprecate `Netzmacht\Contao\Leaflet\Frontend\RequestUrl`. Use router to generate request url for layer data.
- Deprecate `Netzmacht\Contao\Leaflet\Frontend\DataController`. Use introduced endpoint to get map data.
### Changed
- Require PHP 7.1.
- Rewritten about page using own route (#48).
### Fixed
- Pressing enter on backend geocode control doesn't submit form anymore.
- Fix broken marker cluster layer (#60).
## 3.0.4 - 2018-10-08
[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.0.3...3.0.4)
### Fixed
- Fix broken content element attributes (Missing class and custom id).
## 3.0.3 - 2018-09-18
[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.0.2...3.0.3)
### Fixed
- Make alias generator services public for Contao 4.6/Symfony 4.0 compatibility.
## 3.0.2 - 2018-08-23
[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.0.1...3.0.2)
- Run composer require checker and solve issues.
## 3.0.1 - 2018-06-20
[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.0.0...3.0.1)
- Fix broken dynamic bbox related data loading (#57)
## 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-alpha1 - 2017-10-19
[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.0.0-alpha1...3.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

View File

@@ -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

View File

@@ -7,7 +7,7 @@
"leaflet"
],
"type": "contao-bundle",
"license": "LGPL-3.0+",
"license": "LGPL-3.0-or-later",
"authors": [
{
"name": "David Molineus",
@@ -22,19 +22,32 @@
"source": "https://github.com/netzmacht/contao-leaflet-maps"
},
"require": {
"php": ">=7.0",
"php": ">=7.1",
"ext-json": "*",
"ext-pdo": "*",
"contao/core-bundle": "~4.4",
"netzmacht/contao-leaflet-libraries": "^1.0",
"doctrine/dbal": "^2.5",
"symfony/config": "~3.3 || ~4.0",
"symfony/event-dispatcher": "~3.3 || ~4.0",
"symfony/dependency-injection": "~3.3 || ~4.0",
"symfony/filesystem": "~3.3 || ~4.0",
"symfony/http-kernel": "~3.3 || ~4.0",
"symfony/translation": "~3.3 || ~4.0",
"symfony/templating": "~3.3 || ~4.0",
"netzmacht/contao-leaflet-libraries": "^1.3.4",
"netzmacht/contao-leaflet-geocode-widget": "^1.2",
"netzmacht/php-javascript-builder": "^1.0",
"netzmacht/php-leaflet": "^1.0.1",
"netzmacht/contao-toolkit": "^3.0@dev",
"contao-community-alliance/meta-palettes": "^1.5",
"netzmacht/php-leaflet": "^1.1.0",
"netzmacht/contao-toolkit": "~3.0",
"netzmacht/contao-page-context": "~1.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"
"contao/manager-plugin": "^2.1",
"phpstan/phpstan": "^0.10.3"
},
"autoload": {
"psr-4": {
@@ -48,16 +61,16 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev",
"dev-develop": "2.1.x-dev",
"dev-release/3.0.0": "3.0.x-dev"
"dev-master": "3.1.x-dev",
"dev-develop": "3.2.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": "module/languages",
"languages_cto": "src/Bundle/Resources/contao/languages",
"languages_tx": ".tx"
}
}

View File

@@ -1,28 +1,35 @@
var gulp = require('gulp');
var del = require('del');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
const { series, src, watch, dest, parallel, task} = require('gulp');
const del = require('promised-del');
const uglify = require('gulp-uglify');
const concat = require('gulp-concat');
var paths = {
minified: 'contao-leaflet.js',
scripts: ['js/*.js'],
scripts: ['js/vendor/*.js', 'js/*.js'],
dest: 'src/Bundle/Resources/public/js'
};
gulp.task('clear', function() {
del([paths.dest + '/' + paths.minified]);
});
function clean () {
return del([paths.dest + '/' + paths.minified]);
}
gulp.task('scripts', ['clear'], function() {
return gulp.src(paths.scripts)
function build () {
return src(paths.scripts)
.pipe(concat(paths.minified))
.pipe(uglify())
.pipe(gulp.dest(paths.dest));
});
.pipe(dest(paths.dest));
}
const buildTasks = series(clean, build);
gulp.task('default', ['scripts']);
function watchTask () {
watch(
paths.scripts,
buildTasks
)
}
gulp.task('watch', function() {
gulp.watch(paths.scripts, ['scripts']);
});
exports.clean = clean;
exports.watch = watchTask;
exports.build = buildTasks;
exports.default = buildTasks;

View File

@@ -124,8 +124,23 @@ L.Contao = L.Evented.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.
*/
loadUrl: function (url, type, options, customLayer, map) {
url = this.applyFilterToUrl(url, map);
var layer = omnivore[type](url, options, customLayer);
if (map) {
// Required because Control.Loading tries to get _leafet_id which is created here.
@@ -133,7 +148,7 @@ L.Contao = L.Evented.extend({
// Add listener for map bounds changes.
if (map.options.dynamicLoad && layer.options.boundsMode == 'fit') {
layer.options.requestHash = hash;
layer.options.requestUrl = url;
map.on('moveend', layer.refreshData, layer);
map.on('layerremove', function(e) {
@@ -158,6 +173,19 @@ L.Contao = L.Evented.extend({
return layer;
},
/**
* 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) {
return this.loadUrl(url, type, options, customLayer, map);
},
/**
* Point to layer callback. Adds a geo json point to the layer.
*
@@ -299,6 +327,36 @@ L.Contao = L.Evented.extend({
}
return value;
},
/**
* Apply the filter to a request url.
*
* @param {string} url The request url.
* @param {L.Map} map The map.
*
* @returns {string}
*/
applyFilterToUrl: function (url, map) {
var value, query, bounds;
if (!map || !map.options.dynamicLoad) {
return url;
}
url = new URL(url);
query = new URLSearchParams(url.search);
bounds = map.getBounds();
value = bounds.getSouth() + ',' + bounds.getWest();
value += ',' + bounds.getNorth() + ',' + bounds.getEast();
query.set('filter', 'bbox');
query.set('values', value);
url.search = query.toString();
return url.toString();
}
});

View File

@@ -29,6 +29,6 @@ L.GeoJSON.include({
});
// TODO: Allow other data formats.
omnivore.geojson(L.contao.createRequestUrl(this.options.requestHash, e.target), null, dataLayer);
omnivore.geojson(L.contao.applyFilterToUrl(this.options.requestUrl, e.target), null, dataLayer);
}
});

3297
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,11 @@
"description": "Leaflet maps for Contao",
"main": "gulpfile.js",
"dependencies": {
"del": "^3.0.0",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.0",
"gulp-uglify": "^3.0.0"
"gulp": "^4.0.0",
"gulp-cli": "^2.0.1",
"gulp-concat": "^2.6.1",
"gulp-uglify": "^3.0.1",
"promised-del": "^1.0.2"
},
"devDependencies": {},
"scripts": {
@@ -23,7 +24,7 @@
"Maps"
],
"author": "netzmacht David Molineus",
"license": "LGPL-3.0",
"license": "LGPL-3.0-or-later",
"bugs": {
"url": "https://github.com/netzmacht/contao-leaflet-maps/issues"
},

View File

@@ -10,30 +10,59 @@
* @filesource
*/
namespace Netzmacht\Contao\Leaflet\Backend;
namespace Netzmacht\Contao\Leaflet\Backend\Action;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as Engine;
use Symfony\Component\HttpFoundation\Response;
/**
* Credits backend module.
*
* @package Netzmacht\Contao\Leaflet\Backend
*/
class About
final class AboutAction
{
/**
* Templating engine.
*
* @var Engine
*/
private $engine;
/**
* Project directory.
*
* @var string
*/
private $projectDir;
/**
* AboutAction constructor.
*
* @param Engine $engine Templating engine.
* @param string $projectDir Project directory.
*/
public function __construct(Engine $engine, string $projectDir)
{
$this->engine = $engine;
$this->projectDir = $projectDir;
}
/**
* Generate the backend view.
*
* @return string
*/
public function generate()
public function __invoke(): Response
{
$template = new \BackendTemplate('be_leaflet_about');
$data = [
'headline' => 'Leaftlet maps integration for Contao CMS',
'libraries' => $this->getLibraries(),
];
$template->headline = 'Leaftlet maps integration for Contao CMS';
$template->libraries = $this->getLibraries();
[$data['version'], $data['dependencies']] = $this->extractFromComposer();
list($template->version, $template->dependencies) = $this->extractFromComposer();
return $template->parse();
return $this->engine->renderResponse('@NetzmachtContaoLeaflet/backend/about.html.twig', $data);
}
/**
@@ -43,23 +72,22 @@ class About
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
private function getLibraries()
private function getLibraries(): array
{
return array_map(
function ($library) {
$library = array_merge(
array(
[
'homepage' => null,
'version' => null,
),
],
$library
);
if ($library['homepage']) {
$library['homepage'] = sprintf(
'<a href="%s" %s>%s</a>',
'<a href="%s" target="_blank">%s</a>',
$library['homepage'],
LINK_NEW_WINDOW,
preg_replace('#^(https?://(www)?)#i', '', $library['homepage'])
);
}
@@ -69,7 +97,7 @@ class About
array_filter(
$GLOBALS['LEAFLET_LIBRARIES'],
function ($library) {
return isset($library['name']) && isset($library['license']);
return isset($library['name'], $library['license']);
}
)
);
@@ -80,36 +108,36 @@ class About
*
* @return array
*/
private function extractFromComposer()
private function extractFromComposer(): array
{
$extFile = TL_ROOT . '/vendor/netzmacht/contao-leaflet-maps/composer.json';
$lockFile = TL_ROOT . '/composer.lock';
$extFile = $this->projectDir . '/vendor/netzmacht/contao-leaflet-maps/composer.json';
$lockFile = $this->projectDir . '/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(
'<a href="https://packagist.org/packages/%s" target="_blank">Visit packagist</a>',
$package['name']
)
);
),
];
}
}
return array($version, $deps);
return [$version, $deps];
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* Leaflet maps for Contao CMS.
*
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @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 .= ' <span class="tl_gray">(' . $file->path . ')</span>';
}
return $label;
}
}

View File

@@ -15,6 +15,7 @@ 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;
/**
@@ -24,6 +25,23 @@ use Symfony\Component\Translation\TranslatorInterface as Translator;
*/
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}
*/
@@ -37,7 +55,8 @@ final class MarkersLabelRenderer extends AbstractLabelRenderer
*/
public function render(array $row, string $label, Translator $translator): string
{
$count = MarkerModel::countBy('pid', $row['id']);
$repository = $this->repositoryManager->getRepository(MarkerModel::class);
$count = $repository->countBy(['pid=?'], [$row['id']]);
$label .= sprintf(
'<span class="tl_gray"> (%s %s)</span>',
$count,

View File

@@ -29,7 +29,7 @@ final class OverpassLabelRenderer extends AbstractLabelRenderer
*/
protected function getLayerType(): string
{
return 'vectors';
return 'overpass';
}
/**

View File

@@ -15,6 +15,7 @@ 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;
/**
@@ -24,12 +25,29 @@ use Symfony\Component\Translation\TranslatorInterface as Translator;
*/
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 'vectors';
return 'reference';
}
/**
@@ -37,7 +55,8 @@ final class ReferenceLabelRenderer extends AbstractLabelRenderer
*/
public function render(array $row, string $label, Translator $translator): string
{
$reference = LayerModel::findByPk($row['reference']);
$repository = $this->repositoryManager->getRepository(LayerModel::class);
$reference = $repository->find((int) $row['reference']);
if ($reference) {
$label .= '<span class="tl_gray"> (' . $reference->title . ')</span>';

View File

@@ -15,6 +15,7 @@ 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;
/**
@@ -24,6 +25,23 @@ use Symfony\Component\Translation\TranslatorInterface as Translator;
*/
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}
*/
@@ -37,7 +55,8 @@ final class VectorsLabelRenderer extends AbstractLabelRenderer
*/
public function render(array $row, string $label, Translator $translator): string
{
$count = VectorModel::countBy('pid', $row['id']);
$repository = $this->repositoryManager->getRepository(VectorModel::class);
$count = $repository->countBy(['pid=?'], [$row['id']]);
$label .= sprintf(
'<span class="tl_gray"> (%s %s)</span>',
$count,

View File

@@ -18,15 +18,20 @@ use Contao\CoreBundle\ContaoCoreBundle;
use Contao\ManagerPlugin\Bundle\BundlePluginInterface;
use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
use Contao\ManagerPlugin\Routing\RoutingPluginInterface;
use Netzmacht\Contao\Leaflet\Bundle\NetzmachtContaoLeafletBundle;
use Netzmacht\Contao\PageContext\NetzmachtContaoPageContextBundle;
use Netzmacht\Contao\Toolkit\Bundle\NetzmachtContaoToolkitBundle;
use Symfony\Component\Config\Loader\LoaderResolverInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\RouteCollection;
/**
* Contao manager plugin.
*
* @package Netzmacht\Contao\Leaflet\ContaoManager
*/
class Plugin implements BundlePluginInterface
class Plugin implements BundlePluginInterface, RoutingPluginInterface
{
/**
* {@inheritdoc}
@@ -35,8 +40,27 @@ class Plugin implements BundlePluginInterface
{
return [
BundleConfig::create(NetzmachtContaoLeafletBundle::class)
->setLoadAfter([ContaoCoreBundle::class, NetzmachtContaoToolkitBundle::class])
->setReplace(['leaflet'])
->setLoadAfter(
[
ContaoCoreBundle::class,
NetzmachtContaoToolkitBundle::class,
NetzmachtContaoPageContextBundle::class
]
)
->setReplace(['leaflet']),
];
}
/**
* {@inheritdoc}
*/
public function getRouteCollection(LoaderResolverInterface $resolver, KernelInterface $kernel): ?RouteCollection
{
$loader = $resolver->resolve(__DIR__ . '/../Resources/config/routing.yml');
if (!$loader) {
return null;
}
return $loader->load(__DIR__ . '/../Resources/config/routing.yml');
}
}

View File

@@ -49,5 +49,13 @@ class NetzmachtContaoLeafletExtension extends Extension
$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');
}
}
}
}

View File

@@ -14,9 +14,9 @@ declare(strict_types=1);
namespace Netzmacht\Contao\Leaflet\Bundle;
use Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass\RegisterLibrariesPass;
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;

View File

@@ -38,6 +38,13 @@ parameters:
- '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.
#

View File

@@ -42,6 +42,6 @@ services:
- { name: netzmacht.contao_leaflet.encoder }
netzmacht.contao_leaflet.encoder.subscriber:
class: Netzmacht\Contao\Leaflet\Subscriber\EncoderSubscriber
class: Netzmacht\Contao\Leaflet\Encoder\Subscriber\EncoderSubscriber
tags:
- { name: netzmacht.contao_leaflet.encoder }

View File

@@ -32,7 +32,7 @@ parameters:
markercluster:
children: true
icon: 'bundles/netzmachtcontaoleaflet/img/markercluster.png'
icon: 'bundles/netzmachtcontaoleaflet/img/cluster.png'
tile:
children: false
@@ -45,6 +45,12 @@ parameters:
extend: true
fit: true
file:
children: false
icon: 'bundles/netzmachtcontaoleaflet/img/file.png'
boundsMode:
extend: true
services:
_defaults:
public: false
@@ -56,6 +62,8 @@ services:
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' }
@@ -71,10 +79,21 @@ services:
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' }

View File

@@ -1,75 +1,99 @@
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'
- '@translator'
- '@session'
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\IconDcaListener
class: Netzmacht\Contao\Leaflet\Listener\Dca\StyleDcaListener
public: true
arguments:
- '%netzmacht.contao_leaflet.styles%'
netzmacht.contao_leaflet.listeners.geo_json_subscriber:
class: Netzmacht\Contao\Leaflet\Subscriber\GeoJsonSubscriber
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_subscriber' }
- { name: 'kernel.event_listener', event: 'netzmacht.contao_leaflet.mapper.convert_to_geojson', method: 'handle' }
netzmacht.contao_leaflet.listeners.hash_subscriber:
class: Netzmacht\Contao\Leaflet\Subscriber\HashSubscriber
class: Netzmacht\Contao\Leaflet\Listener\HashSubscriber
tags:
- { name: 'kernel.event_subscriber' }
@@ -78,13 +102,26 @@ services:
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' }
netzmacht.contao_leaflet.listeners.backend_menu:
class: Netzmacht\Contao\Leaflet\Listener\Backend\UserNavigationListener
arguments:
- '@request_stack'
- '@router'
- '@translator'
- '@netzmacht.contao_toolkit.assets_manager'
tags:
- { name: 'contao.hook', hook: 'getUserNavigation', method: '__invoke'}

View File

@@ -9,6 +9,8 @@ services:
# 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 }
@@ -28,26 +30,38 @@ services:
netzmacht.contao_leaflet.mapper.markers_layer:
class: Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLayerMapper
arguments:
- '@netzmacht.contao_toolkit.repository_manager'
- '@router'
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'
- '@router'
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 }
@@ -55,9 +69,16 @@ services:
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 }
- { name: netzmacht.contao_leaflet.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:
@@ -82,6 +103,8 @@ services:
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 }
@@ -95,6 +118,7 @@ services:
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 }
@@ -102,6 +126,7 @@ services:
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 }
@@ -109,6 +134,7 @@ services:
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 }
@@ -116,6 +142,7 @@ services:
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 }
@@ -123,6 +150,7 @@ services:
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 }
@@ -130,6 +158,7 @@ services:
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 }
@@ -137,6 +166,7 @@ services:
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 }
@@ -150,6 +180,8 @@ services:
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 }
@@ -171,6 +203,7 @@ services:
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 }

View File

@@ -1,13 +1,22 @@
parameters:
netzmacht.contao_leaflet.providers:
OpenStreetMap:
variants: ['Mapnik', 'BlackAndWhite', 'DE', 'France', 'HOT', 'BZH']
variants: ['Mapnik', 'BlackAndWhite', 'DE', 'CH', 'France', 'HOT', 'BZH']
OpenSeaMap: []
OpenTopoMap: []
OpenPtMap: []
OpenRailwayMap: []
OpenFireMap: []
SafeCast: []
Thunderforest:
class: 'Netzmacht\LeafletPHP\Plugins\LeafletProviders\ThunderforestProvider'
variants:
- 'OpenCycleMap'
- 'Transport'
@@ -16,6 +25,9 @@ parameters:
- 'Landscape'
- 'Outdoors'
- 'Pioneer'
options:
apiKey: 'tile_provider_key'
fields: ['tile_provider_key']
OpenMapSurfer:
variants: ['Roads', 'AdminBounds', 'Grayscale']
@@ -26,7 +38,8 @@ parameters:
MapBox:
class: 'Netzmacht\LeafletPHP\Plugins\LeafletProviders\MapBoxProvider'
options:
key: 'tile_provider_key'
accessToken: 'tile_provider_key'
fields: ['tile_provider_key']
Stamen:
variants:
@@ -56,6 +69,7 @@ parameters:
- 'WorldGrayCanvas'
OpenWeatherMap:
class: 'Netzmacht\LeafletPHP\Plugins\LeafletProviders\OpenWeatherMapProvider'
variants:
- 'Clouds'
- 'CloudsClassic'
@@ -68,6 +82,9 @@ parameters:
- 'Wind'
- 'Temperature'
- 'Snow'
options:
apiKey: 'tile_provider_key'
fields: ['tile_provider_key']
HERE:
class: 'Netzmacht\LeafletPHP\Plugins\LeafletProviders\HereProvider'
@@ -83,12 +100,18 @@ parameters:
- 'normalNightMobile'
- 'normalNightGrey'
- 'normalNightGreyMobile'
- 'normalNightTransit'
- 'normalNightTransitMobile'
- 'reducedDay'
- 'reducedNight'
- 'basicMap'
- 'mapLabels'
- 'trafficFlow'
- 'carnavDayGrey'
- 'hybridDay'
- 'hybridDayMobile'
- 'hybridDayTransit'
- 'hybridDayGrey'
- 'pedestrianDay'
- 'pedestrianNight'
- 'satelliteDay'
@@ -123,6 +146,10 @@ parameters:
- 'DarkMatter'
- 'DarkMatterNoLabels'
- 'DarkMatterOnlyLabels'
- 'Voyager'
- 'VoyagerNoLabels'
- 'VoyagerOnlyLabels'
- 'VoyagerLabelsUnder'
HikeBike:
variants:
@@ -155,3 +182,20 @@ parameters:
- 'ModisTerraChlorophyll'
NLS: []
Wikimedia: []
GeoportailFrance:
variants:
- 'parcels'
- 'ignMaps'
- 'maps'
- 'orthos'
OneMapSG:
variants:
- 'Default'
- 'Night'
- 'Original'
- 'Grey'
- 'LandLot'

View File

@@ -0,0 +1,18 @@
leaflet_layer:
path: /leaflet/api/layer/{layerId}
controller: Netzmacht\Contao\Leaflet\Frontend\Action\LayerDataAction
defaults:
_leaflet_scope: page
_format: geojson
_scope: frontend
requirements:
_format: geojson
context: \w+
contextId: \d+
leaflet_backend_about:
path: /contao/leaflet/about
controller: Netzmacht\Contao\Leaflet\Backend\Action\AboutAction
defaults:
_scope: backend
_backend_module: leaflet_about

View File

@@ -15,6 +15,8 @@ services:
- '@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
@@ -26,9 +28,6 @@ services:
arguments:
- '%netzmacht.contao_leaflet.filters%'
netzmacht.contao_leaflet.cache:
alias: 'netzmacht.contao_leaflet.cache.default'
netzmacht.contao_leaflet.cache.default:
class: Doctrine\Common\Cache\FilesystemCache
arguments:
@@ -75,18 +74,24 @@ services:
netzmacht.contao_leaflet.definition.alias_generator.factory_default:
class: Netzmacht\Contao\Leaflet\Alias\DefaultAliasGeneratorFactory
public: true
arguments:
- '@database_connection'
netzmacht.contao_leaflet.definition.alias_generator.factory_parent:
class: Netzmacht\Contao\Leaflet\Alias\ParentAliasGeneratorFactory
public: true
arguments:
- '@database_connection'
netzmacht.contao_leaflet.frontend.element_factory:
class: Netzmacht\Contao\Leaflet\Frontend\ContentElement\MapElementFactory
arguments:
- '@service_container'
- '@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' }
@@ -94,13 +99,18 @@ services:
netzmacht.contao_leaflet.frontend.module_factory:
class: Netzmacht\Contao\Leaflet\Frontend\Module\MapModuleFactory
arguments:
- '@service_container'
- '@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%'
@@ -112,3 +122,19 @@ services:
arguments:
- '@netzmacht.contao_leaflet.filter_factory'
- '%kernel.debug%'
Netzmacht\Contao\Leaflet\Frontend\PageIdDeterminator:
tags:
- { name: Netzmacht\Contao\PageContext\Request\PageIdDeterminator }
Netzmacht\Contao\Leaflet\Frontend\Action\LayerDataAction:
public: true
arguments:
- '@netzmacht.contao_leaflet.map.provider'
- '@netzmacht.contao_leaflet.filter_factory'
Netzmacht\Contao\Leaflet\Backend\Action\AboutAction:
public: true
arguments:
- '@templating'
- '%kernel.project_dir%'

View File

@@ -17,44 +17,37 @@
array_insert(
$GLOBALS['BE_MOD'],
1,
array(
'leaflet' => array
(
'leaflet_map' => array
(
'tables' => array
(
[
'leaflet' => [
'leaflet_map' => [
'tables' => [
'tl_leaflet_map',
'tl_leaflet_control',
),
],
'icon' => 'bundles/netzmachtcontaoleaflet/img/map.png',
'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/backend.css',
),
'leaflet_layer' => array
(
'tables' => array
(
],
'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' => array
(
'callback' => Netzmacht\Contao\Leaflet\Backend\About::class,
'icon' => 'bundles/netzmachtcontaoleaflet/img/about.png',
'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/about.css',
)
)
)
'javascript' => 'bundles/netzmachtcontaoleaflet/js/backend.js',
],
],
]
);
if (defined('TL_MODE') && TL_MODE === 'BE') {
$GLOBALS['TL_CSS'][] = 'bundles/netzmachtcontaoleaflet/css/backend_global.css';
}
/*
* Models.
*/
@@ -67,12 +60,3 @@ $GLOBALS['TL_MODELS']['tl_leaflet_marker'] = \Netzmacht\Contao\Leaflet\Model\Ma
$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;
/*
* Hooks.
*/
$GLOBALS['TL_HOOKS']['initializeSystem'][] = [
'netzmacht.contao_leaflet.listeners.register_libraries',
'onInitializeSystem'
];

View File

@@ -49,7 +49,7 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_mapId'] = [
$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'],
'options' => $GLOBALS['TL_CSS_UNITS'],
'search' => false,
'exclude' => true,
'eval' => ['rgxp' => 'digit', 'tl_class' => 'clr w50'],
@@ -60,7 +60,7 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_width'] = [
$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'],
'options' => $GLOBALS['TL_CSS_UNITS'],
'search' => false,
'exclude' => true,
'eval' => ['rgxp' => 'digit', 'tl_class' => 'w50'],

View File

@@ -217,6 +217,14 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
'pointToLayer',
],
],
'file extends default' => [
'+config' => ['boundsMode', 'fileFormat'],
'+expert' => [
'onEachFeature',
'pointToLayer',
],
],
],
'metasubselectpalettes' => [
@@ -226,6 +234,11 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
'tile_provider' => [
'MapBox' => ['tile_provider_key'],
'HERE' => ['tile_provider_key', 'tile_provider_code'],
'OpenWeatherMap' => ['tile_provider_key'],
'Thunderforest' => ['tile_provider_key'],
],
'fileFormat' => [
'!' => ['file'],
],
],
@@ -707,14 +720,14 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
'bounds' => [
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['bounds'],
'exclude' => true,
'inputType' => 'text',
'inputType' => 'leaflet_geocode',
'save_callback' => [
],
'eval' => [
'maxlength' => 255,
'multiple' => true,
'size' => 2,
'tl_class' => 'long clr',
'tl_class' => 'clr',
'nullIfEmpty' => true,
],
'sql' => 'mediumblob NULL',
@@ -853,5 +866,37 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
],
'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',
],
],
];

View File

@@ -23,6 +23,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = [
],
'onload_callback' => [
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'loadLanguageFile'],
['netzmacht.contao_leaflet.listeners.dca.map', 'addIncompleteConfigurationWarning'],
],
'onsubmit_callback' => [
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'],

View File

@@ -23,7 +23,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_marker'] = [
],
],
'onload_callback' => [
['netzmacht.contao_leaflet.listeners.dca.marker', 'initialize'],
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'loadLanguageFile'],
],
'onsubmit_callback' => [
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'],

View File

@@ -347,13 +347,13 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = [
'bounds' => [
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['bounds'],
'exclude' => true,
'inputType' => 'text',
'inputType' => 'leaflet_geocode',
'save_callback' => [],
'eval' => [
'maxlength' => 255,
'multiple' => true,
'size' => 2,
'tl_class' => 'long clr',
'tl_class' => 'clr',
'nullIfEmpty' => true,
],
'sql' => 'mediumblob NULL',

View File

@@ -49,7 +49,7 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_mapId'] = [
$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'],
'options' => $GLOBALS['TL_CSS_UNITS'],
'search' => false,
'exclude' => true,
'eval' => ['rgxp' => 'digit', 'tl_class' => 'clr w50'],
@@ -60,7 +60,7 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_width'] = [
$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'],
'options' => $GLOBALS['TL_CSS_UNITS'],
'search' => false,
'exclude' => true,
'eval' => ['rgxp' => 'digit', 'tl_class' => 'w50'],

View File

@@ -8,12 +8,13 @@
*
* @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 <a href="http://leafletjs.com/reference.html#control-attribution" target="_blank">Leaflet-Dokumentation</a>.';
$GLOBALS['TL_LANG']['leaflet_control']['fullscreen']['0'] = 'Fullscreen-Kontrollelement';

View File

@@ -8,7 +8,7 @@
*
* @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';

View File

@@ -8,7 +8,7 @@
*
* @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 <em>fa-envelope</em>';
$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. <em>fa</em>';
$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';

View File

@@ -8,11 +8,12 @@
*
* @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 <em>Padding</em>-Option eingestellt. Wenn 4 Werte angegeben werden, ist <em>paddingTopLeft</em> und <em>paddingBottomRight</em> 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';

View File

@@ -8,7 +8,7 @@
*
* @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.';

View File

@@ -8,17 +8,19 @@
*
* @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 <a href="https://developer.mozilla.org/en/SVG/Attribute/stroke-dasharray" target="_blank">Linienart</a> 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 <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap" target="_blank">Enden der Linie</a> 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 <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin" target="_blank">Form der Ecken</a> 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';

View File

@@ -0,0 +1,15 @@
<?php
/**
* Leaflet maps for Contao CMS.
*
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014-2018 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);
$GLOBALS['TL_LANG']['ERR']['leafletMissingZoomLevel'] = 'No zoom level defined. Only leave it empty on purpose (Zoom level might by initialized by bounds adjustments). Otherwise no map will be shown.';

View File

@@ -39,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 <a href="http://leafletjs.com/reference.html#polyline" target="_blank">Leaflet documentation</a>.';

View File

@@ -145,12 +145,31 @@ $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']['tile_provider_key'][0] = 'API key / Access token';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider_key'][1] = 'Please define the API key / access token which is required for this tile provider.';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider_code'][0] = 'App code';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider_code'][1] = 'Please define the required app code for this tile provider.';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['layer'][0] = 'Layer group';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['layer'][1] = 'Basic layer group. <br> See <a href="http://leafletjs.com/reference.html#layergroup" target="_blank">http://leafletjs.com/reference.html#layergroup</a>';
$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. <br>See <a href="http://leafletjs.com/reference.html#featuregroup" target="_blank">http://leafletjs.com/reference.html#featuregroup</a>';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['gpx'][0] = 'GPX';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['gpx'][1] = 'GPS Exchange format. <a href="https://github.com/mapbox/togeojson#gpx-feature-support" target="_blank">Read the documentation</a> 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. <a href="https://github.com/mapbox/togeojson#kml-feature-support" target="_blank">Read the documentation</a> 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 <a href="https://github.com/mapbox/togeojson#kml-feature-support" target="_blank">Read the documentation</a> 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. <a href="https://github.com/topojson/topojson#api-reference" target="_blank">Read the documentation</a> 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. <a href="https://github.com/mapbox/wellknown" target="_blank">Read the documentation</a> 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';

View File

@@ -1,7 +0,0 @@
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>

View File

@@ -1,125 +0,0 @@
<div class="netzmacht-leaflet-credits">
<div class="header">
<h1 class="sub_headline"><?php echo $this->headline; ?> <small><?php echo $this->version; ?></small></h1>
</div>
<div class="tl_box block row">
<h2>About</h2>
<div class="left">
<p>
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.
</p>
<p>
This software ships with an visible attribution to <em>netzmacht creative</em> in the map attribution control.
If you want to remove this attribution, you have to purchase a commercial license.
For more details visit the <a href="https://netzmacht.de/contao-leaflet" target="_blank">project website</a>.
</p>
</div>
<div class="right">
<a href="http://www.netzmacht.de" <?php echo LINK_NEW_WINDOW; ?>>
<img src="bundles/netzmachtcontaoleaflet/img/logo.png"></a>
<p>
<strong class="company">netzmacht </strong><br>
David Molineus<br>
</p>
<p>
DAB Bank München<br>
IBAN: DE52701204008354237003<br>
BIC: DABBDEMMXXX
</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="YWMA95YS3FT6U">
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
</form>
</div>
</div>
<div class="tl_box">
<h2>Support Contao Leaflet</h2>
<div class="row">
<div class="col">
<h3>Report issues</h3>
<p>If you found a bug, got some troubles or have a feature request - feel free to open an issue.</p>
<p><a href="http://github.com/netzmacht/contao-leaflet-maps/issues" class="btn" target="_blank">Issue tracker</a> </p>
</div>
<div class="col">
<h3>Contribute</h3>
<p>There are many ways you can con&shy;tribute. Translations,
docu&shy;mentation or code contributions are welcome.
</p>
<p><a href="https://netzmacht/contao-leaflet/contribute.html" class="btn" target="_blank">Contribute</a> </p>
</div>
<div class="col">
<h3>Fund a feature</h3>
<p>Contao Leaflet is not feature complete. Have a look at the list of planned feature and support them.</p>
<p><a href="https://netzmacht/contao-leaflet/planned-features.html" class="btn" target="_blank">Planned features</a> </p>
</div>
</div>
<div class="row">
<div class="col">
<h3>Individual development</h3>
<p>If you have special requirements you can hire me for an individual development.</p>
<p><a href="https://netzmacht/contao-leaflet/contact.html" class="btn" target="_blank">Contact</a> </p>
</div>
<div class="col">
<h3>Commercial license</h3>
<p>If you want to remove the attribution in the attribution control, you can purchase a commercial license.</p>
<p><a href="https://netzmacht/contao-leaflet/commercial-license.html" class="btn" target="_blank">Purchase license</a> </p>
</div>
</div>
</div>
<div class="tl_box">
<h2>Credits</h2>
<table class="tl_listing">
<tr>
<th>Name</th>
<th>Version</th>
<th>License</th>
<th>Homepage</th>
</tr>
<?php if ($this->libraries): ?>
<tr><th colspan="4" class="subtitle">Libraries</th> </tr>
<?php endif; ?>
<?php foreach ($this->libraries as $library): ?>
<tr>
<td><?php echo $library['name']; ?></td>
<td><?php echo $library['version']; ?></td>
<td><?php echo $library['license']; ?></td>
<td><?php echo $library['homepage']; ?></td>
</tr>
<?php endforeach; ?>
<tr>
<th class="subtitle" colspan="4">Graphics</th>
</tr>
<tr>
<td>Farm Fresh-Web Icons</td>
<td>3.9.2</td>
<td><a href="http://creativecommons.org/licenses/by/3.0/us/" target="_blank">CC BY 3.0 US</a></td>
<td><a href="http://www.fatcow.com/free-icons" target="_blank">fatcow.com/free-icons</a></td>
</tr>
<tr>
<td>Web Blog Icons by SEM Labs</td>
<td>3.9.2</td>
<td><a href="http://creativecommons.org/licenses/by/4.0/" target="_blank">CC BY 4.0</a></td>
<td><a href="http://semlabs.co.uk/" target="_blank">semlabs.co.uk</a></td>
</tr>
<?php if ($this->dependencies): ?>
<tr><th colspan="4" class="subtitle">Dependencies</th> </tr>
<?php endif; ?>
<?php foreach ($this->dependencies as $dep): ?>
<tr>
<td><?php echo $dep['name']; ?></td>
<td><?php echo $dep['version']; ?></td>
<td><?php echo $dep['license']; ?></td>
<td><?php echo $dep['homepage']; ?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>

View File

@@ -1,8 +1,8 @@
<?php $GLOBALS['TL_CSS'][] = 'assets/leaflet/libs/leaflet/leaflet.css'; ?>
<?php $GLOBALS['TL_CSS'][] = 'assets/leaflet/libs/control-geocoder/Control.Geocoder.css'; ?>
<?php $GLOBALS['TL_CSS'][] = 'assets/leaflet/libs/leaflet/leaflet.min.css'; ?>
<?php $GLOBALS['TL_CSS'][] = 'assets/leaflet/libs/control-geocoder/Control.Geocoder.min.css'; ?>
<?php $GLOBALS['TL_JAVASCRIPT'][] = 'assets/leaflet/libs/leaflet/leaflet.js'; ?>
<?php $GLOBALS['TL_JAVASCRIPT'][] = 'assets/leaflet/libs/control-geocoder/Control.Geocoder.js'; ?>
<?php $GLOBALS['TL_JAVASCRIPT'][] = 'assets/leaflet/libs/control-geocoder/Control.Geocoder.min.js'; ?>
<div id="map_<?php echo $this->field; ?>" style="margin-top: 5px; width: calc(100% - 28px); height: 300px"></div>
<script>
@@ -17,6 +17,12 @@
placeholder: '<?php echo $GLOBALS['TL_LANG']['leaflet']['searchPosition']; ?>'
}).addTo(map);
document.querySelector('.leaflet-control-geocoder input').addEventListener('keydown', function (event) {
if (event.keyCode === 13) {
event.preventDefault();
}
});
geocoder.on('markgeocode', function (event) {
var container = document.createElement('div');
var link = document.createElement('button');
@@ -28,7 +34,8 @@
e.stop();
element.set('value', result.center.lat + ',' + result.center.lng);
});
this._geocodeMarker.closePopup();
}.bind(this));
container.appendHTML(result.html || result.name);
container.appendChild(link);

View File

@@ -1,6 +1,7 @@
<div id="<?php echo $mapId; ?>" style="<?php echo $style; ?>"></div>
<div id="<?= $this->mapId ?>" style="<?= $this->style ?>"></div>
<script>
L.contao.addMap('<?php echo $mapId; ?>', function() {
<?php echo $javascript; ?>
L.contao.addMap('<?= $this->mapId ?>', function () {
<?= $this->javascript ?>
return {map: map, layers: layers, controls: controls, icons: icons};
}());</script>
}());
</script>

View File

@@ -1,5 +1,5 @@
L.contao.addMap('<?php echo $mapId; ?>', function() {
<?php echo $javascript; ?>
L.contao.addMap('<?= $this->mapId ?>', function() {
<?= $this->javascript ?>
return { map: map, layers: layers, controls: controls, icons: icons };
}());

View File

@@ -3,7 +3,6 @@
padding: 15px;
}
.netzmacht-leaflet-credits a {
color: #669A00;
}

View File

@@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="13"
height="12"
viewBox="0 0 13 12"
class="feather feather-map"
version="1.1"
id="svg8"
sodipodi:docname="leaflet.svg"
style="fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round"
inkscape:version="0.92.2 5c3e80d, 2017-08-06">
<metadata
id="metadata14">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs12" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1127"
id="namedview10"
showgrid="false"
inkscape:zoom="9.8333333"
inkscape:cx="12"
inkscape:cy="12"
inkscape:window-x="1680"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg8" />
<polygon
points="23,2 16,6 8,2 1,6 1,22 8,18 16,22 23,18 "
id="polygon2"
style="stroke:#91979c;stroke-opacity:1"
transform="matrix(0.54166667,0,0,0.54166667,0,-0.46604866)" />
<line
x1="4.3333335"
y1="0.61728501"
x2="4.3333335"
y2="9.2839518"
id="line4"
style="stroke:#91979c;stroke-width:1.08333337;stroke-opacity:1" />
<line
x1="8.6666689"
y1="2.7839513"
x2="8.6666689"
y2="11.450619"
id="line6"
style="fill:#91979c;fill-opacity:0;stroke:#91979c;stroke-width:1.08333337;stroke-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,132 @@
{% extends "@ContaoCore/Backend/be_page.html.twig" %}
{% block headline %}{{ "MOD.leaflet_about.1"|trans({}, 'contao_modules') }}{% endblock %}
{% block error %}{% endblock %}
{% block main %}
<div class="netzmacht-leaflet-credits">
<div class="header">
<h1 class="sub_headline">{{ headline }}
<small>{{ version }}</small>
</h1>
</div>
<div class="tl_box block row">
<h2>About</h2>
<p>
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.
</p>
<p>
This software ships with an visible attribution to <em>netzmacht creative</em> in the map attribution
control.
If you want to remove this attribution, you have to purchase a commercial license.
For more details visit the <a href="https://netzmacht.de/contao-leaflet" target="_blank">project
website</a>.
</p>
</div>
<div class="tl_box">
<h2>Support Contao Leaflet</h2>
<div class="row">
<div class="col">
<h3>Report issues</h3>
<p>If you found a bug, got some troubles or have a feature request - feel free to open an issue.</p>
<p><a href="https://github.com/netzmacht/contao-leaflet-maps/issues" class="btn" target="_blank">Issue
tracker</a></p>
</div>
<div class="col">
<h3>Contribute</h3>
<p>There are many ways you can con&shy;tribute. Translations,
docu&shy;mentation or code contributions are welcome.
</p>
<p><a href="https://netzmacht.de/contao-leaflet/contribute.html" class="btn" target="_blank">Contribute</a>
</p>
</div>
<div class="col">
<h3>Fund a feature</h3>
<p>Contao Leaflet is not feature complete. Have a look at the list of planned feature and support
them.</p>
<p><a href="https://github.com/netzmacht/contao-leaflet-maps/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement" class="btn" target="_blank">Planned
features</a></p>
</div>
</div>
<div class="row">
<div class="col">
<h3>Individual development</h3>
<p>If you have special requirements you can hire me for an individual development.</p>
<p><a href="https://netzmacht.de/contao-leaflet/contact.html" class="btn" target="_blank">Contact</a></p>
</div>
<div class="col">
<h3>Commercial license</h3>
<p>If you want to remove the attribution in the attribution control, you can purchase a commercial
license.</p>
<p><a href="https://netzmacht.de/contao-leaflet/commercial-license.html" class="btn" target="_blank">Purchase
license</a></p>
</div>
</div>
</div>
<div class="tl_box">
<h2>Credits</h2>
<table class="tl_listing">
<tr>
<th>Name</th>
<th>Version</th>
<th>License</th>
<th>Homepage</th>
</tr>
{% if libraries %}
<tr>
<th colspan="4" class="subtitle">Libraries</th>
</tr>
{% endif %}
{% for library in libraries %}
<tr>
<td>{{ library.name }}</td>
<td>{{ library.version }}</td>
<td>{{ library.license|raw }}</td>
<td>{{ library.homepage|raw }}</td>
</tr>
{% endfor %}
<tr>
<td>url-polyfill</td>
<td>v1.1.0</td>
<td><a href="https://github.com/lifaon74/url-polyfill/blob/master/LICENSE" target="_blank">MIT</a></td>
<td><a href="https://github.com/lifaon74/url-polyfill" target="_blank">github.com/lifaon74/url-polyfill</a></td>
</tr>
<tr>
<th class="subtitle" colspan="4">Graphics</th>
</tr>
<tr>
<td>Farm Fresh-Web Icons</td>
<td>3.9.2</td>
<td><a href="http://creativecommons.org/licenses/by/3.0/us/" target="_blank">CC BY 3.0 US</a></td>
<td><a href="http://www.fatcow.com/free-icons" target="_blank">fatcow.com/free-icons</a></td>
</tr>
<tr>
<td>Web Blog Icons by SEM Labs</td>
<td>3.9.2</td>
<td><a href="http://creativecommons.org/licenses/by/4.0/" target="_blank">CC BY 4.0</a></td>
<td><a href="http://semlabs.co.uk/" target="_blank">semlabs.co.uk</a></td>
</tr>
{% if dependencies %}
<tr>
<th colspan="4" class="subtitle">Dependencies</th>
</tr>
{% endif %}
{% for dep in dependencies %}
<tr>
<td>{{ dep.name }}</td>
<td>{{ dep.version }}</td>
<td>{{ dep.license|raw }}</td>
<td>{{ dep.homepage|raw }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endblock %}

View File

@@ -44,7 +44,7 @@ class ContaoAssets implements Assets
private $cache = [
'stylesheets' => [],
'javascripts' => [],
'map' => []
'map' => [],
];
/**

View File

@@ -10,14 +10,13 @@
* @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;
@@ -34,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],
];
}
/**
@@ -90,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 = 'loadUrl';
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;
$method = 'load';
}
if ($value->getCustomLayer()) {
@@ -112,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),

View File

@@ -12,7 +12,8 @@
namespace Netzmacht\Contao\Leaflet\Event;
use Netzmacht\Contao\Leaflet\Request\Request;
use Contao\Model;
use Netzmacht\Contao\Leaflet\Mapper\Request;
use Netzmacht\LeafletPHP\Definition;
use Symfony\Component\EventDispatcher\Event;
@@ -35,7 +36,7 @@ class BuildDefinitionEvent extends Event
/**
* The model.
*
* @var \Model
* @var Model
*/
private $model;
@@ -50,10 +51,10 @@ class BuildDefinitionEvent extends Event
* Construct.
*
* @param Definition $definition The leaflet definition.
* @param \Model $model The definition model.
* @param Model $model The definition model.
* @param Request|null $request Building request.
*/
public function __construct(Definition $definition, \Model $model, Request $request = null)
public function __construct(Definition $definition, Model $model, Request $request = null)
{
$this->definition = $definition;
$this->model = $model;
@@ -73,7 +74,7 @@ class BuildDefinitionEvent extends Event
/**
* Get the model.
*
* @return \Model
* @return Model
*/
public function getModel()
{

View File

@@ -68,7 +68,7 @@ class BboxFilter implements Filter
*/
public function getValues()
{
return array('bounds' => $this->bounds);
return ['bounds' => $this->bounds];
}
/**

View File

@@ -88,9 +88,29 @@ class DistanceFilter implements Filter
*/
public function getValues()
{
return array(
return [
'radius' => $this->radius,
'center' => $this->center
);
'center' => $this->center,
];
}
/**
* Get the center coordinate.
*
* @return LatLng
*/
public function getCenter(): LatLng
{
return $this->center;
}
/**
* Get the distance radius.
*
* @return int
*/
public function getRadius(): int
{
return $this->radius;
}
}

View File

@@ -51,7 +51,7 @@ final class FilterFactory
public function create(string $filter, string $values): Filter
{
if (isset($this->filters[$filter])) {
return call_user_func([$filter, 'fromRequest'], $values);
return call_user_func([$this->filters[$filter], 'fromRequest'], $values);
}
throw new \RuntimeException(sprintf('Creating filter failed. Unsupported filter "%s"', $filter));

View File

@@ -14,14 +14,15 @@ declare(strict_types=1);
namespace Netzmacht\Contao\Leaflet\Frontend;
use Contao\Config;
use Contao\Database\Result;
use Contao\Input;
use Contao\Model;
use Contao\Model\Collection;
use Contao\StringUtil;
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;
@@ -42,16 +43,16 @@ abstract class AbstractMapHybrid extends AbstractHybrid
/**
* The user input.
*
* @var \Input
* @var Input
*/
private $input;
/**
* The Contao config.
* Repository manager.
*
* @var \Config
* @var RepositoryManager
*/
private $config;
private $repositoryManager;
/**
* HybridTrait constructor.
@@ -60,8 +61,8 @@ abstract class AbstractMapHybrid extends AbstractHybrid
* @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 Config $config Config.
* @param string $column Column in which the element appears.
*/
public function __construct(
@@ -69,15 +70,15 @@ abstract class AbstractMapHybrid extends AbstractHybrid
TemplateEngine $templateEngine,
Translator $translator,
MapProvider $mapProvider,
RepositoryManager $repositoryManager,
$input,
$config,
$column = null
) {
parent::__construct($model, $templateEngine, $translator, $column);
$this->mapProvider = $mapProvider;
$this->input = $input;
$this->config = $config;
$this->repositoryManager = $repositoryManager;
}
/**
@@ -90,7 +91,8 @@ abstract class AbstractMapHybrid extends AbstractHybrid
$this->mapProvider->handleAjaxRequest($this->getIdentifier());
if (TL_MODE === 'BE') {
$model = MapModel::findByPk($this->get('leaflet_map'));
$repository = $this->repositoryManager->getRepository(MapModel::class);
$model = $repository->find((int) $this->get('leaflet_map'));
$parameters = [
'title' => $this->get('headline'),
];
@@ -117,6 +119,8 @@ abstract class AbstractMapHybrid extends AbstractHybrid
*/
protected function prepareTemplateData(array $data): array
{
$data = parent::prepareTemplateData($data);
try {
$template = $this->get('leaflet_template') ?: 'leaflet_map_js';
$mapId = $this->getIdentifier();
@@ -126,8 +130,8 @@ abstract class AbstractMapHybrid extends AbstractHybrid
$data['mapId'] = $mapId;
$style = '';
$height = deserialize($this->get('leaflet_height'), true);
$width = deserialize($this->get('leaflet_width'), true);
$height = StringUtil::deserialize($this->get('leaflet_height'), true);
$width = StringUtil::deserialize($this->get('leaflet_width'), true);
if (!empty($width['value'])) {
$style .= 'width:' . $width['value'] . $width['unit'] . ';';

View File

@@ -0,0 +1,103 @@
<?php
/**
* Leaflet maps for Contao CMS.
*
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014-2018 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\Action;
use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\Filter\FilterFactory;
use Netzmacht\Contao\Leaflet\MapProvider;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
/**
* Request action which handles request for layer data
*/
final class LayerDataAction
{
/**
* Map provider.
*
* @var MapProvider
*/
private $mapProvider;
/**
* Filter factory.
*
* @var FilterFactory
*/
private $filterFactory;
/**
* LayerDataAction constructor.
*
* @param MapProvider $mapProvider Map provider.
* @param FilterFactory $filterFactory Filter factory.
*/
public function __construct(MapProvider $mapProvider, FilterFactory $filterFactory)
{
$this->mapProvider = $mapProvider;
$this->filterFactory = $filterFactory;
}
/**
* Handle the request.
*
* @param int $layerId The layer id.
* @param string $_format The requested output format.
* @param Request $request The request.
*
* @return Response
*
* @throws BadRequestHttpException When unsupported format is given.
*
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
public function __invoke(int $layerId, string $_format, Request $request): Response
{
$filter = $this->createFilter($request);
$data = $this->mapProvider->getFeatureCollection($layerId, $filter);
if ($_format === 'geojson') {
$response = new JsonResponse($data);
$response->setEncodingOptions(JSON_UNESCAPED_SLASHES);
return $response;
}
throw new BadRequestHttpException(sprintf('Unsupported format "%s"', $_format));
}
/**
* Create the filter if defined in the request.
*
* @param Request $request The request.
*
* @return Filter|null
*/
private function createFilter(Request $request): ?Filter
{
if (!$request->query->has('filter')) {
return null;
}
$filter = (string) $request->query->get('filter');
$values = (string) $request->query->get('values');
return $this->filterFactory->create($filter, $values);
}
}

View File

@@ -14,9 +14,15 @@ 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 Psr\Container\ContainerInterface as Container;
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
use Symfony\Component\Templating\EngineInterface as TemplateEngine;
use Symfony\Component\Translation\TranslatorInterface as Translator;
/**
* Class MapElementFactory
@@ -26,20 +32,61 @@ use Psr\Container\ContainerInterface as Container;
class MapElementFactory implements ComponentFactory
{
/**
* Dependency container.
* Template engine.
*
* @var Container
* @var TemplateEngine
*/
private $container;
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 Container $container Dependency container.
* @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(Container $container)
{
$this->container = $container;
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;
}
/**
@@ -57,11 +104,11 @@ class MapElementFactory implements ComponentFactory
{
return new MapElement(
$model,
$this->container->get('templating'),
$this->container->get('translator'),
$this->container->get('netzmacht.contao_leaflet.map.provider'),
$this->container->get('netzmacht.contao_toolkit.contao.input_adapter'),
$this->container->get('netzmacht.contao_toolkit.contao.config_adapter'),
$this->templating,
$this->translator,
$this->mapProvider,
$this->repositoryManager,
$this->input,
$column
);
}

View File

@@ -12,14 +12,18 @@
namespace Netzmacht\Contao\Leaflet\Frontend;
use const E_USER_DEPRECATED;
use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\Filter\FilterFactory;
use Netzmacht\Contao\Leaflet\MapProvider;
use function trigger_error;
/**
* The data controller handles ajax request for sub data.
*
* @package Netzmacht\Contao\Leaflet\Frontend
*
* @deprecated
*/
class DataController
{
@@ -28,13 +32,13 @@ class DataController
*
* @var array
*/
private $input = array(
private $input = [
'format' => 'geojson',
'type' => 'layer',
'id' => null,
'filter' => null,
'values' => null
);
'values' => null,
];
/**
* Debug mode.
@@ -60,6 +64,13 @@ class DataController
{
$this->debugMode = $debugMode;
$this->filterFactory = $filterFactory;
// @codingStandardsIgnoreStart
@trigger_error(
'Deprecated since 3.1.0 and will be removed in 4.0.0 - Use properly route instead.',
E_USER_DEPRECATED
);
// @codingStandardsIgnoreEnd
}
/**
@@ -140,9 +151,9 @@ class DataController
default:
$error = true;
return array($data, $error);
return [$data, $error];
}
return array($data, $error);
return [$data, $error];
}
}

View File

@@ -14,9 +14,15 @@ 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 Psr\Container\ContainerInterface as Container;
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
use Symfony\Component\Templating\EngineInterface as TemplateEngine;
use Symfony\Component\Translation\TranslatorInterface as Translator;
/**
* Class MapElementFactory
@@ -26,20 +32,61 @@ use Psr\Container\ContainerInterface as Container;
class MapModuleFactory implements ComponentFactory
{
/**
* Dependency container.
* Template engine.
*
* @var Container
* @var TemplateEngine
*/
private $container;
private $templating;
/**
* MapModuleFactory constructor.
* Translator.
*
* @param Container $container Dependency container.
* @var Translator
*/
public function __construct(Container $container)
{
$this->container = $container;
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;
}
/**
@@ -57,11 +104,11 @@ class MapModuleFactory implements ComponentFactory
{
return new MapModule(
$model,
$this->container->get('templating'),
$this->container->get('translator'),
$this->container->get('netzmacht.contao_leaflet.map.provider'),
$this->container->get('netzmacht.contao_toolkit.contao.input_adapter'),
$this->container->get('netzmacht.contao_toolkit.contao.config_adapter'),
$this->templating,
$this->translator,
$this->mapProvider,
$this->repositoryManager,
$this->input,
$column
);
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Leaflet maps for Contao CMS.
*
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014-2018 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 Netzmacht\Contao\PageContext\Exception\DeterminePageIdFailed;
use Netzmacht\Contao\PageContext\Request\PageIdDeterminator as PageContextPageIdDeterminator;
use Symfony\Component\HttpFoundation\Request;
/**
* Class ApiPageIdDeterminator
*/
final class PageIdDeterminator implements PageContextPageIdDeterminator
{
/**
* {@inheritDoc}
*/
public function match(Request $request): bool
{
return ($request->attributes->get('_leaflet_scope') === 'page' && $request->query->get('context') === 'page');
}
/**
* {@inheritDoc}
*
* @throws DeterminePageIdFailed When no context id is given.
*/
public function determinate(Request $request): int
{
if (!$request->query->has('contextId')) {
throw new DeterminePageIdFailed('Could not determine page id for from request.');
}
return $request->query->getInt('contextId');
}
}

View File

@@ -12,13 +12,17 @@
namespace Netzmacht\Contao\Leaflet\Frontend;
use Contao\Config;
use Contao\Frontend;
use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\Request\Request;
use Netzmacht\Contao\Leaflet\Mapper\Request;
/**
* Class RequestUrl creates the request url.
*
* @package Netzmacht\Contao\Leaflet\Request
*
* @deprecated
*/
class RequestUrl implements \JsonSerializable
{
@@ -57,12 +61,12 @@ class RequestUrl implements \JsonSerializable
*/
public static function create($dataId, $type = null, $format = null, Request $request = null)
{
$params = array(
$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;
@@ -72,7 +76,7 @@ class RequestUrl implements \JsonSerializable
$query .= '&amp;f=' . $filter->getName() . '&amp;v=' . $filter->toRequest();
}
$url = \Config::get('websitePath') . '/' . \Frontend::addToUrl($query, false);
$url = Config::get('websitePath') . '/' . Frontend::addToUrl($query, false);
return new static($url, $hash, $request);
}
@@ -87,6 +91,13 @@ class RequestUrl implements \JsonSerializable
{
$this->url = $url;
$this->hash = $hash;
// @codingStandardsIgnoreStart
@trigger_error(
'Deprecated since 3.1.0 and will be removed in 4.0.0. Use The router instead.',
E_USER_DEPRECATED
);
// @codingStandardsIgnoreEnd
}
/**

View File

@@ -73,6 +73,8 @@ class ValueFilter
*/
public function filter($value)
{
return $this->getReplacer()->replace($value);
$value = $this->getReplacer()->replace($value, false);
return $value;
}
}

View File

@@ -0,0 +1,107 @@
<?php
/**
* Leaflet maps for Contao CMS.
*
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014-2018 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\Backend;
use Contao\CoreBundle\Event\MenuEvent;
use Netzmacht\Contao\Toolkit\View\Assets\AssetsManager;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\RouterInterface as Router;
use Symfony\Component\Translation\TranslatorInterface as Translator;
/**
* Class BackendMenuListener adds backend entries to the navigation.
*/
final class UserNavigationListener
{
/**
* Request stack.
*
* @var RequestStack
*/
private $requestStack;
/**
* Router.
*
* @var Router
*/
private $router;
/**
* Translator.
*
* @var Translator
*/
private $translator;
/**
* Assets manager.
*
* @var AssetsManager
*/
private $assets;
/**
* BackendUserNavigationListener constructor.
*
* @param RequestStack $requestStack Request stack.
* @param Router $router Router.
* @param Translator $translator Translator.
* @param AssetsManager $assets Assets manager.
*/
public function __construct(
RequestStack $requestStack,
Router $router,
Translator $translator,
AssetsManager $assets
) {
$this->requestStack = $requestStack;
$this->router = $router;
$this->translator = $translator;
$this->assets = $assets;
}
/**
* Handle the event.
*
* @param array $modules Backend navigation modules.
*
* @return array
*/
public function __invoke(array $modules): array
{
if (!isset($modules['leaflet'])) {
return $modules;
}
$request = $this->requestStack->getCurrentRequest();
$isActive = $request && $request->attributes->get('_backend_module') === 'leaflet_about';
$modules['leaflet']['modules']['leaflet_about'] = [
'label' => $this->translator->trans('MOD.leaflet_about.0', [], 'contao_modules'),
'title' => $this->translator->trans('MOD.leaflet_about.1', [], 'contao_modules'),
'href' => $this->router->generate('leaflet_backend_about'),
'icon' => 'bundles/netzmachtcontaoleaflet/img/about.png',
'class' => 'navigation leaflet_about',
'isActive' => $isActive,
];
if ($isActive) {
$this->assets->addStylesheet('bundles/netzmachtcontaoleaflet/css/about.css');
}
return $modules;
}
}

View File

@@ -14,11 +14,12 @@ 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;
use Netzmacht\Contao\Leaflet\Model\ControlModel;
use Netzmacht\Contao\Leaflet\Model\LayerModel;
/**
* Class Control is the helper for the tl_leaflet_control dca.
@@ -48,19 +49,32 @@ class ControlDcaListener extends AbstractListener
*/
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, array $types)
{
public function __construct(
Manager $manager,
Connection $connection,
RepositoryManager $repositoryManager,
array $types
) {
parent::__construct($manager);
$this->connection = $connection;
$this->types = $types;
$this->repositoryManager = $repositoryManager;
}
/**
@@ -96,7 +110,8 @@ class ControlDcaListener extends AbstractListener
*/
public function getLayers()
{
$collection = LayerModel::findAll();
$repository = $this->repositoryManager->getRepository(LayerModel::class);
$collection = $repository->findAll();
return OptionsBuilder::fromCollection($collection, 'title')
->asTree()
@@ -110,7 +125,8 @@ class ControlDcaListener extends AbstractListener
*/
public function getZoomControls()
{
$collection = ControlModel::findBy('type', 'zoom', array('order' => 'title'));
$repository = $this->repositoryManager->getRepository(ControlModel::class);
$collection = $repository->findBy(['type=?'], ['zoom'], ['order' => 'title']);
return OptionsBuilder::fromCollection($collection, 'title')->getOptions();
}
@@ -166,7 +182,7 @@ class ControlDcaListener extends AbstractListener
'lid' => $layer['layer'],
'cid' => $dataContainer->id,
'mode' => $layer['mode'],
'sorting' => $sorting
'sorting' => $sorting,
];
$this->connection->insert('tl_leaflet_control_layer', $data);
@@ -177,10 +193,10 @@ class ControlDcaListener extends AbstractListener
[
'tstamp' => time(),
'sorting' => $sorting,
'mode' => $layer['mode']
'mode' => $layer['mode'],
],
[
'id' => $values[$layer['layer']]['id']
'id' => $values[$layer['layer']]['id'],
]
);

View File

@@ -14,8 +14,12 @@ declare(strict_types=1);
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
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;
/**
@@ -32,14 +36,23 @@ final class FrontendIntegrationListener
*/
private $translator;
/**
* Repository manager.
*
* @var RepositoryManager
*/
private $repositoryManager;
/**
* FrontendIntegration constructor.
*
* @param RepositoryManager $repositoryManager Repository manager.
* @param Translator $translator Translator.
*/
public function __construct(Translator $translator)
public function __construct(RepositoryManager $repositoryManager, Translator $translator)
{
$this->translator = $translator;
$this->repositoryManager = $repositoryManager;
}
/**
@@ -49,7 +62,8 @@ final class FrontendIntegrationListener
*/
public function getMaps(): array
{
$collection = MapModel::findAll();
$repository = $this->repositoryManager->getRepository(MapModel::class);
$collection = $repository->findAll(['order' => 'title']);
return OptionsBuilder::fromCollection($collection, 'title')->getOptions();
}
@@ -74,11 +88,13 @@ final class FrontendIntegrationListener
'<a href="%s%s&amp;popup=1&amp;rt=%s" %s>%s</a>',
'contao/main.php?do=leaflet_map&amp;table=tl_leaflet_map&amp;act=edit&amp;id=',
$dataContainer->value,
\RequestToken::get(),
RequestToken::get(),
sprintf(
$pattern,
specialchars($this->translator->trans('editalias.1', [$dataContainer->value], 'contao_tl_content')),
specialchars(
StringUtil::specialchars(
$this->translator->trans('editalias.1', [$dataContainer->value], 'contao_tl_content')
),
StringUtil::specialchars(
str_replace(
"'",
"\\'",
@@ -86,7 +102,7 @@ final class FrontendIntegrationListener
)
)
),
\Image::getHtml(
Image::getHtml(
'alias.gif',
$this->translator->trans('editalias.0', [$dataContainer->value], 'contao_tl_content'),
'style="vertical-align:top"'

View File

@@ -12,17 +12,19 @@
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
use Contao\Controller;
use Contao\Backend;
use Contao\CoreBundle\Framework\Adapter;
use Contao\DataContainer;
use Contao\Image;
use Contao\RequestToken;
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;
/**
@@ -53,6 +55,13 @@ class LayerDcaListener extends AbstractListener
*/
private $connection;
/**
* Repository manager.
*
* @var RepositoryManager
*/
private $repositoryManager;
/**
* Tile providers configuration.
*
@@ -81,36 +90,59 @@ class LayerDcaListener extends AbstractListener
*/
private $labelRenderer;
/**
* File formats.
*
* @var array
*/
private $fileFormats;
/**
* Backend adapter.
*
* @var Backend|Adapter
*/
private $backendAdapter;
/**
* Construct.
*
* @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,
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;
}
/**
@@ -149,7 +181,7 @@ class LayerDcaListener extends AbstractListener
return $this->tileProviders[$dataContainer->activeRecord->tile_provider]['variants'];
}
return array();
return [];
}
/**
@@ -205,7 +237,8 @@ class LayerDcaListener extends AbstractListener
)
);
$collection = LayerModel::findMultipleByTypes($types);
$repository = $this->repositoryManager->getRepository(LayerModel::class);
$collection = $repository->findMultipleByTypes($types);
$builder = OptionsBuilder::fromCollection(
$collection,
'id',
@@ -232,43 +265,42 @@ class LayerDcaListener extends AbstractListener
*/
public function getPasteButtons($dataContainer, $row, $table, $whatever, $children)
{
$pasteAfterUrl = \Controller::addToUrl(
$pasteAfterUrl = $this->backendAdapter->addToUrl(
'act=' . $children['mode'] . '&amp;mode=1&amp;pid=' . $row['id']
. (!is_array($children['id']) ? '&amp;id=' . $children['id'] : '')
. '&amp;rt=' . RequestToken::get()
);
$buffer = sprintf(
'<a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a> ',
$pasteAfterUrl,
specialchars($this->translator->trans('pasteafter.1', [$row['id']], 'contao_' . $table)),
\Image::getHtml(
StringUtil::specialchars($this->translator->trans('pasteafter.1', [$row['id']], 'contao_' . $table)),
Image::getHtml(
'pasteafter.gif',
$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&amp;mode=2&amp;pid=%s%s',
$children['mode'],
$row['id'],
!is_array($children['id']) ? '&amp;id=' . $children['id'] : ''
) . '&amp;rt=' . RequestToken::get()
)
);
$buffer .= sprintf(
'<a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a> ',
$pasteIntoUrl,
specialchars($this->translator->trans('pasteinto.1', [$row['id']], 'contao_' . $table)),
\Image::getHtml(
StringUtil::specialchars($this->translator->trans('pasteinto.1', [$row['id']], 'contao_' . $table)),
Image::getHtml(
'pasteinto.gif',
$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;
@@ -337,7 +369,7 @@ class LayerDcaListener extends AbstractListener
$statement->bindValue('lid', $dataContainer->id);
$statement->execute();
$undo['data'] = deserialize($undo['data'], true);
$undo['data'] = StringUtil::deserialize($undo['data'], true);
while ($row = $statement->fetch()) {
$undo['data']['tl_leaflet_map_layer'][] = $row;
@@ -365,7 +397,7 @@ class LayerDcaListener extends AbstractListener
*/
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) {
@@ -389,7 +421,8 @@ class LayerDcaListener extends AbstractListener
*/
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()
@@ -413,7 +446,8 @@ class LayerDcaListener extends AbstractListener
*/
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) {
@@ -424,6 +458,49 @@ class LayerDcaListener extends AbstractListener
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.
*
@@ -440,9 +517,9 @@ class LayerDcaListener extends AbstractListener
{
return sprintf(
'<a href="%s" title="%s">%s</a> ',
\Backend::addToUrl($href . '&amp;id=' . $row['id']),
Backend::addToUrl($href . '&amp;id=' . $row['id']),
$title,
\Image::getHtml($icon, $label, $attributes)
Image::getHtml($icon, $label, $attributes)
);
}
}

View File

@@ -12,11 +12,14 @@
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
use Contao\Controller;
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.
@@ -39,15 +42,47 @@ class LeafletDcaListener
*/
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(Filesystem $fileSystem, string $cacheDir)
{
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;
}
@@ -58,7 +93,7 @@ class LeafletDcaListener
*/
public function loadLanguageFile()
{
Controller::loadLanguageFile('leaflet');
$this->systemAdapter->loadLanguageFile('leaflet');
}
/**
@@ -80,17 +115,17 @@ class LeafletDcaListener
*/
public function getGeocoder($dataContainer)
{
$template = new \BackendTemplate('be_leaflet_geocode');
$template->field = 'ctrl_' . $dataContainer->field;
$data['field'] = 'ctrl_' . $dataContainer->field;
try {
$latLng = LatLng::fromString($dataContainer->value);
$template->marker = json_encode($latLng);
$data['marker'] = json_encode($latLng);
} catch (\Exception $e) {
// LatLng throws an exception of value could not be created. Just let the value empty when.
$data['marker'] = null;
}
return $template->parse();
return $this->templateEngine->render('toolkit:be:be_leaflet_geocode.html5', $data);
}
/**
@@ -100,8 +135,9 @@ class LeafletDcaListener
*/
public function getLayers()
{
$options = array();
$collection = LayerModel::findBy('pid', '0', array('order' => 'title'));
$options = [];
$repository = $this->repositoryManager->getRepository(LayerModel::class);
$collection = $repository->findBy(['pid=?'], ['0'], ['order' => 'title']);
if ($collection) {
foreach ($collection as $model) {

View File

@@ -15,13 +15,20 @@ declare(strict_types=1);
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
use Contao\DataContainer;
use Contao\Input;
use Contao\StringUtil;
use Doctrine\DBAL\Connection;
use Netzmacht\Contao\Leaflet\Model\LayerModel;
use Netzmacht\Contao\Leaflet\Model\MapModel;
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;
use function strlen;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Translation\TranslatorInterface as Translator;
use function var_dump;
/**
* Class Map is the helper class for the tl_leaflet_map dca.
@@ -44,17 +51,77 @@ class MapDcaListener extends AbstractListener
*/
private $connection;
/**
* Repository manager.
*
* @var RepositoryManager
*/
private $repositoryManager;
/**
* Translator.
*
* @var Translator
*/
private $translator;
/**
* Session.
*
* @var Session
*/
private $session;
/**
* Construct.
*
* @param Manager $manager Data container manager.
* @param Connection $connection Database connection.
* @param RepositoryManager $repositoryManager Repository manager.
* @param Translator $translator Translator.
* @param Session $session Session.
*/
public function __construct(Manager $manager, Connection $connection)
{
public function __construct(
Manager $manager,
Connection $connection,
RepositoryManager $repositoryManager,
Translator $translator,
Session $session
) {
parent::__construct($manager);
$this->connection = $connection;
$this->repositoryManager = $repositoryManager;
$this->translator = $translator;
$this->session = $session;
}
/**
* Add warnings for incomplete configurations.
*
* @param DataContainer $dataContainer The data container driver.
*
* @return void
*/
public function addIncompleteConfigurationWarning($dataContainer): void
{
if (Input::get('act') !== 'edit') {
return;
}
$repository = $this->repositoryManager->getRepository(MapModel::class);
$map = $repository->find((int) $dataContainer->id);
if (!$map) {
return;
}
if ($map->zoom === null || $map->zoom === '') {
$this->session->getFlashBag()->add(
'contao.BE.info',
$this->translator->trans('ERR.leafletMissingZoomLevel', [], 'contao_default')
);
}
}
/**
@@ -90,7 +157,7 @@ class MapDcaListener extends AbstractListener
public function saveLayerRelations($layerId, $dataContainer)
{
$new = array_filter(StringUtil::deserialize($layerId, true));
$values = array();
$values = [];
$statement = $this->connection->prepare('SELECT * FROM tl_leaflet_map_layer WHERE mid=:mid order BY sorting');
$statement->bindValue('mid', $dataContainer->id);
@@ -108,7 +175,7 @@ class MapDcaListener extends AbstractListener
'tstamp' => time(),
'lid' => $layerId,
'mid' => $dataContainer->id,
'sorting' => $sorting
'sorting' => $sorting,
];
$this->connection->insert('tl_leaflet_map_layer', $data);
@@ -150,13 +217,12 @@ class MapDcaListener extends AbstractListener
/**
* Get all layers except of the current layer.
*
* @param DataContainer $dataContainer The dataContainer driver.
*
* @return array
*/
public function getLayers($dataContainer)
public function getLayers()
{
$collection = LayerModel::findBy('id !', $dataContainer->id);
$repository = $this->repositoryManager->getRepository(LayerModel::class);
$collection = $repository->findAll(['order' => 'title']);
return OptionsBuilder::fromCollection($collection, 'title')
->asTree()

View File

@@ -13,10 +13,12 @@
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
use Contao\Controller;
use Contao\StringUtil;
use Doctrine\DBAL\Connection;
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
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.
@@ -32,24 +34,23 @@ class MarkerDcaListener
*/
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)
public function __construct(Connection $connection, RepositoryManager $repositoryManager)
{
$this->connection = $connection;
}
/**
* Initialize the language files.
*
* @return void
*/
public function initialize()
{
Controller::loadLanguageFile('leaflet');
$this->repositoryManager = $repositoryManager;
}
/**
@@ -71,7 +72,8 @@ class MarkerDcaListener
*/
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) {
@@ -89,7 +91,8 @@ class MarkerDcaListener
*/
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();
@@ -105,13 +108,13 @@ class MarkerDcaListener
*/
public function saveCoordinates($value, $dataContainer)
{
$combined = array(
$combined = [
'latitude' => null,
'longitude' => null,
'altitude' => null
);
'altitude' => null,
];
$values = trimsplit(',', $value);
$values = StringUtil::trimsplit(',', $value);
$keys = array_keys($combined);
$count = count($values);

View File

@@ -13,6 +13,7 @@
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
use Contao\DataContainer;
use Contao\StringUtil;
use Netzmacht\Contao\Toolkit\Dca\Manager;
use Netzmacht\LeafletPHP\Value\LatLng;
use Symfony\Component\Translation\TranslatorInterface as Translator;
@@ -116,7 +117,7 @@ class Validator
*/
public function validateMultipleCoordinateSets($values, $dataContainer)
{
$sets = deserialize($values, true);
$sets = StringUtil::deserialize($values, true);
foreach ($sets as $lines) {
$this->validateMultipleCoordinates($lines, $dataContainer);
}

View File

@@ -12,12 +12,12 @@
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
use Netzmacht\Contao\Leaflet\Model\IconModel;
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;
use Netzmacht\Contao\Leaflet\Model\StyleModel;
/**
* Helper class for the tl_leaflet_vector dca.
@@ -40,17 +40,26 @@ class VectorDcaListener extends AbstractListener
*/
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, array $vectors)
public function __construct(Manager $dcaManager, RepositoryManager $repositoryManager, array $vectors)
{
parent::__construct($dcaManager);
$this->vectors = $vectors;
$this->repositoryManager = $repositoryManager;
}
/**
@@ -86,29 +95,12 @@ class VectorDcaListener extends AbstractListener
*/
public function getStyles()
{
$collection = StyleModel::findAll(array('order' => 'title'));
$repository = $this->repositoryManager->getRepository(StyleModel::class);
$collection = $repository->findAll(['order' => 'title']);
return OptionsBuilder::fromCollection($collection, 'title')->getOptions();
}
/**
* Get all icons.
*
* @return array
*/
public function getIcons()
{
$collection = IconModel::findAll(array('order' => 'title'));
$builder = OptionsBuilder::fromCollection(
$collection,
function ($model) {
return sprintf('%s [%s]', $model['title'], $model['type']);
}
);
return $builder->getOptions();
}
/**
* Get all popups.
*
@@ -116,7 +108,8 @@ class VectorDcaListener extends AbstractListener
*/
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();

View File

@@ -10,24 +10,31 @@
* @filesource
*/
namespace Netzmacht\Contao\Leaflet\Subscriber;
declare(strict_types=1);
namespace Netzmacht\Contao\Leaflet\Listener;
use Contao\FilesModel;
use Contao\Model;
use Contao\StringUtil;
use Netzmacht\Contao\Leaflet\Event\ConvertToGeoJsonEvent;
use Netzmacht\Contao\Leaflet\Model\LayerModel;
use Netzmacht\LeafletPHP\Definition\Vector;
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.
@@ -36,43 +43,54 @@ class GeoJsonSubscriber implements EventSubscriberInterface
*/
private $featureModelProperties;
/**
* Repository manager.
*
* @var RepositoryManager
*/
private $repositoryManager;
/**
* GeoJsonSubscriber constructor.
*
* @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());
@@ -91,18 +109,16 @@ 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 Vector)
&& $model instanceof \Model && $feature instanceof Feature) {
&& $model instanceof Model && $feature instanceof Feature) {
$this->setDataProperty($model, $feature);
$this->setBoundsInformation($model, $feature);
}
@@ -111,33 +127,29 @@ 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
if (!$model instanceof Model || !$feature instanceof Feature
|| empty($this->featureModelProperties[$model->getTable()])) {
return;
}
@@ -158,12 +170,12 @@ class GeoJsonSubscriber implements EventSubscriberInterface
/**
* Parse the model value based on the config.
*
* @param \Model $model The model.
* @param Model $model The model.
* @param mixed $property The property config.
*
* @return array|mixed|null
*/
private function parseModelValue(\Model $model, &$property)
private function parseModelValue(Model $model, &$property)
{
if (is_array($property)) {
list($property, $type) = $property;
@@ -172,21 +184,23 @@ class GeoJsonSubscriber implements EventSubscriberInterface
switch ($type) {
case 'array':
case 'object':
$value = deserialize($value, true);
$value = StringUtil::deserialize($value, true);
break;
case 'file':
$file = \FilesModel::findByUuid($value);
$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(StringUtil::deserialize($value, true));
if ($collection) {
$value = $collection->fetchEach('path');
} else {
$value = array();
$value = [];
}
break;
@@ -213,7 +227,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);

View File

@@ -10,8 +10,9 @@
* @filesource
*/
namespace Netzmacht\Contao\Leaflet\Subscriber;
namespace Netzmacht\Contao\Leaflet\Listener;
use Contao\Model;
use Netzmacht\Contao\Leaflet\Event\GetHashEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -27,12 +28,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],
],
];
}
/**
@@ -46,7 +47,7 @@ class HashSubscriber implements EventSubscriberInterface
{
$data = $event->getData();
if ($data instanceof \Model) {
if ($data instanceof Model) {
$event->setHash($data->getTable() . '::' . $data->{$data->getPk()});
}
}

View File

@@ -14,10 +14,12 @@ declare(strict_types=1);
namespace Netzmacht\Contao\Leaflet\Listener;
use Contao\File;
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;
@@ -50,18 +52,31 @@ class LoadAssetsListener
*/
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, LibrariesConfiguration $libraries)
{
public function __construct(
Assets $assets,
DefinitionMapper $definitionMapper,
RepositoryManager $repositoryManager,
LibrariesConfiguration $libraries
) {
$this->assets = $assets;
$this->definitionMapper = $definitionMapper;
$this->libraries = $libraries;
$this->repositoryManager = $repositoryManager;
}
/**
@@ -76,7 +91,8 @@ class LoadAssetsListener
ContaoAssets::TYPE_FILE
);
$collection = IconModel::findBy('active', true);
$repository = $this->repositoryManager->getRepository(IconModel::class);
$collection = $repository->findBy(['active=?'], [true]);
if ($collection) {
$buffer = '';
@@ -102,7 +118,7 @@ class LoadAssetsListener
// TODO: Cache it.
// codingStandardsIgnoreEnd
$file = new \File('assets/leaflet/js/icons.js');
$file = new File('assets/leaflet/js/icons.js');
$file->write($buffer);
$file->close();

View File

@@ -19,13 +19,16 @@ use Netzmacht\Contao\Leaflet\Event\GetJavascriptEvent;
use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\Frontend\DataController;
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\Contao\Leaflet\Request\Request;
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.
@@ -83,6 +86,20 @@ class MapProvider
*/
private $dataController;
/**
* Repository manager.
*
* @var RepositoryManager
*/
private $repositoryManager;
/**
* Template engine.
*
* @var TemplateEngine
*/
private $templateEngine;
/**
* Construct.
*
@@ -93,8 +110,8 @@ class MapProvider
* @param ContaoAssets $assets Assets handler.
* @param Cache $cache Cache.
* @param DataController $dataController Data controller.
*
* @internal param FilterFactory $filterFactory Filter factory.
* @param RepositoryManager $repositoryManager Repository manager.
* @param TemplateEngine $templateEngine Template engine.
*/
public function __construct(
DefinitionMapper $mapper,
@@ -103,7 +120,9 @@ class MapProvider
$input,
ContaoAssets $assets,
Cache $cache,
DataController $dataController
DataController $dataController,
RepositoryManager $repositoryManager,
TemplateEngine $templateEngine
) {
$this->mapper = $mapper;
$this->leaflet = $leaflet;
@@ -112,6 +131,8 @@ class MapProvider
$this->assets = $assets;
$this->cache = $cache;
$this->dataController = $dataController;
$this->repositoryManager = $repositoryManager;
$this->templateEngine = $templateEngine;
}
/**
@@ -149,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));
@@ -184,7 +206,10 @@ class MapProvider
$model = $this->getModel($mapId);
}
if ($model->cache) {
$cacheKey = null;
$doCache = $model->cache;
if ($doCache) {
$cacheKey = $this->getCacheKey($mapId, $filter, $elementId, $template, $style);
if ($this->cache->contains($cacheKey)) {
@@ -197,12 +222,12 @@ class MapProvider
$buffer = $this->doGenerate($model, $filter, $elementId, $template, $style);
if ($model->cache) {
if ($doCache) {
$this->cache->save(
$cacheKey,
[
'assets' => $this->assets->toArray(),
'javascript' => $buffer
'javascript' => $buffer,
],
(int) $model->cacheLifeTime
);
@@ -226,7 +251,8 @@ 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) {
@@ -279,7 +305,7 @@ 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) {
@@ -345,18 +371,20 @@ 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,
];
$content = $this->templateEngine->render($templateReference, $parameters);
$event = new GetJavascriptEvent($definition, $content);
$this->eventDispatcher->dispatch($event::NAME, $event);

View File

@@ -13,7 +13,6 @@
namespace Netzmacht\Contao\Leaflet\Mapper;
use Contao\Model;
use Netzmacht\Contao\Leaflet\Request\Request;
use Netzmacht\LeafletPHP\Definition;
/**
@@ -157,9 +156,9 @@ abstract class AbstractMapper implements Mapper
Request $request = null,
$elementId = null
) {
return array(
$this->getElementId($model, $elementId)
);
return [
$this->getElementId($model, $elementId),
];
}
/**

View File

@@ -12,8 +12,6 @@
namespace Netzmacht\Contao\Leaflet\Mapper;
use Netzmacht\Contao\Leaflet\Request\Request;
/**
* Class AbstractTypeMapper is the base mapper for tables containing different types of definitins.
*

View File

@@ -13,8 +13,9 @@
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
use Contao\Model;
use Contao\StringUtil;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Request\Request;
use Netzmacht\Contao\Leaflet\Mapper\Request;
use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Definition\Control\Attribution;
use Netzmacht\LeafletPHP\Definition\Map;
@@ -31,7 +32,7 @@ class AttributionControlMapper extends AbstractControlMapper
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Attribution';
protected static $definitionClass = Attribution::class;
/**
* Layer type.
@@ -68,7 +69,7 @@ class AttributionControlMapper extends AbstractControlMapper
$parent->setAttributionControl(false);
}
$attributions = deserialize($model->attributions, true);
$attributions = StringUtil::deserialize($model->attributions, true);
foreach ($attributions as $attribution) {
$definition->addAttribution($attribution);

View File

@@ -12,6 +12,8 @@
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
use Netzmacht\LeafletPHP\Plugins\FullScreen\FullScreenControl;
/**
* Class FullscreenControlMapper.
*
@@ -24,7 +26,7 @@ class FullscreenControlMapper extends AbstractControlMapper
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Plugins\FullScreen\FullScreenControl';
protected static $definitionClass = FullScreenControl::class;
/**
* Layer type.

View File

@@ -14,8 +14,9 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Control;
use Contao\Model;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Mapper\Request;
use Netzmacht\Contao\Leaflet\Model\ControlModel;
use Netzmacht\Contao\Leaflet\Request\Request;
use Netzmacht\LeafletPHP\Definition\Control\Layers;
/**
* Class LayersControlMapper maps the control model to the layers control definition.
@@ -29,7 +30,7 @@ class LayersControlMapper extends AbstractControlMapper
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Layers';
protected static $definitionClass = Layers::class;
/**
* Layer type.
@@ -48,8 +49,8 @@ class LayersControlMapper extends AbstractControlMapper
$elementId = null
) {
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
$arguments[1] = array();
$arguments[2] = array();
$arguments[1] = [];
$arguments[2] = [];
/** @var ControlModel $model */
$collection = $model->findActiveLayers();

View File

@@ -14,8 +14,9 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Control;
use Contao\Model;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Mapper\Request;
use Netzmacht\Contao\Leaflet\Model\ControlModel;
use Netzmacht\Contao\Leaflet\Request\Request;
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Definition\Control\Zoom;
use Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl;
@@ -35,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, Request $request = null)
{
if ($model->spinjs) {
return 'Netzmacht\LeafletPHP\Plugins\Loading\SpinJsLoadingControl';
return SpinJsLoadingControl::class;
}
return 'Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl';
return LoadingControl::class;
}
/**
@@ -79,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) {

View File

@@ -12,6 +12,8 @@
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.
*
@@ -24,7 +26,7 @@ class ScaleControlMapper extends AbstractControlMapper
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Scale';
protected static $definitionClass = Scale::class;
/**
* Layer type.

View File

@@ -12,6 +12,8 @@
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
use Netzmacht\LeafletPHP\Definition\Control\Zoom;
/**
* Class ZoomControlMapper maps the zoom database definition to the zoom control.
*
@@ -24,7 +26,7 @@ class ZoomControlMapper extends AbstractControlMapper
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Zoom';
protected static $definitionClass = Zoom::class;
/**
* Layer type.

View File

@@ -15,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\Request\Request;
use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Value\GeoJson\ConvertsToGeoJsonFeature;
use Netzmacht\LeafletPHP\Value\GeoJson\Feature;
@@ -35,7 +34,7 @@ class DefinitionMapper
*
* @var Mapper[][]
*/
private $mappers = array();
private $mappers = [];
/**
* The event dispatcher.
@@ -49,7 +48,7 @@ class DefinitionMapper
*
* @var array
*/
private $mapped = array();
private $mapped = [];
/**
* Construct.
@@ -85,7 +84,7 @@ class DefinitionMapper
*/
public function reset()
{
$this->mapped = array();
$this->mapped = [];
return $this;
}

View File

@@ -13,7 +13,6 @@
namespace Netzmacht\Contao\Leaflet\Mapper;
use Contao\Model;
use Netzmacht\Contao\Leaflet\Request\Request;
use Netzmacht\LeafletPHP\Value\GeoJson\GeoJsonFeature;
/**

View File

@@ -0,0 +1,170 @@
<?php
/**
* Leaflet maps for Contao CMS.
*
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @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));
}
}
}
}

View File

@@ -14,9 +14,11 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
use Contao\Model;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Mapper\Request;
use Netzmacht\Contao\Leaflet\Model\LayerModel;
use Netzmacht\Contao\Leaflet\Request\Request;
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;
@@ -34,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, 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;
}
/**
@@ -60,10 +81,11 @@ class GroupLayerMapper extends AbstractLayerMapper
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) {

View File

@@ -15,8 +15,9 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
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\Leaflet\Request\Request;
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
use Netzmacht\JavascriptBuilder\Type\AnonymousFunction;
use Netzmacht\JavascriptBuilder\Type\Expression;
use Netzmacht\LeafletPHP\Definition;
@@ -36,7 +37,7 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Plugins\MarkerCluster\MarkerClusterGroup';
protected static $definitionClass = MarkerClusterGroup::class;
/**
* Layer type.
@@ -53,15 +54,24 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper
private $assets;
/**
* MarkerClusterLayerMapper constructor.
* Repository manager.
*
* @var RepositoryManager
*/
private $repositoryManager;
/**
* Construct.
*
* @param ContaoAssets $assets Assets manager.
* @param RepositoryManager $repositoryManager Repository manager.
*/
public function __construct(ContaoAssets $assets)
public function __construct(ContaoAssets $assets, RepositoryManager $repositoryManager)
{
parent::__construct();
$this->repositoryManager = $repositoryManager;
$this->assets = $assets;
parent::__construct();
}
/**
@@ -107,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) {

View File

@@ -15,13 +15,15 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
use Contao\Model;
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\Leaflet\Request\Request;
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;
use Symfony\Component\Routing\RouterInterface;
/**
* Class MarkersLayerMapper maps the layer model to the markers definition.
@@ -37,16 +39,44 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
*/
protected static $type = 'markers';
/**
* Repository manager.
*
* @var RepositoryManager
*/
private $repositoryManager;
/**
* Router.
*
* @var RouterInterface
*/
private $router;
/**
* Construct.
*
* @param RepositoryManager $repositoryManager Repository manager.
* @param RouterInterface $router Router.
*/
public function __construct(RepositoryManager $repositoryManager, RouterInterface $router)
{
$this->repositoryManager = $repositoryManager;
$this->router = $router;
parent::__construct();
}
/**
* {@inheritdoc}
*/
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;
}
/**
@@ -70,18 +100,18 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
$layer->setOption('boundsMode', $model->boundsMode);
}
return array(
return [
$this->getElementId($model, $elementId),
RequestUrl::create($model->id, null, null, $request),
array(),
$layer
);
$this->generateUrl((int) $model->id, $request),
[],
$layer,
];
}
return array(
return [
$this->getElementId($model, $elementId),
RequestUrl::create($model->id, null, null, $request)
);
$this->generateUrl((int) $model->id, $request),
];
}
return parent::buildConstructArguments($model, $mapper, $request, $elementId);
@@ -149,14 +179,43 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
* @param Model $model The layer model.
* @param Request $request Optional building request.
*
* @return \Model\Collection|null
* @return \Contao\Model\Collection|null
*/
protected function loadMarkerModels(Model $model, Request $request = null)
{
if ($model->boundsMode == 'fit') {
return MarkerModel::findByFilter($model->id, $request->getFilter());
$repository = $this->repositoryManager->getRepository(MarkerModel::class);
if ($model->boundsMode === 'fit') {
return $repository->findByFilter($model->id, $request->getFilter());
}
return MarkerModel::findByFilter($model->id);
return $repository->findByFilter($model->id);
}
/**
* Generate the data url for a layer.
*
* @param int $layerId The layer id.
* @param Request|null $request The request.
*
* @return string
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
private function generateUrl(int $layerId, ?Request $request = null): string
{
$params = ['layerId' => $layerId];
if ($request && ($filter = $request->getFilter())) {
$params['filter'] = $filter::getName();
$params['values'] = $filter->toRequest();
}
if (isset($GLOBALS['objPage'])) {
$params['context'] = 'page';
$params['contextId'] = $GLOBALS['objPage']->id;
}
return $this->router->generate('leaflet_layer', $params, RouterInterface::ABSOLUTE_URL);
}
}

View File

@@ -13,10 +13,12 @@
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
use Contao\Model;
use Contao\StringUtil;
use Netzmacht\Contao\Leaflet\Definition\Layer\OverpassLayer;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Mapper\Request;
use Netzmacht\Contao\Leaflet\Model\IconModel;
use Netzmacht\Contao\Leaflet\Request\Request;
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
use Netzmacht\JavascriptBuilder\Type\Expression;
use Netzmacht\LeafletPHP\Definition;
@@ -41,6 +43,25 @@ class OverpassLayerMapper extends AbstractLayerMapper
*/
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}
*/
@@ -97,7 +118,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) {
@@ -125,7 +147,7 @@ class OverpassLayerMapper extends AbstractLayerMapper
*/
private function filterAmenityIconsConfig($amenityIconsConfig)
{
$amenityIconsConfig = deserialize($amenityIconsConfig, true);
$amenityIconsConfig = StringUtil::deserialize($amenityIconsConfig, true);
$amenityIconsMap = [];
foreach ($amenityIconsConfig as $config) {

View File

@@ -15,8 +15,9 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
use Contao\Model;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Mapper\OptionsBuilder;
use Netzmacht\Contao\Leaflet\Request\Request;
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.
@@ -60,7 +61,7 @@ class ProviderLayerMapper extends AbstractLayerMapper
return $this->providers[$model->tile_provider]['class'];
}
return 'Netzmacht\LeafletPHP\Plugins\LeafletProviders\Provider';
return Provider::class;
}
/**
@@ -91,10 +92,10 @@ class ProviderLayerMapper extends AbstractLayerMapper
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,
];
}
}

View File

@@ -13,8 +13,9 @@
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Mapper\Request;
use Netzmacht\Contao\Leaflet\Model\LayerModel;
use Netzmacht\Contao\Leaflet\Request\Request;
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
use Netzmacht\LeafletPHP\Definition;
/**
@@ -31,6 +32,25 @@ 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}
*/
@@ -41,7 +61,8 @@ class ReferenceLayerMapper extends AbstractLayerMapper
$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;

Some files were not shown because too many files have changed in this diff Show More