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

278 lines
9.9 KiB
PHP
Raw Normal View History

2014-12-27 22:58:58 +01:00
<?php
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',
),
'icon' => 'system/modules/leaflet/assets/img/layers.png',
'stylesheet' => 'system/modules/leaflet/assets/css/backend.css',
)
)
)
2014-12-29 12:17:40 +01:00
);
/*
* Content elements.
*/
$GLOBALS['TL_CTE']['includes']['leaflet'] = 'Netzmacht\Contao\Leaflet\LeafletMapElement';
/*
* 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-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.
2014-12-29 16:23:08 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\ProviderLayerMapper';
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';
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-09 11:53:58 +01:00
// Vector mappers.
2015-01-07 17:59:56 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolylineMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolygonMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMarkerMapper';
2015-01-07 18:58:52 +01:00
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\RectangleMapper';
2014-12-29 12:17:40 +01:00
2015-01-09 11:53:58 +01:00
// Miscellaneous mappers.
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\ImageIconMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\DivIconMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Style\FixedStyleMapper';
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\Javascript\Subscriber\EncoderSubscriber';
$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,
'icon' => 'system/modules/leaflet/assets/img/tile.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-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-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-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-08 11:01:22 +01:00
$GLOBALS['LEAFLET_CONTROLS'] = array('zoom', 'layers', 'scale', 'attribution', 'loading');
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.
*/
2015-01-06 21:30:57 +01:00
$GLOBALS['LEAFLET_ICONS'] = array('image', 'div');
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';
2014-12-29 12:17:40 +01:00
2015-01-06 14:54:51 +01:00
2014-12-29 12:17:40 +01:00
/*
* 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.
2015-01-08 12:44:42 +01:00
*
* 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.
2014-12-29 12:17:40 +01:00
*/
2015-01-08 12:44:42 +01:00
$GLOBALS['LEAFLET_ASSETS'] = array
(
'leaflet' => array
(
'css' => 'assets/leaflet/libs/leaflet/leaflet.css',
'javascript' => 'assets/leaflet/libs/leaflet/leaflet.js'
2014-12-29 16:23:08 +01:00
),
2015-01-08 12:44:42 +01:00
'leaflet-providers' => array
(
'javascript' => 'assets/leaflet/libs/leaflet-providers/leaflet-providers.js'
2015-01-08 11:01:22 +01:00
),
2015-01-08 12:44:42 +01:00
'leaflet-ajax' => array
(
'javascript' => 'assets/leaflet/libs/leaflet-ajax/leaflet.ajax.min.js'
),
'leaflet-loading' => array
(
'css' => 'assets/leaflet/libs/leaflet-loading/Control.Loading.css',
'javascript' => 'assets/leaflet/libs/leaflet-loading/Control.Loading.js'
),
'spin.js' => array
(
'javascript' => 'assets/leaflet/libs/spin-js/spin.min.js'
2015-01-08 11:01:22 +01:00
)
);