Files
contao-leaflet-maps/module/config/config.php

383 lines
14 KiB
PHP
Raw Normal View History

2014-12-27 22:58:58 +01:00
<?php
2015-01-12 19:03:29 +01:00
/**
2016-10-11 10:40:15 +02:00
* @package contao-leaflet-maps
2015-01-12 19:03:29 +01:00
* @author David Molineus <david.molineus@netzmacht.de>
2016-10-11 10:40:15 +02:00
* @copyright 2014-2016 netzmacht David Molineus
2015-01-12 19:03:29 +01:00
* @license LGPL 3.0
* @filesource
*
*/
2014-12-29 12:17:40 +01:00
/*
* Backend module.
*/
2015-01-09 11:53:58 +01:00
array_insert(
$GLOBALS['BE_MOD'],
1,
array(
'leaflet' => array
(
'leaflet_map' => array
(
'tables' => array
(
'tl_leaflet_map',
'tl_leaflet_control',
),
2015-01-09 15:24:34 +01:00
'icon' => 'system/modules/leaflet/assets/img/map.png',
2015-01-09 11:53:58 +01:00
'stylesheet' => 'system/modules/leaflet/assets/css/backend.css',
),
'leaflet_layer' => array
(
'tables' => array
(
'tl_leaflet_layer',
'tl_leaflet_marker',
'tl_leaflet_vector',
'tl_leaflet_icon',
'tl_leaflet_style',
2015-01-27 17:14:58 +01:00
'tl_leaflet_popup',
2015-01-09 11:53:58 +01:00
),
'icon' => 'system/modules/leaflet/assets/img/layers.png',
'stylesheet' => 'system/modules/leaflet/assets/css/backend.css',
2015-01-09 20:57:19 +01:00
),
2015-01-19 09:54:33 +01:00
'leaflet_about' => array
2015-01-09 20:57:19 +01:00
(
2015-01-19 09:54:33 +01:00
'callback' => 'Netzmacht\Contao\Leaflet\Backend\About',
'icon' => 'system/modules/leaflet/assets/img/about.png',
'stylesheet' => 'system/modules/leaflet/assets/css/about.css',
2015-01-09 11:53:58 +01:00
)
)
)
2014-12-29 12:17:40 +01:00
);
2015-01-27 17:14:58 +01:00
2014-12-29 12:17:40 +01:00
/*
* Content elements.
*/
$GLOBALS['TL_CTE']['includes']['leaflet'] = 'Netzmacht\Contao\Toolkit\Component\ContentElement\ContentElementDecorator';
2014-12-29 12:17:40 +01:00
2015-01-27 17:14:58 +01:00
2015-01-09 23:20:07 +01:00
/*
* Frontend modules
*/
$GLOBALS['FE_MOD']['includes']['leaflet'] = 'Netzmacht\Contao\Toolkit\Component\Module\ModuleDecorator';
2015-01-09 23:20:07 +01:00
2015-01-27 17:14:58 +01:00
2014-12-29 12:17:40 +01:00
/*
* Models.
*/
2015-01-05 12:25:46 +01:00
$GLOBALS['TL_MODELS']['tl_leaflet_control'] = 'Netzmacht\Contao\Leaflet\Model\ControlModel';
2015-01-06 21:30:57 +01:00
$GLOBALS['TL_MODELS']['tl_leaflet_icon'] = 'Netzmacht\Contao\Leaflet\Model\IconModel';
$GLOBALS['TL_MODELS']['tl_leaflet_layer'] = 'Netzmacht\Contao\Leaflet\Model\LayerModel';
$GLOBALS['TL_MODELS']['tl_leaflet_map'] = 'Netzmacht\Contao\Leaflet\Model\MapModel';
2015-01-06 14:54:51 +01:00
$GLOBALS['TL_MODELS']['tl_leaflet_marker'] = 'Netzmacht\Contao\Leaflet\Model\MarkerModel';
2015-01-27 17:14:58 +01:00
$GLOBALS['TL_MODELS']['tl_leaflet_popup'] = 'Netzmacht\Contao\Leaflet\Model\PopupModel';
2015-01-09 11:53:58 +01:00
$GLOBALS['TL_MODELS']['tl_leaflet_style'] = 'Netzmacht\Contao\Leaflet\Model\StyleModel';
2015-01-07 17:59:56 +01:00
$GLOBALS['TL_MODELS']['tl_leaflet_vector'] = 'Netzmacht\Contao\Leaflet\Model\VectorModel';
2014-12-29 12:17:40 +01:00
/*
* Leaflet mappers.
*
* Mappers do the translations between the database models and the leaflet definition.
*/
$GLOBALS['LEAFLET_MAPPERS'] = array();
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\MapMapper';
2015-01-09 11:53:58 +01:00
// Layer mappers.
2015-01-22 13:34:07 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\TileLayerMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
return new \Netzmacht\Contao\Leaflet\Mapper\Layer\ProviderLayerMapper(
$GLOBALS['LEAFLET_TILE_PROVIDERS']
);
};
2015-01-06 14:54:51 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLayerMapper';
2015-01-07 12:13:26 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\GroupLayerMapper';
2015-01-07 17:59:56 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper';
2015-01-09 15:24:34 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\ReferenceLayerMapper';
2016-11-09 10:27:18 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\OverpassLayerMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
return new \Netzmacht\Contao\Leaflet\Mapper\Layer\MarkerClusterLayerMapper(
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::MAP_ASSETS]
);
};
2015-01-09 11:53:58 +01:00
// Control mappers.
2015-01-05 12:25:46 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\ZoomControlMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\ScaleControlMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\LayersControlMapper';
2015-01-05 14:58:37 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\AttributionControlMapper';
2015-01-08 11:01:22 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\LoadingControlMapper';
2015-01-20 17:36:19 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\FullscreenControlMapper';
2015-01-09 11:53:58 +01:00
// Vector mappers.
2016-10-06 08:53:23 +02:00
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
2016-10-05 08:52:46 +02:00
return new Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper(
2016-10-06 08:53:23 +02:00
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
2016-10-05 08:52:46 +02:00
);
};
2016-10-06 08:53:23 +02:00
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
2016-10-05 08:52:46 +02:00
return new Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolylineMapper(
2016-10-06 08:53:23 +02:00
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
2016-10-05 08:52:46 +02:00
);
};
2016-10-06 08:53:23 +02:00
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
2016-10-05 08:52:46 +02:00
return new Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonMapper(
2016-10-06 08:53:23 +02:00
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
2016-10-05 08:52:46 +02:00
);
};
2016-10-06 08:53:23 +02:00
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
2016-10-05 08:52:46 +02:00
return new Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolygonMapper(
2016-10-06 08:53:23 +02:00
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
2016-10-05 08:52:46 +02:00
);
};
2016-10-06 08:53:23 +02:00
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
2016-10-05 08:52:46 +02:00
return new Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMapper(
2016-10-06 08:53:23 +02:00
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
2016-10-05 08:52:46 +02:00
);
};
2016-10-06 08:53:23 +02:00
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
2016-10-05 08:52:46 +02:00
return new Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMarkerMapper(
2016-10-06 08:53:23 +02:00
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
2016-10-05 08:52:46 +02:00
);
};
2016-10-06 08:53:23 +02:00
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
2016-10-05 08:52:46 +02:00
return new Netzmacht\Contao\Leaflet\Mapper\Vector\RectangleMapper(
2016-10-06 08:53:23 +02:00
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
2016-10-05 08:52:46 +02:00
);
};
2014-12-29 12:17:40 +01:00
2015-01-09 11:53:58 +01:00
// Miscellaneous mappers.
2015-01-27 17:14:58 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\UI\PopupMapper';
2015-01-09 11:53:58 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\ImageIconMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\DivIconMapper';
2016-11-14 13:31:19 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\ExtraMarkersIconMapper';
2015-01-09 11:53:58 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Style\FixedStyleMapper';
2016-10-06 08:53:23 +02:00
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
2016-10-05 08:52:46 +02:00
return new \Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper(
2016-10-06 08:53:23 +02:00
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
2016-10-05 08:52:46 +02:00
);
};
2015-01-09 11:53:58 +01:00
2014-12-29 12:17:40 +01:00
/*
* Leaflet encoders.
*
* The encoders transforms the definitions into javascript. The encoders has to be an implementation of the
* EventDispatcherInterface of the event dispatcher.
*
* You can define the encoders using the syntax of the cca event dispatcher implementation.
*
* @see https://github.com/contao-community-alliance/event-dispatcher#event-subscriber-per-configuration
*/
$GLOBALS['LEAFLET_ENCODERS'] = array();
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\MapEncoder';
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\ControlEncoder';
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\GroupEncoder';
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\RasterEncoder';
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\VectorEncoder';
2015-01-06 14:54:51 +01:00
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\UIEncoder';
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\TypeEncoder';
2014-12-29 12:17:40 +01:00
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\Contao\Leaflet\Subscriber\EncoderSubscriber';
2015-01-05 12:25:46 +01:00
/*
* Leaflet layer types.
*
* The type is used for the database driven definitions.
*/
2015-01-06 14:54:51 +01:00
$GLOBALS['LEAFLET_LAYERS'] = array
(
'provider' => array
(
'children' => false,
2015-01-22 14:56:58 +01:00
'icon' => 'system/modules/leaflet/assets/img/provider.png',
2015-01-09 15:24:34 +01:00
'label' => function ($row, $label) {
if (!empty($GLOBALS['TL_LANG']['leaflet_provider'][$row['tile_provider']][0])) {
$provider = $GLOBALS['TL_LANG']['leaflet_provider'][$row['tile_provider']][0];
} else {
$provider = $row['tile_provider'];
}
$label .= sprintf('<span class="tl_gray"> (%s)</span>', $provider);
return $label;
}
2015-01-06 14:54:51 +01:00
),
'group' => array
(
'children' => true,
'icon' => 'system/modules/leaflet/assets/img/group.png',
),
'markers' => array
(
'children' => false,
'icon' => 'system/modules/leaflet/assets/img/markers.png',
'markers' => true,
2015-01-27 00:02:17 +01:00
'boundsMode' => array(
'extend' => true,
'fit' => 'deferred'
),
2015-01-09 15:24:34 +01:00
'label' => function ($row, $label) {
$count = \Netzmacht\Contao\Leaflet\Model\MarkerModel::countBy('pid', $row['id']);
$label .= sprintf(
'<span class="tl_gray"> (%s %s)</span>',
$count,
$GLOBALS['TL_LANG']['tl_leaflet_layer']['countEntries']
);
return $label;
}
2015-01-06 14:54:51 +01:00
),
'vectors' => array
(
'children' => false,
'icon' => 'system/modules/leaflet/assets/img/vectors.png',
2015-01-06 18:49:22 +01:00
'vectors' => true,
2015-01-27 00:02:17 +01:00
'boundsMode' => array(
'extend' => true,
),
2015-01-09 15:24:34 +01:00
'label' => function ($row, $label) {
$count = \Netzmacht\Contao\Leaflet\Model\VectorModel::countBy('pid', $row['id']);
$label .= sprintf(
'<span class="tl_gray"> (%s %s)</span>',
$count,
$GLOBALS['TL_LANG']['tl_leaflet_layer']['countEntries']
);
return $label;
}
2015-01-06 14:54:51 +01:00
),
2015-01-09 15:24:34 +01:00
'reference' => array
(
'children' => false,
'icon' => 'system/modules/leaflet/assets/img/reference.png',
'label' => function ($row, $label) {
$reference = \Netzmacht\Contao\Leaflet\Model\LayerModel::findByPk($row['reference']);
if ($reference) {
$label .= '<span class="tl_gray"> (' . $reference->title . ')</span>';
}
return $label;
}
2015-01-21 14:24:22 +01:00
),
'markercluster' => array
(
'children' => true,
'icon' => 'system/modules/leaflet/assets/img/cluster.png',
2015-01-22 13:34:07 +01:00
),
'tile' => array(
'children' => false,
'icon' => 'system/modules/leaflet/assets/img/tile.png',
),
2016-11-09 11:23:26 +01:00
'overpass' => array(
'children' => false,
'icon' => 'system/modules/leaflet/assets/img/overpass.png',
2016-11-09 11:47:57 +01:00
'label' => function ($row, $label) {
if ($row['overpassQuery']) {
$label .= '<span class="tl_gray"> ' . \StringUtil::substr($row['overpassQuery'], 50) . '</span>';
}
return $label;
},
'boundsMode' => array(
'extend' => true,
'fit' => true,
),
2016-11-09 11:23:26 +01:00
),
2015-01-06 14:54:51 +01:00
);
2015-01-05 12:25:46 +01:00
/*
* leaflet controls.
*
* Supported leaflet control types. Register your type for the database driven definition here.
*/
2015-01-20 17:36:19 +01:00
$GLOBALS['LEAFLET_CONTROLS'] = array('zoom', 'layers', 'scale', 'attribution', 'loading', 'fullscreen');
2015-01-05 12:25:46 +01:00
2015-01-07 17:59:56 +01:00
/*
* Leaflet icons.
*
* Supported leaflet icon types. Register you type for the database driven definition here.
*/
2016-11-14 13:31:19 +01:00
$GLOBALS['LEAFLET_ICONS'] = array('image', 'div', 'extra');
2014-12-29 16:23:08 +01:00
2015-01-07 17:59:56 +01:00
2015-01-09 11:53:58 +01:00
/*
* The style concept is not part of the LeafletJS library. Styles are extracted from the Path options. Instead
* of defining the style for every vector again, manage them at one place.
*
* The goal is to provide different style strategies. For instance a random style chooser, one which uses a color
* range and so one.
*/
$GLOBALS['LEAFLET_STYLES'] = array('fixed');
2015-01-07 17:59:56 +01:00
/*
* Leaflet vectors.
*
* Supported leaflet vector types. Register you type for the database driven definition here.
*/
$GLOBALS['LEAFLET_VECTORS'] = array
(
'polyline',
'polygon',
'multiPolyline',
'multiPolygon',
'rectangle',
'circle',
'circleMarker'
);
2014-12-29 16:23:08 +01:00
/*
* Leaflet tile layer providers.
*/
2015-01-05 12:25:46 +01:00
require_once TL_ROOT . '/system/modules/leaflet/config/leaflet_providers.php';
/*
* Leaflet assets.
*
* The leaflet definition are aware of the required javascript libraries. Register the assets so that they are
* loaded automatically.
*
* Each entry is an array of 2 values. The first is the resource. The second is a type. Supported types are:
* - url: An valid url.
* - file: An file path relative to the Contao Root.
* - source: Inline css/javascript.
*
* You don't have to define it as array if you simply add a file. Do not add |static and or media type flag to it.
* It's getting added by default if not being in debug mode.
*/
if (!isset($GLOBALS['LEAFLET_LIBRARIES'])) {
$GLOBALS['LEAFLET_LIBRARIES'] = array();
}
/*
* When creating a GeoJSON feature of a map object a feature.properties.model object is passed.
* Define the properties you always want to set.
*
* For more control you can subscribe the ConvertToGeoJsonEvent.
*
* The entry can be a string or an array. If an array is passed, the 2nd value is the type. Following types
* are supported.
* - array: Use deserialize before adding the value
* - file: Thread value a uuid and find the path.
* - files: Thread values as a list of file uuids and get an array of paths.
*/
$GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES']['tl_leaflet_marker'][] = 'id';
$GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES']['tl_leaflet_marker'][] = 'title';
$GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES']['tl_leaflet_marker'][] = 'alias';
$GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES']['tl_leaflet_vector'][] = 'id';
$GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES']['tl_leaflet_vector'][] = 'title';
$GLOBALS['LEAFLET_FEATURE_MODEL_PROPERTIES']['tl_leaflet_vector'][] = 'alias';
2015-01-27 00:02:17 +01:00
/*
* Filters can be passed to a data request to get only specific data from a layer.
*/
$GLOBALS['LEAFLET_FILTERS']['bbox'] = 'Netzmacht\Contao\Leaflet\Filter\BboxFilter';
$GLOBALS['LEAFLET_FILTERS']['distance'] = 'Netzmacht\Contao\Leaflet\Filter\DistanceFilter';