mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-29 11:33:46 +01:00
Compare commits
30 Commits
3.0.0-alph
...
3.0.0-alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
099cd6ca9d | ||
|
|
86fb4f4e12 | ||
|
|
ae4d9cec13 | ||
|
|
08dea6e1da | ||
|
|
ef7b493b2d | ||
|
|
ce9de6ded3 | ||
|
|
7498aef141 | ||
|
|
28adc54d36 | ||
|
|
451d13fe98 | ||
|
|
a4192b4b1a | ||
|
|
7741f44428 | ||
|
|
0716354952 | ||
|
|
dd23d386eb | ||
|
|
edb4ac9eeb | ||
|
|
5501887231 | ||
|
|
60306459d2 | ||
|
|
c465b724f4 | ||
|
|
6ded7441d9 | ||
|
|
ae5fe11d20 | ||
|
|
8dbe464ca8 | ||
|
|
d261e8b4ba | ||
|
|
57fe57b8ea | ||
|
|
46e6dcc2fa | ||
|
|
01b3962b78 | ||
|
|
734aecf738 | ||
|
|
50465e4026 | ||
|
|
0abc4676f1 | ||
|
|
d1f26056e9 | ||
|
|
31a5cc40a5 | ||
|
|
59df74c3f9 |
16
CHANGELOG.md
Normal file
16
CHANGELOG.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Changelog
|
||||||
|
=========
|
||||||
|
|
||||||
|
3.0.0-alpha1 (2017-10-19)
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/netzmacht/contao-leaflet-maps/compare/3.0.0-alpha1...2.0.0-alpha2)
|
||||||
|
|
||||||
|
Implemented enhancements
|
||||||
|
|
||||||
|
- Refactor to a more service oriented architecture
|
||||||
|
- Use a proper template for the map templates (Customize templates has to be adjusted!)
|
||||||
|
- New file layer for gpx,kml,wkt,topojson,geojson files added
|
||||||
|
- Bypass filesystem cache in debug mode
|
||||||
|
- Changelog added
|
||||||
27
README.md
27
README.md
@@ -17,17 +17,19 @@ Features
|
|||||||
|
|
||||||
- Define Leaflet maps with multiple layers.
|
- Define Leaflet maps with multiple layers.
|
||||||
- Manage map controls
|
- Manage map controls
|
||||||
- [Layers control](http://leafletjs.com/reference-1.0.0.html#control-layers)
|
- [Layers control](http://leafletjs.com/reference-1.2.0.html#control-layers)
|
||||||
- [Zoom control](http://leafletjs.com/reference-1.0.0.html#control-zoom)
|
- [Zoom control](http://leafletjs.com/reference-1.2.0.html#control-zoom)
|
||||||
- [Scale control]((http://leafletjs.com/reference-1.0.0.html#control-scale))
|
- [Scale control]((http://leafletjs.com/reference-1.2.0.html#control-scale))
|
||||||
- [Attribution control](http://leafletjs.com/reference-1.0.0.html#control-attribution)
|
- [Attribution control](http://leafletjs.com/reference-1.2.0.html#control-attribution)
|
||||||
- [Loading control](https://github.com/ebrelsford/Leaflet.loading)
|
- [Loading control](https://github.com/ebrelsford/Leaflet.loading)
|
||||||
- Manage layers
|
- Manage layers
|
||||||
- [Tile provider](https://github.com/leaflet-extras/leaflet-providers)
|
- [Tile provider](https://github.com/leaflet-extras/leaflet-providers)
|
||||||
- Markers - A set of [markers](http://leafletjs.com/reference-1.0.0.html#marker)
|
- Markers - A set of [markers](http://leafletjs.com/reference-1.2.0.html#marker)
|
||||||
- Vectors - A set of [vectors](http://leafletjs.com/reference-1.0.0.html)
|
- Vectors - A set of [vectors](http://leafletjs.com/reference-1.2.0.html)
|
||||||
- Groups - A group of layers
|
- Groups - A group of layers
|
||||||
- Reference - A link to another layer
|
- Reference - A link to another layer
|
||||||
|
- [Markercluster](https://github.com/Leaflet/Leaflet.markercluster)
|
||||||
|
- External geo data files (gpx,kml,wkt,geojson,topojson)
|
||||||
- Manage marker icons
|
- Manage marker icons
|
||||||
- Manage vector styles
|
- Manage vector styles
|
||||||
- Optional deferred ajax loading of layer data
|
- Optional deferred ajax loading of layer data
|
||||||
@@ -36,11 +38,22 @@ Features
|
|||||||
- Autoloading of required assets.
|
- Autoloading of required assets.
|
||||||
- [Layer for MetaModels](https://github.com/netzmacht/contao-leaflet-metamodels)
|
- [Layer for MetaModels](https://github.com/netzmacht/contao-leaflet-metamodels)
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
---------
|
||||||
|
|
||||||
|
View the [CHANGELOG.md](CHANGELOG.md) for the latest changes.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
- Contao 4.4
|
||||||
|
- PHP >= 7.0
|
||||||
|
|
||||||
Install
|
Install
|
||||||
-------
|
-------
|
||||||
|
|
||||||
```
|
```
|
||||||
$ php composer.phar require netzmacht/contao-leaflet-maps:~2.0
|
$ php composer.phar require netzmacht/contao-leaflet-maps:~3.0
|
||||||
```
|
```
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
"contao/core-bundle": "~4.4",
|
"contao/core-bundle": "~4.4",
|
||||||
"netzmacht/contao-leaflet-libraries": "^1.0",
|
"netzmacht/contao-leaflet-libraries": "^1.0",
|
||||||
"netzmacht/php-javascript-builder": "^1.0",
|
"netzmacht/php-javascript-builder": "^1.0",
|
||||||
"netzmacht/php-leaflet": "^1.0.1",
|
"netzmacht/php-leaflet": "^1.0.2",
|
||||||
"netzmacht/contao-toolkit": "^3.0@dev",
|
"netzmacht/contao-toolkit": "~3.0@beta",
|
||||||
"contao-community-alliance/meta-palettes": "^1.5",
|
"contao-community-alliance/meta-palettes": "^1.5",
|
||||||
"menatwork/contao-multicolumnwizard": "^3.2",
|
"menatwork/contao-multicolumnwizard": "^3.2",
|
||||||
"doctrine/cache": "^1.0"
|
"doctrine/cache": "^1.0"
|
||||||
|
|||||||
18
js/Contao.js
18
js/Contao.js
@@ -124,8 +124,22 @@ L.Contao = L.Evented.extend({
|
|||||||
* @param map Pass a map object so that the data loading events are passed to the map.
|
* @param map Pass a map object so that the data loading events are passed to the map.
|
||||||
*/
|
*/
|
||||||
load: function (hash, type, options, customLayer, map) {
|
load: function (hash, type, options, customLayer, map) {
|
||||||
var url = this.createRequestUrl(hash, map),
|
var url = this.createRequestUrl(hash, map);
|
||||||
layer = omnivore[type](url, options, customLayer);
|
|
||||||
|
return this.loadFile(url, type, options, customLayer, map);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load data from an url into a layer using omnivore.
|
||||||
|
*
|
||||||
|
* @param url A file url.
|
||||||
|
* @param type The response content format.
|
||||||
|
* @param options Parser options
|
||||||
|
* @param customLayer optional custom layer.
|
||||||
|
* @param map Pass a map object so that the data loading events are passed to the map.
|
||||||
|
*/
|
||||||
|
loadFile: function (url, type, options, customLayer, map) {
|
||||||
|
var layer = omnivore[type](url, options, customLayer);
|
||||||
|
|
||||||
if (map) {
|
if (map) {
|
||||||
// Required because Control.Loading tries to get _leafet_id which is created here.
|
// Required because Control.Loading tries to get _leafet_id which is created here.
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ class About
|
|||||||
return array_map(
|
return array_map(
|
||||||
function ($library) {
|
function ($library) {
|
||||||
$library = array_merge(
|
$library = array_merge(
|
||||||
array(
|
[
|
||||||
'homepage' => null,
|
'homepage' => null,
|
||||||
'version' => null,
|
'version' => null,
|
||||||
),
|
],
|
||||||
$library
|
$library
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -86,30 +86,30 @@ class About
|
|||||||
$lockFile = TL_ROOT . '/composer.lock';
|
$lockFile = TL_ROOT . '/composer.lock';
|
||||||
|
|
||||||
if (!file_exists($extFile) || !file_exists($lockFile)) {
|
if (!file_exists($extFile) || !file_exists($lockFile)) {
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$extension = json_decode(file_get_contents($extFile), true);
|
$extension = json_decode(file_get_contents($extFile), true);
|
||||||
$installed = json_decode(file_get_contents($lockFile), true);
|
$installed = json_decode(file_get_contents($lockFile), true);
|
||||||
$deps = array();
|
$deps = [];
|
||||||
$version = null;
|
$version = null;
|
||||||
|
|
||||||
foreach ($installed['packages'] as $package) {
|
foreach ($installed['packages'] as $package) {
|
||||||
if ($package['name'] === 'netzmacht/contao-leaflet-maps') {
|
if ($package['name'] === 'netzmacht/contao-leaflet-maps') {
|
||||||
$version = $package['version'];
|
$version = $package['version'];
|
||||||
} elseif (isset($extension['require'][$package['name']])) {
|
} elseif (isset($extension['require'][$package['name']])) {
|
||||||
$deps[] = array(
|
$deps[] = [
|
||||||
'name' => $package['name'],
|
'name' => $package['name'],
|
||||||
'version' => $package['version'],
|
'version' => $package['version'],
|
||||||
'license' => !empty($package['license']) ? implode(', ', $package['license']) : '',
|
'license' => !empty($package['license']) ? implode(', ', $package['license']) : '',
|
||||||
'homepage' => sprintf(
|
'homepage' => sprintf(
|
||||||
'<a href="https://packagist.org/packages/%s" target="_blank">Visit packagist</a>',
|
'<a href="https://packagist.org/packages/%s" target="_blank">Visit packagist</a>',
|
||||||
$package['name']
|
$package['name']
|
||||||
)
|
),
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array($version, $deps);
|
return [$version, $deps];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
67
src/Backend/Renderer/Label/Layer/FileLabelRenderer.php
Normal file
67
src/Backend/Renderer/Label/Layer/FileLabelRenderer.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-2017 netzmacht David Molineus. All rights reserved.
|
||||||
|
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer;
|
||||||
|
|
||||||
|
use Contao\FilesModel;
|
||||||
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class FileLabelRenderer
|
||||||
|
*
|
||||||
|
* @package Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer
|
||||||
|
*/
|
||||||
|
class FileLabelRenderer extends AbstractLabelRenderer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FileLabelRenderer constructor.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
protected function getLayerType(): string
|
||||||
|
{
|
||||||
|
return 'file';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function render(array $row, string $label, Translator $translator): string
|
||||||
|
{
|
||||||
|
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||||
|
$file = $repository->findByPk($row['file']);
|
||||||
|
|
||||||
|
if ($file) {
|
||||||
|
$label .= ' <span class="tl_gray">(' . $file->path . ')</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $label;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||||||
namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer;
|
namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Model\MarkerModel;
|
use Netzmacht\Contao\Leaflet\Model\MarkerModel;
|
||||||
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,6 +25,23 @@ use Symfony\Component\Translation\TranslatorInterface as Translator;
|
|||||||
*/
|
*/
|
||||||
final class MarkersLabelRenderer extends AbstractLabelRenderer
|
final class MarkersLabelRenderer extends AbstractLabelRenderer
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FileLabelRenderer constructor.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -37,7 +55,8 @@ final class MarkersLabelRenderer extends AbstractLabelRenderer
|
|||||||
*/
|
*/
|
||||||
public function render(array $row, string $label, Translator $translator): string
|
public function render(array $row, string $label, Translator $translator): string
|
||||||
{
|
{
|
||||||
$count = MarkerModel::countBy('pid', $row['id']);
|
$repository = $this->repositoryManager->getRepository(MarkerModel::class);
|
||||||
|
$count = $repository->countBy(['pid=?'], [$row['pid']]);
|
||||||
$label .= sprintf(
|
$label .= sprintf(
|
||||||
'<span class="tl_gray"> (%s %s)</span>',
|
'<span class="tl_gray"> (%s %s)</span>',
|
||||||
$count,
|
$count,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ final class OverpassLabelRenderer extends AbstractLabelRenderer
|
|||||||
*/
|
*/
|
||||||
protected function getLayerType(): string
|
protected function getLayerType(): string
|
||||||
{
|
{
|
||||||
return 'vectors';
|
return 'overpass';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||||||
namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer;
|
namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,12 +25,29 @@ use Symfony\Component\Translation\TranslatorInterface as Translator;
|
|||||||
*/
|
*/
|
||||||
final class ReferenceLabelRenderer extends AbstractLabelRenderer
|
final class ReferenceLabelRenderer extends AbstractLabelRenderer
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FileLabelRenderer constructor.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getLayerType(): string
|
protected function getLayerType(): string
|
||||||
{
|
{
|
||||||
return 'vectors';
|
return 'reference';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +55,8 @@ final class ReferenceLabelRenderer extends AbstractLabelRenderer
|
|||||||
*/
|
*/
|
||||||
public function render(array $row, string $label, Translator $translator): string
|
public function render(array $row, string $label, Translator $translator): string
|
||||||
{
|
{
|
||||||
$reference = LayerModel::findByPk($row['reference']);
|
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||||
|
$reference = $repository->find((int) $row['reference']);
|
||||||
|
|
||||||
if ($reference) {
|
if ($reference) {
|
||||||
$label .= '<span class="tl_gray"> (' . $reference->title . ')</span>';
|
$label .= '<span class="tl_gray"> (' . $reference->title . ')</span>';
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||||||
namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer;
|
namespace Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Model\VectorModel;
|
use Netzmacht\Contao\Leaflet\Model\VectorModel;
|
||||||
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,6 +25,23 @@ use Symfony\Component\Translation\TranslatorInterface as Translator;
|
|||||||
*/
|
*/
|
||||||
final class VectorsLabelRenderer extends AbstractLabelRenderer
|
final class VectorsLabelRenderer extends AbstractLabelRenderer
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FileLabelRenderer constructor.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -37,7 +55,8 @@ final class VectorsLabelRenderer extends AbstractLabelRenderer
|
|||||||
*/
|
*/
|
||||||
public function render(array $row, string $label, Translator $translator): string
|
public function render(array $row, string $label, Translator $translator): string
|
||||||
{
|
{
|
||||||
$count = VectorModel::countBy('pid', $row['id']);
|
$repository = $this->repositoryManager->getRepository(VectorModel::class);
|
||||||
|
$count = $repository->countBy(['pid=?'], [$row['id']]);
|
||||||
$label .= sprintf(
|
$label .= sprintf(
|
||||||
'<span class="tl_gray"> (%s %s)</span>',
|
'<span class="tl_gray"> (%s %s)</span>',
|
||||||
$count,
|
$count,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class Plugin implements BundlePluginInterface
|
|||||||
return [
|
return [
|
||||||
BundleConfig::create(NetzmachtContaoLeafletBundle::class)
|
BundleConfig::create(NetzmachtContaoLeafletBundle::class)
|
||||||
->setLoadAfter([ContaoCoreBundle::class, NetzmachtContaoToolkitBundle::class])
|
->setLoadAfter([ContaoCoreBundle::class, NetzmachtContaoToolkitBundle::class])
|
||||||
->setReplace(['leaflet'])
|
->setReplace(['leaflet']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class NetzmachtContaoLeafletExtension extends Extension
|
|||||||
{
|
{
|
||||||
$loader = new YamlFileLoader(
|
$loader = new YamlFileLoader(
|
||||||
$container,
|
$container,
|
||||||
new FileLocator(dirname(__DIR__) .'/Resources/config')
|
new FileLocator(dirname(__DIR__) . '/Resources/config')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Common config, services and listeners
|
// Common config, services and listeners
|
||||||
@@ -49,5 +49,13 @@ class NetzmachtContaoLeafletExtension extends Extension
|
|||||||
$loader->load('mappers.yml');
|
$loader->load('mappers.yml');
|
||||||
$loader->load('encoders.yml');
|
$loader->load('encoders.yml');
|
||||||
$loader->load('layers.yml');
|
$loader->load('layers.yml');
|
||||||
|
|
||||||
|
if (!$container->hasDefinition('netzmacht.contao_leaflet.cache')) {
|
||||||
|
if ($container->getParameter('kernel.debug')) {
|
||||||
|
$container->setAlias('netzmacht.contao_leaflet.cache', 'netzmacht.contao_leaflet.cache.debug');
|
||||||
|
} else {
|
||||||
|
$container->setAlias('netzmacht.contao_leaflet.cache', 'netzmacht.contao_leaflet.cache.default');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Bundle;
|
namespace Netzmacht\Contao\Leaflet\Bundle;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass\RegisterLibrariesPass;
|
|
||||||
use Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass\RegisterDefinitionMapperPass;
|
use Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass\RegisterDefinitionMapperPass;
|
||||||
use Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass\RegisterEncodersPass;
|
use Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass\RegisterEncodersPass;
|
||||||
|
use Netzmacht\Contao\Leaflet\Bundle\DependencyInjection\Pass\RegisterLibrariesPass;
|
||||||
use Netzmacht\Contao\Toolkit\Bundle\DependencyInjection\Compiler\AddTaggedServicesAsArgumentPass;
|
use Netzmacht\Contao\Toolkit\Bundle\DependencyInjection\Compiler\AddTaggedServicesAsArgumentPass;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||||
|
|||||||
@@ -38,6 +38,13 @@ parameters:
|
|||||||
- 'circle'
|
- 'circle'
|
||||||
- 'circleMarker'
|
- 'circleMarker'
|
||||||
|
|
||||||
|
netzmacht.contao_leaflet.file_formats:
|
||||||
|
gpx: ['gpx']
|
||||||
|
kml: ['kml']
|
||||||
|
wkt: ['wkt']
|
||||||
|
geojson: ['json', 'geojson']
|
||||||
|
topojson: ['json', 'topojson']
|
||||||
|
|
||||||
# When creating a GeoJSON feature of a map object a feature.properties.model object is passed.
|
# When creating a GeoJSON feature of a map object a feature.properties.model object is passed.
|
||||||
# Define the properties you always want to set.
|
# Define the properties you always want to set.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -42,6 +42,6 @@ services:
|
|||||||
- { name: netzmacht.contao_leaflet.encoder }
|
- { name: netzmacht.contao_leaflet.encoder }
|
||||||
|
|
||||||
netzmacht.contao_leaflet.encoder.subscriber:
|
netzmacht.contao_leaflet.encoder.subscriber:
|
||||||
class: Netzmacht\Contao\Leaflet\Subscriber\EncoderSubscriber
|
class: Netzmacht\Contao\Leaflet\Encoder\Subscriber\EncoderSubscriber
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.encoder }
|
- { name: netzmacht.contao_leaflet.encoder }
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ parameters:
|
|||||||
extend: true
|
extend: true
|
||||||
fit: true
|
fit: true
|
||||||
|
|
||||||
|
file:
|
||||||
|
children: false
|
||||||
|
icon: 'bundles/netzmachtcontaoleaflet/img/file.png'
|
||||||
|
boundsMode:
|
||||||
|
extend: true
|
||||||
|
|
||||||
services:
|
services:
|
||||||
_defaults:
|
_defaults:
|
||||||
public: false
|
public: false
|
||||||
@@ -56,6 +62,8 @@ services:
|
|||||||
|
|
||||||
netzmacht.contao_leaflet.layer_label_renderer.markers:
|
netzmacht.contao_leaflet.layer_label_renderer.markers:
|
||||||
class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\MarkersLabelRenderer
|
class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\MarkersLabelRenderer
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
tags:
|
tags:
|
||||||
- { name: 'netzmacht.contao_leaflet.layer_label_renderer' }
|
- { name: 'netzmacht.contao_leaflet.layer_label_renderer' }
|
||||||
|
|
||||||
@@ -71,10 +79,21 @@ services:
|
|||||||
|
|
||||||
netzmacht.contao_leaflet.layer_label_renderer.reference:
|
netzmacht.contao_leaflet.layer_label_renderer.reference:
|
||||||
class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\ReferenceLabelRenderer
|
class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\ReferenceLabelRenderer
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
tags:
|
tags:
|
||||||
- { name: 'netzmacht.contao_leaflet.layer_label_renderer' }
|
- { name: 'netzmacht.contao_leaflet.layer_label_renderer' }
|
||||||
|
|
||||||
netzmacht.contao_leaflet.layer_label_renderer.vectors:
|
netzmacht.contao_leaflet.layer_label_renderer.vectors:
|
||||||
class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\VectorsLabelRenderer
|
class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\VectorsLabelRenderer
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
|
tags:
|
||||||
|
- { name: 'netzmacht.contao_leaflet.layer_label_renderer' }
|
||||||
|
|
||||||
|
netzmacht.contao_leaflet.layer_label_renderer.file:
|
||||||
|
class: Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\FileLabelRenderer
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
tags:
|
tags:
|
||||||
- { name: 'netzmacht.contao_leaflet.layer_label_renderer' }
|
- { name: 'netzmacht.contao_leaflet.layer_label_renderer' }
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ services:
|
|||||||
netzmacht.contao_leaflet.listeners.dca.leaflet:
|
netzmacht.contao_leaflet.listeners.dca.leaflet:
|
||||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\LeafletDcaListener
|
class: Netzmacht\Contao\Leaflet\Listener\Dca\LeafletDcaListener
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
|
- '@templating'
|
||||||
- '@filesystem'
|
- '@filesystem'
|
||||||
|
- '@netzmacht.contao_toolkit.contao.system_adapter'
|
||||||
- '%netzmacht.contao_leaflet.cache_dir%'
|
- '%netzmacht.contao_leaflet.cache_dir%'
|
||||||
|
|
||||||
netzmacht.contao_leaflet.listeners.dca.validator:
|
netzmacht.contao_leaflet.listeners.dca.validator:
|
||||||
@@ -14,6 +17,7 @@ services:
|
|||||||
netzmacht.contao_leaflet.listeners.dca.frontend_integration:
|
netzmacht.contao_leaflet.listeners.dca.frontend_integration:
|
||||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\FrontendIntegrationListener
|
class: Netzmacht\Contao\Leaflet\Listener\Dca\FrontendIntegrationListener
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '@translator'
|
- '@translator'
|
||||||
|
|
||||||
netzmacht.contao_leaflet.listeners.dca.map:
|
netzmacht.contao_leaflet.listeners.dca.map:
|
||||||
@@ -21,6 +25,8 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- '@netzmacht.contao_toolkit.dca.manager'
|
- '@netzmacht.contao_toolkit.dca.manager'
|
||||||
- '@database_connection'
|
- '@database_connection'
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
|
|
||||||
netzmacht.contao_leaflet.listeners.dca.control:
|
netzmacht.contao_leaflet.listeners.dca.control:
|
||||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\ControlDcaListener
|
class: Netzmacht\Contao\Leaflet\Listener\Dca\ControlDcaListener
|
||||||
@@ -34,21 +40,26 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- '@netzmacht.contao_toolkit.dca.manager'
|
- '@netzmacht.contao_toolkit.dca.manager'
|
||||||
- '@database_connection'
|
- '@database_connection'
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '@translator'
|
- '@translator'
|
||||||
- '@netzmacht.contao_leaflet.layer_label_renderer'
|
- '@netzmacht.contao_leaflet.layer_label_renderer'
|
||||||
|
- '@netzmacht.contao_toolkit.contao.backend_adapter'
|
||||||
- '%netzmacht.contao_leaflet.layers%'
|
- '%netzmacht.contao_leaflet.layers%'
|
||||||
- '%netzmacht.contao_leaflet.providers%'
|
- '%netzmacht.contao_leaflet.providers%'
|
||||||
- '%netzmacht.contao_leaflet.amenities%'
|
- '%netzmacht.contao_leaflet.amenities%'
|
||||||
|
- '%netzmacht.contao_leaflet.file_formats%'
|
||||||
|
|
||||||
netzmacht.contao_leaflet.listeners.dca.marker:
|
netzmacht.contao_leaflet.listeners.dca.marker:
|
||||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\MarkerDcaListener
|
class: Netzmacht\Contao\Leaflet\Listener\Dca\MarkerDcaListener
|
||||||
arguments:
|
arguments:
|
||||||
- '@database_connection'
|
- '@database_connection'
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
|
|
||||||
netzmacht.contao_leaflet.listeners.dca.vector:
|
netzmacht.contao_leaflet.listeners.dca.vector:
|
||||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\VectorDcaListener
|
class: Netzmacht\Contao\Leaflet\Listener\Dca\VectorDcaListener
|
||||||
arguments:
|
arguments:
|
||||||
- '@netzmacht.contao_toolkit.dca.manager'
|
- '@netzmacht.contao_toolkit.dca.manager'
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '%netzmacht.contao_leaflet.vectors%'
|
- '%netzmacht.contao_leaflet.vectors%'
|
||||||
|
|
||||||
netzmacht.contao_leaflet.listeners.dca.icon:
|
netzmacht.contao_leaflet.listeners.dca.icon:
|
||||||
@@ -61,15 +72,16 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- '%netzmacht.contao_leaflet.styles%'
|
- '%netzmacht.contao_leaflet.styles%'
|
||||||
|
|
||||||
netzmacht.contao_leaflet.listeners.geo_json_subscriber:
|
netzmacht.contao_leaflet.listeners.geo_json_listener:
|
||||||
class: Netzmacht\Contao\Leaflet\Subscriber\GeoJsonSubscriber
|
class: Netzmacht\Contao\Leaflet\Listener\GeoJsonListener
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '%netzmacht.contao_leaflet.feature_model_properties%'
|
- '%netzmacht.contao_leaflet.feature_model_properties%'
|
||||||
tags:
|
tags:
|
||||||
- { name: 'kernel.event_subscriber' }
|
- { name: 'kernel.event_listener', event: 'netzmacht.contao_leaflet.mapper.convert_to_geojson', method: 'handle' }
|
||||||
|
|
||||||
netzmacht.contao_leaflet.listeners.hash_subscriber:
|
netzmacht.contao_leaflet.listeners.hash_subscriber:
|
||||||
class: Netzmacht\Contao\Leaflet\Subscriber\HashSubscriber
|
class: Netzmacht\Contao\Leaflet\Listener\HashSubscriber
|
||||||
tags:
|
tags:
|
||||||
- { name: 'kernel.event_subscriber' }
|
- { name: 'kernel.event_subscriber' }
|
||||||
|
|
||||||
@@ -78,6 +90,7 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- '@netzmacht.contao_leaflet.map.assets'
|
- '@netzmacht.contao_leaflet.map.assets'
|
||||||
- '@netzmacht.contao_leaflet.definition.mapper'
|
- '@netzmacht.contao_leaflet.definition.mapper'
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '@netzmacht.contao_leaflet.libraries'
|
- '@netzmacht.contao_leaflet.libraries'
|
||||||
tags:
|
tags:
|
||||||
- { name: 'kernel.event_listener', event: 'netzmacht.contao_leaflet.get_javascript', method: 'onGetJavascriptEvent' }
|
- { name: 'kernel.event_listener', event: 'netzmacht.contao_leaflet.get_javascript', method: 'onGetJavascriptEvent' }
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ services:
|
|||||||
# Map mapper
|
# Map mapper
|
||||||
netzmacht.contao_leaflet.mapper.map:
|
netzmacht.contao_leaflet.mapper.map:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\MapMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\MapMapper
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
|
|
||||||
@@ -28,26 +30,36 @@ services:
|
|||||||
|
|
||||||
netzmacht.contao_leaflet.mapper.markers_layer:
|
netzmacht.contao_leaflet.mapper.markers_layer:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLayerMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLayerMapper
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
|
|
||||||
netzmacht.contao_leaflet.mapper.group_layer:
|
netzmacht.contao_leaflet.mapper.group_layer:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\GroupLayerMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Layer\GroupLayerMapper
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
|
|
||||||
netzmacht.contao_leaflet.mapper.vectors_layer:
|
netzmacht.contao_leaflet.mapper.vectors_layer:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
|
|
||||||
netzmacht.contao_leaflet.mapper.reference_layer:
|
netzmacht.contao_leaflet.mapper.reference_layer:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\ReferenceLayerMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Layer\ReferenceLayerMapper
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
|
|
||||||
netzmacht.contao_leaflet.mapper.overpass_layer:
|
netzmacht.contao_leaflet.mapper.overpass_layer:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\OverpassLayerMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Layer\OverpassLayerMapper
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
|
|
||||||
@@ -55,9 +67,16 @@ services:
|
|||||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\MarkerClusterLayerMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Layer\MarkerClusterLayerMapper
|
||||||
arguments:
|
arguments:
|
||||||
- '@netzmacht.contao_leaflet.map.assets'
|
- '@netzmacht.contao_leaflet.map.assets'
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leflet_maps.mapper }
|
- { name: netzmacht.contao_leflet_maps.mapper }
|
||||||
|
|
||||||
|
netzmacht.contao_leaflet.mapper.file_layer:
|
||||||
|
class: Netzmacht\Contao\Leaflet\Mapper\Layer\FileLayerMapper
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
|
tags:
|
||||||
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
|
|
||||||
# Control mappers
|
# Control mappers
|
||||||
netzmacht.contao_leaflet.mapper.zoom_control:
|
netzmacht.contao_leaflet.mapper.zoom_control:
|
||||||
@@ -82,6 +101,8 @@ services:
|
|||||||
|
|
||||||
netzmacht.contao_leaflet.mapper.loading_control:
|
netzmacht.contao_leaflet.mapper.loading_control:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Control\LoadingControlMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Control\LoadingControlMapper
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
|
|
||||||
@@ -95,6 +116,7 @@ services:
|
|||||||
netzmacht.contao_leaflet.mapper.polyline:
|
netzmacht.contao_leaflet.mapper.polyline:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
@@ -102,6 +124,7 @@ services:
|
|||||||
netzmacht.contao_leaflet.mapper.multi_polyline:
|
netzmacht.contao_leaflet.mapper.multi_polyline:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolylineMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolylineMapper
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
@@ -109,6 +132,7 @@ services:
|
|||||||
netzmacht.contao_leaflet.mapper.polygon:
|
netzmacht.contao_leaflet.mapper.polygon:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonMapper
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
@@ -116,6 +140,7 @@ services:
|
|||||||
netzmacht.contao_leaflet.mapper.multi_polygon:
|
netzmacht.contao_leaflet.mapper.multi_polygon:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolygonMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolygonMapper
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
@@ -123,6 +148,7 @@ services:
|
|||||||
netzmacht.contao_leaflet.mapper.circle:
|
netzmacht.contao_leaflet.mapper.circle:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMapper
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
@@ -130,6 +156,7 @@ services:
|
|||||||
netzmacht.contao_leaflet.mapper.circle_mapper:
|
netzmacht.contao_leaflet.mapper.circle_mapper:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMarkerMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMarkerMapper
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
@@ -137,6 +164,7 @@ services:
|
|||||||
netzmacht.contao_leaflet.mapper.rectangle_mapper:
|
netzmacht.contao_leaflet.mapper.rectangle_mapper:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\RectangleMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Vector\RectangleMapper
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
@@ -150,6 +178,8 @@ services:
|
|||||||
|
|
||||||
netzmacht.contao_leaflet.mapper.image_icon:
|
netzmacht.contao_leaflet.mapper.image_icon:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\Type\ImageIconMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\Type\ImageIconMapper
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
|
|
||||||
@@ -171,6 +201,7 @@ services:
|
|||||||
netzmacht.contao_leaflet.mapper.marker:
|
netzmacht.contao_leaflet.mapper.marker:
|
||||||
class: Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper
|
class: Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||||
tags:
|
tags:
|
||||||
- { name: netzmacht.contao_leaflet.mapper }
|
- { name: netzmacht.contao_leaflet.mapper }
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ services:
|
|||||||
- '@netzmacht.contao_leaflet.map.assets'
|
- '@netzmacht.contao_leaflet.map.assets'
|
||||||
- '@netzmacht.contao_leaflet.cache'
|
- '@netzmacht.contao_leaflet.cache'
|
||||||
- '@netzmacht.contao_leaflet.frontend.data_controller'
|
- '@netzmacht.contao_leaflet.frontend.data_controller'
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
|
- '@templating'
|
||||||
|
|
||||||
netzmacht.contao_leaflet.libraries:
|
netzmacht.contao_leaflet.libraries:
|
||||||
class: Netzmacht\Contao\Leaflet\Frontend\Assets\LibrariesConfiguration
|
class: Netzmacht\Contao\Leaflet\Frontend\Assets\LibrariesConfiguration
|
||||||
@@ -26,9 +28,6 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- '%netzmacht.contao_leaflet.filters%'
|
- '%netzmacht.contao_leaflet.filters%'
|
||||||
|
|
||||||
netzmacht.contao_leaflet.cache:
|
|
||||||
alias: 'netzmacht.contao_leaflet.cache.default'
|
|
||||||
|
|
||||||
netzmacht.contao_leaflet.cache.default:
|
netzmacht.contao_leaflet.cache.default:
|
||||||
class: Doctrine\Common\Cache\FilesystemCache
|
class: Doctrine\Common\Cache\FilesystemCache
|
||||||
arguments:
|
arguments:
|
||||||
@@ -86,7 +85,11 @@ services:
|
|||||||
netzmacht.contao_leaflet.frontend.element_factory:
|
netzmacht.contao_leaflet.frontend.element_factory:
|
||||||
class: Netzmacht\Contao\Leaflet\Frontend\ContentElement\MapElementFactory
|
class: Netzmacht\Contao\Leaflet\Frontend\ContentElement\MapElementFactory
|
||||||
arguments:
|
arguments:
|
||||||
- '@service_container'
|
- '@templating'
|
||||||
|
- '@translator'
|
||||||
|
- '@netzmacht.contao_leaflet.map.provider'
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
|
- '@netzmacht.contao_toolkit.contao.input_adapter'
|
||||||
tags:
|
tags:
|
||||||
- { name: 'netzmacht.contao_toolkit.component.content_element_factory' }
|
- { name: 'netzmacht.contao_toolkit.component.content_element_factory' }
|
||||||
- { name: 'netzmacht.contao_toolkit.component.content_element', alias: 'leaflet', category: 'includes' }
|
- { name: 'netzmacht.contao_toolkit.component.content_element', alias: 'leaflet', category: 'includes' }
|
||||||
@@ -94,7 +97,11 @@ services:
|
|||||||
netzmacht.contao_leaflet.frontend.module_factory:
|
netzmacht.contao_leaflet.frontend.module_factory:
|
||||||
class: Netzmacht\Contao\Leaflet\Frontend\Module\MapModuleFactory
|
class: Netzmacht\Contao\Leaflet\Frontend\Module\MapModuleFactory
|
||||||
arguments:
|
arguments:
|
||||||
- '@service_container'
|
- '@templating'
|
||||||
|
- '@translator'
|
||||||
|
- '@netzmacht.contao_leaflet.map.provider'
|
||||||
|
- '@netzmacht.contao_toolkit.repository_manager'
|
||||||
|
- '@netzmacht.contao_toolkit.contao.input_adapter'
|
||||||
tags:
|
tags:
|
||||||
- { name: 'netzmacht.contao_toolkit.component.frontend_module_factory' }
|
- { name: 'netzmacht.contao_toolkit.component.frontend_module_factory' }
|
||||||
- { name: 'netzmacht.contao_toolkit.component.frontend_module', alias: 'leaflet', category: 'includes' }
|
- { name: 'netzmacht.contao_toolkit.component.frontend_module', alias: 'leaflet', category: 'includes' }
|
||||||
|
|||||||
@@ -17,44 +17,42 @@
|
|||||||
array_insert(
|
array_insert(
|
||||||
$GLOBALS['BE_MOD'],
|
$GLOBALS['BE_MOD'],
|
||||||
1,
|
1,
|
||||||
array(
|
[
|
||||||
'leaflet' => array
|
'leaflet' => [
|
||||||
(
|
'leaflet_map' => [
|
||||||
'leaflet_map' => array
|
'tables' => [
|
||||||
(
|
|
||||||
'tables' => array
|
|
||||||
(
|
|
||||||
'tl_leaflet_map',
|
'tl_leaflet_map',
|
||||||
'tl_leaflet_control',
|
'tl_leaflet_control',
|
||||||
),
|
],
|
||||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/map.png',
|
'icon' => 'bundles/netzmachtcontaoleaflet/img/map.png',
|
||||||
'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/backend.css',
|
'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/backend.css',
|
||||||
),
|
],
|
||||||
'leaflet_layer' => array
|
'leaflet_layer' => [
|
||||||
(
|
'tables' => [
|
||||||
'tables' => array
|
|
||||||
(
|
|
||||||
'tl_leaflet_layer',
|
'tl_leaflet_layer',
|
||||||
'tl_leaflet_marker',
|
'tl_leaflet_marker',
|
||||||
'tl_leaflet_vector',
|
'tl_leaflet_vector',
|
||||||
'tl_leaflet_icon',
|
'tl_leaflet_icon',
|
||||||
'tl_leaflet_style',
|
'tl_leaflet_style',
|
||||||
'tl_leaflet_popup',
|
'tl_leaflet_popup',
|
||||||
),
|
],
|
||||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/layers.png',
|
'icon' => 'bundles/netzmachtcontaoleaflet/img/layers.png',
|
||||||
'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/backend.css',
|
'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/backend.css',
|
||||||
'javascript' => 'bundles/netzmachtcontaoleaflet/js/backend.js'
|
'javascript' => 'bundles/netzmachtcontaoleaflet/js/backend.js',
|
||||||
),
|
],
|
||||||
'leaflet_about' => array
|
'leaflet_about' => [
|
||||||
(
|
|
||||||
'callback' => Netzmacht\Contao\Leaflet\Backend\About::class,
|
'callback' => Netzmacht\Contao\Leaflet\Backend\About::class,
|
||||||
'icon' => 'bundles/netzmachtcontaoleaflet/img/about.png',
|
'icon' => 'bundles/netzmachtcontaoleaflet/img/about.png',
|
||||||
'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/about.css',
|
'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/about.css',
|
||||||
)
|
],
|
||||||
)
|
],
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (TL_MODE === 'BE') {
|
||||||
|
$GLOBALS['TL_CSS'][] = 'bundles/netzmachtcontaoleaflet/css/backend_hacks.css';
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Models.
|
* Models.
|
||||||
*/
|
*/
|
||||||
@@ -74,5 +72,5 @@ $GLOBALS['TL_MODELS']['tl_leaflet_vector'] = \Netzmacht\Contao\Leaflet\Model\Ve
|
|||||||
|
|
||||||
$GLOBALS['TL_HOOKS']['initializeSystem'][] = [
|
$GLOBALS['TL_HOOKS']['initializeSystem'][] = [
|
||||||
'netzmacht.contao_leaflet.listeners.register_libraries',
|
'netzmacht.contao_leaflet.listeners.register_libraries',
|
||||||
'onInitializeSystem'
|
'onInitializeSystem',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -217,6 +217,14 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
|
|||||||
'pointToLayer',
|
'pointToLayer',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'file extends default' => [
|
||||||
|
'+config' => ['boundsMode', 'fileFormat'],
|
||||||
|
'+expert' => [
|
||||||
|
'onEachFeature',
|
||||||
|
'pointToLayer',
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
'metasubselectpalettes' => [
|
'metasubselectpalettes' => [
|
||||||
@@ -227,6 +235,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
|
|||||||
'MapBox' => ['tile_provider_key'],
|
'MapBox' => ['tile_provider_key'],
|
||||||
'HERE' => ['tile_provider_key', 'tile_provider_code'],
|
'HERE' => ['tile_provider_key', 'tile_provider_code'],
|
||||||
],
|
],
|
||||||
|
'fileFormat' => [
|
||||||
|
'!' => ['file']
|
||||||
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
'metasubpalettes' => [
|
'metasubpalettes' => [
|
||||||
@@ -853,5 +864,37 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
|
|||||||
],
|
],
|
||||||
'sql' => 'mediumtext NULL',
|
'sql' => 'mediumtext NULL',
|
||||||
],
|
],
|
||||||
|
'fileFormat' => [
|
||||||
|
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormat'],
|
||||||
|
'exclude' => true,
|
||||||
|
'inputType' => 'select',
|
||||||
|
'filter' => true,
|
||||||
|
'eval' => [
|
||||||
|
'mandatory' => true,
|
||||||
|
'tl_class' => 'w50',
|
||||||
|
'includeBlankOption' => true,
|
||||||
|
'submitOnChange' => true,
|
||||||
|
'chosen' => true,
|
||||||
|
'helpwizard' => true,
|
||||||
|
],
|
||||||
|
'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.layer', 'getFileFormats'],
|
||||||
|
'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats'],
|
||||||
|
'sql' => "varchar(32) NOT NULL default ''",
|
||||||
|
],
|
||||||
|
'file' => [
|
||||||
|
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['file'],
|
||||||
|
'exclude' => true,
|
||||||
|
'inputType' => 'fileTree',
|
||||||
|
'load_callback' => [
|
||||||
|
['netzmacht.contao_leaflet.listeners.dca.layer', 'prepareFileWidget'],
|
||||||
|
],
|
||||||
|
'eval' => [
|
||||||
|
'filesOnly' => true,
|
||||||
|
'fieldType' => 'radio',
|
||||||
|
'mandatory' => true,
|
||||||
|
'tl_class' => 'clr',
|
||||||
|
],
|
||||||
|
'sql' => 'binary(16) NULL',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_marker'] = [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
'onload_callback' => [
|
'onload_callback' => [
|
||||||
['netzmacht.contao_leaflet.listeners.dca.marker', 'initialize'],
|
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'loadLanguageFile'],
|
||||||
],
|
],
|
||||||
'onsubmit_callback' => [
|
'onsubmit_callback' => [
|
||||||
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'],
|
['netzmacht.contao_leaflet.listeners.dca.leaflet', 'clearCache'],
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ $GLOBALS['TL_LANG']['leaflet_layer']['tile'][0] = 'Tile layer';
|
|||||||
$GLOBALS['TL_LANG']['leaflet_layer']['tile'][1] = 'Tile layer with full config options.';
|
$GLOBALS['TL_LANG']['leaflet_layer']['tile'][1] = 'Tile layer with full config options.';
|
||||||
$GLOBALS['TL_LANG']['leaflet_layer']['overpass'][0] = 'Overpass API';
|
$GLOBALS['TL_LANG']['leaflet_layer']['overpass'][0] = 'Overpass API';
|
||||||
$GLOBALS['TL_LANG']['leaflet_layer']['overpass'][1] = 'Overpass API data layer.';
|
$GLOBALS['TL_LANG']['leaflet_layer']['overpass'][1] = 'Overpass API data layer.';
|
||||||
|
$GLOBALS['TL_LANG']['leaflet_layer']['file'][0] = 'File';
|
||||||
|
$GLOBALS['TL_LANG']['leaflet_layer']['file'][1] = 'Geo data from a file (gpx,kml,wkt).';
|
||||||
|
|
||||||
$GLOBALS['TL_LANG']['leaflet_vector']['polyline'][0] = 'Polyline';
|
$GLOBALS['TL_LANG']['leaflet_vector']['polyline'][0] = 'Polyline';
|
||||||
$GLOBALS['TL_LANG']['leaflet_vector']['polyline'][1] = 'Polyline overlay. For more details read the <a href="http://leafletjs.com/reference.html#polyline" target="_blank">Leaflet documentation</a>.';
|
$GLOBALS['TL_LANG']['leaflet_vector']['polyline'][1] = 'Polyline overlay. For more details read the <a href="http://leafletjs.com/reference.html#polyline" target="_blank">Leaflet documentation</a>.';
|
||||||
|
|||||||
@@ -145,12 +145,27 @@ $GLOBALS['TL_LANG']['tl_leaflet_layer']['amenity'][0] = 'Amen
|
|||||||
$GLOBALS['TL_LANG']['tl_leaflet_layer']['amenity'][1] = 'OSM amenity.';
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['amenity'][1] = 'OSM amenity.';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_layer']['amenityIcon'][1] = 'Icon';
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['amenityIcon'][1] = 'Icon';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_layer']['amenityIcon'][0] = 'Icon style';
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['amenityIcon'][0] = 'Icon style';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormat'][0] = 'File formats';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormat'][1] = 'Choose which file format is used.';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['file'][0] = 'File';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['file'][1] = 'Choose a file containing geodata. Supported formats are: %s.';
|
||||||
|
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['layer'][0] = 'Layer group';
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['layer'][0] = 'Layer group';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['layer'][1] = 'Basic layer group. <br> See <a href="http://leafletjs.com/reference.html#layergroup" target="_blank">http://leafletjs.com/reference.html#layergroup</a>';
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['layer'][1] = 'Basic layer group. <br> See <a href="http://leafletjs.com/reference.html#layergroup" target="_blank">http://leafletjs.com/reference.html#layergroup</a>';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['feature'][0] = 'Feature group';
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['feature'][0] = 'Feature group';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['feature'][1] = 'Extended layer group with events and popup support. <br>See <a href="http://leafletjs.com/reference.html#featuregroup" target="_blank">http://leafletjs.com/reference.html#featuregroup</a>';
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['groupTypes']['feature'][1] = 'Extended layer group with events and popup support. <br>See <a href="http://leafletjs.com/reference.html#featuregroup" target="_blank">http://leafletjs.com/reference.html#featuregroup</a>';
|
||||||
|
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['gpx'][0] = 'GPX';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['gpx'][1] = 'GPS Exchange format. <a href="https://github.com/mapbox/togeojson#gpx-feature-support" target="_blank">Read the documentation</a> for more information.';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['kml'][0] = 'KML';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['kml'][1] = 'Keyhole Markup Language. <a href="https://github.com/mapbox/togeojson#kml-feature-support" target="_blank">Read the documentation</a> for more information.';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['wkt'][0] = 'WKT';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['wkt'][1] = 'Well-known text <a href="https://github.com/mapbox/togeojson#kml-feature-support" target="_blank">Read the documentation</a> for more information.';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['topojson'][0] = 'TopoJSON';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['topojson'][1] = 'TopoJSON is a topological geospatial data interchange format based on GeoJSON. <a href="https://github.com/topojson/topojson#api-reference" target="_blank">Read the documentation</a> for more information.';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['geojson'][0] = 'GeoJSON';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['fileFormats']['geojson'][1] = 'GeoJSON is a format for encoding a variety of geographic data structures. <a href="https://github.com/mapbox/wellknown" target="_blank">Read the documentation</a> for more information.';
|
||||||
|
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_layer']['pasteinto'][1] = 'Paste into layer %s';
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['pasteinto'][1] = 'Paste into layer %s';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_layer']['pasteafter'][1] = 'Paste after layer %s';
|
$GLOBALS['TL_LANG']['tl_leaflet_layer']['pasteafter'][1] = 'Paste after layer %s';
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
<div class="netzmacht-leaflet-credits">
|
<div class="netzmacht-leaflet-credits">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1 class="sub_headline"><?php echo $this->headline; ?> <small><?php echo $this->version; ?></small></h1>
|
<h1 class="sub_headline"><?php echo $this->headline; ?>
|
||||||
</div>
|
<small><?php echo $this->version; ?></small>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="tl_box block row">
|
<div class="tl_box block row">
|
||||||
<h2>About</h2>
|
<h2>About</h2>
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<p>
|
<p>
|
||||||
@@ -11,9 +13,11 @@
|
|||||||
This extension is only exists because of great other Open Source Software which it heavenly depends on.
|
This extension is only exists because of great other Open Source Software which it heavenly depends on.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
This software ships with an visible attribution to <em>netzmacht creative</em> in the map attribution control.
|
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.
|
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>.
|
For more details visit the <a href="https://netzmacht.de/contao-leaflet" target="_blank">project
|
||||||
|
website</a>.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
@@ -31,32 +35,37 @@
|
|||||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
<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="cmd" value="_s-xclick">
|
||||||
<input type="hidden" name="hosted_button_id" value="YWMA95YS3FT6U">
|
<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.">
|
<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">
|
<img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tl_box">
|
<div class="tl_box">
|
||||||
<h2>Support Contao Leaflet</h2>
|
<h2>Support Contao Leaflet</h2>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h3>Report issues</h3>
|
<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>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>
|
<p><a href="http://github.com/netzmacht/contao-leaflet-maps/issues" class="btn" target="_blank">Issue
|
||||||
|
tracker</a></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h3>Contribute</h3>
|
<h3>Contribute</h3>
|
||||||
<p>There are many ways you can con­tribute. Translations,
|
<p>There are many ways you can con­tribute. Translations,
|
||||||
docu­mentation or code contributions are welcome.
|
docu­mentation or code contributions are welcome.
|
||||||
</p>
|
</p>
|
||||||
<p><a href="https://netzmacht/contao-leaflet/contribute.html" class="btn" target="_blank">Contribute</a> </p>
|
<p><a href="https://netzmacht/contao-leaflet/contribute.html" class="btn" target="_blank">Contribute</a>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h3>Fund a feature</h3>
|
<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>Contao Leaflet is not feature complete. Have a look at the list of planned feature and support
|
||||||
<p><a href="https://netzmacht/contao-leaflet/planned-features.html" class="btn" target="_blank">Planned features</a> </p>
|
them.</p>
|
||||||
|
<p><a href="https://netzmacht/contao-leaflet/planned-features.html" class="btn" target="_blank">Planned
|
||||||
|
features</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -64,17 +73,19 @@
|
|||||||
<div class="col">
|
<div class="col">
|
||||||
<h3>Individual development</h3>
|
<h3>Individual development</h3>
|
||||||
<p>If you have special requirements you can hire me for an individual development.</p>
|
<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>
|
<p><a href="https://netzmacht/contao-leaflet/contact.html" class="btn" target="_blank">Contact</a></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h3>Commercial license</h3>
|
<h3>Commercial license</h3>
|
||||||
<p>If you want to remove the attribution in the attribution control, you can purchase a commercial license.</p>
|
<p>If you want to remove the attribution in the attribution control, you can purchase a commercial
|
||||||
<p><a href="https://netzmacht/contao-leaflet/commercial-license.html" class="btn" target="_blank">Purchase license</a> </p>
|
license.</p>
|
||||||
|
<p><a href="https://netzmacht/contao-leaflet/commercial-license.html" class="btn" target="_blank">Purchase
|
||||||
|
license</a></p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="tl_box">
|
<div class="tl_box">
|
||||||
<h2>Credits</h2>
|
<h2>Credits</h2>
|
||||||
<table class="tl_listing">
|
<table class="tl_listing">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -84,7 +95,9 @@
|
|||||||
<th>Homepage</th>
|
<th>Homepage</th>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if ($this->libraries): ?>
|
<?php if ($this->libraries): ?>
|
||||||
<tr><th colspan="4" class="subtitle">Libraries</th> </tr>
|
<tr>
|
||||||
|
<th colspan="4" class="subtitle">Libraries</th>
|
||||||
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php foreach ($this->libraries as $library): ?>
|
<?php foreach ($this->libraries as $library): ?>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -110,7 +123,9 @@
|
|||||||
<td><a href="http://semlabs.co.uk/" target="_blank">semlabs.co.uk</a></td>
|
<td><a href="http://semlabs.co.uk/" target="_blank">semlabs.co.uk</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if ($this->dependencies): ?>
|
<?php if ($this->dependencies): ?>
|
||||||
<tr><th colspan="4" class="subtitle">Dependencies</th> </tr>
|
<tr>
|
||||||
|
<th colspan="4" class="subtitle">Dependencies</th>
|
||||||
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php foreach ($this->dependencies as $dep): ?>
|
<?php foreach ($this->dependencies as $dep): ?>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -121,5 +136,5 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,14 +17,14 @@
|
|||||||
placeholder: '<?php echo $GLOBALS['TL_LANG']['leaflet']['searchPosition']; ?>'
|
placeholder: '<?php echo $GLOBALS['TL_LANG']['leaflet']['searchPosition']; ?>'
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
geocoder.on('markgeocode', function(event) {
|
geocoder.on('markgeocode', function (event) {
|
||||||
var container = document.createElement('div');
|
var container = document.createElement('div');
|
||||||
var link = document.createElement('button');
|
var link = document.createElement('button');
|
||||||
var result = event.geocode;
|
var result = event.geocode;
|
||||||
|
|
||||||
link.set('style', 'margin-left: 10px;');
|
link.set('style', 'margin-left: 10px;');
|
||||||
link.appendText('<?php echo $GLOBALS['TL_LANG']['leaflet']['applyPosition']; ?>');
|
link.appendText('<?php echo $GLOBALS['TL_LANG']['leaflet']['applyPosition']; ?>');
|
||||||
link.addEvent('click', function(e) {
|
link.addEvent('click', function (e) {
|
||||||
e.stop();
|
e.stop();
|
||||||
|
|
||||||
element.set('value', result.center.lat + ',' + result.center.lng);
|
element.set('value', result.center.lat + ',' + result.center.lng);
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
map.removeLayer(this._geocodeMarker);
|
map.removeLayer(this._geocodeMarker);
|
||||||
}
|
}
|
||||||
|
|
||||||
map.fitBounds(result.bbox, { padding: [0, 70]});
|
map.fitBounds(result.bbox, {padding: [0, 70]});
|
||||||
map.panTo(result.center);
|
map.panTo(result.center);
|
||||||
|
|
||||||
this._geocodeMarker = new L.Marker(result.center, {draggable: true})
|
this._geocodeMarker = new L.Marker(result.center, {draggable: true})
|
||||||
|
|||||||
@@ -9,5 +9,5 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- indexer::continue -->
|
<!-- indexer::continue -->
|
||||||
<?php $GLOBALS['TL_BODY'][] = '<script>' . $this->javascript .'</script>'; ?>
|
<?php $GLOBALS['TL_BODY'][] = '<script>' . $this->javascript . '</script>'; ?>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<div id="<?php echo $mapId; ?>" style="<?php echo $style; ?>"></div>
|
<div id="<?= $this->mapId ?>" style="<?= $this->style ?>"></div>
|
||||||
<script>
|
<script>
|
||||||
L.contao.addMap('<?php echo $mapId; ?>', function() {
|
L.contao.addMap('<?= $this->mapId ?>', function () {
|
||||||
<?php echo $javascript; ?>
|
<?= $this->javascript ?>
|
||||||
return { map: map, layers: layers, controls: controls, icons: icons };
|
return {map: map, layers: layers, controls: controls, icons: icons};
|
||||||
}());</script>
|
}());
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
L.contao.addMap('<?php echo $mapId; ?>', function() {
|
L.contao.addMap('<?= $this->mapId ?>', function() {
|
||||||
<?php echo $javascript; ?>
|
<?= $this->javascript ?>
|
||||||
|
|
||||||
return { map: map, layers: layers, controls: controls, icons: icons };
|
return { map: map, layers: layers, controls: controls, icons: icons };
|
||||||
}());
|
}());
|
||||||
|
|||||||
@@ -9,4 +9,4 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- indexer::continue -->
|
<!-- indexer::continue -->
|
||||||
<?php $GLOBALS['TL_BODY'][] = '<script>' . $this->javascript .'</script>'; ?>
|
<?php $GLOBALS['TL_BODY'][] = '<script>' . $this->javascript . '</script>'; ?>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
padding: 15px;
|
padding: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.netzmacht-leaflet-credits a {
|
.netzmacht-leaflet-credits a {
|
||||||
color: #669A00;
|
color: #669A00;
|
||||||
}
|
}
|
||||||
@@ -17,7 +16,7 @@
|
|||||||
.netzmacht-leaflet-credits h1 {
|
.netzmacht-leaflet-credits h1 {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 1.4em;
|
font-size: 1.4em;
|
||||||
text-shadow: 0 -1px 1px rgba(0,0,0,0.35);
|
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.35);
|
||||||
}
|
}
|
||||||
|
|
||||||
.netzmacht-leaflet-credits .row:after {
|
.netzmacht-leaflet-credits .row:after {
|
||||||
|
|||||||
3
src/Bundle/Resources/public/css/backend_hacks.css
Normal file
3
src/Bundle/Resources/public/css/backend_hacks.css
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.tl_help_table a {
|
||||||
|
color: #77ac45
|
||||||
|
}
|
||||||
BIN
src/Bundle/Resources/public/img/file.png
Normal file
BIN
src/Bundle/Resources/public/img/file.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 619 B |
BIN
src/Bundle/Resources/public/img/file_1.png
Normal file
BIN
src/Bundle/Resources/public/img/file_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 546 B |
File diff suppressed because one or more lines are too long
@@ -44,7 +44,7 @@ class ContaoAssets implements Assets
|
|||||||
private $cache = [
|
private $cache = [
|
||||||
'stylesheets' => [],
|
'stylesheets' => [],
|
||||||
'javascripts' => [],
|
'javascripts' => [],
|
||||||
'map' => []
|
'map' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,14 +10,13 @@
|
|||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Subscriber;
|
namespace Netzmacht\Contao\Leaflet\Encoder\Subscriber;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
||||||
use Netzmacht\JavascriptBuilder\Encoder;
|
|
||||||
use Netzmacht\JavascriptBuilder\Flags;
|
|
||||||
use Netzmacht\JavascriptBuilder\Symfony\Event\EncodeValueEvent;
|
|
||||||
use Netzmacht\JavascriptBuilder\Symfony\Event\EncodeReferenceEvent;
|
|
||||||
use Netzmacht\JavascriptBuilder\Exception\EncodeValueFailed;
|
use Netzmacht\JavascriptBuilder\Exception\EncodeValueFailed;
|
||||||
|
use Netzmacht\JavascriptBuilder\Flags;
|
||||||
|
use Netzmacht\JavascriptBuilder\Symfony\Event\EncodeReferenceEvent;
|
||||||
|
use Netzmacht\JavascriptBuilder\Symfony\Event\EncodeValueEvent;
|
||||||
use Netzmacht\LeafletPHP\Definition\Type\Icon;
|
use Netzmacht\LeafletPHP\Definition\Type\Icon;
|
||||||
use Netzmacht\LeafletPHP\Plugins\Omnivore\OmnivoreLayer;
|
use Netzmacht\LeafletPHP\Plugins\Omnivore\OmnivoreLayer;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
@@ -34,13 +33,13 @@ class EncoderSubscriber implements EventSubscriberInterface
|
|||||||
*/
|
*/
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
EncodeValueEvent::NAME => array(
|
EncodeValueEvent::NAME => [
|
||||||
array('encodeIcons', 1000),
|
['encodeIcons', 1000],
|
||||||
array('loadLayer', 100),
|
['loadLayer', 100],
|
||||||
),
|
],
|
||||||
EncodeReferenceEvent::NAME => array('referenceIcon', 100),
|
EncodeReferenceEvent::NAME => ['referenceIcon', 100],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,16 +89,15 @@ class EncoderSubscriber implements EventSubscriberInterface
|
|||||||
{
|
{
|
||||||
$value = $event->getValue();
|
$value = $event->getValue();
|
||||||
$encoder = $event->getEncoder();
|
$encoder = $event->getEncoder();
|
||||||
$template = 'L.contao.load(%s, %s, %s, %s, map);';
|
$template = 'L.contao.%s(%s, %s, %s, %s, map);';
|
||||||
|
$method = 'loadFile';
|
||||||
|
|
||||||
if ($value instanceof OmnivoreLayer) {
|
if ($value instanceof OmnivoreLayer) {
|
||||||
$url = $value->getUrl();
|
$url = $value->getUrl();
|
||||||
|
|
||||||
if ($url instanceof RequestUrl) {
|
if ($url instanceof RequestUrl) {
|
||||||
$url = $url->getHash();
|
$url = $url->getHash();
|
||||||
} elseif (strpos($url, '/') !== false) {
|
$method = 'load';
|
||||||
// Slash found, not a Contao leaflet hash, do not replace encoding.
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($value->getCustomLayer()) {
|
if ($value->getCustomLayer()) {
|
||||||
@@ -112,6 +110,7 @@ class EncoderSubscriber implements EventSubscriberInterface
|
|||||||
$event->addLine(
|
$event->addLine(
|
||||||
sprintf(
|
sprintf(
|
||||||
$template,
|
$template,
|
||||||
|
$method,
|
||||||
$encoder->encodeValue($url),
|
$encoder->encodeValue($url),
|
||||||
$encoder->encodeValue(strtolower(str_replace('Omnivore.', '', $value->getType()))),
|
$encoder->encodeValue(strtolower(str_replace('Omnivore.', '', $value->getType()))),
|
||||||
$encoder->encodeArray($value->getOptions(), JSON_FORCE_OBJECT),
|
$encoder->encodeArray($value->getOptions(), JSON_FORCE_OBJECT),
|
||||||
@@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Event;
|
namespace Netzmacht\Contao\Leaflet\Event;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Contao\Model;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
|
|
||||||
@@ -50,10 +51,10 @@ class BuildDefinitionEvent extends Event
|
|||||||
* Construct.
|
* Construct.
|
||||||
*
|
*
|
||||||
* @param Definition $definition The leaflet definition.
|
* @param Definition $definition The leaflet definition.
|
||||||
* @param \Model $model The definition model.
|
* @param Model $model The definition model.
|
||||||
* @param Request|null $request Building request.
|
* @param Request|null $request Building request.
|
||||||
*/
|
*/
|
||||||
public function __construct(Definition $definition, \Model $model, Request $request = null)
|
public function __construct(Definition $definition, Model $model, Request $request = null)
|
||||||
{
|
{
|
||||||
$this->definition = $definition;
|
$this->definition = $definition;
|
||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class BboxFilter implements Filter
|
|||||||
*/
|
*/
|
||||||
public function getValues()
|
public function getValues()
|
||||||
{
|
{
|
||||||
return array('bounds' => $this->bounds);
|
return ['bounds' => $this->bounds];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -88,9 +88,9 @@ class DistanceFilter implements Filter
|
|||||||
*/
|
*/
|
||||||
public function getValues()
|
public function getValues()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
'radius' => $this->radius,
|
'radius' => $this->radius,
|
||||||
'center' => $this->center
|
'center' => $this->center,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Frontend;
|
namespace Netzmacht\Contao\Leaflet\Frontend;
|
||||||
|
|
||||||
use Contao\Config;
|
|
||||||
use Contao\Database\Result;
|
use Contao\Database\Result;
|
||||||
use Contao\Input;
|
use Contao\Input;
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
@@ -22,6 +21,7 @@ use Contao\Model\Collection;
|
|||||||
use Netzmacht\Contao\Leaflet\MapProvider;
|
use Netzmacht\Contao\Leaflet\MapProvider;
|
||||||
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
||||||
use Netzmacht\Contao\Toolkit\Component\Hybrid\AbstractHybrid;
|
use Netzmacht\Contao\Toolkit\Component\Hybrid\AbstractHybrid;
|
||||||
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Symfony\Component\Templating\EngineInterface as TemplateEngine;
|
use Symfony\Component\Templating\EngineInterface as TemplateEngine;
|
||||||
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||||
|
|
||||||
@@ -42,16 +42,16 @@ abstract class AbstractMapHybrid extends AbstractHybrid
|
|||||||
/**
|
/**
|
||||||
* The user input.
|
* The user input.
|
||||||
*
|
*
|
||||||
* @var \Input
|
* @var Input
|
||||||
*/
|
*/
|
||||||
private $input;
|
private $input;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Contao config.
|
* Repository manager.
|
||||||
*
|
*
|
||||||
* @var \Config
|
* @var RepositoryManager
|
||||||
*/
|
*/
|
||||||
private $config;
|
private $repositoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HybridTrait constructor.
|
* HybridTrait constructor.
|
||||||
@@ -60,8 +60,8 @@ abstract class AbstractMapHybrid extends AbstractHybrid
|
|||||||
* @param TemplateEngine $templateEngine Template engine.
|
* @param TemplateEngine $templateEngine Template engine.
|
||||||
* @param Translator $translator Translator.
|
* @param Translator $translator Translator.
|
||||||
* @param MapProvider $mapProvider Map provider.
|
* @param MapProvider $mapProvider Map provider.
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
* @param Input $input Request Input.
|
* @param Input $input Request Input.
|
||||||
* @param Config $config Config.
|
|
||||||
* @param string $column Column in which the element appears.
|
* @param string $column Column in which the element appears.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
@@ -69,15 +69,15 @@ abstract class AbstractMapHybrid extends AbstractHybrid
|
|||||||
TemplateEngine $templateEngine,
|
TemplateEngine $templateEngine,
|
||||||
Translator $translator,
|
Translator $translator,
|
||||||
MapProvider $mapProvider,
|
MapProvider $mapProvider,
|
||||||
|
RepositoryManager $repositoryManager,
|
||||||
$input,
|
$input,
|
||||||
$config,
|
|
||||||
$column = null
|
$column = null
|
||||||
) {
|
) {
|
||||||
parent::__construct($model, $templateEngine, $translator, $column);
|
parent::__construct($model, $templateEngine, $translator, $column);
|
||||||
|
|
||||||
$this->mapProvider = $mapProvider;
|
$this->mapProvider = $mapProvider;
|
||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
$this->config = $config;
|
$this->repositoryManager = $repositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,7 +90,8 @@ abstract class AbstractMapHybrid extends AbstractHybrid
|
|||||||
$this->mapProvider->handleAjaxRequest($this->getIdentifier());
|
$this->mapProvider->handleAjaxRequest($this->getIdentifier());
|
||||||
|
|
||||||
if (TL_MODE === 'BE') {
|
if (TL_MODE === 'BE') {
|
||||||
$model = MapModel::findByPk($this->get('leaflet_map'));
|
$repository = $this->repositoryManager->getRepository(MapModel::class);
|
||||||
|
$model = $repository->find((int) $this->get('leaflet_map'));
|
||||||
$parameters = [
|
$parameters = [
|
||||||
'title' => $this->get('headline'),
|
'title' => $this->get('headline'),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -14,9 +14,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Frontend\ContentElement;
|
namespace Netzmacht\Contao\Leaflet\Frontend\ContentElement;
|
||||||
|
|
||||||
|
use Contao\Config;
|
||||||
|
use Contao\CoreBundle\Framework\Adapter;
|
||||||
|
use Contao\Input;
|
||||||
|
use Netzmacht\Contao\Leaflet\MapProvider;
|
||||||
use Netzmacht\Contao\Toolkit\Component\Component;
|
use Netzmacht\Contao\Toolkit\Component\Component;
|
||||||
use Netzmacht\Contao\Toolkit\Component\ComponentFactory;
|
use Netzmacht\Contao\Toolkit\Component\ComponentFactory;
|
||||||
use Psr\Container\ContainerInterface as Container;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
|
use Symfony\Component\Templating\EngineInterface as TemplateEngine;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class MapElementFactory
|
* Class MapElementFactory
|
||||||
@@ -26,20 +32,61 @@ use Psr\Container\ContainerInterface as Container;
|
|||||||
class MapElementFactory implements ComponentFactory
|
class MapElementFactory implements ComponentFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dependency container.
|
* Template engine.
|
||||||
*
|
*
|
||||||
* @var Container
|
* @var TemplateEngine
|
||||||
*/
|
*/
|
||||||
private $container;
|
private $templating;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translator.
|
||||||
|
*
|
||||||
|
* @var Translator
|
||||||
|
*/
|
||||||
|
private $translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map provider.
|
||||||
|
*
|
||||||
|
* @var MapProvider
|
||||||
|
*/
|
||||||
|
private $mapProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input adapter.
|
||||||
|
*
|
||||||
|
* @var Input|Adapter
|
||||||
|
*/
|
||||||
|
private $input;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MapElementFactory constructor.
|
* MapElementFactory constructor.
|
||||||
*
|
*
|
||||||
* @param Container $container Dependency container.
|
* @param TemplateEngine $engine Template engine.
|
||||||
|
* @param Translator $translator Translator.
|
||||||
|
* @param MapProvider $mapProvider Map provider.
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
* @param Input|Adapter $input Input adapter.
|
||||||
*/
|
*/
|
||||||
public function __construct(Container $container)
|
public function __construct(
|
||||||
{
|
TemplateEngine $engine,
|
||||||
$this->container = $container;
|
Translator $translator,
|
||||||
|
MapProvider $mapProvider,
|
||||||
|
RepositoryManager $repositoryManager,
|
||||||
|
$input
|
||||||
|
) {
|
||||||
|
$this->templating = $engine;
|
||||||
|
$this->translator = $translator;
|
||||||
|
$this->mapProvider = $mapProvider;
|
||||||
|
$this->input = $input;
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,11 +104,11 @@ class MapElementFactory implements ComponentFactory
|
|||||||
{
|
{
|
||||||
return new MapElement(
|
return new MapElement(
|
||||||
$model,
|
$model,
|
||||||
$this->container->get('templating'),
|
$this->templating,
|
||||||
$this->container->get('translator'),
|
$this->translator,
|
||||||
$this->container->get('netzmacht.contao_leaflet.map.provider'),
|
$this->mapProvider,
|
||||||
$this->container->get('netzmacht.contao_toolkit.contao.input_adapter'),
|
$this->repositoryManager,
|
||||||
$this->container->get('netzmacht.contao_toolkit.contao.config_adapter'),
|
$this->input,
|
||||||
$column
|
$column
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ class DataController
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $input = array(
|
private $input = [
|
||||||
'format' => 'geojson',
|
'format' => 'geojson',
|
||||||
'type' => 'layer',
|
'type' => 'layer',
|
||||||
'id' => null,
|
'id' => null,
|
||||||
'filter' => null,
|
'filter' => null,
|
||||||
'values' => null
|
'values' => null,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug mode.
|
* Debug mode.
|
||||||
@@ -140,9 +140,9 @@ class DataController
|
|||||||
default:
|
default:
|
||||||
$error = true;
|
$error = true;
|
||||||
|
|
||||||
return array($data, $error);
|
return [$data, $error];
|
||||||
}
|
}
|
||||||
|
|
||||||
return array($data, $error);
|
return [$data, $error];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Frontend\Module;
|
namespace Netzmacht\Contao\Leaflet\Frontend\Module;
|
||||||
|
|
||||||
|
use Contao\Config;
|
||||||
|
use Contao\CoreBundle\Framework\Adapter;
|
||||||
|
use Contao\Input;
|
||||||
|
use Netzmacht\Contao\Leaflet\MapProvider;
|
||||||
use Netzmacht\Contao\Toolkit\Component\Component;
|
use Netzmacht\Contao\Toolkit\Component\Component;
|
||||||
use Netzmacht\Contao\Toolkit\Component\ComponentFactory;
|
use Netzmacht\Contao\Toolkit\Component\ComponentFactory;
|
||||||
use Psr\Container\ContainerInterface as Container;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
|
use Symfony\Component\Templating\EngineInterface as TemplateEngine;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class MapElementFactory
|
* Class MapElementFactory
|
||||||
@@ -26,20 +32,61 @@ use Psr\Container\ContainerInterface as Container;
|
|||||||
class MapModuleFactory implements ComponentFactory
|
class MapModuleFactory implements ComponentFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dependency container.
|
* Template engine.
|
||||||
*
|
*
|
||||||
* @var Container
|
* @var TemplateEngine
|
||||||
*/
|
*/
|
||||||
private $container;
|
private $templating;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MapModuleFactory constructor.
|
* Translator.
|
||||||
*
|
*
|
||||||
* @param Container $container Dependency container.
|
* @var Translator
|
||||||
*/
|
*/
|
||||||
public function __construct(Container $container)
|
private $translator;
|
||||||
{
|
|
||||||
$this->container = $container;
|
/**
|
||||||
|
* Map provider.
|
||||||
|
*
|
||||||
|
* @var MapProvider
|
||||||
|
*/
|
||||||
|
private $mapProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input adapter.
|
||||||
|
*
|
||||||
|
* @var Input|Adapter
|
||||||
|
*/
|
||||||
|
private $input;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MapElementFactory constructor.
|
||||||
|
*
|
||||||
|
* @param TemplateEngine $engine Template engine.
|
||||||
|
* @param Translator $translator Translator.
|
||||||
|
* @param MapProvider $mapProvider Map provider.
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
* @param Input|Adapter $input Input adapter.
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
TemplateEngine $engine,
|
||||||
|
Translator $translator,
|
||||||
|
MapProvider $mapProvider,
|
||||||
|
RepositoryManager $repositoryManager,
|
||||||
|
$input
|
||||||
|
) {
|
||||||
|
$this->templating = $engine;
|
||||||
|
$this->translator = $translator;
|
||||||
|
$this->mapProvider = $mapProvider;
|
||||||
|
$this->input = $input;
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,11 +104,11 @@ class MapModuleFactory implements ComponentFactory
|
|||||||
{
|
{
|
||||||
return new MapModule(
|
return new MapModule(
|
||||||
$model,
|
$model,
|
||||||
$this->container->get('templating'),
|
$this->templating,
|
||||||
$this->container->get('translator'),
|
$this->translator,
|
||||||
$this->container->get('netzmacht.contao_leaflet.map.provider'),
|
$this->mapProvider,
|
||||||
$this->container->get('netzmacht.contao_toolkit.contao.input_adapter'),
|
$this->repositoryManager,
|
||||||
$this->container->get('netzmacht.contao_toolkit.contao.config_adapter'),
|
$this->input,
|
||||||
$column
|
$column
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
namespace Netzmacht\Contao\Leaflet\Frontend;
|
namespace Netzmacht\Contao\Leaflet\Frontend;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RequestUrl creates the request url.
|
* Class RequestUrl creates the request url.
|
||||||
@@ -57,12 +57,12 @@ class RequestUrl implements \JsonSerializable
|
|||||||
*/
|
*/
|
||||||
public static function create($dataId, $type = null, $format = null, Request $request = null)
|
public static function create($dataId, $type = null, $format = null, Request $request = null)
|
||||||
{
|
{
|
||||||
$params = array(
|
$params = [
|
||||||
'for' => $request ? $request->getMapIdentifier() : null,
|
'for' => $request ? $request->getMapIdentifier() : null,
|
||||||
'type' => $type != 'layer' ? $type : null,
|
'type' => $type != 'layer' ? $type : null,
|
||||||
'id' => $dataId,
|
'id' => $dataId,
|
||||||
'format' => $format != 'geojson' ? $format : null
|
'format' => $format != 'geojson' ? $format : null,
|
||||||
);
|
];
|
||||||
|
|
||||||
$hash = base64_encode(implode(',', $params));
|
$hash = base64_encode(implode(',', $params));
|
||||||
$query = 'leaflet=' . $hash;
|
$query = 'leaflet=' . $hash;
|
||||||
|
|||||||
@@ -14,11 +14,12 @@ namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
|||||||
|
|
||||||
use Contao\StringUtil;
|
use Contao\StringUtil;
|
||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
|
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
||||||
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Listener\AbstractListener;
|
use Netzmacht\Contao\Toolkit\Dca\Listener\AbstractListener;
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Manager;
|
use Netzmacht\Contao\Toolkit\Dca\Manager;
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
||||||
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Control is the helper for the tl_leaflet_control dca.
|
* Class Control is the helper for the tl_leaflet_control dca.
|
||||||
@@ -48,19 +49,32 @@ class ControlDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
private $types;
|
private $types;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct.
|
* Construct.
|
||||||
*
|
*
|
||||||
* @param Manager $manager Data container manager.
|
* @param Manager $manager Data container manager.
|
||||||
* @param Connection $connection Database connection.
|
* @param Connection $connection Database connection.
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
* @param array $types Control types.
|
* @param array $types Control types.
|
||||||
*/
|
*/
|
||||||
public function __construct(Manager $manager, Connection $connection, array $types)
|
public function __construct(
|
||||||
{
|
Manager $manager,
|
||||||
|
Connection $connection,
|
||||||
|
RepositoryManager $repositoryManager,
|
||||||
|
array $types
|
||||||
|
) {
|
||||||
parent::__construct($manager);
|
parent::__construct($manager);
|
||||||
|
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
$this->types = $types;
|
$this->types = $types;
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +110,8 @@ class ControlDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
public function getLayers()
|
public function getLayers()
|
||||||
{
|
{
|
||||||
$collection = LayerModel::findAll();
|
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||||
|
$collection = $repository->findAll();
|
||||||
|
|
||||||
return OptionsBuilder::fromCollection($collection, 'title')
|
return OptionsBuilder::fromCollection($collection, 'title')
|
||||||
->asTree()
|
->asTree()
|
||||||
@@ -110,7 +125,8 @@ class ControlDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
public function getZoomControls()
|
public function getZoomControls()
|
||||||
{
|
{
|
||||||
$collection = ControlModel::findBy('type', 'zoom', array('order' => 'title'));
|
$repository = $this->repositoryManager->getRepository(ControlModel::class);
|
||||||
|
$collection = $repository->findBy(['type=?'], ['zoom'], ['order' => 'title']);
|
||||||
|
|
||||||
return OptionsBuilder::fromCollection($collection, 'title')->getOptions();
|
return OptionsBuilder::fromCollection($collection, 'title')->getOptions();
|
||||||
}
|
}
|
||||||
@@ -166,7 +182,7 @@ class ControlDcaListener extends AbstractListener
|
|||||||
'lid' => $layer['layer'],
|
'lid' => $layer['layer'],
|
||||||
'cid' => $dataContainer->id,
|
'cid' => $dataContainer->id,
|
||||||
'mode' => $layer['mode'],
|
'mode' => $layer['mode'],
|
||||||
'sorting' => $sorting
|
'sorting' => $sorting,
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->connection->insert('tl_leaflet_control_layer', $data);
|
$this->connection->insert('tl_leaflet_control_layer', $data);
|
||||||
@@ -177,10 +193,10 @@ class ControlDcaListener extends AbstractListener
|
|||||||
[
|
[
|
||||||
'tstamp' => time(),
|
'tstamp' => time(),
|
||||||
'sorting' => $sorting,
|
'sorting' => $sorting,
|
||||||
'mode' => $layer['mode']
|
'mode' => $layer['mode'],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => $values[$layer['layer']]['id']
|
'id' => $values[$layer['layer']]['id'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||||
|
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
use Contao\Image;
|
||||||
|
use Contao\RequestToken;
|
||||||
|
use Contao\StringUtil;
|
||||||
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
||||||
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
|
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
||||||
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,14 +36,23 @@ final class FrontendIntegrationListener
|
|||||||
*/
|
*/
|
||||||
private $translator;
|
private $translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FrontendIntegration constructor.
|
* FrontendIntegration constructor.
|
||||||
*
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
* @param Translator $translator Translator.
|
* @param Translator $translator Translator.
|
||||||
*/
|
*/
|
||||||
public function __construct(Translator $translator)
|
public function __construct(RepositoryManager $repositoryManager, Translator $translator)
|
||||||
{
|
{
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,7 +62,8 @@ final class FrontendIntegrationListener
|
|||||||
*/
|
*/
|
||||||
public function getMaps(): array
|
public function getMaps(): array
|
||||||
{
|
{
|
||||||
$collection = MapModel::findAll();
|
$repository = $this->repositoryManager->getRepository(MapModel::class);
|
||||||
|
$collection = $repository->findAll(['order' => 'title']);
|
||||||
|
|
||||||
return OptionsBuilder::fromCollection($collection, 'title')->getOptions();
|
return OptionsBuilder::fromCollection($collection, 'title')->getOptions();
|
||||||
}
|
}
|
||||||
@@ -74,11 +88,13 @@ final class FrontendIntegrationListener
|
|||||||
'<a href="%s%s&popup=1&rt=%s" %s>%s</a>',
|
'<a href="%s%s&popup=1&rt=%s" %s>%s</a>',
|
||||||
'contao/main.php?do=leaflet_map&table=tl_leaflet_map&act=edit&id=',
|
'contao/main.php?do=leaflet_map&table=tl_leaflet_map&act=edit&id=',
|
||||||
$dataContainer->value,
|
$dataContainer->value,
|
||||||
\RequestToken::get(),
|
RequestToken::get(),
|
||||||
sprintf(
|
sprintf(
|
||||||
$pattern,
|
$pattern,
|
||||||
specialchars($this->translator->trans('editalias.1', [$dataContainer->value], 'contao_tl_content')),
|
StringUtil::specialchars(
|
||||||
specialchars(
|
$this->translator->trans('editalias.1', [$dataContainer->value], 'contao_tl_content')
|
||||||
|
),
|
||||||
|
StringUtil::specialchars(
|
||||||
str_replace(
|
str_replace(
|
||||||
"'",
|
"'",
|
||||||
"\\'",
|
"\\'",
|
||||||
@@ -86,7 +102,7 @@ final class FrontendIntegrationListener
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
\Image::getHtml(
|
Image::getHtml(
|
||||||
'alias.gif',
|
'alias.gif',
|
||||||
$this->translator->trans('editalias.0', [$dataContainer->value], 'contao_tl_content'),
|
$this->translator->trans('editalias.0', [$dataContainer->value], 'contao_tl_content'),
|
||||||
'style="vertical-align:top"'
|
'style="vertical-align:top"'
|
||||||
|
|||||||
@@ -12,17 +12,19 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||||
|
|
||||||
use Contao\Controller;
|
use Contao\Backend;
|
||||||
|
use Contao\CoreBundle\Framework\Adapter;
|
||||||
|
use Contao\DataContainer;
|
||||||
use Contao\Image;
|
use Contao\Image;
|
||||||
use Contao\RequestToken;
|
|
||||||
use Contao\StringUtil;
|
use Contao\StringUtil;
|
||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
use Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\LayerLabelRenderer;
|
use Netzmacht\Contao\Leaflet\Backend\Renderer\Label\Layer\LayerLabelRenderer;
|
||||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
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\AbstractListener;
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Manager;
|
use Netzmacht\Contao\Toolkit\Dca\Manager;
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
|
||||||
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,6 +55,13 @@ class LayerDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tile providers configuration.
|
* Tile providers configuration.
|
||||||
*
|
*
|
||||||
@@ -81,36 +90,59 @@ class LayerDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
private $labelRenderer;
|
private $labelRenderer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File formats.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $fileFormats;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Backend adapter.
|
||||||
|
*
|
||||||
|
* @var Backend|Adapter
|
||||||
|
*/
|
||||||
|
private $backendAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct.
|
* Construct.
|
||||||
*
|
*
|
||||||
* @param Manager $manager Data container manager.
|
* @param Manager $manager Data container manager.
|
||||||
* @param Connection $connection Database connection.
|
* @param Connection $connection Database connection.
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
* @param Translator $translator Translator.
|
* @param Translator $translator Translator.
|
||||||
* @param LayerLabelRenderer $labelRenderer Layer label renderer.
|
* @param LayerLabelRenderer $labelRenderer Layer label renderer.
|
||||||
|
* @param Adapter|Backend $backendAdapter Backend adapter.
|
||||||
* @param array $layers Leaflet layer configuration.
|
* @param array $layers Leaflet layer configuration.
|
||||||
* @param array $tileProviders Tile providers.
|
* @param array $tileProviders Tile providers.
|
||||||
* @param array $amenities OSM amenities.
|
* @param array $amenities OSM amenities.
|
||||||
|
* @param array $fileFormats File formats.
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Manager $manager,
|
Manager $manager,
|
||||||
Connection $connection,
|
Connection $connection,
|
||||||
|
RepositoryManager $repositoryManager,
|
||||||
Translator $translator,
|
Translator $translator,
|
||||||
LayerLabelRenderer $labelRenderer,
|
LayerLabelRenderer $labelRenderer,
|
||||||
|
$backendAdapter,
|
||||||
array $layers,
|
array $layers,
|
||||||
array $tileProviders,
|
array $tileProviders,
|
||||||
array $amenities
|
array $amenities,
|
||||||
|
array $fileFormats
|
||||||
) {
|
) {
|
||||||
parent::__construct($manager);
|
parent::__construct($manager);
|
||||||
|
|
||||||
Controller::loadLanguageFile('leaflet_layer');
|
|
||||||
|
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
$this->layers = $layers;
|
$this->layers = $layers;
|
||||||
$this->tileProviders = $tileProviders;
|
$this->tileProviders = $tileProviders;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->amenities = $amenities;
|
$this->amenities = $amenities;
|
||||||
$this->labelRenderer = $labelRenderer;
|
$this->labelRenderer = $labelRenderer;
|
||||||
|
$this->fileFormats = $fileFormats;
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
$this->backendAdapter = $backendAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,7 +181,7 @@ class LayerDcaListener extends AbstractListener
|
|||||||
return $this->tileProviders[$dataContainer->activeRecord->tile_provider]['variants'];
|
return $this->tileProviders[$dataContainer->activeRecord->tile_provider]['variants'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -205,7 +237,8 @@ class LayerDcaListener extends AbstractListener
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$collection = LayerModel::findMultipleByTypes($types);
|
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||||
|
$collection = $repository->findMultipleByTypes($types);
|
||||||
$builder = OptionsBuilder::fromCollection(
|
$builder = OptionsBuilder::fromCollection(
|
||||||
$collection,
|
$collection,
|
||||||
'id',
|
'id',
|
||||||
@@ -232,43 +265,42 @@ class LayerDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
public function getPasteButtons($dataContainer, $row, $table, $whatever, $children)
|
public function getPasteButtons($dataContainer, $row, $table, $whatever, $children)
|
||||||
{
|
{
|
||||||
$pasteAfterUrl = \Controller::addToUrl(
|
$pasteAfterUrl = $this->backendAdapter->addToUrl(
|
||||||
'act='.$children['mode'].'&mode=1&pid='.$row['id']
|
'act=' . $children['mode'] . '&mode=1&pid=' . $row['id']
|
||||||
.(!is_array($children['id']) ? '&id='.$children['id'] : '')
|
. (!is_array($children['id']) ? '&id=' . $children['id'] : '')
|
||||||
. '&rt=' . RequestToken::get()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$buffer = sprintf(
|
$buffer = sprintf(
|
||||||
'<a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a> ',
|
'<a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a> ',
|
||||||
$pasteAfterUrl,
|
$pasteAfterUrl,
|
||||||
specialchars($this->translator->trans('pasteafter.1', [$row['id']], 'contao_' . $table)),
|
StringUtil::specialchars($this->translator->trans('pasteafter.1', [$row['id']], 'contao_' . $table)),
|
||||||
\Image::getHtml(
|
Image::getHtml(
|
||||||
'pasteafter.gif',
|
'pasteafter.gif',
|
||||||
$this->translator->trans('pasteafter.1', [$row['id']], 'contao_' . $table)
|
$this->translator->trans('pasteafter.1', [$row['id']], 'contao_' . $table)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!empty($this->layers[$row['type']]['children'])) {
|
if (!empty($this->layers[$row['type']]['children'])) {
|
||||||
$pasteIntoUrl = \Controller::addToUrl(
|
$pasteIntoUrl = $this->backendAdapter->addToUrl(
|
||||||
sprintf(
|
sprintf(
|
||||||
'act=%s&mode=2&pid=%s%s',
|
'act=%s&mode=2&pid=%s%s',
|
||||||
$children['mode'],
|
$children['mode'],
|
||||||
$row['id'],
|
$row['id'],
|
||||||
!is_array($children['id']) ? '&id='.$children['id'] : ''
|
!is_array($children['id']) ? '&id=' . $children['id'] : ''
|
||||||
) . '&rt=' . RequestToken::get()
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$buffer .= sprintf(
|
$buffer .= sprintf(
|
||||||
'<a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a> ',
|
'<a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a> ',
|
||||||
$pasteIntoUrl,
|
$pasteIntoUrl,
|
||||||
specialchars($this->translator->trans('pasteinto.1', [$row['id']], 'contao_' . $table)),
|
StringUtil::specialchars($this->translator->trans('pasteinto.1', [$row['id']], 'contao_' . $table)),
|
||||||
\Image::getHtml(
|
Image::getHtml(
|
||||||
'pasteinto.gif',
|
'pasteinto.gif',
|
||||||
$this->translator->trans('pasteinto.1', [$row['id']], 'contao_' . $table)
|
$this->translator->trans('pasteinto.1', [$row['id']], 'contao_' . $table)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} elseif ($row['id'] > 0) {
|
} elseif ($row['id'] > 0) {
|
||||||
$buffer .= \Image::getHtml('pasteinto_.gif');
|
$buffer .= Image::getHtml('pasteinto_.gif');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $buffer;
|
return $buffer;
|
||||||
@@ -337,7 +369,7 @@ class LayerDcaListener extends AbstractListener
|
|||||||
$statement->bindValue('lid', $dataContainer->id);
|
$statement->bindValue('lid', $dataContainer->id);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$undo['data'] = deserialize($undo['data'], true);
|
$undo['data'] = StringUtil::deserialize($undo['data'], true);
|
||||||
|
|
||||||
while ($row = $statement->fetch()) {
|
while ($row = $statement->fetch()) {
|
||||||
$undo['data']['tl_leaflet_map_layer'][] = $row;
|
$undo['data']['tl_leaflet_map_layer'][] = $row;
|
||||||
@@ -365,7 +397,7 @@ class LayerDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
public function getBoundsModes($dataContainer)
|
public function getBoundsModes($dataContainer)
|
||||||
{
|
{
|
||||||
$options = array();
|
$options = [];
|
||||||
|
|
||||||
if ($dataContainer->activeRecord && !empty($this->layers[$dataContainer->activeRecord->type]['boundsMode'])) {
|
if ($dataContainer->activeRecord && !empty($this->layers[$dataContainer->activeRecord->type]['boundsMode'])) {
|
||||||
foreach ($this->layers[$dataContainer->activeRecord->type]['boundsMode'] as $mode => $enabled) {
|
foreach ($this->layers[$dataContainer->activeRecord->type]['boundsMode'] as $mode => $enabled) {
|
||||||
@@ -389,7 +421,8 @@ class LayerDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
public function getLayers($dataContainer)
|
public function getLayers($dataContainer)
|
||||||
{
|
{
|
||||||
$collection = LayerModel::findBy('id !', $dataContainer->id);
|
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||||
|
$collection = $repository->findBy(['tl_leaflet_layer.id!=?'], [$dataContainer->id]);
|
||||||
|
|
||||||
return OptionsBuilder::fromCollection($collection, 'title')
|
return OptionsBuilder::fromCollection($collection, 'title')
|
||||||
->asTree()
|
->asTree()
|
||||||
@@ -413,7 +446,8 @@ class LayerDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
public function getIcons()
|
public function getIcons()
|
||||||
{
|
{
|
||||||
$collection = IconModel::findAll(array('order' => 'title'));
|
$repository = $this->repositoryManager->getRepository(IconModel::class);
|
||||||
|
$collection = $repository->findAll(['order' => 'title']);
|
||||||
$builder = OptionsBuilder::fromCollection(
|
$builder = OptionsBuilder::fromCollection(
|
||||||
$collection,
|
$collection,
|
||||||
function ($model) {
|
function ($model) {
|
||||||
@@ -424,6 +458,49 @@ class LayerDcaListener extends AbstractListener
|
|||||||
return $builder->getOptions();
|
return $builder->getOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the file formats.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getFileFormats(): array
|
||||||
|
{
|
||||||
|
return array_keys($this->fileFormats);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the file widget.
|
||||||
|
*
|
||||||
|
* @param mixed $value Given value.
|
||||||
|
* @param DataContainer $dataContainer Data container driver.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function prepareFileWidget($value, $dataContainer)
|
||||||
|
{
|
||||||
|
if ($dataContainer->activeRecord) {
|
||||||
|
$fileFormat = $dataContainer->activeRecord->fileFormat;
|
||||||
|
|
||||||
|
if (isset($this->fileFormats[$fileFormat])) {
|
||||||
|
$definition = $this->getDefinition();
|
||||||
|
$definition->set(
|
||||||
|
['fields', $dataContainer->field, 'eval', 'extensions'],
|
||||||
|
implode(',', $this->fileFormats[$fileFormat])
|
||||||
|
);
|
||||||
|
|
||||||
|
$definition->set(
|
||||||
|
['fields', $dataContainer->field, 'label', 1],
|
||||||
|
sprintf(
|
||||||
|
$definition->get(['fields', $dataContainer->field, 'label', 1]),
|
||||||
|
implode(', ', $this->fileFormats[$fileFormat])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a button.
|
* Generate a button.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -12,11 +12,14 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||||
|
|
||||||
use Contao\Controller;
|
use Contao\CoreBundle\Framework\Adapter;
|
||||||
use Contao\DataContainer;
|
use Contao\DataContainer;
|
||||||
|
use Contao\System;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLng;
|
use Netzmacht\LeafletPHP\Value\LatLng;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
use Symfony\Component\Templating\EngineInterface as TemplateEngine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Leaflet is the base helper providing different methods.
|
* Class Leaflet is the base helper providing different methods.
|
||||||
@@ -39,15 +42,47 @@ class LeafletDcaListener
|
|||||||
*/
|
*/
|
||||||
private $cacheDir;
|
private $cacheDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template engine.
|
||||||
|
*
|
||||||
|
* @var TemplateEngine
|
||||||
|
*/
|
||||||
|
private $templateEngine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* System adapter.
|
||||||
|
*
|
||||||
|
* @var Adapter|System
|
||||||
|
*/
|
||||||
|
private $systemAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LeafletCallbacks constructor.
|
* LeafletCallbacks constructor.
|
||||||
*
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
* @param TemplateEngine $templateEngine Template engine.
|
||||||
* @param Filesystem $fileSystem File system.
|
* @param Filesystem $fileSystem File system.
|
||||||
|
* @param Adapter|System $systemAdapter Contao system adapter.
|
||||||
* @param string $cacheDir Cache dir.
|
* @param string $cacheDir Cache dir.
|
||||||
*/
|
*/
|
||||||
public function __construct(Filesystem $fileSystem, string $cacheDir)
|
public function __construct(
|
||||||
{
|
RepositoryManager $repositoryManager,
|
||||||
|
TemplateEngine $templateEngine,
|
||||||
|
Filesystem $fileSystem,
|
||||||
|
$systemAdapter,
|
||||||
|
string $cacheDir
|
||||||
|
) {
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
$this->templateEngine = $templateEngine;
|
||||||
$this->fileSystem = $fileSystem;
|
$this->fileSystem = $fileSystem;
|
||||||
|
$this->systemAdapter = $systemAdapter;
|
||||||
$this->cacheDir = $cacheDir;
|
$this->cacheDir = $cacheDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +93,7 @@ class LeafletDcaListener
|
|||||||
*/
|
*/
|
||||||
public function loadLanguageFile()
|
public function loadLanguageFile()
|
||||||
{
|
{
|
||||||
Controller::loadLanguageFile('leaflet');
|
$this->systemAdapter->loadLanguageFile('leaflet');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,17 +115,16 @@ class LeafletDcaListener
|
|||||||
*/
|
*/
|
||||||
public function getGeocoder($dataContainer)
|
public function getGeocoder($dataContainer)
|
||||||
{
|
{
|
||||||
$template = new \BackendTemplate('be_leaflet_geocode');
|
$data['field'] = 'ctrl_' . $dataContainer->field;
|
||||||
$template->field = 'ctrl_' . $dataContainer->field;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$latLng = LatLng::fromString($dataContainer->value);
|
$latLng = LatLng::fromString($dataContainer->value);
|
||||||
$template->marker = json_encode($latLng);
|
$data['marker'] = json_encode($latLng);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// LatLng throws an exception of value could not be created. Just let the value empty when.
|
// LatLng throws an exception of value could not be created. Just let the value empty when.
|
||||||
}
|
}
|
||||||
|
|
||||||
return $template->parse();
|
return $this->templateEngine->render('toolkit:be:be_leaflet_geocode.html5', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,8 +134,9 @@ class LeafletDcaListener
|
|||||||
*/
|
*/
|
||||||
public function getLayers()
|
public function getLayers()
|
||||||
{
|
{
|
||||||
$options = array();
|
$options = [];
|
||||||
$collection = LayerModel::findBy('pid', '0', array('order' => 'title'));
|
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||||
|
$collection = $repository->findBy(['pid=?'], ['0'], ['order' => 'title']);
|
||||||
|
|
||||||
if ($collection) {
|
if ($collection) {
|
||||||
foreach ($collection as $model) {
|
foreach ($collection as $model) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use Contao\DataContainer;
|
|||||||
use Contao\StringUtil;
|
use Contao\StringUtil;
|
||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
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\AbstractListener;
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Manager;
|
use Netzmacht\Contao\Toolkit\Dca\Manager;
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
||||||
@@ -44,17 +45,26 @@ class MapDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct.
|
* Construct.
|
||||||
*
|
*
|
||||||
* @param Manager $manager Data container manager.
|
* @param Manager $manager Data container manager.
|
||||||
* @param Connection $connection Database connection.
|
* @param Connection $connection Database connection.
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
*/
|
*/
|
||||||
public function __construct(Manager $manager, Connection $connection)
|
public function __construct(Manager $manager, Connection $connection, RepositoryManager $repositoryManager)
|
||||||
{
|
{
|
||||||
parent::__construct($manager);
|
parent::__construct($manager);
|
||||||
|
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,7 +100,7 @@ class MapDcaListener extends AbstractListener
|
|||||||
public function saveLayerRelations($layerId, $dataContainer)
|
public function saveLayerRelations($layerId, $dataContainer)
|
||||||
{
|
{
|
||||||
$new = array_filter(StringUtil::deserialize($layerId, true));
|
$new = array_filter(StringUtil::deserialize($layerId, true));
|
||||||
$values = array();
|
$values = [];
|
||||||
$statement = $this->connection->prepare('SELECT * FROM tl_leaflet_map_layer WHERE mid=:mid order BY sorting');
|
$statement = $this->connection->prepare('SELECT * FROM tl_leaflet_map_layer WHERE mid=:mid order BY sorting');
|
||||||
|
|
||||||
$statement->bindValue('mid', $dataContainer->id);
|
$statement->bindValue('mid', $dataContainer->id);
|
||||||
@@ -108,7 +118,7 @@ class MapDcaListener extends AbstractListener
|
|||||||
'tstamp' => time(),
|
'tstamp' => time(),
|
||||||
'lid' => $layerId,
|
'lid' => $layerId,
|
||||||
'mid' => $dataContainer->id,
|
'mid' => $dataContainer->id,
|
||||||
'sorting' => $sorting
|
'sorting' => $sorting,
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->connection->insert('tl_leaflet_map_layer', $data);
|
$this->connection->insert('tl_leaflet_map_layer', $data);
|
||||||
@@ -150,13 +160,12 @@ class MapDcaListener extends AbstractListener
|
|||||||
/**
|
/**
|
||||||
* Get all layers except of the current layer.
|
* Get all layers except of the current layer.
|
||||||
*
|
*
|
||||||
* @param DataContainer $dataContainer The dataContainer driver.
|
|
||||||
*
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getLayers($dataContainer)
|
public function getLayers()
|
||||||
{
|
{
|
||||||
$collection = LayerModel::findBy('id !', $dataContainer->id);
|
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||||
|
$collection = $repository->findAll(['order' => 'title']);
|
||||||
|
|
||||||
return OptionsBuilder::fromCollection($collection, 'title')
|
return OptionsBuilder::fromCollection($collection, 'title')
|
||||||
->asTree()
|
->asTree()
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
|||||||
|
|
||||||
use Contao\Controller;
|
use Contao\Controller;
|
||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
|
||||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||||
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
|
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Marker is the dca helper class for the tl_leaflet_marker dca.
|
* Class Marker is the dca helper class for the tl_leaflet_marker dca.
|
||||||
@@ -32,24 +33,23 @@ class MarkerDcaListener
|
|||||||
*/
|
*/
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MarkerDcaListener constructor.
|
* MarkerDcaListener constructor.
|
||||||
*
|
*
|
||||||
* @param Connection $connection Database connection.
|
* @param Connection $connection Database connection.
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
*/
|
*/
|
||||||
public function __construct(Connection $connection)
|
public function __construct(Connection $connection, RepositoryManager $repositoryManager)
|
||||||
{
|
{
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
}
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the language files.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function initialize()
|
|
||||||
{
|
|
||||||
Controller::loadLanguageFile('leaflet');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +71,8 @@ class MarkerDcaListener
|
|||||||
*/
|
*/
|
||||||
public function getIcons()
|
public function getIcons()
|
||||||
{
|
{
|
||||||
$collection = IconModel::findAll(array('order' => 'title'));
|
$repository = $this->repositoryManager->getRepository(IconModel::class);
|
||||||
|
$collection = $repository->findAll(['order' => 'title']);
|
||||||
$builder = OptionsBuilder::fromCollection(
|
$builder = OptionsBuilder::fromCollection(
|
||||||
$collection,
|
$collection,
|
||||||
function ($model) {
|
function ($model) {
|
||||||
@@ -89,7 +90,8 @@ class MarkerDcaListener
|
|||||||
*/
|
*/
|
||||||
public function getPopups()
|
public function getPopups()
|
||||||
{
|
{
|
||||||
$collection = PopupModel::findAll(array('order' => 'title'));
|
$repository = $this->repositoryManager->getRepository(PopupModel::class);
|
||||||
|
$collection = $repository->findAll(['order' => 'title']);
|
||||||
$builder = OptionsBuilder::fromCollection($collection, 'title');
|
$builder = OptionsBuilder::fromCollection($collection, 'title');
|
||||||
|
|
||||||
return $builder->getOptions();
|
return $builder->getOptions();
|
||||||
@@ -105,11 +107,11 @@ class MarkerDcaListener
|
|||||||
*/
|
*/
|
||||||
public function saveCoordinates($value, $dataContainer)
|
public function saveCoordinates($value, $dataContainer)
|
||||||
{
|
{
|
||||||
$combined = array(
|
$combined = [
|
||||||
'latitude' => null,
|
'latitude' => null,
|
||||||
'longitude' => null,
|
'longitude' => null,
|
||||||
'altitude' => null
|
'altitude' => null,
|
||||||
);
|
];
|
||||||
|
|
||||||
$values = trimsplit(',', $value);
|
$values = trimsplit(',', $value);
|
||||||
$keys = array_keys($combined);
|
$keys = array_keys($combined);
|
||||||
|
|||||||
@@ -12,12 +12,12 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
|
||||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||||
|
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
||||||
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Listener\AbstractListener;
|
use Netzmacht\Contao\Toolkit\Dca\Listener\AbstractListener;
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Manager;
|
use Netzmacht\Contao\Toolkit\Dca\Manager;
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
||||||
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for the tl_leaflet_vector dca.
|
* Helper class for the tl_leaflet_vector dca.
|
||||||
@@ -40,17 +40,26 @@ class VectorDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
private $vectors;
|
private $vectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct.
|
* Construct.
|
||||||
*
|
*
|
||||||
* @param Manager $dcaManager Data container manager.
|
* @param Manager $dcaManager Data container manager.
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
* @param array $vectors Vectors.
|
* @param array $vectors Vectors.
|
||||||
*/
|
*/
|
||||||
public function __construct(Manager $dcaManager, array $vectors)
|
public function __construct(Manager $dcaManager, RepositoryManager $repositoryManager, array $vectors)
|
||||||
{
|
{
|
||||||
parent::__construct($dcaManager);
|
parent::__construct($dcaManager);
|
||||||
|
|
||||||
$this->vectors = $vectors;
|
$this->vectors = $vectors;
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,29 +95,12 @@ class VectorDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
public function getStyles()
|
public function getStyles()
|
||||||
{
|
{
|
||||||
$collection = StyleModel::findAll(array('order' => 'title'));
|
$repository = $this->repositoryManager->getRepository(StyleModel::class);
|
||||||
|
$collection = $repository->findAll(['order' => 'title']);
|
||||||
|
|
||||||
return OptionsBuilder::fromCollection($collection, 'title')->getOptions();
|
return OptionsBuilder::fromCollection($collection, 'title')->getOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all icons.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getIcons()
|
|
||||||
{
|
|
||||||
$collection = IconModel::findAll(array('order' => 'title'));
|
|
||||||
$builder = OptionsBuilder::fromCollection(
|
|
||||||
$collection,
|
|
||||||
function ($model) {
|
|
||||||
return sprintf('%s [%s]', $model['title'], $model['type']);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return $builder->getOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all popups.
|
* Get all popups.
|
||||||
*
|
*
|
||||||
@@ -116,7 +108,8 @@ class VectorDcaListener extends AbstractListener
|
|||||||
*/
|
*/
|
||||||
public function getPopups()
|
public function getPopups()
|
||||||
{
|
{
|
||||||
$collection = PopupModel::findAll(array('order' => 'title'));
|
$repository = $this->repositoryManager->getRepository(PopupModel::class);
|
||||||
|
$collection = $repository->findAll(['order' => 'title']);
|
||||||
$builder = OptionsBuilder::fromCollection($collection, 'title');
|
$builder = OptionsBuilder::fromCollection($collection, 'title');
|
||||||
|
|
||||||
return $builder->getOptions();
|
return $builder->getOptions();
|
||||||
|
|||||||
@@ -10,24 +10,30 @@
|
|||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Subscriber;
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Netzmacht\Contao\Leaflet\Listener;
|
||||||
|
|
||||||
|
use Contao\FilesModel;
|
||||||
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Event\ConvertToGeoJsonEvent;
|
use Netzmacht\Contao\Leaflet\Event\ConvertToGeoJsonEvent;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\Feature;
|
use Netzmacht\LeafletPHP\Definition as LeafletDefinition;
|
||||||
use Netzmacht\LeafletPHP\Definition\HasPopup;
|
use Netzmacht\LeafletPHP\Definition\HasPopup;
|
||||||
use Netzmacht\LeafletPHP\Definition\UI\Marker;
|
use Netzmacht\LeafletPHP\Definition\UI\Marker;
|
||||||
|
use Netzmacht\LeafletPHP\Definition\Vector;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\Circle;
|
use Netzmacht\LeafletPHP\Definition\Vector\Circle;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\CircleMarker;
|
use Netzmacht\LeafletPHP\Definition\Vector\CircleMarker;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Netzmacht\LeafletPHP\Value\GeoJson\Feature;
|
||||||
|
use Netzmacht\LeafletPHP\Value\GeoJson\GeoJsonObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GeoJsonSubscriber provides subscribers when a definition is converted to a geo json feature.
|
* Class GeoJsonSubscriber provides subscribers when a definition is converted to a geo json feature.
|
||||||
*
|
*
|
||||||
* @package Netzmacht\Contao\Leaflet\Subscriber
|
* @package Netzmacht\Contao\Leaflet\Subscriber
|
||||||
*/
|
*/
|
||||||
class GeoJsonSubscriber implements EventSubscriberInterface
|
final class GeoJsonListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Property mapping between models and features.
|
* Property mapping between models and features.
|
||||||
@@ -36,43 +42,54 @@ class GeoJsonSubscriber implements EventSubscriberInterface
|
|||||||
*/
|
*/
|
||||||
private $featureModelProperties;
|
private $featureModelProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GeoJsonSubscriber constructor.
|
* GeoJsonSubscriber constructor.
|
||||||
*
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
* @param array $featureModelProperties Property mapping between models and features.
|
* @param array $featureModelProperties Property mapping between models and features.
|
||||||
*/
|
*/
|
||||||
public function __construct(array $featureModelProperties)
|
public function __construct(RepositoryManager $repositoryManager, array $featureModelProperties)
|
||||||
{
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
$this->featureModelProperties = $featureModelProperties;
|
$this->featureModelProperties = $featureModelProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param ConvertToGeoJsonEvent $event The event.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function getSubscribedEvents()
|
public function handle(ConvertToGeoJsonEvent $event)
|
||||||
{
|
{
|
||||||
return array(
|
$feature = $event->getGeoJson();
|
||||||
ConvertToGeoJsonEvent::NAME => array(
|
$definition = $event->getDefinition();
|
||||||
array('addPopup'),
|
$model = $event->getModel();
|
||||||
array('enrichObjects'),
|
|
||||||
array('enrichCircle'),
|
$this->addPopup($feature, $definition);
|
||||||
array('setModelData')
|
$this->enrichObjects($feature, $definition, $model);
|
||||||
)
|
$this->enrichCircle($feature, $definition);
|
||||||
);
|
$this->setModelData($feature, $model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add popup property for definitions with an popup.
|
* Add popup property for definitions with an popup.
|
||||||
*
|
*
|
||||||
* @param ConvertToGeoJsonEvent $event The subscribed event.
|
* @param GeoJsonObject $feature The geojson feature object.
|
||||||
|
* @param LeafletDefinition $definition The definition.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addPopup(ConvertToGeoJsonEvent $event)
|
public function addPopup(GeoJsonObject $feature, LeafletDefinition $definition)
|
||||||
{
|
{
|
||||||
$feature = $event->getGeoJson();
|
|
||||||
$definition = $event->getDefinition();
|
|
||||||
|
|
||||||
if ($definition instanceof HasPopup && $feature instanceof Feature) {
|
if ($definition instanceof HasPopup && $feature instanceof Feature) {
|
||||||
if ($definition->getPopup()) {
|
if ($definition->getPopup()) {
|
||||||
$feature->setProperty('popup', $definition->getPopup());
|
$feature->setProperty('popup', $definition->getPopup());
|
||||||
@@ -91,16 +108,14 @@ class GeoJsonSubscriber implements EventSubscriberInterface
|
|||||||
/**
|
/**
|
||||||
* Enrich map object with feature data and bounds information.
|
* Enrich map object with feature data and bounds information.
|
||||||
*
|
*
|
||||||
* @param ConvertToGeoJsonEvent $event The subscribed event.
|
* @param GeoJsonObject $feature The geojson feature object.
|
||||||
|
* @param LeafletDefinition $definition The definition.
|
||||||
|
* @param Model|object $model The data model.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function enrichObjects(ConvertToGeoJsonEvent $event)
|
public function enrichObjects(GeoJsonObject $feature, LeafletDefinition $definition, $model)
|
||||||
{
|
{
|
||||||
$feature = $event->getGeoJson();
|
|
||||||
$definition = $event->getDefinition();
|
|
||||||
$model = $event->getModel();
|
|
||||||
|
|
||||||
if (($definition instanceof Marker || $definition instanceof Vector)
|
if (($definition instanceof Marker || $definition instanceof Vector)
|
||||||
&& $model instanceof \Model && $feature instanceof Feature) {
|
&& $model instanceof \Model && $feature instanceof Feature) {
|
||||||
$this->setDataProperty($model, $feature);
|
$this->setDataProperty($model, $feature);
|
||||||
@@ -111,32 +126,28 @@ class GeoJsonSubscriber implements EventSubscriberInterface
|
|||||||
/**
|
/**
|
||||||
* Enrich the the circle with constructor arguments.
|
* Enrich the the circle with constructor arguments.
|
||||||
*
|
*
|
||||||
* @param ConvertToGeoJsonEvent $event The subscribed events.
|
* @param GeoJsonObject $feature The geojson feature object.
|
||||||
|
* @param LeafletDefinition $definition The definition.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function enrichCircle(ConvertToGeoJsonEvent $event)
|
public function enrichCircle(GeoJsonObject $feature, LeafletDefinition $definition)
|
||||||
{
|
{
|
||||||
$feature = $event->getGeoJson();
|
|
||||||
$definition = $event->getDefinition();
|
|
||||||
|
|
||||||
if ($definition instanceof Circle && !$definition instanceof CircleMarker && $feature instanceof Feature) {
|
if ($definition instanceof Circle && !$definition instanceof CircleMarker && $feature instanceof Feature) {
|
||||||
$feature->setProperty('arguments', array($definition->getLatLng(), $definition->getRadius()));
|
$feature->setProperty('arguments', [$definition->getLatLng(), $definition->getRadius()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass configured properties on an model to the properties.model key.
|
* Pass configured properties on an model to the properties.model key.
|
||||||
*
|
*
|
||||||
* @param ConvertToGeoJsonEvent $event The subscribed events.
|
* @param GeoJsonObject $feature The geojson feature object.
|
||||||
|
* @param Model|object $model The data model.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setModelData(ConvertToGeoJsonEvent $event)
|
public function setModelData(GeoJsonObject $feature, $model)
|
||||||
{
|
{
|
||||||
$feature = $event->getGeoJson();
|
|
||||||
$model = $event->getModel();
|
|
||||||
|
|
||||||
if (!$model instanceof \Model || !$feature instanceof Feature
|
if (!$model instanceof \Model || !$feature instanceof Feature
|
||||||
|| empty($this->featureModelProperties[$model->getTable()])) {
|
|| empty($this->featureModelProperties[$model->getTable()])) {
|
||||||
return;
|
return;
|
||||||
@@ -176,17 +187,19 @@ class GeoJsonSubscriber implements EventSubscriberInterface
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'file':
|
case 'file':
|
||||||
$file = \FilesModel::findByUuid($value);
|
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||||
|
$file = $repository->findByUuid($value);
|
||||||
$value = $file->path;
|
$value = $file->path;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'files':
|
case 'files':
|
||||||
$collection = \FilesModel::findMultipleByUuids(deserialize($value, true));
|
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||||
|
$collection = $repository->findMultipleByUuids(deserialize($value, true));
|
||||||
|
|
||||||
if ($collection) {
|
if ($collection) {
|
||||||
$value = $collection->fetchEach('path');
|
$value = $collection->fetchEach('path');
|
||||||
} else {
|
} else {
|
||||||
$value = array();
|
$value = [];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -213,7 +226,8 @@ class GeoJsonSubscriber implements EventSubscriberInterface
|
|||||||
if ($model->ignoreForBounds) {
|
if ($model->ignoreForBounds) {
|
||||||
$feature->setProperty('ignoreForBounds', true);
|
$feature->setProperty('ignoreForBounds', true);
|
||||||
} else {
|
} else {
|
||||||
$parent = LayerModel::findByPk($model->pid);
|
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||||
|
$parent = $repository->find((int) $model->pid);
|
||||||
|
|
||||||
if ($parent && $parent->boundsMode !== 'extend') {
|
if ($parent && $parent->boundsMode !== 'extend') {
|
||||||
$feature->setProperty('ignoreForBounds', true);
|
$feature->setProperty('ignoreForBounds', true);
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Subscriber;
|
namespace Netzmacht\Contao\Leaflet\Listener;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Event\GetHashEvent;
|
use Netzmacht\Contao\Leaflet\Event\GetHashEvent;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
@@ -27,12 +27,12 @@ class HashSubscriber implements EventSubscriberInterface
|
|||||||
*/
|
*/
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
GetHashEvent::NAME => array(
|
GetHashEvent::NAME => [
|
||||||
array('getModelHash'),
|
['getModelHash'],
|
||||||
array('getFallback', -100)
|
['getFallback', -100],
|
||||||
)
|
],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,6 +18,7 @@ use Netzmacht\Contao\Leaflet\Encoder\ContaoAssets;
|
|||||||
use Netzmacht\Contao\Leaflet\Frontend\Assets\LibrariesConfiguration;
|
use Netzmacht\Contao\Leaflet\Frontend\Assets\LibrariesConfiguration;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||||
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\LeafletPHP\Assets;
|
use Netzmacht\LeafletPHP\Assets;
|
||||||
use Netzmacht\LeafletPHP\Definition\Type\Icon;
|
use Netzmacht\LeafletPHP\Definition\Type\Icon;
|
||||||
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
||||||
@@ -50,18 +51,31 @@ class LoadAssetsListener
|
|||||||
*/
|
*/
|
||||||
private $libraries;
|
private $libraries;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LoadAssetsListener constructor.
|
* LoadAssetsListener constructor.
|
||||||
*
|
*
|
||||||
* @param Assets $assets Assets.
|
* @param Assets $assets Assets.
|
||||||
* @param DefinitionMapper $definitionMapper Definition mapper.
|
* @param DefinitionMapper $definitionMapper Definition mapper.
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
* @param LibrariesConfiguration $libraries Libraries.
|
* @param LibrariesConfiguration $libraries Libraries.
|
||||||
*/
|
*/
|
||||||
public function __construct(Assets $assets, DefinitionMapper $definitionMapper, LibrariesConfiguration $libraries)
|
public function __construct(
|
||||||
{
|
Assets $assets,
|
||||||
|
DefinitionMapper $definitionMapper,
|
||||||
|
RepositoryManager $repositoryManager,
|
||||||
|
LibrariesConfiguration $libraries
|
||||||
|
) {
|
||||||
$this->assets = $assets;
|
$this->assets = $assets;
|
||||||
$this->definitionMapper = $definitionMapper;
|
$this->definitionMapper = $definitionMapper;
|
||||||
$this->libraries = $libraries;
|
$this->libraries = $libraries;
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +90,8 @@ class LoadAssetsListener
|
|||||||
ContaoAssets::TYPE_FILE
|
ContaoAssets::TYPE_FILE
|
||||||
);
|
);
|
||||||
|
|
||||||
$collection = IconModel::findBy('active', true);
|
$repository = $this->repositoryManager->getRepository(IconModel::class);
|
||||||
|
$collection = $repository->findBy(['active=?'], [true]);
|
||||||
|
|
||||||
if ($collection) {
|
if ($collection) {
|
||||||
$buffer = '';
|
$buffer = '';
|
||||||
@@ -127,12 +142,12 @@ class LoadAssetsListener
|
|||||||
$assets = $this->libraries[$library];
|
$assets = $this->libraries[$library];
|
||||||
|
|
||||||
if (!empty($assets['css'])) {
|
if (!empty($assets['css'])) {
|
||||||
list ($source, $type) = (array)$assets['css'];
|
list ($source, $type) = (array) $assets['css'];
|
||||||
$this->assets->addStylesheet($source, $type ?: Assets::TYPE_FILE);
|
$this->assets->addStylesheet($source, $type ?: Assets::TYPE_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($assets['javascript'])) {
|
if (!empty($assets['javascript'])) {
|
||||||
list ($source, $type) = (array)$assets['javascript'];
|
list ($source, $type) = (array) $assets['javascript'];
|
||||||
$this->assets->addJavascript($source, $type ?: Assets::TYPE_FILE);
|
$this->assets->addJavascript($source, $type ?: Assets::TYPE_FILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,13 +19,16 @@ use Netzmacht\Contao\Leaflet\Event\GetJavascriptEvent;
|
|||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\DataController;
|
use Netzmacht\Contao\Leaflet\Frontend\DataController;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection;
|
use Netzmacht\Contao\Toolkit\View\Template\TemplateReference;
|
||||||
use Netzmacht\LeafletPHP\Definition\Map;
|
use Netzmacht\LeafletPHP\Definition\Map;
|
||||||
use Netzmacht\LeafletPHP\Leaflet;
|
use Netzmacht\LeafletPHP\Leaflet;
|
||||||
|
use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface as EventDispatcher;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface as EventDispatcher;
|
||||||
|
use Symfony\Component\Templating\EngineInterface as TemplateEngine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class MapProvider.
|
* Class MapProvider.
|
||||||
@@ -83,6 +86,20 @@ class MapProvider
|
|||||||
*/
|
*/
|
||||||
private $dataController;
|
private $dataController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template engine.
|
||||||
|
*
|
||||||
|
* @var TemplateEngine
|
||||||
|
*/
|
||||||
|
private $templateEngine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct.
|
* Construct.
|
||||||
*
|
*
|
||||||
@@ -93,8 +110,8 @@ class MapProvider
|
|||||||
* @param ContaoAssets $assets Assets handler.
|
* @param ContaoAssets $assets Assets handler.
|
||||||
* @param Cache $cache Cache.
|
* @param Cache $cache Cache.
|
||||||
* @param DataController $dataController Data controller.
|
* @param DataController $dataController Data controller.
|
||||||
*
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
* @internal param FilterFactory $filterFactory Filter factory.
|
* @param TemplateEngine $templateEngine Template engine.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
@@ -103,7 +120,9 @@ class MapProvider
|
|||||||
$input,
|
$input,
|
||||||
ContaoAssets $assets,
|
ContaoAssets $assets,
|
||||||
Cache $cache,
|
Cache $cache,
|
||||||
DataController $dataController
|
DataController $dataController,
|
||||||
|
RepositoryManager $repositoryManager,
|
||||||
|
TemplateEngine $templateEngine
|
||||||
) {
|
) {
|
||||||
$this->mapper = $mapper;
|
$this->mapper = $mapper;
|
||||||
$this->leaflet = $leaflet;
|
$this->leaflet = $leaflet;
|
||||||
@@ -112,6 +131,8 @@ class MapProvider
|
|||||||
$this->assets = $assets;
|
$this->assets = $assets;
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
$this->dataController = $dataController;
|
$this->dataController = $dataController;
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
$this->templateEngine = $templateEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,7 +170,8 @@ class MapProvider
|
|||||||
*/
|
*/
|
||||||
public function getModel($mapId)
|
public function getModel($mapId)
|
||||||
{
|
{
|
||||||
$model = MapModel::findByIdOrAlias($mapId);
|
$repository = $this->repositoryManager->getRepository(MapModel::class);
|
||||||
|
$model = $repository->findByIdOrAlias($mapId);
|
||||||
|
|
||||||
if ($model === null) {
|
if ($model === null) {
|
||||||
throw new \InvalidArgumentException(sprintf('Model "%s" not found', $mapId));
|
throw new \InvalidArgumentException(sprintf('Model "%s" not found', $mapId));
|
||||||
@@ -202,7 +224,7 @@ class MapProvider
|
|||||||
$cacheKey,
|
$cacheKey,
|
||||||
[
|
[
|
||||||
'assets' => $this->assets->toArray(),
|
'assets' => $this->assets->toArray(),
|
||||||
'javascript' => $buffer
|
'javascript' => $buffer,
|
||||||
],
|
],
|
||||||
(int) $model->cacheLifeTime
|
(int) $model->cacheLifeTime
|
||||||
);
|
);
|
||||||
@@ -226,7 +248,8 @@ class MapProvider
|
|||||||
if ($layerId instanceof LayerModel) {
|
if ($layerId instanceof LayerModel) {
|
||||||
$model = $layerId;
|
$model = $layerId;
|
||||||
} else {
|
} else {
|
||||||
$model = LayerModel::findByPK($layerId);
|
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||||
|
$model = $repository->find((int) $layerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$model || !$model->active) {
|
if (!$model || !$model->active) {
|
||||||
@@ -279,7 +302,7 @@ class MapProvider
|
|||||||
throw new \RuntimeException('Bad request. Could not resolve query params');
|
throw new \RuntimeException('Bad request. Could not resolve query params');
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array_combine(array('for', 'type', 'id', 'format', 'filter', 'values'), $data);
|
$data = array_combine(['for', 'type', 'id', 'format', 'filter', 'values'], $data);
|
||||||
$data = array_filter($data);
|
$data = array_filter($data);
|
||||||
|
|
||||||
if (empty($data['for']) || $data['for'] != $identifier) {
|
if (empty($data['for']) || $data['for'] != $identifier) {
|
||||||
@@ -345,18 +368,20 @@ class MapProvider
|
|||||||
protected function doGenerate($model, $filter, $elementId, $template, $style)
|
protected function doGenerate($model, $filter, $elementId, $template, $style)
|
||||||
{
|
{
|
||||||
$definition = $this->getDefinition($model, $filter, $elementId);
|
$definition = $this->getDefinition($model, $filter, $elementId);
|
||||||
$template = \Controller::getTemplate($template);
|
|
||||||
|
|
||||||
// @codingStandardsIgnoreStart - Set for the template.
|
|
||||||
$javascript = $this->leaflet->build($definition, $this->assets);
|
$javascript = $this->leaflet->build($definition, $this->assets);
|
||||||
$mapId = $definition->getId();
|
$mapId = $definition->getId();
|
||||||
// @codingStandardsIgnoreEnd
|
|
||||||
|
|
||||||
ob_start();
|
$templateReference = new TemplateReference($template, 'html5', TemplateReference::SCOPE_FRONTEND);
|
||||||
include $template;
|
$parameters = [
|
||||||
$content = ob_get_contents();
|
'definition' => $definition,
|
||||||
ob_end_clean();
|
'model' => $model,
|
||||||
|
'elementId' => $elementId,
|
||||||
|
'style' => $style,
|
||||||
|
'javascript' => $javascript,
|
||||||
|
'mapId' => $mapId,
|
||||||
|
];
|
||||||
|
|
||||||
|
$content = $this->templateEngine->render($templateReference, $parameters);
|
||||||
$event = new GetJavascriptEvent($definition, $content);
|
$event = new GetJavascriptEvent($definition, $content);
|
||||||
$this->eventDispatcher->dispatch($event::NAME, $event);
|
$this->eventDispatcher->dispatch($event::NAME, $event);
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,9 +156,9 @@ abstract class AbstractMapper implements Mapper
|
|||||||
Request $request = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
return array(
|
return [
|
||||||
$this->getElementId($model, $elementId)
|
$this->getElementId($model, $elementId),
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AbstractTypeMapper is the base mapper for tables containing different types of definitins.
|
* Class AbstractTypeMapper is the base mapper for tables containing different types of definitins.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
|||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Control\Attribution;
|
use Netzmacht\LeafletPHP\Definition\Control\Attribution;
|
||||||
use Netzmacht\LeafletPHP\Definition\Map;
|
use Netzmacht\LeafletPHP\Definition\Map;
|
||||||
@@ -31,7 +31,7 @@ class AttributionControlMapper extends AbstractControlMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Attribution';
|
protected static $definitionClass = Attribution::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
||||||
|
|
||||||
|
use Netzmacht\LeafletPHP\Plugins\FullScreen\FullScreenControl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class FullscreenControlMapper.
|
* Class FullscreenControlMapper.
|
||||||
*
|
*
|
||||||
@@ -24,7 +26,7 @@ class FullscreenControlMapper extends AbstractControlMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Plugins\FullScreen\FullScreenControl';
|
protected static $definitionClass = FullScreenControl::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
|||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\LeafletPHP\Definition\Control\Layers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class LayersControlMapper maps the control model to the layers control definition.
|
* Class LayersControlMapper maps the control model to the layers control definition.
|
||||||
@@ -29,7 +30,7 @@ class LayersControlMapper extends AbstractControlMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Layers';
|
protected static $definitionClass = Layers::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
@@ -48,8 +49,8 @@ class LayersControlMapper extends AbstractControlMapper
|
|||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||||
$arguments[1] = array();
|
$arguments[1] = [];
|
||||||
$arguments[2] = array();
|
$arguments[2] = [];
|
||||||
|
|
||||||
/** @var ControlModel $model */
|
/** @var ControlModel $model */
|
||||||
$collection = $model->findActiveLayers();
|
$collection = $model->findActiveLayers();
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
|||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Control\Zoom;
|
use Netzmacht\LeafletPHP\Definition\Control\Zoom;
|
||||||
use Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl;
|
use Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl;
|
||||||
@@ -35,16 +36,35 @@ class LoadingControlMapper extends AbstractControlMapper
|
|||||||
*/
|
*/
|
||||||
protected static $type = 'loading';
|
protected static $type = 'loading';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
if ($model->spinjs) {
|
if ($model->spinjs) {
|
||||||
return 'Netzmacht\LeafletPHP\Plugins\Loading\SpinJsLoadingControl';
|
return SpinJsLoadingControl::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl';
|
return LoadingControl::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,9 +99,10 @@ class LoadingControlMapper extends AbstractControlMapper
|
|||||||
|
|
||||||
if ($definition instanceof LoadingControl && !$definition->isSeparate() && $model->zoomControl) {
|
if ($definition instanceof LoadingControl && !$definition->isSeparate() && $model->zoomControl) {
|
||||||
// Only assign if zoom control is activated and part of the map.
|
// Only assign if zoom control is activated and part of the map.
|
||||||
$control = ControlModel::findOneBy(
|
$repository = $this->repositoryManager->getRepository(ControlModel::class);
|
||||||
array('active=1', 'type=?', 'pid=?', 'id=?'),
|
$control = $repository->findOneBy(
|
||||||
array('zoom', $model->pid, $model->zoomControl)
|
['active=1', 'type=?', 'pid=?', 'id=?'],
|
||||||
|
['zoom', $model->pid, $model->zoomControl]
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($control) {
|
if ($control) {
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
||||||
|
|
||||||
|
use Netzmacht\LeafletPHP\Definition\Control\Scale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ScaleControlMapper maps the database item of the type "scale" to the scale control.
|
* Class ScaleControlMapper maps the database item of the type "scale" to the scale control.
|
||||||
*
|
*
|
||||||
@@ -24,7 +26,7 @@ class ScaleControlMapper extends AbstractControlMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Scale';
|
protected static $definitionClass = Scale::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
||||||
|
|
||||||
|
use Netzmacht\LeafletPHP\Definition\Control\Zoom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ZoomControlMapper maps the zoom database definition to the zoom control.
|
* Class ZoomControlMapper maps the zoom database definition to the zoom control.
|
||||||
*
|
*
|
||||||
@@ -24,7 +26,7 @@ class ZoomControlMapper extends AbstractControlMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Zoom';
|
protected static $definitionClass = Zoom::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ namespace Netzmacht\Contao\Leaflet\Mapper;
|
|||||||
use Netzmacht\Contao\Leaflet\Event\BuildDefinitionEvent;
|
use Netzmacht\Contao\Leaflet\Event\BuildDefinitionEvent;
|
||||||
use Netzmacht\Contao\Leaflet\Event\ConvertToGeoJsonEvent;
|
use Netzmacht\Contao\Leaflet\Event\ConvertToGeoJsonEvent;
|
||||||
use Netzmacht\Contao\Leaflet\Event\GetHashEvent;
|
use Netzmacht\Contao\Leaflet\Event\GetHashEvent;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\ConvertsToGeoJsonFeature;
|
use Netzmacht\LeafletPHP\Value\GeoJson\ConvertsToGeoJsonFeature;
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\Feature;
|
use Netzmacht\LeafletPHP\Value\GeoJson\Feature;
|
||||||
@@ -35,7 +34,7 @@ class DefinitionMapper
|
|||||||
*
|
*
|
||||||
* @var Mapper[][]
|
* @var Mapper[][]
|
||||||
*/
|
*/
|
||||||
private $mappers = array();
|
private $mappers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The event dispatcher.
|
* The event dispatcher.
|
||||||
@@ -49,7 +48,7 @@ class DefinitionMapper
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $mapped = array();
|
private $mapped = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct.
|
* Construct.
|
||||||
@@ -85,7 +84,7 @@ class DefinitionMapper
|
|||||||
*/
|
*/
|
||||||
public function reset()
|
public function reset()
|
||||||
{
|
{
|
||||||
$this->mapped = array();
|
$this->mapped = [];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\GeoJsonFeature;
|
use Netzmacht\LeafletPHP\Value\GeoJson\GeoJsonFeature;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
171
src/Mapper/Layer/FileLayerMapper.php
Normal file
171
src/Mapper/Layer/FileLayerMapper.php
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leaflet maps for Contao CMS.
|
||||||
|
*
|
||||||
|
* @package contao-leaflet-maps
|
||||||
|
* @author David Molineus <david.molineus@netzmacht.de>
|
||||||
|
* @copyright 2014-2017 netzmacht David Molineus. All rights reserved.
|
||||||
|
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||||
|
|
||||||
|
use Contao\FilesModel;
|
||||||
|
use Contao\Model;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
|
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||||
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
use Netzmacht\LeafletPHP\Definition\Group\FeatureGroup;
|
||||||
|
use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
|
||||||
|
use Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson as OmnivoreGeoJson;
|
||||||
|
use Netzmacht\LeafletPHP\Plugins\Omnivore\Gpx;
|
||||||
|
use Netzmacht\LeafletPHP\Plugins\Omnivore\Kml;
|
||||||
|
use Netzmacht\LeafletPHP\Plugins\Omnivore\OmnivoreLayer;
|
||||||
|
use Netzmacht\LeafletPHP\Plugins\Omnivore\TopoJson;
|
||||||
|
use Netzmacht\LeafletPHP\Plugins\Omnivore\Wkt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class FileLayerMapper.
|
||||||
|
*
|
||||||
|
* @package Netzmacht\Contao\Leaflet\Mapper\Layer
|
||||||
|
*/
|
||||||
|
class FileLayerMapper extends AbstractLayerMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The definition type.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected static $type = 'file';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class of the model being build.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected static $definitionClass = FeatureGroup::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function handle(
|
||||||
|
$model,
|
||||||
|
DefinitionMapper $mapper,
|
||||||
|
Request $request = null,
|
||||||
|
$elementId = null,
|
||||||
|
Definition $parent = null
|
||||||
|
) {
|
||||||
|
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||||
|
$fileModel = $repository->findByPk($model->file);
|
||||||
|
$definition = $this->createInstance($model, $mapper, $request, $elementId, $fileModel);
|
||||||
|
|
||||||
|
$this->optionsBuilder->build($definition, $model);
|
||||||
|
$this->build($definition, $model, $mapper, $request, $parent);
|
||||||
|
|
||||||
|
return $definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
protected function createInstance(
|
||||||
|
Model $model,
|
||||||
|
DefinitionMapper $mapper,
|
||||||
|
Request $request = null,
|
||||||
|
$elementId = null,
|
||||||
|
FilesModel $fileModel = null
|
||||||
|
) {
|
||||||
|
$layerId = $this->getElementId($model, $elementId);
|
||||||
|
|
||||||
|
if ($fileModel instanceof FilesModel && $fileModel->type === 'file') {
|
||||||
|
switch ($model->fileFormat) {
|
||||||
|
case 'gpx':
|
||||||
|
$layer = new Gpx($layerId, $fileModel->path);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'kml':
|
||||||
|
$layer = new Kml($layerId, $fileModel->path);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'wkt':
|
||||||
|
$layer = new Wkt($layerId, $fileModel->path);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'geojson':
|
||||||
|
$layer = new OmnivoreGeoJson($layerId, $fileModel->path);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'topojson':
|
||||||
|
$layer = new TopoJson($layerId, $fileModel->path);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return parent::createInstance($model, $mapper, $request, $elementId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$customId = $layerId . '_data';
|
||||||
|
$customLayer = new GeoJson($customId);
|
||||||
|
|
||||||
|
$layer->setCustomLayer($customLayer);
|
||||||
|
|
||||||
|
return $layer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::createInstance($model, $mapper, $request, $elementId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
protected function build(
|
||||||
|
Definition $definition,
|
||||||
|
Model $model,
|
||||||
|
DefinitionMapper $mapper,
|
||||||
|
Request $request = null,
|
||||||
|
Definition $parent = null
|
||||||
|
) {
|
||||||
|
if (!$definition instanceof OmnivoreLayer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$customLayer = $definition->getCustomLayer();
|
||||||
|
if ($customLayer instanceof GeoJson) {
|
||||||
|
if ($model->boundsMode) {
|
||||||
|
$customLayer->setOption('boundsMode', $model->boundsMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($model->pointToLayer) {
|
||||||
|
$customLayer->setPointToLayer(new Expression($model->pointToLayer));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($model->onEachFeature) {
|
||||||
|
$customLayer->setOnEachFeature(new Expression($model->onEachFeature));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,9 +14,11 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
|||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
use Netzmacht\LeafletPHP\Definition\Group\FeatureGroup;
|
||||||
use Netzmacht\LeafletPHP\Definition\Group\LayerGroup;
|
use Netzmacht\LeafletPHP\Definition\Group\LayerGroup;
|
||||||
use Netzmacht\LeafletPHP\Definition\Layer;
|
use Netzmacht\LeafletPHP\Definition\Layer;
|
||||||
|
|
||||||
@@ -34,16 +36,35 @@ class GroupLayerMapper extends AbstractLayerMapper
|
|||||||
*/
|
*/
|
||||||
protected static $type = 'group';
|
protected static $type = 'group';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
if ($model->groupType === 'feature') {
|
if ($model->groupType === 'feature') {
|
||||||
return 'Netzmacht\LeafletPHP\Definition\Group\FeatureGroup';
|
return FeatureGroup::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'Netzmacht\LeafletPHP\Definition\Group\LayerGroup';
|
return LayerGroup::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,10 +81,11 @@ class GroupLayerMapper extends AbstractLayerMapper
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$collection = LayerModel::findBy(
|
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||||
array('pid=?', 'active=1'),
|
$collection = $repository->findBy(
|
||||||
array($model->id),
|
['pid=?', 'active=1'],
|
||||||
array('order' => 'sorting')
|
[$model->id],
|
||||||
|
['order' => 'sorting']
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($collection) {
|
if ($collection) {
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
|||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Encoder\ContaoAssets;
|
use Netzmacht\Contao\Leaflet\Encoder\ContaoAssets;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\JavascriptBuilder\Type\AnonymousFunction;
|
use Netzmacht\JavascriptBuilder\Type\AnonymousFunction;
|
||||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
@@ -36,7 +37,7 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Plugins\MarkerCluster\MarkerClusterGroup';
|
protected static $definitionClass = MarkerClusterGroup::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
@@ -53,15 +54,24 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper
|
|||||||
private $assets;
|
private $assets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MarkerClusterLayerMapper constructor.
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct.
|
||||||
*
|
*
|
||||||
* @param ContaoAssets $assets Assets manager.
|
* @param ContaoAssets $assets Assets manager.
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
*/
|
*/
|
||||||
public function __construct(ContaoAssets $assets)
|
public function __construct(ContaoAssets $assets, RepositoryManager $repositoryManager)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
$this->assets = $assets;
|
$this->assets = $assets;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,10 +117,11 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper
|
|||||||
$this->assets->addStylesheet('assets/leaflet/libs/leaflet-markercluster/MarkerCluster.Default.css');
|
$this->assets->addStylesheet('assets/leaflet/libs/leaflet-markercluster/MarkerCluster.Default.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
$collection = LayerModel::findBy(
|
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||||
array('pid=?', 'active=1'),
|
$collection = $repository->findBy(
|
||||||
array($model->id),
|
['pid=?', 'active=1'],
|
||||||
array('order' => 'sorting')
|
[$model->id],
|
||||||
|
['order' => 'sorting']
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($collection) {
|
if ($collection) {
|
||||||
|
|||||||
@@ -13,15 +13,17 @@
|
|||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
|
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\MarkerModel;
|
use Netzmacht\Contao\Leaflet\Model\MarkerModel;
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
|
||||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection;
|
|
||||||
use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
|
use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
|
||||||
|
use Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson as OmnivoreGeoJson;
|
||||||
|
use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class MarkersLayerMapper maps the layer model to the markers definition.
|
* Class MarkersLayerMapper maps the layer model to the markers definition.
|
||||||
@@ -37,16 +39,35 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
*/
|
*/
|
||||||
protected static $type = 'markers';
|
protected static $type = 'markers';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
if ($model->deferred) {
|
if ($model->deferred) {
|
||||||
return 'Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson';
|
return OmnivoreGeoJson::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'Netzmacht\LeafletPHP\Definition\Group\GeoJson';
|
return GeoJson::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,18 +91,18 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
$layer->setOption('boundsMode', $model->boundsMode);
|
$layer->setOption('boundsMode', $model->boundsMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
$this->getElementId($model, $elementId),
|
$this->getElementId($model, $elementId),
|
||||||
RequestUrl::create($model->id, null, null, $request),
|
RequestUrl::create($model->id, null, null, $request),
|
||||||
array(),
|
[],
|
||||||
$layer
|
$layer,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
$this->getElementId($model, $elementId),
|
$this->getElementId($model, $elementId),
|
||||||
RequestUrl::create($model->id, null, null, $request)
|
RequestUrl::create($model->id, null, null, $request),
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
return parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||||
@@ -153,10 +174,12 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
*/
|
*/
|
||||||
protected function loadMarkerModels(Model $model, Request $request = null)
|
protected function loadMarkerModels(Model $model, Request $request = null)
|
||||||
{
|
{
|
||||||
|
$repository = $this->repositoryManager->getRepository(MarkerModel::class);
|
||||||
|
|
||||||
if ($model->boundsMode == 'fit') {
|
if ($model->boundsMode == 'fit') {
|
||||||
return MarkerModel::findByFilter($model->id, $request->getFilter());
|
return $repository->findByFilter($model->id, $request->getFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
return MarkerModel::findByFilter($model->id);
|
return $repository->findByFilter($model->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
|||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Definition\Layer\OverpassLayer;
|
use Netzmacht\Contao\Leaflet\Definition\Layer\OverpassLayer;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
|
||||||
@@ -41,6 +42,25 @@ class OverpassLayerMapper extends AbstractLayerMapper
|
|||||||
*/
|
*/
|
||||||
protected static $definitionClass = OverpassLayer::class;
|
protected static $definitionClass = OverpassLayer::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -97,7 +117,8 @@ class OverpassLayerMapper extends AbstractLayerMapper
|
|||||||
$amenityIconsMap = $this->filterAmenityIconsConfig($model->amenityIcons);
|
$amenityIconsMap = $this->filterAmenityIconsConfig($model->amenityIcons);
|
||||||
|
|
||||||
if ($amenityIconsMap) {
|
if ($amenityIconsMap) {
|
||||||
$collection = IconModel::findMultipleByIds(array_unique($amenityIconsMap));
|
$repository = $this->repositoryManager->getRepository(IconModel::class);
|
||||||
|
$collection = $repository->findMultipleByIds(array_unique($amenityIconsMap));
|
||||||
$icons = [];
|
$icons = [];
|
||||||
|
|
||||||
if ($collection) {
|
if ($collection) {
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
|||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\OptionsBuilder;
|
use Netzmacht\Contao\Leaflet\Mapper\OptionsBuilder;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
use Netzmacht\LeafletPHP\Plugins\LeafletProviders\Provider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ProviderLayerMapper maps the layer model to the tile provider definition.
|
* Class ProviderLayerMapper maps the layer model to the tile provider definition.
|
||||||
@@ -60,7 +61,7 @@ class ProviderLayerMapper extends AbstractLayerMapper
|
|||||||
return $this->providers[$model->tile_provider]['class'];
|
return $this->providers[$model->tile_provider]['class'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'Netzmacht\LeafletPHP\Plugins\LeafletProviders\Provider';
|
return Provider::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,10 +92,10 @@ class ProviderLayerMapper extends AbstractLayerMapper
|
|||||||
Request $request = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
return array(
|
return [
|
||||||
$model->alias ?: ('layer_' . $model->id),
|
$model->alias ?: ('layer_' . $model->id),
|
||||||
$model->tile_provider,
|
$model->tile_provider,
|
||||||
$model->tile_provider_variant ?: null
|
$model->tile_provider_variant ?: null,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,6 +32,25 @@ class ReferenceLayerMapper extends AbstractLayerMapper
|
|||||||
*/
|
*/
|
||||||
protected static $type = 'reference';
|
protected static $type = 'reference';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -41,7 +61,8 @@ class ReferenceLayerMapper extends AbstractLayerMapper
|
|||||||
$elementId = null,
|
$elementId = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
$reference = LayerModel::findByPk($model->reference);
|
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||||
|
$reference = $repository->findByPk($model->reference);
|
||||||
|
|
||||||
if (!$reference || !$reference->active) {
|
if (!$reference || !$reference->active) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
|||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Contao\StringUtil;
|
use Contao\StringUtil;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Raster\TileLayer;
|
use Netzmacht\LeafletPHP\Definition\Raster\TileLayer;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLngBounds;
|
use Netzmacht\LeafletPHP\Value\LatLngBounds;
|
||||||
@@ -32,7 +32,7 @@ class TileLayerMapper extends AbstractLayerMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Raster\TileLayer';
|
protected static $definitionClass = TileLayer::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The layer type.
|
* The layer type.
|
||||||
|
|||||||
@@ -14,15 +14,17 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
|||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Contao\Model\Collection;
|
use Contao\Model\Collection;
|
||||||
|
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\VectorModel;
|
use Netzmacht\Contao\Leaflet\Model\VectorModel;
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
|
||||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection;
|
|
||||||
use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
|
use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
|
||||||
|
use Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson as OmnivoreGeoJson;
|
||||||
|
use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class VectorsLayerMapper maps the layer model for the Vectors layer definition.
|
* Class VectorsLayerMapper maps the layer model for the Vectors layer definition.
|
||||||
@@ -38,16 +40,35 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
*/
|
*/
|
||||||
protected static $type = 'vectors';
|
protected static $type = 'vectors';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
if ($model->deferred) {
|
if ($model->deferred) {
|
||||||
return 'Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson';
|
return OmnivoreGeoJson::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'Netzmacht\LeafletPHP\Definition\Group\GeoJson';
|
return GeoJson::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,7 +81,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
if ($model->deferred) {
|
if ($model->deferred) {
|
||||||
$options = array();
|
$options = [];
|
||||||
|
|
||||||
if ($model->pointToLayer) {
|
if ($model->pointToLayer) {
|
||||||
$options['pointToLayer'] = new Expression($model->pointToLayer);
|
$options['pointToLayer'] = new Expression($model->pointToLayer);
|
||||||
@@ -78,18 +99,18 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
$layer = new GeoJson($this->getElementId($model, $elementId));
|
$layer = new GeoJson($this->getElementId($model, $elementId));
|
||||||
$layer->setOptions($options);
|
$layer->setOptions($options);
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
$this->getElementId($model, $elementId),
|
$this->getElementId($model, $elementId),
|
||||||
RequestUrl::create($model->id, null, null, $request),
|
RequestUrl::create($model->id, null, null, $request),
|
||||||
array(),
|
[],
|
||||||
$layer
|
$layer,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
$this->getElementId($model, $elementId),
|
$this->getElementId($model, $elementId),
|
||||||
RequestUrl::create($model->id, null, null, $request)
|
RequestUrl::create($model->id, null, null, $request),
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
return parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||||
@@ -158,7 +179,9 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
*/
|
*/
|
||||||
protected function loadVectorModels(Model $model)
|
protected function loadVectorModels(Model $model)
|
||||||
{
|
{
|
||||||
return VectorModel::findActiveBy('pid', $model->id, ['order' => 'sorting']);
|
$repository = $this->repositoryManager->getRepository(VectorModel::class);
|
||||||
|
|
||||||
|
return $repository->findActiveBy(['pid=?'], [$model->id], ['order' => 'sorting']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper;
|
|||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Control;
|
use Netzmacht\LeafletPHP\Definition\Control;
|
||||||
use Netzmacht\LeafletPHP\Definition\Layer;
|
use Netzmacht\LeafletPHP\Definition\Layer;
|
||||||
@@ -40,7 +40,26 @@ class MapMapper extends AbstractMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Map';
|
protected static $definitionClass = Map::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@@ -51,8 +70,8 @@ class MapMapper extends AbstractMapper
|
|||||||
->addOptions('center', 'zoom', 'zoomControl')
|
->addOptions('center', 'zoom', 'zoomControl')
|
||||||
->addOptions('dragging', 'touchZoom', 'scrollWheelZoom', 'doubleClickZoom', 'boxZoom', 'tap', 'keyboard')
|
->addOptions('dragging', 'touchZoom', 'scrollWheelZoom', 'doubleClickZoom', 'boxZoom', 'tap', 'keyboard')
|
||||||
->addOptions('trackResize', 'closeOnClick', 'bounceAtZoomLimits')
|
->addOptions('trackResize', 'closeOnClick', 'bounceAtZoomLimits')
|
||||||
->addConditionalOptions('adjustZoomExtra', array('minZoom', 'maxZoom', 'zoomSnap', 'zoomDelta'))
|
->addConditionalOptions('adjustZoomExtra', ['minZoom', 'maxZoom', 'zoomSnap', 'zoomDelta'])
|
||||||
->addConditionalOptions('keyboard', array('keyboardPanOffset', 'keyboardZoomOffset'));
|
->addConditionalOptions('keyboard', ['keyboardPanOffset', 'keyboardZoomOffset']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,10 +102,10 @@ class MapMapper extends AbstractMapper
|
|||||||
Request $request = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
return array(
|
return [
|
||||||
$this->getElementId($model, $elementId),
|
$this->getElementId($model, $elementId),
|
||||||
$this->getElementId($model, $elementId)
|
$this->getElementId($model, $elementId),
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +141,8 @@ class MapMapper extends AbstractMapper
|
|||||||
*/
|
*/
|
||||||
private function buildControls(Map $map, MapModel $model, DefinitionMapper $mapper, Request $request = null)
|
private function buildControls(Map $map, MapModel $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
$collection = ControlModel::findActiveBy('pid', $model->id, array('order' => 'sorting'));
|
$repository = $this->repositoryManager->getRepository(ControlModel::class);
|
||||||
|
$collection = $repository->findActiveBy(['pid=?'], [$model->id], ['order' => 'sorting']);
|
||||||
|
|
||||||
if (!$collection) {
|
if (!$collection) {
|
||||||
return;
|
return;
|
||||||
@@ -208,13 +228,13 @@ class MapMapper extends AbstractMapper
|
|||||||
private function buildLocate(Map $map, MapModel $model)
|
private function buildLocate(Map $map, MapModel $model)
|
||||||
{
|
{
|
||||||
if ($model->locate) {
|
if ($model->locate) {
|
||||||
$options = array();
|
$options = [];
|
||||||
|
|
||||||
$mapping = array(
|
$mapping = [
|
||||||
'setView' => 'locateSetView',
|
'setView' => 'locateSetView',
|
||||||
'watch' => 'locateWatch',
|
'watch' => 'locateWatch',
|
||||||
'enableHighAccuracy' => 'enableHighAccuracy',
|
'enableHighAccuracy' => 'enableHighAccuracy',
|
||||||
);
|
];
|
||||||
|
|
||||||
foreach ($mapping as $option => $property) {
|
foreach ($mapping as $option => $property) {
|
||||||
if ($model->$property) {
|
if ($model->$property) {
|
||||||
@@ -222,11 +242,11 @@ class MapMapper extends AbstractMapper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$mapping = array(
|
$mapping = [
|
||||||
'maxZoom' => 'locateMaxZoom',
|
'maxZoom' => 'locateMaxZoom',
|
||||||
'timeout' => 'locateTimeout',
|
'timeout' => 'locateTimeout',
|
||||||
'maximumAge' => 'locateMaximumAge',
|
'maximumAge' => 'locateMaximumAge',
|
||||||
);
|
];
|
||||||
|
|
||||||
foreach ($mapping as $option => $property) {
|
foreach ($mapping as $option => $property) {
|
||||||
if ($model->$property) {
|
if ($model->$property) {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE
|
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
@@ -30,14 +31,14 @@ class OptionsBuilder
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $options = array();
|
private $options = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conditional option mapping.
|
* Conditional option mapping.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $conditional = array();
|
private $conditional = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a option mapping.
|
* Add a option mapping.
|
||||||
@@ -253,7 +254,7 @@ class OptionsBuilder
|
|||||||
*/
|
*/
|
||||||
private static function getDefaultOption($option, $definition)
|
private static function getDefaultOption($option, $definition)
|
||||||
{
|
{
|
||||||
$keys = array('has', 'is', 'get');
|
$keys = ['has', 'is', 'get'];
|
||||||
$suffix = ucfirst($option);
|
$suffix = ucfirst($option);
|
||||||
|
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Request;
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ class FixedStyleMapper extends AbstractStyleMapper
|
|||||||
->addConditionalOption('lineCap')
|
->addConditionalOption('lineCap')
|
||||||
->addConditionalOption('lineJoin')
|
->addConditionalOption('lineJoin')
|
||||||
->addConditionalOption('dashArray')
|
->addConditionalOption('dashArray')
|
||||||
->addConditionalOptions('fill', array('fillColor', 'fillOpacity'))
|
->addConditionalOptions('fill', ['fillColor', 'fillOpacity'])
|
||||||
->addOption('fill');
|
->addOption('fill');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Type;
|
|||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Type\DivIcon;
|
use Netzmacht\LeafletPHP\Definition\Type\DivIcon;
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ class DivIconMapper extends AbstractIconMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Type\DivIcon';
|
protected static $definitionClass = DivIcon::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Type;
|
|||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Type\DivIcon;
|
use Netzmacht\LeafletPHP\Definition\Type\DivIcon;
|
||||||
|
use Netzmacht\LeafletPHP\Plugins\ExtraMarkers\ExtraMarkersIcon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DivIconMapper maps the icon model to the div icon definition.
|
* Class DivIconMapper maps the icon model to the div icon definition.
|
||||||
@@ -30,7 +31,7 @@ class ExtraMarkersIconMapper extends AbstractIconMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Plugins\ExtraMarkers\ExtraMarkersIcon';
|
protected static $definitionClass = ExtraMarkersIcon::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -12,10 +12,12 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Type;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Type;
|
||||||
|
|
||||||
|
use Contao\FilesModel;
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
||||||
|
|
||||||
@@ -31,7 +33,7 @@ class ImageIconMapper extends AbstractIconMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Type\ImageIcon';
|
protected static $definitionClass = ImageIcon::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
@@ -40,6 +42,25 @@ class ImageIconMapper extends AbstractIconMapper
|
|||||||
*/
|
*/
|
||||||
protected static $type = 'image';
|
protected static $type = 'image';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct.
|
||||||
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
|
*/
|
||||||
|
public function __construct(RepositoryManager $repositoryManager)
|
||||||
|
{
|
||||||
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -52,7 +73,8 @@ class ImageIconMapper extends AbstractIconMapper
|
|||||||
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||||
|
|
||||||
if ($model->iconImage) {
|
if ($model->iconImage) {
|
||||||
$file = \FilesModel::findByUuid($model->iconImage);
|
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||||
|
$file = $repository->findByUuid($model->iconImage);
|
||||||
|
|
||||||
if ($file) {
|
if ($file) {
|
||||||
$arguments[] = $file->path;
|
$arguments[] = $file->path;
|
||||||
@@ -88,21 +110,23 @@ class ImageIconMapper extends AbstractIconMapper
|
|||||||
*/
|
*/
|
||||||
private function addIcon(ImageIcon $definition, IconModel $model)
|
private function addIcon(ImageIcon $definition, IconModel $model)
|
||||||
{
|
{
|
||||||
|
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||||
|
|
||||||
if ($model->iconImage) {
|
if ($model->iconImage) {
|
||||||
$file = \FilesModel::findByUuid($model->iconImage);
|
$file = $repository->findByUuid($model->iconImage);
|
||||||
|
|
||||||
if ($file) {
|
if ($file) {
|
||||||
$definition->setIconUrl($file->path);
|
$definition->setIconUrl($file->path);
|
||||||
|
|
||||||
$file = new \File($file->path);
|
$file = new \File($file->path);
|
||||||
$definition->setIconSize(array($file->width, $file->height));
|
$definition->setIconSize([$file->width, $file->height]);
|
||||||
|
|
||||||
if (!$model->iconAnchor) {
|
if (!$model->iconAnchor) {
|
||||||
$definition->setIconAnchor(array($file->width / 2, $file->height));
|
$definition->setIconAnchor([($file->width / 2), $file->height]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$model->popupAnchor) {
|
if (!$model->popupAnchor) {
|
||||||
$definition->setPopupAnchor(array(0, 8 - $file->height));
|
$definition->setPopupAnchor([0, (8 - $file->height)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +136,7 @@ class ImageIconMapper extends AbstractIconMapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($model->iconRetinaImage) {
|
if ($model->iconRetinaImage) {
|
||||||
$file = \FilesModel::findByUuid($model->iconRetinaImage);
|
$file = $repository->findByUuid($model->iconRetinaImage);
|
||||||
|
|
||||||
if ($file) {
|
if ($file) {
|
||||||
$definition->setIconRetinaUrl($file->path);
|
$definition->setIconRetinaUrl($file->path);
|
||||||
@@ -130,17 +154,19 @@ class ImageIconMapper extends AbstractIconMapper
|
|||||||
*/
|
*/
|
||||||
private function addShadow(ImageIcon $definition, $model)
|
private function addShadow(ImageIcon $definition, $model)
|
||||||
{
|
{
|
||||||
|
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||||
|
|
||||||
if ($model->shadowImage) {
|
if ($model->shadowImage) {
|
||||||
$file = \FilesModel::findByUuid($model->shadowImage);
|
$file = $repository->findByUuid($model->shadowImage);
|
||||||
|
|
||||||
if ($file) {
|
if ($file) {
|
||||||
$definition->setShadowUrl($file->path);
|
$definition->setShadowUrl($file->path);
|
||||||
|
|
||||||
$file = new \File($file->path);
|
$file = new \File($file->path);
|
||||||
$definition->setShadowSize(array($file->width, $file->height));
|
$definition->setShadowSize([$file->width, $file->height]);
|
||||||
|
|
||||||
if (!$model->shadowAnchor) {
|
if (!$model->shadowAnchor) {
|
||||||
$definition->setShadowAnchor(array($file->width / 2, $file->height));
|
$definition->setShadowAnchor([($file->width / 2), $file->height]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +176,7 @@ class ImageIconMapper extends AbstractIconMapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($model->shadowRetinaImage) {
|
if ($model->shadowRetinaImage) {
|
||||||
$file = \FilesModel::findByUuid($model->shadowRetinaImage);
|
$file = $repository->findByUuid($model->shadowRetinaImage);
|
||||||
|
|
||||||
if ($file) {
|
if ($file) {
|
||||||
$definition->setShadowRetinaUrl($file->path);
|
$definition->setShadowRetinaUrl($file->path);
|
||||||
|
|||||||
@@ -16,10 +16,11 @@ use Contao\Model;
|
|||||||
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\MarkerModel;
|
use Netzmacht\Contao\Leaflet\Model\MarkerModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
||||||
use Netzmacht\LeafletPHP\Definition\UI\Marker;
|
use Netzmacht\LeafletPHP\Definition\UI\Marker;
|
||||||
@@ -53,16 +54,25 @@ class MarkerMapper extends AbstractMapper
|
|||||||
*/
|
*/
|
||||||
protected $valueFilter;
|
protected $valueFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct.
|
* Construct.
|
||||||
*
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
* @param ValueFilter $valueFilter Frontend filter.
|
* @param ValueFilter $valueFilter Frontend filter.
|
||||||
*/
|
*/
|
||||||
public function __construct(ValueFilter $valueFilter)
|
public function __construct(RepositoryManager $repositoryManager, ValueFilter $valueFilter)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
$this->valueFilter = $valueFilter;
|
$this->valueFilter = $valueFilter;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +85,7 @@ class MarkerMapper extends AbstractMapper
|
|||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||||
$arguments[] = array($model->latitude, $model->longitude, $model->altitude ?: null) ?: null;
|
$arguments[] = [$model->latitude, $model->longitude, $model->altitude ?: null] ?: null;
|
||||||
|
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
@@ -108,7 +118,8 @@ class MarkerMapper extends AbstractMapper
|
|||||||
$content = $this->valueFilter->filter($model->popupContent);
|
$content = $this->valueFilter->filter($model->popupContent);
|
||||||
|
|
||||||
if ($model->popup) {
|
if ($model->popup) {
|
||||||
$popupModel = PopupModel::findActiveByPK($model->popup);
|
$popupRepository = $this->repositoryManager->getRepository(PopupModel::class);
|
||||||
|
$popupModel = $popupRepository->findActiveByPK($model->popup);
|
||||||
|
|
||||||
if ($popupModel) {
|
if ($popupModel) {
|
||||||
$popup = $mapper->handle($popupModel, $request, null, $definition);
|
$popup = $mapper->handle($popupModel, $request, null, $definition);
|
||||||
@@ -123,10 +134,11 @@ class MarkerMapper extends AbstractMapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($model->customIcon) {
|
if ($model->customIcon) {
|
||||||
$iconModel = IconModel::findBy(
|
$iconRepository = $this->repositoryManager->getRepository(IconModel::class);
|
||||||
array('id=?', 'active=1'),
|
$iconModel = $iconRepository->findBy(
|
||||||
array($model->icon),
|
['id=?', 'active=1'],
|
||||||
array('return' => 'Model')
|
[$model->icon],
|
||||||
|
['return' => 'Model']
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($iconModel) {
|
if ($iconModel) {
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ namespace Netzmacht\Contao\Leaflet\Mapper\UI;
|
|||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\UI\Popup;
|
use Netzmacht\LeafletPHP\Definition\UI\Popup;
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,11 @@ use Netzmacht\Contao\Leaflet\Definition\Style;
|
|||||||
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\VectorModel;
|
use Netzmacht\Contao\Leaflet\Model\VectorModel;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\HasPopup;
|
use Netzmacht\LeafletPHP\Definition\HasPopup;
|
||||||
use Netzmacht\LeafletPHP\Definition\UI\Popup;
|
use Netzmacht\LeafletPHP\Definition\UI\Popup;
|
||||||
@@ -47,16 +48,25 @@ class AbstractVectorMapper extends AbstractTypeMapper
|
|||||||
*/
|
*/
|
||||||
protected $valueFilter;
|
protected $valueFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository manager.
|
||||||
|
*
|
||||||
|
* @var RepositoryManager
|
||||||
|
*/
|
||||||
|
private $repositoryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct.
|
* Construct.
|
||||||
*
|
*
|
||||||
|
* @param RepositoryManager $repositoryManager Repository manager.
|
||||||
* @param ValueFilter $valueFilter Frontend filter.
|
* @param ValueFilter $valueFilter Frontend filter.
|
||||||
*/
|
*/
|
||||||
public function __construct(ValueFilter $valueFilter)
|
public function __construct(RepositoryManager $repositoryManager, ValueFilter $valueFilter)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
$this->repositoryManager = $repositoryManager;
|
||||||
|
|
||||||
$this->valueFilter = $valueFilter;
|
$this->valueFilter = $valueFilter;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +82,8 @@ class AbstractVectorMapper extends AbstractTypeMapper
|
|||||||
parent::build($definition, $model, $mapper, $request);
|
parent::build($definition, $model, $mapper, $request);
|
||||||
|
|
||||||
if ($definition instanceof Path && $model->style) {
|
if ($definition instanceof Path && $model->style) {
|
||||||
$styleModel = StyleModel::findActiveByPK($model->style);
|
$repository = $this->repositoryManager->getRepository(StyleModel::class);
|
||||||
|
$styleModel = $repository->findActiveByPK($model->style);
|
||||||
|
|
||||||
if ($styleModel) {
|
if ($styleModel) {
|
||||||
$style = $mapper->handle($styleModel);
|
$style = $mapper->handle($styleModel);
|
||||||
@@ -107,7 +118,8 @@ class AbstractVectorMapper extends AbstractTypeMapper
|
|||||||
$content = $this->valueFilter->filter($model->popupContent);
|
$content = $this->valueFilter->filter($model->popupContent);
|
||||||
|
|
||||||
if ($model->popup) {
|
if ($model->popup) {
|
||||||
$popupModel = PopupModel::findActiveByPK($model->popup);
|
$repository = $this->repositoryManager->getRepository(PopupModel::class);
|
||||||
|
$popupModel = $repository->findActiveByPK($model->popup);
|
||||||
|
|
||||||
if ($popupModel) {
|
if ($popupModel) {
|
||||||
$popup = $mapper->handle($popupModel, $request, null, $definition);
|
$popup = $mapper->handle($popupModel, $request, null, $definition);
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
|||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
use Netzmacht\LeafletPHP\Definition\Vector\Circle;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\CircleMarker;
|
use Netzmacht\LeafletPHP\Definition\Vector\CircleMarker;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLng;
|
use Netzmacht\LeafletPHP\Value\LatLng;
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ class CircleMapper extends AbstractVectorMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Circle';
|
protected static $definitionClass = Circle::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||||
|
|
||||||
|
use Netzmacht\LeafletPHP\Definition\Vector\CircleMarker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CircleMarkerMapper maps the database model to the circle marker definition.
|
* Class CircleMarkerMapper maps the database model to the circle marker definition.
|
||||||
*
|
*
|
||||||
@@ -24,7 +26,7 @@ class CircleMarkerMapper extends CircleMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\CircleMarker';
|
protected static $definitionClass = CircleMarker::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
|||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\Polygon;
|
use Netzmacht\LeafletPHP\Definition\Vector\Polygon;
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ class MultiPolygonMapper extends MultiPolylineMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Polygon';
|
protected static $definitionClass = Polygon::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
|||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\Polyline;
|
use Netzmacht\LeafletPHP\Definition\Vector\Polyline;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLng;
|
use Netzmacht\LeafletPHP\Value\LatLng;
|
||||||
@@ -31,7 +31,7 @@ class MultiPolylineMapper extends AbstractVectorMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Polyline';
|
protected static $definitionClass = Polyline::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||||
|
|
||||||
|
use Netzmacht\LeafletPHP\Definition\Vector\Polygon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PolygonMapper maps the database model to the polygon definition.
|
* Class PolygonMapper maps the database model to the polygon definition.
|
||||||
*
|
*
|
||||||
@@ -24,7 +26,7 @@ class PolygonMapper extends PolylineMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Polygon';
|
protected static $definitionClass = Polygon::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
|||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLng;
|
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\Polyline;
|
use Netzmacht\LeafletPHP\Definition\Vector\Polyline;
|
||||||
|
use Netzmacht\LeafletPHP\Value\LatLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PolylineMapper maps the database model to the polyline definition.
|
* Class PolylineMapper maps the database model to the polyline definition.
|
||||||
@@ -31,7 +31,7 @@ class PolylineMapper extends AbstractVectorMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Polyline';
|
protected static $definitionClass = Polyline::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
|||||||
|
|
||||||
use Contao\Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Request\Request;
|
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||||
|
use Netzmacht\LeafletPHP\Definition\Vector\Rectangle;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLng;
|
use Netzmacht\LeafletPHP\Value\LatLng;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLngBounds;
|
use Netzmacht\LeafletPHP\Value\LatLngBounds;
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ class RectangleMapper extends AbstractVectorMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Rectangle';
|
protected static $definitionClass = Rectangle::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ abstract class AbstractActiveModel extends \Model
|
|||||||
*
|
*
|
||||||
* @return \Model|null
|
* @return \Model|null
|
||||||
*/
|
*/
|
||||||
public static function findActiveByPK($modelId, $options = array())
|
public static function findActiveByPK($modelId, $options = [])
|
||||||
{
|
{
|
||||||
return static::findOneBy('active=1 AND id', $modelId, $options);
|
return static::findOneBy('active=1 AND id', $modelId, $options);
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ abstract class AbstractActiveModel extends \Model
|
|||||||
*
|
*
|
||||||
* @return Collection|null
|
* @return Collection|null
|
||||||
*/
|
*/
|
||||||
public static function findActiveBy($column, $value, $options = array())
|
public static function findActiveBy($column, $value, $options = [])
|
||||||
{
|
{
|
||||||
if (is_array($column)) {
|
if (is_array($column)) {
|
||||||
$column[] = 'active=1';
|
$column[] = 'active=1';
|
||||||
@@ -61,7 +61,7 @@ abstract class AbstractActiveModel extends \Model
|
|||||||
*
|
*
|
||||||
* @return Collection|null
|
* @return Collection|null
|
||||||
*/
|
*/
|
||||||
public static function findActives($options = array())
|
public static function findActives($options = [])
|
||||||
{
|
{
|
||||||
return static::findBy('active', '1', $options);
|
return static::findBy('active', '1', $options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,18 +42,18 @@ class LayerModel extends AbstractActiveModel
|
|||||||
*
|
*
|
||||||
* @return Collection|null
|
* @return Collection|null
|
||||||
*/
|
*/
|
||||||
public static function findMultipleByTypes(array $types, $options = array())
|
public static function findMultipleByTypes(array $types, $options = [])
|
||||||
{
|
{
|
||||||
if (empty($types)) {
|
if (empty($types)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$options['column'] = array(
|
$options['column'] = [
|
||||||
sprintf(
|
sprintf(
|
||||||
'type IN (%s)',
|
'type IN (%s)',
|
||||||
substr(str_repeat('?,', count($types)), 0, -1)
|
substr(str_repeat('?,', count($types)), 0, -1)
|
||||||
)
|
),
|
||||||
);
|
];
|
||||||
|
|
||||||
$options['value'] = $types;
|
$options['value'] = $types;
|
||||||
$options['return'] = 'Collection';
|
$options['return'] = 'Collection';
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class MarkerModel extends AbstractActiveModel
|
|||||||
public static function findByFilter($pid, Filter $filter = null)
|
public static function findByFilter($pid, Filter $filter = null)
|
||||||
{
|
{
|
||||||
if (!$filter) {
|
if (!$filter) {
|
||||||
return static::findActiveBy('pid', $pid, array('order' => 'sorting'));
|
return static::findActiveBy('pid', $pid, ['order' => 'sorting']);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($filter->getName()) {
|
switch ($filter->getName()) {
|
||||||
@@ -63,23 +63,23 @@ class MarkerModel extends AbstractActiveModel
|
|||||||
*/
|
*/
|
||||||
public static function findByBBoxFilter($pid, BboxFilter $filter)
|
public static function findByBBoxFilter($pid, BboxFilter $filter)
|
||||||
{
|
{
|
||||||
$columns = array(
|
$columns = [
|
||||||
'active=1',
|
'active=1',
|
||||||
'pid=?',
|
'pid=?',
|
||||||
'latitude > ? AND latitude < ?',
|
'latitude > ? AND latitude < ?',
|
||||||
'longitude > ? AND longitude < ?'
|
'longitude > ? AND longitude < ?',
|
||||||
);
|
];
|
||||||
|
|
||||||
/** @var LatLngBounds $bounds */
|
/** @var LatLngBounds $bounds */
|
||||||
$bounds = $filter->getValues()['bounds'];
|
$bounds = $filter->getValues()['bounds'];
|
||||||
$values = array(
|
$values = [
|
||||||
$pid,
|
$pid,
|
||||||
$bounds->getSouthWest()->getLatitude(),
|
$bounds->getSouthWest()->getLatitude(),
|
||||||
$bounds->getNorthEast()->getLatitude(),
|
$bounds->getNorthEast()->getLatitude(),
|
||||||
$bounds->getSouthWest()->getLongitude(),
|
$bounds->getSouthWest()->getLongitude(),
|
||||||
$bounds->getNorthEast()->getLongitude()
|
$bounds->getNorthEast()->getLongitude(),
|
||||||
);
|
];
|
||||||
|
|
||||||
return static::findBy($columns, $values, array('order' => 'sorting'));
|
return static::findBy($columns, $values, ['order' => 'sorting']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user