From f68f623288de91de1abb346d4670f6b4e6432d5c Mon Sep 17 00:00:00 2001 From: David Molineus Date: Thu, 22 Jan 2015 16:17:21 +0100 Subject: [PATCH] Add option to replace default attribution control. --- module/dca/tl_leaflet_control.php | 11 ++++++++++- module/languages/en/tl_leaflet_control.php | 2 ++ .../Mapper/Control/AttributionControlMapper.php | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/module/dca/tl_leaflet_control.php b/module/dca/tl_leaflet_control.php index 3e02557..678005c 100644 --- a/module/dca/tl_leaflet_control.php +++ b/module/dca/tl_leaflet_control.php @@ -115,7 +115,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array 'config' => array('maxWidth', 'metric', 'imperial', 'updateWhenIdle') ), 'attribution extends default' => array( - 'config' => array('attributions', 'prefix') + 'config' => array('attributions', 'prefix', 'disableDefault') ), 'loading extends default' => array( 'config' => array('separate', 'zoomControl', 'spinjs') @@ -418,5 +418,14 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''" ), + 'disableDefault' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['disableDefault'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'default' => true, + 'eval' => array('tl_class' => 'w50 m12'), + 'sql' => "char(1) NOT NULL default ''" + ), ), ); diff --git a/module/languages/en/tl_leaflet_control.php b/module/languages/en/tl_leaflet_control.php index 3d5ca86..358eb6f 100644 --- a/module/languages/en/tl_leaflet_control.php +++ b/module/languages/en/tl_leaflet_control.php @@ -75,6 +75,8 @@ $GLOBALS['TL_LANG']['tl_leaflet_control']['buttonTitle'][0] = 'Button tit $GLOBALS['TL_LANG']['tl_leaflet_control']['buttonTitle'][1] = 'Title attribute of the control button.'; $GLOBALS['TL_LANG']['tl_leaflet_control']['simulateFullScreen'][0] = 'Always simulate fullscreen'; $GLOBALS['TL_LANG']['tl_leaflet_control']['simulateFullScreen'][1] = 'Simulate fullscreen no matter if the browser supports the Fullscreen API.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['disableDefault'][0] = 'Replace default control'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['disableDefault'][1] = 'If enabled the default control will be disabled.'; $GLOBALS['TL_LANG']['tl_leaflet_control']['bottomleft'][0] = 'Bottom left'; $GLOBALS['TL_LANG']['tl_leaflet_control']['bottomleft'][1] = 'Bottom left of the map.'; diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/AttributionControlMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Control/AttributionControlMapper.php index ee54fe8..7e7712d 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Control/AttributionControlMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Control/AttributionControlMapper.php @@ -14,6 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Control; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Control\Attribution; +use Netzmacht\LeafletPHP\Definition\Map; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; /** @@ -61,6 +62,10 @@ class AttributionControlMapper extends AbstractControlMapper return; } + if ($model->disableDefault && $parent instanceof Map) { + $parent->setAttributionControl(false); + } + $attributions = deserialize($model->attributions, true); foreach ($attributions as $attribution) {