mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-29 19:43:50 +01:00
Add popup support for vectors.
This commit is contained in:
@@ -157,7 +157,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
|
|||||||
'circleMarker extends circle' => array(),
|
'circleMarker extends circle' => array(),
|
||||||
),
|
),
|
||||||
'metasubpalettes' => array(
|
'metasubpalettes' => array(
|
||||||
'addPopup' => array('popupContent'),
|
'addPopup' => array('popup', 'popupContent'),
|
||||||
),
|
),
|
||||||
|
|
||||||
'fields' => array
|
'fields' => array
|
||||||
@@ -242,9 +242,23 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
|
|||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'inputType' => 'checkbox',
|
'inputType' => 'checkbox',
|
||||||
'filter' => true,
|
'filter' => true,
|
||||||
'eval' => array('tl_class' => 'w50', 'submitOnChange' => true),
|
'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => true),
|
||||||
'sql' => "char(1) NOT NULL default ''"
|
'sql' => "char(1) NOT NULL default ''"
|
||||||
),
|
),
|
||||||
|
'popup' => array
|
||||||
|
(
|
||||||
|
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popup'],
|
||||||
|
'exclude' => true,
|
||||||
|
'inputType' => 'select',
|
||||||
|
'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\Marker', 'getPopups'),
|
||||||
|
'eval' => array(
|
||||||
|
'mandatory' => false,
|
||||||
|
'tl_class' => 'w50',
|
||||||
|
'chosen' => true,
|
||||||
|
'includeBlankOption' => true,
|
||||||
|
),
|
||||||
|
'sql' => "int(10) unsigned NOT NULL default '0'",
|
||||||
|
),
|
||||||
'popupContent' => array
|
'popupContent' => array
|
||||||
(
|
(
|
||||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popupContent'],
|
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popupContent'],
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ $GLOBALS['TL_LANG']['tl_leaflet_marker']['alt'][0] = 'Alternative te
|
|||||||
$GLOBALS['TL_LANG']['tl_leaflet_marker']['alt'][1] = 'Text for the alt attribute of the icon image (useful for accessibility).';
|
$GLOBALS['TL_LANG']['tl_leaflet_marker']['alt'][1] = 'Text for the alt attribute of the icon image (useful for accessibility).';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_marker']['addPopup'][0] = 'Add popup';
|
$GLOBALS['TL_LANG']['tl_leaflet_marker']['addPopup'][0] = 'Add popup';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_marker']['addPopup'][1] = 'Add a popup for the marker';
|
$GLOBALS['TL_LANG']['tl_leaflet_marker']['addPopup'][1] = 'Add a popup for the marker';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_marker']['popup'][0] = 'Popup';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_marker']['popup'][1] = 'Choose a popup which options should be applied.';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_marker']['popupContent'][0] = 'Popup content';
|
$GLOBALS['TL_LANG']['tl_leaflet_marker']['popupContent'][0] = 'Popup content';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_marker']['popupContent'][1] = 'Content of the popup. Insert tags are replaced.';
|
$GLOBALS['TL_LANG']['tl_leaflet_marker']['popupContent'][1] = 'Content of the popup. Insert tags are replaced.';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_marker']['clickable'][0] = 'Clickable';
|
$GLOBALS['TL_LANG']['tl_leaflet_marker']['clickable'][0] = 'Clickable';
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ $GLOBALS['TL_LANG']['tl_leaflet_vector']['multiData'][0] = 'Multi data';
|
|||||||
$GLOBALS['TL_LANG']['tl_leaflet_vector']['multiData'][1] = 'Define coordinates of each vector in a new textarea.';
|
$GLOBALS['TL_LANG']['tl_leaflet_vector']['multiData'][1] = 'Define coordinates of each vector in a new textarea.';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_vector']['addPopup'][0] = 'Add popup';
|
$GLOBALS['TL_LANG']['tl_leaflet_vector']['addPopup'][0] = 'Add popup';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_vector']['addPopup'][1] = 'Add a popup to the vector.';
|
$GLOBALS['TL_LANG']['tl_leaflet_vector']['addPopup'][1] = 'Add a popup to the vector.';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_vector']['popup'][0] = 'Popup';
|
||||||
|
$GLOBALS['TL_LANG']['tl_leaflet_vector']['popup'][1] = 'Choose a popup which options should be used.';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_vector']['popupContent'][0] = 'Popup content';
|
$GLOBALS['TL_LANG']['tl_leaflet_vector']['popupContent'][0] = 'Popup content';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_vector']['popupContent'][1] = 'Content of the popup. Insert tags are replaced.';
|
$GLOBALS['TL_LANG']['tl_leaflet_vector']['popupContent'][1] = 'Content of the popup. Insert tags are replaced.';
|
||||||
$GLOBALS['TL_LANG']['tl_leaflet_vector']['clickable'][0] = 'Clickable';
|
$GLOBALS['TL_LANG']['tl_leaflet_vector']['clickable'][0] = 'Clickable';
|
||||||
|
|||||||
@@ -15,10 +15,12 @@ use Netzmacht\Contao\Leaflet\Definition\Style;
|
|||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
||||||
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\Model\PopupModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
||||||
use Netzmacht\Contao\Leaflet\ServiceContainerTrait;
|
use Netzmacht\Contao\Leaflet\ServiceContainerTrait;
|
||||||
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\Vector\Path;
|
use Netzmacht\LeafletPHP\Definition\Vector\Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,12 +64,25 @@ class AbstractVectorMapper extends AbstractTypeMapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($definition instanceof HasPopup && $model->addPopup) {
|
if ($definition instanceof HasPopup && $model->addPopup) {
|
||||||
|
$popup = null;
|
||||||
$content = $this
|
$content = $this
|
||||||
->getServiceContainer()
|
->getServiceContainer()
|
||||||
->getFrontendValueFilter()
|
->getFrontendValueFilter()
|
||||||
->filter($model->popupContent);
|
->filter($model->popupContent);
|
||||||
|
|
||||||
|
if ($model->popup) {
|
||||||
|
$popupModel = PopupModel::findActiveByPK($model->popup);
|
||||||
|
|
||||||
|
if ($popupModel) {
|
||||||
|
$popup = $mapper->handle($popupModel, $filter, null, $definition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($popup instanceof Popup) {
|
||||||
|
$definition->bindPopup($content, $popup->getOptions());
|
||||||
|
} else {
|
||||||
$definition->bindPopup($content);
|
$definition->bindPopup($content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user