mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-28 11:04:08 +01:00
Compare commits
30 Commits
3.0.4
...
feature/pe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdca0adb56 | ||
|
|
20efff72d9 | ||
|
|
d5407357d8 | ||
|
|
1ba19f63b1 | ||
|
|
878492c0b1 | ||
|
|
57ba63556a | ||
|
|
fa1ceb9402 | ||
|
|
f2959b2df0 | ||
|
|
d7fbc361d7 | ||
|
|
0e2b8dd3cd | ||
|
|
91d3786187 | ||
|
|
5e20b83503 | ||
|
|
ca103521aa | ||
|
|
f422459be2 | ||
|
|
c661abb626 | ||
|
|
83226cdd80 | ||
|
|
ed10175072 | ||
|
|
d2338332b4 | ||
|
|
7aa4f38902 | ||
|
|
cb03dcfa41 | ||
|
|
2108de32d9 | ||
|
|
314e2d21ee | ||
|
|
6faaa866ad | ||
|
|
b22563b38c | ||
|
|
a10e55a126 | ||
|
|
e27ac21902 | ||
|
|
0ba725ed38 | ||
|
|
7ec2ee0d96 | ||
|
|
9e54f12555 | ||
|
|
b323049f9d |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -25,4 +25,3 @@ build.properties
|
||||
|
||||
# NPM
|
||||
node_modules
|
||||
package-lock.json
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- "7.0"
|
||||
- "7.1"
|
||||
- "7.2"
|
||||
|
||||
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:
|
||||
|
||||
36
CHANGELOG.md
36
CHANGELOG.md
@@ -6,6 +6,42 @@ 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.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)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"source": "https://github.com/netzmacht/contao-leaflet-maps"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.0",
|
||||
"php": ">=7.1",
|
||||
"ext-json": "*",
|
||||
"ext-pdo": "*",
|
||||
"contao/core-bundle": "~4.4",
|
||||
@@ -39,9 +39,11 @@
|
||||
"netzmacht/php-javascript-builder": "^1.0",
|
||||
"netzmacht/php-leaflet": "^1.0.2",
|
||||
"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"
|
||||
"doctrine/cache": "^1.0",
|
||||
"codefog/contao-widget_tree_picker": "^2.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpcq/all-tasks": "^1.2",
|
||||
@@ -60,8 +62,8 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0.x-dev",
|
||||
"dev-develop": "3.1.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",
|
||||
|
||||
39
gulpfile.js
39
gulpfile.js
@@ -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;
|
||||
|
||||
48
js/Contao.js
48
js/Contao.js
@@ -138,7 +138,8 @@ L.Contao = L.Evented.extend({
|
||||
* @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) {
|
||||
loadUrl: function (url, type, options, customLayer, map) {
|
||||
url = this.applyFilterToUrl(url, map);
|
||||
var layer = omnivore[type](url, options, customLayer);
|
||||
|
||||
if (map) {
|
||||
@@ -147,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) {
|
||||
@@ -172,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.
|
||||
*
|
||||
@@ -313,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();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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
3297
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@@ -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"
|
||||
},
|
||||
|
||||
@@ -10,32 +10,59 @@
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Backend;
|
||||
namespace Netzmacht\Contao\Leaflet\Backend\Action;
|
||||
|
||||
use Contao\BackendTemplate;
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +72,7 @@ class About
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
*/
|
||||
private function getLibraries()
|
||||
private function getLibraries(): array
|
||||
{
|
||||
return array_map(
|
||||
function ($library) {
|
||||
@@ -70,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']);
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -81,10 +108,10 @@ 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 [];
|
||||
@@ -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])
|
||||
->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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ parameters:
|
||||
|
||||
markercluster:
|
||||
children: true
|
||||
icon: 'bundles/netzmachtcontaoleaflet/img/markercluster.png'
|
||||
icon: 'bundles/netzmachtcontaoleaflet/img/cluster.png'
|
||||
|
||||
tile:
|
||||
children: false
|
||||
|
||||
@@ -30,6 +30,8 @@ services:
|
||||
- '@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
|
||||
@@ -49,6 +51,8 @@ services:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@translator'
|
||||
- '@netzmacht.contao_leaflet.layer_label_renderer'
|
||||
- '@netzmacht.contao_toolkit.contao.backend_user'
|
||||
- '@netzmacht.contao_toolkit.dca.listeners.state_button_callback'
|
||||
- '@netzmacht.contao_toolkit.contao.backend_adapter'
|
||||
- '%netzmacht.contao_leaflet.layers%'
|
||||
- '%netzmacht.contao_leaflet.providers%'
|
||||
@@ -61,6 +65,7 @@ services:
|
||||
arguments:
|
||||
- '@database_connection'
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@netzmacht.contao_toolkit.contao.backend_user'
|
||||
|
||||
netzmacht.contao_leaflet.listeners.dca.vector:
|
||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\VectorDcaListener
|
||||
@@ -68,20 +73,52 @@ services:
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.dca.manager'
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@netzmacht.contao_toolkit.contao.backend_user'
|
||||
- '%netzmacht.contao_leaflet.vectors%'
|
||||
|
||||
netzmacht.contao_leaflet.listeners.dca.icon:
|
||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\IconDcaListener
|
||||
public: true
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.contao.backend_user'
|
||||
- '%netzmacht.contao_leaflet.icons%'
|
||||
|
||||
netzmacht.contao_leaflet.listeners.dca.style:
|
||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\StyleDcaListener
|
||||
public: true
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.contao.backend_user'
|
||||
- '%netzmacht.contao_leaflet.styles%'
|
||||
|
||||
netzmacht.contao_leaflet.listeners.dca.popup:
|
||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\PopupDcaListener
|
||||
public: true
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.contao.backend_user'
|
||||
|
||||
netzmacht.contao_leaflet.listeners.dca.user:
|
||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\UserDcaListener
|
||||
public: true
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.dca.manager'
|
||||
- '@netzmacht.contao_leaflet.layer_label_renderer'
|
||||
- '@translator'
|
||||
- '%netzmacht.contao_leaflet.layers%'
|
||||
-
|
||||
netzmacht.contao_leaflet.listeners.dca.user_group:
|
||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\UserGroupDcaListener
|
||||
public: true
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.dca.manager'
|
||||
- '@netzmacht.contao_leaflet.layer_label_renderer'
|
||||
- '@translator'
|
||||
- '%netzmacht.contao_leaflet.layers%'
|
||||
|
||||
Netzmacht\Contao\Leaflet\Listener\Dca\OperationsListener:
|
||||
public: true
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.contao.backend_user'
|
||||
|
||||
netzmacht.contao_leaflet.listeners.geo_json_listener:
|
||||
class: Netzmacht\Contao\Leaflet\Listener\GeoJsonListener
|
||||
arguments:
|
||||
@@ -113,3 +150,13 @@ services:
|
||||
- '@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'}
|
||||
|
||||
@@ -32,6 +32,7 @@ services:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLayerMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@router'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
|
||||
@@ -46,6 +47,7 @@ services:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@router'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
|
||||
@@ -69,7 +71,7 @@ services:
|
||||
- '@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
|
||||
|
||||
18
src/Bundle/Resources/config/routing.yml
Normal file
18
src/Bundle/Resources/config/routing.yml
Normal 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
|
||||
@@ -122,3 +122,17 @@ 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:
|
||||
arguments:
|
||||
- '@netzmacht.contao_leaflet.map.provider'
|
||||
- '@netzmacht.contao_leaflet.filter_factory'
|
||||
|
||||
Netzmacht\Contao\Leaflet\Backend\Action\AboutAction:
|
||||
arguments:
|
||||
- '@templating'
|
||||
- '%kernel.project_dir%'
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Backend module.
|
||||
* Backend modules
|
||||
*/
|
||||
|
||||
array_insert(
|
||||
@@ -40,11 +40,6 @@ array_insert(
|
||||
'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/backend.css',
|
||||
'javascript' => 'bundles/netzmachtcontaoleaflet/js/backend.js',
|
||||
],
|
||||
'leaflet_about' => [
|
||||
'callback' => Netzmacht\Contao\Leaflet\Backend\About::class,
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/about.png',
|
||||
'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/about.css',
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
@@ -53,8 +48,9 @@ if (TL_MODE === 'BE') {
|
||||
$GLOBALS['TL_CSS'][] = 'bundles/netzmachtcontaoleaflet/css/backend_global.css';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Models.
|
||||
* Models
|
||||
*/
|
||||
|
||||
$GLOBALS['TL_MODELS']['tl_leaflet_control'] = \Netzmacht\Contao\Leaflet\Model\ControlModel::class;
|
||||
@@ -65,3 +61,12 @@ $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;
|
||||
|
||||
|
||||
/*
|
||||
* Permissions
|
||||
*/
|
||||
|
||||
$GLOBALS['TL_PERMISSIONS'][] = 'leaflet_layers';
|
||||
$GLOBALS['TL_PERMISSIONS'][] = 'leaflet_layer_permissions';
|
||||
$GLOBALS['TL_PERMISSIONS'][] = 'leaflet_tables';
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Listener\Dca\OperationsListener;
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_leaflet_icon'] = [
|
||||
'config' => [
|
||||
'dataContainer' => 'Table',
|
||||
@@ -20,6 +22,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = [
|
||||
'alias' => 'unique',
|
||||
],
|
||||
],
|
||||
'onload_callback' => [
|
||||
['netzmacht.contao_leaflet.listeners.dca.icon', 'checkPermission'],
|
||||
],
|
||||
'onsubmit_callback' => [
|
||||
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'],
|
||||
],
|
||||
@@ -45,16 +50,19 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = [
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"',
|
||||
],
|
||||
'styles' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['styles'],
|
||||
'href' => 'table=tl_leaflet_style',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/style.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['styles'],
|
||||
'href' => 'table=tl_leaflet_style',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/style.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'button_callback' => [OperationsListener::class, 'styleOperation'],
|
||||
|
||||
],
|
||||
'popups' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['popups'],
|
||||
'href' => 'table=tl_leaflet_popup',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['popups'],
|
||||
'href' => 'table=tl_leaflet_popup',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'button_callback' => [OperationsListener::class, 'popupOperation'],
|
||||
],
|
||||
'all' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
|
||||
|
||||
@@ -10,14 +10,13 @@
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Listener\Dca\OperationsListener;
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
|
||||
'config' => [
|
||||
'dataContainer' => 'Table',
|
||||
'enableVersioning' => true,
|
||||
'ctable' => ['tl_leaflet_vector', 'tl_leaflet_marker'],
|
||||
'ondelete_callback' => [
|
||||
['netzmacht.contao_leaflet.listeners.dca.layer', 'deleteRelations'],
|
||||
],
|
||||
'sql' => [
|
||||
'keys' => [
|
||||
'id' => 'primary',
|
||||
@@ -26,8 +25,12 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
|
||||
],
|
||||
],
|
||||
'onload_callback' => [
|
||||
['netzmacht.contao_leaflet.listeners.dca.layer', 'checkPermissions'],
|
||||
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'loadLanguageFile'],
|
||||
],
|
||||
'ondelete_callback' => [
|
||||
['netzmacht.contao_leaflet.listeners.dca.layer', 'deleteRelations'],
|
||||
],
|
||||
'onsubmit_callback' => [
|
||||
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'],
|
||||
],
|
||||
@@ -48,22 +51,25 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
|
||||
],
|
||||
'global_operations' => [
|
||||
'styles' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['styles'],
|
||||
'href' => 'table=tl_leaflet_style',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/style.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['styles'],
|
||||
'href' => 'table=tl_leaflet_style',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/style.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'button_callback' => [OperationsListener::class, 'styleOperation'],
|
||||
],
|
||||
'icons' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['icons'],
|
||||
'href' => 'table=tl_leaflet_icon',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/icons.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['icons'],
|
||||
'href' => 'table=tl_leaflet_icon',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/icons.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'button_callback' => [OperationsListener::class, 'iconOperation'],
|
||||
],
|
||||
'popups' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['popups'],
|
||||
'href' => 'table=tl_leaflet_popup',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['popups'],
|
||||
'href' => 'table=tl_leaflet_popup',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'button_callback' => [OperationsListener::class, 'popupOperation'],
|
||||
],
|
||||
'all' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
|
||||
@@ -86,27 +92,31 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
|
||||
'button_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'generateVectorsButton'],
|
||||
],
|
||||
'edit' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['edit'],
|
||||
'href' => 'act=edit',
|
||||
'icon' => 'header.gif',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['edit'],
|
||||
'href' => 'act=edit',
|
||||
'icon' => 'header.gif',
|
||||
'button_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'generateEditButton'],
|
||||
],
|
||||
'copy' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['copy'],
|
||||
'href' => 'act=copy',
|
||||
'icon' => 'copy.gif',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['copy'],
|
||||
'href' => 'act=copy',
|
||||
'icon' => 'copy.gif',
|
||||
'button_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'generateCopyButton'],
|
||||
],
|
||||
'cut' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['cut'],
|
||||
'href' => 'act=paste&mode=cut',
|
||||
'icon' => 'cut.gif',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset()"',
|
||||
'button_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'generateEditButton'],
|
||||
],
|
||||
'delete' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['delete'],
|
||||
'href' => 'act=delete',
|
||||
'icon' => 'delete.gif',
|
||||
'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm']
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['delete'],
|
||||
'href' => 'act=delete',
|
||||
'icon' => 'delete.gif',
|
||||
'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm']
|
||||
. '\'))return false;Backend.getScrollOffset()"',
|
||||
'button_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'generateDeleteButton'],
|
||||
],
|
||||
'toggle' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['toggle'],
|
||||
@@ -114,8 +124,8 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();
|
||||
return ContaoLeafletAjaxRequest.toggleVisibility(this,%s)"',
|
||||
'button_callback' => [
|
||||
'netzmacht.contao_toolkit.dca.listeners.state_button_callback',
|
||||
'handleButtonCallback',
|
||||
'netzmacht.contao_leaflet.listeners.dca.layer',
|
||||
'generateToggleButton',
|
||||
],
|
||||
'toolkit' => [
|
||||
'state_button' => [
|
||||
@@ -235,9 +245,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
|
||||
'MapBox' => ['tile_provider_key'],
|
||||
'HERE' => ['tile_provider_key', 'tile_provider_code'],
|
||||
],
|
||||
'fileFormat' => [
|
||||
'!' => ['file']
|
||||
]
|
||||
'fileFormat' => [
|
||||
'!' => ['file'],
|
||||
],
|
||||
],
|
||||
|
||||
'metasubpalettes' => [
|
||||
@@ -864,7 +874,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
|
||||
],
|
||||
'sql' => 'mediumtext NULL',
|
||||
],
|
||||
'fileFormat' => [
|
||||
'fileFormat' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormat'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'select',
|
||||
@@ -882,19 +892,19 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
|
||||
'sql' => "varchar(32) NOT NULL default ''",
|
||||
],
|
||||
'file' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['file'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'fileTree',
|
||||
'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',
|
||||
'eval' => [
|
||||
'filesOnly' => true,
|
||||
'fieldType' => 'radio',
|
||||
'mandatory' => true,
|
||||
'tl_class' => 'clr',
|
||||
],
|
||||
'sql' => 'binary(16) NULL',
|
||||
'sql' => 'binary(16) NULL',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Listener\Dca\OperationsListener;
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_leaflet_marker'] = [
|
||||
'config' => [
|
||||
'dataContainer' => 'Table',
|
||||
@@ -23,6 +25,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_marker'] = [
|
||||
],
|
||||
],
|
||||
'onload_callback' => [
|
||||
['netzmacht.contao_leaflet.listeners.dca.marker', 'checkPermissions'],
|
||||
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'loadLanguageFile'],
|
||||
],
|
||||
'onsubmit_callback' => [
|
||||
@@ -45,16 +48,18 @@ $GLOBALS['TL_DCA']['tl_leaflet_marker'] = [
|
||||
],
|
||||
'global_operations' => [
|
||||
'icons' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['icons'],
|
||||
'href' => 'table=tl_leaflet_icon&id=',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/icons.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['icons'],
|
||||
'href' => 'table=tl_leaflet_icon&id=',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/icons.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"',
|
||||
'button_callback' => [OperationsListener::class, 'iconOperation'],
|
||||
],
|
||||
'popups' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['popups'],
|
||||
'href' => 'table=tl_leaflet_popup',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['popups'],
|
||||
'href' => 'table=tl_leaflet_popup',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'button_callback' => [OperationsListener::class, 'popupOperation'],
|
||||
],
|
||||
'all' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Listener\Dca\OperationsListener;
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_leaflet_popup'] = [
|
||||
'config' => [
|
||||
'dataContainer' => 'Table',
|
||||
@@ -20,6 +22,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_popup'] = [
|
||||
'alias' => 'unique',
|
||||
],
|
||||
],
|
||||
'onload_callback' => [
|
||||
['netzmacht.contao_leaflet.listeners.dca.popup', 'checkPermission'],
|
||||
],
|
||||
'onsubmit_callback' => [
|
||||
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'],
|
||||
],
|
||||
@@ -45,16 +50,18 @@ $GLOBALS['TL_DCA']['tl_leaflet_popup'] = [
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"',
|
||||
],
|
||||
'styles' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['styles'],
|
||||
'href' => 'table=tl_leaflet_style',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/style.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['styles'],
|
||||
'href' => 'table=tl_leaflet_style',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/style.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'button_callback' => [OperationsListener::class, 'styleOperation'],
|
||||
],
|
||||
'icons' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['icons'],
|
||||
'href' => 'table=tl_leaflet_icon',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/icons.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['icons'],
|
||||
'href' => 'table=tl_leaflet_icon',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/icons.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'button_callback' => [OperationsListener::class, 'iconOperation'],
|
||||
],
|
||||
'all' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Listener\Dca\OperationsListener;
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_leaflet_style'] = [
|
||||
'config' => [
|
||||
'dataContainer' => 'Table',
|
||||
@@ -20,6 +22,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_style'] = [
|
||||
'alias' => 'unique',
|
||||
],
|
||||
],
|
||||
'onload_callback' => [
|
||||
['netzmacht.contao_leaflet.listeners.dca.style', 'checkPermission'],
|
||||
],
|
||||
'onsubmit_callback' => [
|
||||
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'],
|
||||
],
|
||||
@@ -45,16 +50,18 @@ $GLOBALS['TL_DCA']['tl_leaflet_style'] = [
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"',
|
||||
],
|
||||
'icons' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['icons'],
|
||||
'href' => 'table=tl_leaflet_icon',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/icons.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['icons'],
|
||||
'href' => 'table=tl_leaflet_icon',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/icons.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'button_callback' => [OperationsListener::class, 'iconOperation'],
|
||||
],
|
||||
'popups' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['popups'],
|
||||
'href' => 'table=tl_leaflet_popup',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['popups'],
|
||||
'href' => 'table=tl_leaflet_popup',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'button_callback' => [OperationsListener::class, 'popupOperation'],
|
||||
],
|
||||
'all' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Listener\Dca\OperationsListener;
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_leaflet_vector'] = [
|
||||
'config' => [
|
||||
'dataContainer' => 'Table',
|
||||
@@ -45,16 +47,18 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = [
|
||||
],
|
||||
'global_operations' => [
|
||||
'styles' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['styles'],
|
||||
'href' => 'table=tl_leaflet_style',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/style.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['styles'],
|
||||
'href' => 'table=tl_leaflet_style',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/style.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'button_callback' => [OperationsListener::class, 'styleOperation'],
|
||||
],
|
||||
'popups' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popups'],
|
||||
'href' => 'table=tl_leaflet_popup',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popups'],
|
||||
'href' => 'table=tl_leaflet_popup',
|
||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/popup.png',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();"',
|
||||
'button_callback' => [OperationsListener::class, 'popupOperation'],
|
||||
],
|
||||
'all' => [
|
||||
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
|
||||
|
||||
@@ -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'],
|
||||
|
||||
68
src/Bundle/Resources/contao/dca/tl_user.php
Normal file
68
src/Bundle/Resources/contao/dca/tl_user.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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);
|
||||
|
||||
use Contao\CoreBundle\DataContainer\PaletteManipulator;
|
||||
|
||||
PaletteManipulator::create()
|
||||
->addLegend('leaflet_legend', 'amg_legend', PaletteManipulator::POSITION_BEFORE)
|
||||
->addField(
|
||||
['leaflet_layers', 'leaflet_layer_permissions', 'leaflet_tables'],
|
||||
'leaflet_legend',
|
||||
PaletteManipulator::POSITION_APPEND
|
||||
)
|
||||
->applyToPalette('extend', 'tl_user')
|
||||
->applyToPalette('custom', 'tl_user');
|
||||
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_user']['fields']['leaflet_layers'] = [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_user']['leaflet_layers'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'treePicker',
|
||||
'eval' => [
|
||||
'foreignTable' => 'tl_leaflet_layer',
|
||||
'titleField' => 'title',
|
||||
'searchField' => 'title',
|
||||
'managerHref' => 'do=leaflet_layer',
|
||||
'fieldType' => 'checkbox',
|
||||
'selectParents' => true,
|
||||
'multiple' => true,
|
||||
'pickerCallback' => ['netzmacht.contao_leaflet.listeners.dca.user', 'generateLayersRowLabel']
|
||||
],
|
||||
'sql' => 'blob NULL',
|
||||
];
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_user']['fields']['leaflet_tables'] = [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_user']['leaflet_tables'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkbox',
|
||||
'options' => ['tl_leaflet_style', 'tl_leaflet_icon', 'tl_leaflet_popup'],
|
||||
'reference' => &$GLOBALS['TL_LANG']['MOD'],
|
||||
'eval' => [
|
||||
'multiple' => true,
|
||||
],
|
||||
'sql' => 'mediumblob NULL',
|
||||
];
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_user']['fields']['leaflet_layer_permissions'] = [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_user']['leaflet_layer_permissions'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkbox',
|
||||
'options' => ['create', 'edit', 'delete', 'data'],
|
||||
'reference' => &$GLOBALS['TL_LANG']['tl_user']['leaflet_layer_permissions_options'],
|
||||
'eval' => [
|
||||
'helpwizard' => true,
|
||||
'multiple' => true,
|
||||
],
|
||||
'sql' => 'mediumblob NULL',
|
||||
];
|
||||
67
src/Bundle/Resources/contao/dca/tl_user_group.php
Normal file
67
src/Bundle/Resources/contao/dca/tl_user_group.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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);
|
||||
|
||||
use Contao\CoreBundle\DataContainer\PaletteManipulator;
|
||||
|
||||
PaletteManipulator::create()
|
||||
->addLegend('leaflet_legend', 'amg_legend', PaletteManipulator::POSITION_BEFORE)
|
||||
->addField(
|
||||
['leaflet_layers', 'leaflet_layer_permissions', 'leaflet_tables'],
|
||||
'leaflet_legend',
|
||||
PaletteManipulator::POSITION_APPEND
|
||||
)
|
||||
->applyToPalette('default', 'tl_user_group');
|
||||
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_user_group']['fields']['leaflet_layers'] = [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layers'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'treePicker',
|
||||
'eval' => [
|
||||
'foreignTable' => 'tl_leaflet_layer',
|
||||
'titleField' => 'title',
|
||||
'searchField' => 'title',
|
||||
'managerHref' => 'do=leaflet_layer',
|
||||
'fieldType' => 'checkbox',
|
||||
'selectParents' => true,
|
||||
'multiple' => true,
|
||||
'pickerCallback' => ['netzmacht.contao_leaflet.listeners.dca.user_group', 'generateLayersRowLabel']
|
||||
],
|
||||
'sql' => 'blob NULL',
|
||||
];
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_user_group']['fields']['leaflet_tables'] = [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_user_group']['leaflet_tables'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkbox',
|
||||
'options' => ['tl_leaflet_style', 'tl_leaflet_icon', 'tl_leaflet_popup'],
|
||||
'reference' => &$GLOBALS['TL_LANG']['MOD'],
|
||||
'eval' => [
|
||||
'multiple' => true,
|
||||
],
|
||||
'sql' => 'mediumblob NULL',
|
||||
];
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_user_group']['fields']['leaflet_layer_permissions'] = [
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layer_permissions'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkbox',
|
||||
'options' => ['create', 'edit', 'delete', 'data'],
|
||||
'reference' => &$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layer_permissions_options'],
|
||||
'eval' => [
|
||||
'helpwizard' => true,
|
||||
'multiple' => true,
|
||||
],
|
||||
'sql' => 'mediumblob NULL',
|
||||
];
|
||||
15
src/Bundle/Resources/contao/languages/en/default.php
Normal file
15
src/Bundle/Resources/contao/languages/en/default.php
Normal 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.';
|
||||
@@ -22,6 +22,8 @@ $GLOBALS['TL_LANG']['MOD']['leaflet_about'][1] = 'About the Leaflet integration
|
||||
$GLOBALS['TL_LANG']['MOD']['tl_leaflet_map'] = 'Maps';
|
||||
$GLOBALS['TL_LANG']['MOD']['tl_leaflet_layer'] = 'Layers';
|
||||
$GLOBALS['TL_LANG']['MOD']['tl_leaflet_icon'] = 'Icons';
|
||||
$GLOBALS['TL_LANG']['MOD']['tl_leaflet_style'] = 'Styles';
|
||||
$GLOBALS['TL_LANG']['MOD']['tl_leaflet_popup'] = 'Popup';
|
||||
$GLOBALS['TL_LANG']['MOD']['tl_leaflet_marker'] = 'Markers';
|
||||
$GLOBALS['TL_LANG']['MOD']['tl_leaflet_control'] = 'Controls';
|
||||
|
||||
|
||||
31
src/Bundle/Resources/contao/languages/en/tl_user.php
Normal file
31
src/Bundle/Resources/contao/languages/en/tl_user.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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']['tl_user']['leaflet_legend'] = 'Leaflet Maps Permissions';
|
||||
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_layers'][0] = 'Allowed map layers';
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_layers'][1] = 'Please choose the allowed map layers.';
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_layer_permissions'][0] = 'Layer permissions';
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_layer_permissions'][1] = 'Please choose which permissions are allowed for the map layer.';
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_tables'][0] = 'Allows map tables';
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_tables'][1] = 'Please choose which tables are allowed.';
|
||||
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_layer_permissions_options']['create'][0] = 'Create layers';
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_layer_permissions_options']['create'][1] = 'Grant permission to create new layers.';
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_layer_permissions_options']['edit'][0] = 'Edit layers';
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_layer_permissions_options']['edit'][1] = 'Grant permission to edit layers.';
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_layer_permissions_options']['delete'][0] = 'Delete layers';
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_layer_permissions_options']['delete'][1] = 'Grant permission to delete layers.';
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_layer_permissions_options']['data'][0] = 'Edit data';
|
||||
$GLOBALS['TL_LANG']['tl_user']['leaflet_layer_permissions_options']['data'][1] = 'Grant permission to edit data of a layer.';
|
||||
31
src/Bundle/Resources/contao/languages/en/tl_user_group.php
Normal file
31
src/Bundle/Resources/contao/languages/en/tl_user_group.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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']['tl_user_group']['leaflet_legend'] = 'Leaflet Maps Permissions';
|
||||
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layers'][0] = 'Allowed map layers';
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layers'][1] = 'Please choose the allowed map layers.';
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layer_permissions'][0] = 'Layer permissions';
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layer_permissions'][1] = 'Please choose which permissions are allowed for the map layer.';
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_tables'][0] = 'Allows map tables';
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_tables'][1] = 'Please choose which tables are allowed.';
|
||||
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layer_permissions_options']['create'][0] = 'Create layers';
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layer_permissions_options']['create'][1] = 'Grant permission to create new layers.';
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layer_permissions_options']['edit'][0] = 'Edit layers';
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layer_permissions_options']['edit'][1] = 'Grant permission to edit layers.';
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layer_permissions_options']['delete'][0] = 'Delete layers';
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layer_permissions_options']['delete'][1] = 'Grant permission to delete layers.';
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layer_permissions_options']['data'][0] = 'Edit data';
|
||||
$GLOBALS['TL_LANG']['tl_user_group']['leaflet_layer_permissions_options']['data'][1] = 'Grant permission to edit data of a layer.';
|
||||
@@ -1,140 +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" target="_blank">
|
||||
<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­tribute. Translations,
|
||||
docu­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>
|
||||
@@ -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);
|
||||
|
||||
File diff suppressed because one or more lines are too long
130
src/Bundle/Resources/views/backend/about.html.twig
Normal file
130
src/Bundle/Resources/views/backend/about.html.twig
Normal file
@@ -0,0 +1,130 @@
|
||||
{% extends "@ContaoCore/Backend/be_page.html.twig" %}
|
||||
|
||||
{% block headline %}{{ "MOD.leaflet_about.1"|trans({}, 'contao_modules') }}{% 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­tribute. Translations,
|
||||
docu­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 %}
|
||||
@@ -90,7 +90,7 @@ class EncoderSubscriber implements EventSubscriberInterface
|
||||
$value = $event->getValue();
|
||||
$encoder = $event->getEncoder();
|
||||
$template = 'L.contao.%s(%s, %s, %s, %s, map);';
|
||||
$method = 'loadFile';
|
||||
$method = 'loadUrl';
|
||||
|
||||
if ($value instanceof OmnivoreLayer) {
|
||||
$url = $value->getUrl();
|
||||
|
||||
@@ -93,4 +93,24 @@ class DistanceFilter implements Filter
|
||||
'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;
|
||||
}
|
||||
}
|
||||
|
||||
103
src/Frontend/Action/LayerDataAction.php
Normal file
103
src/Frontend/Action/LayerDataAction.php
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
47
src/Frontend/PageIdDeterminator.php
Normal file
47
src/Frontend/PageIdDeterminator.php
Normal 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');
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,8 @@ use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
* Class RequestUrl creates the request url.
|
||||
*
|
||||
* @package Netzmacht\Contao\Leaflet\Request
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
class RequestUrl implements \JsonSerializable
|
||||
{
|
||||
@@ -89,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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,6 +73,8 @@ class ValueFilter
|
||||
*/
|
||||
public function filter($value)
|
||||
{
|
||||
return $this->getReplacer()->replace($value);
|
||||
$value = $this->getReplacer()->replace($value, false);
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
107
src/Listener/Backend/UserNavigationListener.php
Normal file
107
src/Listener/Backend/UserNavigationListener.php
Normal 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;
|
||||
}
|
||||
}
|
||||
109
src/Listener/Dca/AbstractUserDcaListener.php
Normal file
109
src/Listener/Dca/AbstractUserDcaListener.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?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\Dca;
|
||||
|
||||
use Contao\Image;
|
||||
use Contao\StringUtil;
|
||||
use Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\LayerLabelRenderer;
|
||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||
use Netzmacht\Contao\Toolkit\Dca\Listener\AbstractListener;
|
||||
use Netzmacht\Contao\Toolkit\Dca\Manager;
|
||||
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||
|
||||
/**
|
||||
* Class AbstractUserDcaListener
|
||||
*/
|
||||
abstract class AbstractUserDcaListener extends AbstractListener
|
||||
{
|
||||
/**
|
||||
* Layer label renderer.
|
||||
*
|
||||
* @var LayerLabelRenderer
|
||||
*/
|
||||
private $labelRenderer;
|
||||
|
||||
/**
|
||||
* Translator.
|
||||
*
|
||||
* @var Translator
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
/**
|
||||
* Layers definitions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $layers;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Manager $dcaManager Dca manager.
|
||||
* @param LayerLabelRenderer $labelRenderer Layer label renderer.
|
||||
* @param Translator $translator Translator.
|
||||
* @param array $layers Layers definition.
|
||||
*/
|
||||
public function __construct(
|
||||
Manager $dcaManager,
|
||||
LayerLabelRenderer $labelRenderer,
|
||||
Translator $translator,
|
||||
array $layers
|
||||
) {
|
||||
parent::__construct($dcaManager);
|
||||
|
||||
$this->labelRenderer = $labelRenderer;
|
||||
$this->translator = $translator;
|
||||
$this->layers = $layers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the layers row label.
|
||||
*
|
||||
* @param array $row Layer data row.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateLayersRowLabel(array $row): string
|
||||
{
|
||||
if (!empty($this->layers[$row['type']]['icon'])) {
|
||||
$src = $this->layers[$row['type']]['icon'];
|
||||
} else {
|
||||
$src = 'iconPLAIN.gif';
|
||||
}
|
||||
|
||||
$activeIcon = $src;
|
||||
$disabledIcon = preg_replace('/(\.[^\.]+)$/', '_1$1', $src);
|
||||
|
||||
if (!$row['active']) {
|
||||
$src = $disabledIcon;
|
||||
}
|
||||
|
||||
$alt = $this->getFormatter(LayerModel::getTable())->formatValue('type', $row['type']);
|
||||
$attributes = sprintf(
|
||||
'class="list-icon" title="%s" data-icon="%s" data-icon-disabled="%s"',
|
||||
StringUtil::specialchars(strip_tags($alt)),
|
||||
$activeIcon,
|
||||
$disabledIcon
|
||||
);
|
||||
|
||||
$label = $this->getFormatter(LayerModel::getTable())->formatValue('title', $row['title']);
|
||||
$label .= sprintf(' <span class="tl_gray">[ID %s]</span>', $row['id']);
|
||||
$icon = Image::getHtml($src, $alt, $attributes);
|
||||
$label = $this->labelRenderer->render($row, $label, $this->translator);
|
||||
|
||||
return $icon . ' ' . $label;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||
|
||||
use Contao\BackendUser;
|
||||
use Contao\CoreBundle\Exception\AccessDeniedException;
|
||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||
|
||||
/**
|
||||
* Class IconDcaListener.
|
||||
*
|
||||
@@ -21,6 +25,13 @@ namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||
*/
|
||||
class IconDcaListener
|
||||
{
|
||||
/**
|
||||
* Contao backend user.
|
||||
*
|
||||
* @var BackendUser
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Icon type options.
|
||||
*
|
||||
@@ -31,13 +42,33 @@ class IconDcaListener
|
||||
/**
|
||||
* IconDcaListener constructor.
|
||||
*
|
||||
* @param array $icons Icon type options.
|
||||
* @param BackendUser $user Backend user.
|
||||
* @param array $icons Icon type options.
|
||||
*/
|
||||
public function __construct(array $icons)
|
||||
public function __construct(BackendUser $user, array $icons)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->icons = $icons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the permission.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws AccessDeniedException If user has not the permission.
|
||||
*/
|
||||
public function checkPermission(): void
|
||||
{
|
||||
if ($this->user->hasAccess(IconModel::getTable(), 'leaflet_tables')) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AccessDeniedException(
|
||||
sprintf('Access denied to "%s" for user "%s"', IconModel::getTable(), $this->user->id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get icon options.
|
||||
*
|
||||
|
||||
@@ -13,9 +13,12 @@
|
||||
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||
|
||||
use Contao\Backend;
|
||||
use Contao\BackendUser;
|
||||
use Contao\CoreBundle\Exception\AccessDeniedException;
|
||||
use Contao\CoreBundle\Framework\Adapter;
|
||||
use Contao\DataContainer;
|
||||
use Contao\Image;
|
||||
use Contao\Input;
|
||||
use Contao\StringUtil;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\LayerLabelRenderer;
|
||||
@@ -23,6 +26,7 @@ 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\Listener\Button\StateButtonCallbackListener;
|
||||
use Netzmacht\Contao\Toolkit\Dca\Manager;
|
||||
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
||||
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||
@@ -30,7 +34,7 @@ use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||
/**
|
||||
* Class Layer is the helper class for the tl_leaflet_layer dca.
|
||||
*
|
||||
* @package Netzmacht\Contao\Leaflet\Dca
|
||||
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
||||
*/
|
||||
class LayerDcaListener extends AbstractListener
|
||||
{
|
||||
@@ -76,6 +80,13 @@ class LayerDcaListener extends AbstractListener
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
/**
|
||||
* Backend user.
|
||||
*
|
||||
* @var BackendUser
|
||||
*/
|
||||
private $backendUser;
|
||||
|
||||
/**
|
||||
* OSM amenities.
|
||||
*
|
||||
@@ -104,19 +115,28 @@ class LayerDcaListener extends AbstractListener
|
||||
*/
|
||||
private $backendAdapter;
|
||||
|
||||
/**
|
||||
* State button callback listener.
|
||||
*
|
||||
* @var StateButtonCallbackListener
|
||||
*/
|
||||
private $stateButtonCallbackListener;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @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 BackendUser $backendUser Backend user.
|
||||
* @param StateButtonCallbackListener $stateButtonCallbackListener State button callback listener.
|
||||
* @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)
|
||||
*/
|
||||
@@ -126,6 +146,8 @@ class LayerDcaListener extends AbstractListener
|
||||
RepositoryManager $repositoryManager,
|
||||
Translator $translator,
|
||||
LayerLabelRenderer $labelRenderer,
|
||||
BackendUser $backendUser,
|
||||
StateButtonCallbackListener $stateButtonCallbackListener,
|
||||
$backendAdapter,
|
||||
array $layers,
|
||||
array $tileProviders,
|
||||
@@ -134,15 +156,55 @@ class LayerDcaListener extends AbstractListener
|
||||
) {
|
||||
parent::__construct($manager);
|
||||
|
||||
$this->connection = $connection;
|
||||
$this->layers = $layers;
|
||||
$this->tileProviders = $tileProviders;
|
||||
$this->translator = $translator;
|
||||
$this->amenities = $amenities;
|
||||
$this->labelRenderer = $labelRenderer;
|
||||
$this->fileFormats = $fileFormats;
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
$this->backendAdapter = $backendAdapter;
|
||||
$this->connection = $connection;
|
||||
$this->layers = $layers;
|
||||
$this->tileProviders = $tileProviders;
|
||||
$this->translator = $translator;
|
||||
$this->amenities = $amenities;
|
||||
$this->labelRenderer = $labelRenderer;
|
||||
$this->fileFormats = $fileFormats;
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
$this->backendAdapter = $backendAdapter;
|
||||
$this->backendUser = $backendUser;
|
||||
$this->stateButtonCallbackListener = $stateButtonCallbackListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the permissions.
|
||||
*
|
||||
* @param DataContainer $dataContainer Data container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws AccessDeniedException If permissions are not granted.
|
||||
*/
|
||||
public function checkPermissions(DataContainer $dataContainer): void
|
||||
{
|
||||
if ($this->backendUser->isAdmin) {
|
||||
return;
|
||||
}
|
||||
|
||||
$action = Input::get('act');
|
||||
$permission = $this->determinePermission($action);
|
||||
|
||||
if ($permission && !$this->backendUser->hasAccess($permission, 'leaflet_layer_permissions')) {
|
||||
throw new AccessDeniedException(
|
||||
sprintf('Permission "%s" not granted to access layer "%s"', $permission, $dataContainer->id)
|
||||
);
|
||||
}
|
||||
|
||||
$this->getDefinition()->set(['list', 'sorting', 'root'], $this->backendUser->leaflet_layers);
|
||||
|
||||
$layerId = $this->determineLayerId();
|
||||
if ($layerId && !$this->backendUser->hasAccess($layerId, 'leaflet_layers')) {
|
||||
throw new AccessDeniedException(
|
||||
sprintf('User "%s" not allowed to access layer "%s"', $this->backendUser->id, $layerId)
|
||||
);
|
||||
}
|
||||
|
||||
if (!$this->backendUser->hasAccess(LayerModel::PERMISSION_CREATE, 'leaflet_layer_permissions')) {
|
||||
$this->getDefinition()->set(['config', 'closed'], true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,6 +368,148 @@ class LayerDcaListener extends AbstractListener
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the edit button.
|
||||
*
|
||||
* @param array $row Current row.
|
||||
* @param string $href The button href.
|
||||
* @param string $label The button label.
|
||||
* @param string $title The button title.
|
||||
* @param string $icon The button icon.
|
||||
* @param string $attributes Optional attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateEditButton($row, $href, $label, $title, $icon, $attributes): string
|
||||
{
|
||||
if ($this->backendUser->hasAccess('edit', 'leaflet_layer_permissions')) {
|
||||
return $this->generateButton($row, $href, $label, $title, $icon, $attributes);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the cut button.
|
||||
*
|
||||
* @param array $row Current row.
|
||||
* @param string $href The button href.
|
||||
* @param string $label The button label.
|
||||
* @param string $title The button title.
|
||||
* @param string $icon The button icon.
|
||||
* @param string $attributes Optional attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateCutButton($row, $href, $label, $title, $icon, $attributes): string
|
||||
{
|
||||
if ($this->backendUser->hasAccess('edit', 'leaflet_layer_permissions')) {
|
||||
return $this->generateButton($row, $href, $label, $title, $icon, $attributes);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the copy button.
|
||||
*
|
||||
* @param array $row Current row.
|
||||
* @param string $href The button href.
|
||||
* @param string $label The button label.
|
||||
* @param string $title The button title.
|
||||
* @param string $icon The button icon.
|
||||
* @param string $attributes Optional attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateCopyButton($row, $href, $label, $title, $icon, $attributes): string
|
||||
{
|
||||
if ($this->backendUser->hasAccess('create', 'leaflet_layer_permissions')) {
|
||||
return $this->generateButton($row, $href, $label, $title, $icon, $attributes);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the toggle button.
|
||||
*
|
||||
* @param array $row Current data row.
|
||||
* @param string|null $href Button link.
|
||||
* @param string|null $label Button label.
|
||||
* @param string|null $title Button title.
|
||||
* @param string|null $icon Enabled button icon.
|
||||
* @param string|null $attributes Html attributes as string.
|
||||
* @param string $tableName Table name.
|
||||
* @param array|null $rootIds Root ids.
|
||||
* @param array|null $childRecordIds Child record ids.
|
||||
* @param bool $circularReference Circular reference flag.
|
||||
* @param string|null $previous Previous button name.
|
||||
* @param string|null $next Next button name.
|
||||
* @param DataContainer $dataContainer Data container driver.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
|
||||
*/
|
||||
public function generateToggleButton(
|
||||
array $row,
|
||||
$href,
|
||||
$label,
|
||||
$title,
|
||||
$icon,
|
||||
$attributes,
|
||||
string $tableName,
|
||||
$rootIds,
|
||||
$childRecordIds,
|
||||
bool $circularReference,
|
||||
$previous,
|
||||
$next,
|
||||
$dataContainer
|
||||
): string {
|
||||
if ($this->backendUser->hasAccess('edit', 'leaflet_layer_permissions')) {
|
||||
return $this->stateButtonCallbackListener->handleButtonCallback(
|
||||
$row,
|
||||
$href,
|
||||
$label,
|
||||
$title,
|
||||
$icon,
|
||||
$attributes,
|
||||
$tableName,
|
||||
$rootIds,
|
||||
$childRecordIds,
|
||||
$circularReference,
|
||||
$previous,
|
||||
$next,
|
||||
$dataContainer
|
||||
);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the edit button.
|
||||
*
|
||||
* @param array $row Current row.
|
||||
* @param string $href The button href.
|
||||
* @param string $label The button label.
|
||||
* @param string $title The button title.
|
||||
* @param string $icon The button icon.
|
||||
* @param string $attributes Optional attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateDeleteButton($row, $href, $label, $title, $icon, $attributes): string
|
||||
{
|
||||
if ($this->backendUser->hasAccess('delete', 'leaflet_layer_permissions')) {
|
||||
return $this->generateButton($row, $href, $label, $title, $icon, $attributes);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the markers button.
|
||||
*
|
||||
@@ -324,6 +528,10 @@ class LayerDcaListener extends AbstractListener
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!$this->backendUser->hasAccess('data', 'leaflet_layer_permissions')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->generateButton($row, $href, $label, $title, $icon, $attributes);
|
||||
}
|
||||
|
||||
@@ -345,6 +553,10 @@ class LayerDcaListener extends AbstractListener
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!$this->backendUser->hasAccess('data', 'leaflet_layer_permissions')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->generateButton($row, $href, $label, $title, $icon, $attributes);
|
||||
}
|
||||
|
||||
@@ -522,4 +734,82 @@ class LayerDcaListener extends AbstractListener
|
||||
Image::getHtml($icon, $label, $attributes)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine permission for current action.
|
||||
*
|
||||
* @param string|null $action Given action.
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
private function determinePermission(?string $action): ?string
|
||||
{
|
||||
$permission = null;
|
||||
|
||||
switch ($action) {
|
||||
case 'edit':
|
||||
case 'toggle':
|
||||
case 'editAll':
|
||||
case 'overrideAll':
|
||||
case 'cutAll':
|
||||
return LayerModel::PERMISSION_EDIT;
|
||||
|
||||
case 'delete':
|
||||
case 'deleteAll':
|
||||
return LayerModel::PERMISSION_DELETE;
|
||||
|
||||
case 'copyAll':
|
||||
return LayerModel::PERMISSION_CREATE;
|
||||
|
||||
case 'paste':
|
||||
$mode = Input::get('mode');
|
||||
|
||||
switch ($mode) {
|
||||
case 'create':
|
||||
return LayerModel::PERMISSION_CREATE;
|
||||
|
||||
case 'cut':
|
||||
return LayerModel::PERMISSION_EDIT;
|
||||
|
||||
default:
|
||||
return $permission;
|
||||
}
|
||||
|
||||
// Comment just to please phpcs
|
||||
default:
|
||||
return $permission;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine the layer id.
|
||||
*
|
||||
* @return int|null
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
private function determineLayerId(): ?int
|
||||
{
|
||||
// Check the current action
|
||||
switch (Input::get('act')) {
|
||||
case 'edit':
|
||||
case 'delete':
|
||||
case 'paste':
|
||||
case 'show':
|
||||
return (int) Input::get('id');
|
||||
|
||||
case 'editAll':
|
||||
case 'deleteAll':
|
||||
case 'overrideAll':
|
||||
case 'cutAll':
|
||||
case 'copyAll':
|
||||
return (int) CURRENT_ID;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ class LeafletDcaListener
|
||||
$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 $this->templateEngine->render('toolkit:be:be_leaflet_geocode.html5', $data);
|
||||
|
||||
@@ -15,14 +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.
|
||||
@@ -52,19 +58,70 @@ class MapDcaListener extends AbstractListener
|
||||
*/
|
||||
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, RepositoryManager $repositoryManager)
|
||||
{
|
||||
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')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,10 +12,13 @@
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||
|
||||
use Contao\Controller;
|
||||
use Contao\BackendUser;
|
||||
use Contao\CoreBundle\Exception\AccessDeniedException;
|
||||
use Contao\Input;
|
||||
use Contao\StringUtil;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
||||
@@ -41,16 +44,48 @@ class MarkerDcaListener
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Backend user.
|
||||
*
|
||||
* @var BackendUser
|
||||
*/
|
||||
private $backendUser;
|
||||
|
||||
/**
|
||||
* MarkerDcaListener constructor.
|
||||
*
|
||||
* @param Connection $connection Database connection.
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
* @param BackendUser $backendUser Backend user.
|
||||
*/
|
||||
public function __construct(Connection $connection, RepositoryManager $repositoryManager)
|
||||
public function __construct(Connection $connection, RepositoryManager $repositoryManager, BackendUser $backendUser)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
$this->backendUser = $backendUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check permissions.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws AccessDeniedException When permission is not granted.
|
||||
*/
|
||||
public function checkPermissions(): void
|
||||
{
|
||||
if (!$this->backendUser->hasAccess(LayerModel::PERMISSION_DATA, 'leaflet_layer_permissions')) {
|
||||
throw new AccessDeniedException(
|
||||
sprintf('User "%s" not allowed to access layer data.', $this->backendUser->id)
|
||||
);
|
||||
}
|
||||
|
||||
$layerId = $this->determineLayerId();
|
||||
if ($layerId && !$this->backendUser->hasAccess($layerId, 'leaflet_layers')) {
|
||||
throw new AccessDeniedException(
|
||||
sprintf('User "%s" not allowed to access layer "%s"', $this->backendUser->id, $layerId)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,4 +200,25 @@ class MarkerDcaListener
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the layer id.
|
||||
*
|
||||
* @return int|null
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
private function determineLayerId(): ?int
|
||||
{
|
||||
// Check the current action
|
||||
switch (Input::get('act')) {
|
||||
case '':
|
||||
case 'create':
|
||||
case 'select':
|
||||
return (int) Input::get('id');
|
||||
|
||||
default:
|
||||
return (int) CURRENT_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
169
src/Listener/Dca/OperationsListener.php
Normal file
169
src/Listener/Dca/OperationsListener.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?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\Dca;
|
||||
|
||||
use Contao\Backend;
|
||||
use Contao\BackendUser;
|
||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
||||
|
||||
/**
|
||||
* Class OperationsListener
|
||||
*/
|
||||
final class OperationsListener
|
||||
{
|
||||
/**
|
||||
* Backend user.
|
||||
*
|
||||
* @var BackendUser
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* OperationsListener constructor.
|
||||
*
|
||||
* @param BackendUser $user Backend user.
|
||||
*/
|
||||
public function __construct(BackendUser $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the style operation.
|
||||
*
|
||||
* @param string $href Button link.
|
||||
* @param string $label Button label.
|
||||
* @param string $title Button title.
|
||||
* @param string $class Button icon class.
|
||||
* @param string $attributes Html attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function styleOperation(
|
||||
string $href,
|
||||
string $label,
|
||||
string $title,
|
||||
string $class,
|
||||
string $attributes
|
||||
): string {
|
||||
return $this->renderIfPermissionIsGranted(StyleModel::getTable(), $href, $label, $title, $class, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the icon operation.
|
||||
*
|
||||
* @param string $href Button link.
|
||||
* @param string $label Button label.
|
||||
* @param string $title Button title.
|
||||
* @param string $class Button icon class.
|
||||
* @param string $attributes Html attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function iconOperation(
|
||||
string $href,
|
||||
string $label,
|
||||
string $title,
|
||||
string $class,
|
||||
string $attributes
|
||||
): string {
|
||||
return $this->renderIfPermissionIsGranted(IconModel::getTable(), $href, $label, $title, $class, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the popup operation.
|
||||
*
|
||||
* @param string $href Button link.
|
||||
* @param string $label Button label.
|
||||
* @param string $title Button title.
|
||||
* @param string $class Button icon class.
|
||||
* @param string $attributes Html attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function popupOperation(
|
||||
string $href,
|
||||
string $label,
|
||||
string $title,
|
||||
string $class,
|
||||
string $attributes
|
||||
): string {
|
||||
return $this->renderIfPermissionIsGranted(PopupModel::getTable(), $href, $label, $title, $class, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user has permission to access the leaflet table.
|
||||
*
|
||||
* @param string $permission The table permission.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function hasPermission(string $permission): bool
|
||||
{
|
||||
return (bool) $this->user->hasAccess($permission, 'leaflet_tables');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the style operation.
|
||||
*
|
||||
* @param string $permission Table permission to check.
|
||||
* @param string $href Button link.
|
||||
* @param string $label Button label.
|
||||
* @param string $title Button title.
|
||||
* @param string $class Button icon class.
|
||||
* @param string $attributes Html attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function renderIfPermissionIsGranted(
|
||||
string $permission,
|
||||
string $href,
|
||||
string $label,
|
||||
string $title,
|
||||
string $class,
|
||||
string $attributes
|
||||
): string {
|
||||
if ($this->hasPermission($permission)) {
|
||||
return $this->render($href, $label, $title, $class, $attributes);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a button.
|
||||
*
|
||||
* @param string $href Button link.
|
||||
* @param string $label Button label.
|
||||
* @param string $title Button title.
|
||||
* @param string $class Button icon class.
|
||||
* @param string $attributes Html attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function render(string $href, string $label, string $title, string $class, string $attributes): string
|
||||
{
|
||||
return sprintf(
|
||||
' <a href="%s" title="%s" class="%s" %s>%s</a>',
|
||||
Backend::addToUrl($href),
|
||||
$title,
|
||||
$class,
|
||||
$attributes,
|
||||
$label
|
||||
);
|
||||
}
|
||||
}
|
||||
60
src/Listener/Dca/PopupDcaListener.php
Normal file
60
src/Listener/Dca/PopupDcaListener.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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\Dca;
|
||||
|
||||
use Contao\BackendUser;
|
||||
use Contao\CoreBundle\Exception\AccessDeniedException;
|
||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||
|
||||
/**
|
||||
* Class PopupDcaListener
|
||||
*/
|
||||
final class PopupDcaListener
|
||||
{
|
||||
/**
|
||||
* Backend user.
|
||||
*
|
||||
* @var BackendUser
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* PopupDcaListener constructor.
|
||||
*
|
||||
* @param BackendUser $user Backend user.
|
||||
*/
|
||||
public function __construct(BackendUser $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the permission.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws AccessDeniedException If user has not the permission.
|
||||
*/
|
||||
public function checkPermission(): void
|
||||
{
|
||||
if ($this->user->hasAccess(PopupModel::getTable(), 'leaflet_tables')) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AccessDeniedException(
|
||||
sprintf('Access denied to "%s" for user "%s"', PopupModel::getTable(), $this->user->id)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||
|
||||
use Contao\BackendUser;
|
||||
use Contao\CoreBundle\Exception\AccessDeniedException;
|
||||
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
||||
|
||||
/**
|
||||
* Class StyleDcaListener.
|
||||
*
|
||||
@@ -21,6 +25,13 @@ namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||
*/
|
||||
class StyleDcaListener
|
||||
{
|
||||
/**
|
||||
* Backend user.
|
||||
*
|
||||
* @var BackendUser
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Style type options.
|
||||
*
|
||||
@@ -31,11 +42,31 @@ class StyleDcaListener
|
||||
/**
|
||||
* StyleDcaListener constructor.
|
||||
*
|
||||
* @param array $styles Styles options.
|
||||
* @param BackendUser $user Backend user.
|
||||
* @param array $styles Styles options.
|
||||
*/
|
||||
public function __construct(array $styles)
|
||||
public function __construct(BackendUser $user, array $styles)
|
||||
{
|
||||
$this->icons = $styles;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the permission.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws AccessDeniedException If user has not the permission.
|
||||
*/
|
||||
public function checkPermission(): void
|
||||
{
|
||||
if ($this->user->hasAccess(StyleModel::getTable(), 'leaflet_tables')) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AccessDeniedException(
|
||||
sprintf('Access denied to "%s" for user "%s"', StyleModel::getTable(), $this->user->id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
28
src/Listener/Dca/UserDcaListener.php
Normal file
28
src/Listener/Dca/UserDcaListener.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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\Dca;
|
||||
|
||||
/**
|
||||
* Class UserDcaListener
|
||||
*/
|
||||
final class UserDcaListener extends AbstractUserDcaListener
|
||||
{
|
||||
/**
|
||||
* Data container name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $name = 'tl_user';
|
||||
}
|
||||
28
src/Listener/Dca/UserGroupDcaListener.php
Normal file
28
src/Listener/Dca/UserGroupDcaListener.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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\Dca;
|
||||
|
||||
/**
|
||||
* Class UserGroupDcaListener
|
||||
*/
|
||||
final class UserGroupDcaListener extends AbstractUserDcaListener
|
||||
{
|
||||
/**
|
||||
* Data container name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $name = 'tl_user_group';
|
||||
}
|
||||
@@ -12,6 +12,10 @@
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||
|
||||
use Contao\BackendUser;
|
||||
use Contao\CoreBundle\Exception\AccessDeniedException;
|
||||
use Contao\Input;
|
||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
@@ -47,19 +51,55 @@ class VectorDcaListener extends AbstractListener
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Backend user.
|
||||
*
|
||||
* @var BackendUser
|
||||
*/
|
||||
private $backendUser;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param Manager $dcaManager Data container manager.
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
* @param BackendUser $backendUser Backend user.
|
||||
* @param array $vectors Vectors.
|
||||
*/
|
||||
public function __construct(Manager $dcaManager, RepositoryManager $repositoryManager, array $vectors)
|
||||
{
|
||||
public function __construct(
|
||||
Manager $dcaManager,
|
||||
RepositoryManager $repositoryManager,
|
||||
BackendUser $backendUser,
|
||||
array $vectors
|
||||
) {
|
||||
parent::__construct($dcaManager);
|
||||
|
||||
$this->vectors = $vectors;
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
$this->backendUser = $backendUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check permissions.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws AccessDeniedException When permission is not granted.
|
||||
*/
|
||||
public function checkPermissions(): void
|
||||
{
|
||||
if (!$this->backendUser->hasAccess(LayerModel::PERMISSION_DATA, 'leaflet_layer_permissions')) {
|
||||
throw new AccessDeniedException(
|
||||
sprintf('User "%s" not allowed to access layer data.', $this->backendUser->id)
|
||||
);
|
||||
}
|
||||
|
||||
$layerId = $this->determineLayerId();
|
||||
if ($layerId && !$this->backendUser->hasAccess($layerId, 'leaflet_layers')) {
|
||||
throw new AccessDeniedException(
|
||||
sprintf('User "%s" not allowed to access layer "%s"', $this->backendUser->id, $layerId)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,4 +154,25 @@ class VectorDcaListener extends AbstractListener
|
||||
|
||||
return $builder->getOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the layer id.
|
||||
*
|
||||
* @return int|null
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
private function determineLayerId(): ?int
|
||||
{
|
||||
// Check the current action
|
||||
switch (Input::get('act')) {
|
||||
case '':
|
||||
case 'create':
|
||||
case 'select':
|
||||
return (int) Input::get('id');
|
||||
|
||||
default:
|
||||
return (int) CURRENT_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||
|
||||
use Contao\Model;
|
||||
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
@@ -24,6 +23,7 @@ use Netzmacht\LeafletPHP\Definition;
|
||||
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.
|
||||
@@ -46,14 +46,23 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Router.
|
||||
*
|
||||
* @var RouterInterface
|
||||
*/
|
||||
private $router;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
* @param RouterInterface $router Router.
|
||||
*/
|
||||
public function __construct(RepositoryManager $repositoryManager)
|
||||
public function __construct(RepositoryManager $repositoryManager, RouterInterface $router)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
$this->router = $router;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -93,7 +102,7 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
|
||||
return [
|
||||
$this->getElementId($model, $elementId),
|
||||
RequestUrl::create($model->id, null, null, $request),
|
||||
$this->generateUrl((int) $model->id, $request),
|
||||
[],
|
||||
$layer,
|
||||
];
|
||||
@@ -101,7 +110,7 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
|
||||
return [
|
||||
$this->getElementId($model, $elementId),
|
||||
RequestUrl::create($model->id, null, null, $request),
|
||||
$this->generateUrl((int) $model->id, $request),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -176,10 +185,37 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
{
|
||||
$repository = $this->repositoryManager->getRepository(MarkerModel::class);
|
||||
|
||||
if ($model->boundsMode == 'fit') {
|
||||
if ($model->boundsMode === 'fit') {
|
||||
return $repository->findByFilter($model->id, $request->getFilter());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||
|
||||
use Contao\Model;
|
||||
use Contao\Model\Collection;
|
||||
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
@@ -25,6 +24,7 @@ use Netzmacht\LeafletPHP\Definition;
|
||||
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 VectorsLayerMapper maps the layer model for the Vectors layer definition.
|
||||
@@ -47,14 +47,23 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Router.
|
||||
*
|
||||
* @var RouterInterface
|
||||
*/
|
||||
private $router;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
* @param RouterInterface $router Router
|
||||
*/
|
||||
public function __construct(RepositoryManager $repositoryManager)
|
||||
public function __construct(RepositoryManager $repositoryManager, RouterInterface $router)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
$this->router = $router;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -101,7 +110,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
|
||||
return [
|
||||
$this->getElementId($model, $elementId),
|
||||
RequestUrl::create($model->id, null, null, $request),
|
||||
$this->generateUrl((int) $model->id, $request),
|
||||
[],
|
||||
$layer,
|
||||
];
|
||||
@@ -109,7 +118,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
|
||||
return [
|
||||
$this->getElementId($model, $elementId),
|
||||
RequestUrl::create($model->id, null, null, $request),
|
||||
$this->generateUrl((int) $model->id, $request),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -202,4 +211,31 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
$definition->setOnEachFeature(new Expression($model->onEachFeature));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,14 @@ use Contao\Model\Collection;
|
||||
*/
|
||||
class LayerModel extends AbstractActiveModel
|
||||
{
|
||||
public const PERMISSION_EDIT = 'edit';
|
||||
|
||||
public const PERMISSION_CREATE = 'create';
|
||||
|
||||
public const PERMISSION_DELETE = 'delete';
|
||||
|
||||
public const PERMISSION_DATA = 'data';
|
||||
|
||||
/**
|
||||
* Model table.
|
||||
*
|
||||
|
||||
@@ -12,9 +12,12 @@
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Model;
|
||||
|
||||
use Contao\Model\Collection;
|
||||
use Netzmacht\Contao\Leaflet\Filter\BboxFilter;
|
||||
use Netzmacht\Contao\Leaflet\Filter\DistanceFilter;
|
||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
||||
use Netzmacht\LeafletPHP\Value\LatLngBounds;
|
||||
use function var_dump;
|
||||
|
||||
/**
|
||||
* Class MarkerModel for the tl_leaflet_marker table.
|
||||
@@ -33,21 +36,35 @@ class MarkerModel extends AbstractActiveModel
|
||||
/**
|
||||
* Find by a filter.
|
||||
*
|
||||
* @param int $pid The parent id.
|
||||
* @param Filter $filter The filter.
|
||||
* @param int $pid The parent id.
|
||||
* @param Filter|null $filter The filter.
|
||||
*
|
||||
* @return \Contao\Model\Collection|null
|
||||
* @return Collection|null
|
||||
*/
|
||||
public static function findByFilter($pid, Filter $filter = null)
|
||||
public static function findByFilter($pid, ?Filter $filter = null)
|
||||
{
|
||||
if (!$filter) {
|
||||
return static::findActiveBy('pid', $pid, ['order' => 'sorting']);
|
||||
$table = static::getTable();
|
||||
|
||||
return static::findBy(
|
||||
[
|
||||
$table . '.active=1',
|
||||
$table . '.pid=?',
|
||||
$table . '.latitude>0',
|
||||
$table . '.longitude>0',
|
||||
],
|
||||
[$pid],
|
||||
['order' => 'sorting']
|
||||
);
|
||||
}
|
||||
|
||||
switch ($filter->getName()) {
|
||||
case 'bbox':
|
||||
switch (true) {
|
||||
case $filter instanceof BboxFilter:
|
||||
return static::findByBBoxFilter($pid, $filter);
|
||||
|
||||
case $filter instanceof DistanceFilter:
|
||||
return static::findByDistanceFilter($pid, $filter);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -59,15 +76,16 @@ class MarkerModel extends AbstractActiveModel
|
||||
* @param int $pid The layer id.
|
||||
* @param BboxFilter $filter The bbox filter.
|
||||
*
|
||||
* @return \Contao\Model\Collection|null
|
||||
* @return Collection|null|MarkerModel[]
|
||||
*/
|
||||
public static function findByBBoxFilter($pid, BboxFilter $filter)
|
||||
{
|
||||
$table = static::getTable();
|
||||
$columns = [
|
||||
'active=1',
|
||||
'pid=?',
|
||||
'latitude > ? AND latitude < ?',
|
||||
'longitude > ? AND longitude < ?',
|
||||
$table . '.active=1',
|
||||
$table . '.pid=?',
|
||||
$table . '.latitude > ? AND ' . $table . '.latitude < ?',
|
||||
$table . '.longitude > ? AND ' . $table . '.longitude < ?',
|
||||
];
|
||||
|
||||
/** @var LatLngBounds $bounds */
|
||||
@@ -80,6 +98,39 @@ class MarkerModel extends AbstractActiveModel
|
||||
$bounds->getNorthEast()->getLongitude(),
|
||||
];
|
||||
|
||||
return static::findBy($columns, $values, ['order' => 'sorting']);
|
||||
return static::findBy($columns, $values, ['order' => $table . '.sorting']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find marker by distance filter.
|
||||
*
|
||||
* @param int $pid The layer id.
|
||||
* @param DistanceFilter $filter THe distance filter.
|
||||
*
|
||||
* @return Collection|null|MarkerModel[]
|
||||
*/
|
||||
public static function findByDistanceFilter($pid, DistanceFilter $filter): ?Collection
|
||||
{
|
||||
$table = static::getTable();
|
||||
$query = <<<SQL
|
||||
round(
|
||||
sqrt(
|
||||
power( 2 * pi() / 360 * (? - {$table}.latitude) * 6371,2)
|
||||
+ power( 2 * pi() / 360 * (? - {$table}.longitude) * 6371 * COS( 2 * pi() / 360 * (? + {$table}.latitude) * 0.5 ),2)
|
||||
)
|
||||
) <= ?
|
||||
SQL;
|
||||
|
||||
$center = $filter->getCenter();
|
||||
$latitude = $center->getLatitude();
|
||||
$longitude = $center->getLongitude();
|
||||
$values = [$pid, $latitude, $longitude, $latitude, $filter->getRadius()];
|
||||
$columns = [
|
||||
$table . '.active=1',
|
||||
$table . '.pid=?',
|
||||
$query
|
||||
];
|
||||
|
||||
return static::findBy($columns, $values, ['order' => $table . '.sorting']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user