Add popup support.

This commit is contained in:
David Molineus
2015-01-27 17:14:58 +01:00
parent 126b84f524
commit c9c2bd3cce
19 changed files with 597 additions and 5 deletions

BIN
module/assets/img/popup.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

View File

@@ -37,6 +37,7 @@ array_insert(
'tl_leaflet_vector', 'tl_leaflet_vector',
'tl_leaflet_icon', 'tl_leaflet_icon',
'tl_leaflet_style', 'tl_leaflet_style',
'tl_leaflet_popup',
), ),
'icon' => 'system/modules/leaflet/assets/img/layers.png', 'icon' => 'system/modules/leaflet/assets/img/layers.png',
'stylesheet' => 'system/modules/leaflet/assets/css/backend.css', 'stylesheet' => 'system/modules/leaflet/assets/css/backend.css',
@@ -51,21 +52,25 @@ array_insert(
) )
); );
/* /*
* Content elements. * Content elements.
*/ */
$GLOBALS['TL_CTE']['includes']['leaflet'] = 'Netzmacht\Contao\Leaflet\Frontend\MapElement'; $GLOBALS['TL_CTE']['includes']['leaflet'] = 'Netzmacht\Contao\Leaflet\Frontend\MapElement';
/* /*
* Frontend modules * Frontend modules
*/ */
$GLOBALS['FE_MOD']['includes']['leaflet'] = 'Netzmacht\Contao\Leaflet\Frontend\MapModule'; $GLOBALS['FE_MOD']['includes']['leaflet'] = 'Netzmacht\Contao\Leaflet\Frontend\MapModule';
/* /*
* Hooks * Hooks
*/ */
$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('Netzmacht\Contao\Leaflet\Frontend\Hooks', 'replaceInsertTags'); $GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('Netzmacht\Contao\Leaflet\Frontend\Hooks', 'replaceInsertTags');
/* /*
* Models. * Models.
*/ */
@@ -74,6 +79,7 @@ $GLOBALS['TL_MODELS']['tl_leaflet_icon'] = 'Netzmacht\Contao\Leaflet\Model\Ic
$GLOBALS['TL_MODELS']['tl_leaflet_layer'] = 'Netzmacht\Contao\Leaflet\Model\LayerModel'; $GLOBALS['TL_MODELS']['tl_leaflet_layer'] = 'Netzmacht\Contao\Leaflet\Model\LayerModel';
$GLOBALS['TL_MODELS']['tl_leaflet_map'] = 'Netzmacht\Contao\Leaflet\Model\MapModel'; $GLOBALS['TL_MODELS']['tl_leaflet_map'] = 'Netzmacht\Contao\Leaflet\Model\MapModel';
$GLOBALS['TL_MODELS']['tl_leaflet_marker'] = 'Netzmacht\Contao\Leaflet\Model\MarkerModel'; $GLOBALS['TL_MODELS']['tl_leaflet_marker'] = 'Netzmacht\Contao\Leaflet\Model\MarkerModel';
$GLOBALS['TL_MODELS']['tl_leaflet_popup'] = 'Netzmacht\Contao\Leaflet\Model\PopupModel';
$GLOBALS['TL_MODELS']['tl_leaflet_style'] = 'Netzmacht\Contao\Leaflet\Model\StyleModel'; $GLOBALS['TL_MODELS']['tl_leaflet_style'] = 'Netzmacht\Contao\Leaflet\Model\StyleModel';
$GLOBALS['TL_MODELS']['tl_leaflet_vector'] = 'Netzmacht\Contao\Leaflet\Model\VectorModel'; $GLOBALS['TL_MODELS']['tl_leaflet_vector'] = 'Netzmacht\Contao\Leaflet\Model\VectorModel';
@@ -114,6 +120,7 @@ $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\Rectangl
// Miscellaneous mappers. // Miscellaneous mappers.
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper'; $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\UI\PopupMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\ImageIconMapper'; $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\Type\DivIconMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Style\FixedStyleMapper'; $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Style\FixedStyleMapper';

View File

@@ -55,6 +55,13 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array
'icon' => 'system/modules/leaflet/assets/img/style.png', 'icon' => 'system/modules/leaflet/assets/img/style.png',
'attributes' => 'onclick="Backend.getScrollOffset();"' 'attributes' => 'onclick="Backend.getScrollOffset();"'
), ),
'popups' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_icon']['popups'],
'href' => 'table=tl_leaflet_popup',
'icon' => 'system/modules/leaflet/assets/img/popup.png',
'attributes' => 'onclick="Backend.getScrollOffset();"'
),
'all' => array 'all' => array
( (
'label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'label' => &$GLOBALS['TL_LANG']['MSC']['all'],

View File

@@ -66,6 +66,13 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array
'icon' => 'system/modules/leaflet/assets/img/icons.png', 'icon' => 'system/modules/leaflet/assets/img/icons.png',
'attributes' => 'onclick="Backend.getScrollOffset();"' 'attributes' => 'onclick="Backend.getScrollOffset();"'
), ),
'popups' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['popups'],
'href' => 'table=tl_leaflet_popup',
'icon' => 'system/modules/leaflet/assets/img/popup.png',
'attributes' => 'onclick="Backend.getScrollOffset();"'
),
'all' => array 'all' => array
( (
'label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'label' => &$GLOBALS['TL_LANG']['MSC']['all'],

View File

@@ -56,6 +56,13 @@ $GLOBALS['TL_DCA']['tl_leaflet_marker'] = array
'icon' => 'system/modules/leaflet/assets/img/icons.png', 'icon' => 'system/modules/leaflet/assets/img/icons.png',
'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"' 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"'
), ),
'popups' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['popups'],
'href' => 'table=tl_leaflet_popup',
'icon' => 'system/modules/leaflet/assets/img/popup.png',
'attributes' => 'onclick="Backend.getScrollOffset();"'
),
'all' => array 'all' => array
( (
'label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
@@ -124,7 +131,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_marker'] = array
), ),
), ),
'metasubpalettes' => array( 'metasubpalettes' => array(
'addPopup' => array('popupContent'), 'addPopup' => array('popup', 'popupContent'),
'customIcon' => array('icon') 'customIcon' => array('icon')
), ),
@@ -249,9 +256,23 @@ $GLOBALS['TL_DCA']['tl_leaflet_marker'] = 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_marker']['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_marker']['popupContent'], 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_marker']['popupContent'],

View File

@@ -0,0 +1,290 @@
<?php
/**
* @package dev
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014 netzmacht creative David Molineus
* @license LGPL 3.0
* @filesource
*
*/
$GLOBALS['TL_DCA']['tl_leaflet_popup'] = array
(
'config' => array(
'dataContainer' => 'Table',
'enableVersioning' => true,
'sql' => array
(
'keys' => array
(
'id' => 'primary',
'alias' => 'unique',
)
)
),
'list' => array
(
'sorting' => array
(
'mode' => 1,
'fields' => array('title'),
'flag' => 1,
'panelLayout' => 'limit',
'headerFields' => array('title', 'type'),
),
'label' => array
(
'fields' => array('title', 'type'),
'format' => '%s <span class="tl_gray">[%s]</span>',
),
'global_operations' => array
(
'layers' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['layersBtn'],
'href' => 'table=tl_leaflet_layer',
'icon' => 'system/modules/leaflet/assets/img/layers.png',
'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"'
),
'styles' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['styles'],
'href' => 'table=tl_leaflet_style',
'icon' => 'system/modules/leaflet/assets/img/style.png',
'attributes' => 'onclick="Backend.getScrollOffset();"'
),
'icons' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['icons'],
'href' => 'table=tl_leaflet_icon',
'icon' => 'system/modules/leaflet/assets/img/icons.png',
'attributes' => 'onclick="Backend.getScrollOffset();"'
),
'all' => array
(
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
'href' => 'act=select',
'class' => 'header_edit_all',
'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"'
),
),
'operations' => array
(
'edit' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['edit'],
'href' => 'act=edit',
'icon' => 'edit.gif'
),
'copy' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['copy'],
'href' => 'act=copy',
'icon' => 'copy.gif'
),
'delete' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['delete'],
'href' => 'act=delete',
'icon' => 'delete.gif',
'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'
),
'toggle' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['toggle'],
'icon' => 'visible.gif',
'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"',
'button_callback' => \Netzmacht\Contao\DevTools\Dca::createToggleIconCallback(
'tl_leaflet_popup',
'active'
)
),
'show' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['show'],
'href' => 'act=show',
'icon' => 'show.gif'
)
)
),
'palettes' => array(
'__selector__' => array('type')
),
'metapalettes' => array(
'default' => array(
'title' => array('title', 'alias'),
'size' => array('maxWidth', 'minWidth', 'maxHeight'),
'config' => array(
':hide',
'closeButton',
'keepInView',
'closeOnClick',
'zoomAnimation',
'offset',
'className',
'autoPan'
),
'active' => array('active'),
),
),
'metasubpalettes' => array(
'autoPan' => array('autoPanPadding')
),
'fields' => array
(
'id' => array
(
'sql' => "int(10) unsigned NOT NULL auto_increment"
),
'tstamp' => array
(
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'title' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['title'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'),
'sql' => "varchar(255) NOT NULL default ''"
),
'alias' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['alias'],
'exclude' => true,
'inputType' => 'text',
'save_callback' => array(
\Netzmacht\Contao\DevTools\Dca::createGenerateAliasCallback('tl_leaflet_popup', 'title'),
),
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50', 'unique' => true),
'sql' => "varchar(255) NOT NULL default ''"
),
'maxWidth' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['maxWidth'],
'exclude' => true,
'inputType' => 'text',
'default' => null,
'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'),
'sql' => "int(4) NULL"
),
'minWidth' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['minWidth'],
'exclude' => true,
'inputType' => 'text',
'default' => null,
'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'),
'sql' => "int(4) NULL"
),
'maxHeight' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['maxHeight'],
'exclude' => true,
'inputType' => 'text',
'default' => null,
'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'),
'sql' => "int(4) NULL"
),
'autoPan' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['autoPan'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => true,
'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => true),
'sql' => "char(1) NOT NULL default '1'"
),
'keepInView' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['keepInView'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => false,
'eval' => array('tl_class' => 'w50', 'submitOnChange' => false),
'sql' => "char(1) NOT NULL default ''"
),
'closeButton' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['closeButton'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => true,
'eval' => array('tl_class' => 'w50', 'submitOnChange' => false),
'sql' => "char(1) NOT NULL default '1'"
),
'offset' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['offset'],
'exclude' => true,
'inputType' => 'text',
'save_callback' => array(
array('Netzmacht\Contao\Leaflet\Dca\Leaflet', 'validateCoordinate')
),
'eval' => array(
'maxlength' => 255,
'tl_class' => 'w50',
'nullIfEmpty' => true,
),
'sql' => "varchar(255) NULL"
),
'autoPanPadding' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['autoPanPadding'],
'exclude' => true,
'inputType' => 'text',
'eval' => array(
'maxlength' => 255,
'tl_class' => 'w50',
'nullIfEmpty' => true,
'multiple' => true,
'size' => 2,
),
'sql' => "varchar(255) NULL"
),
'zoomAnimation' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['zoomAnimation'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => true,
'eval' => array('tl_class' => 'w50', 'submitOnChange' => false),
'sql' => "char(1) NOT NULL default '1'"
),
'closeOnClick' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['closeOnClick'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => true,
'eval' => array('tl_class' => 'w50', 'submitOnChange' => false),
'sql' => "char(1) NOT NULL default '1'"
),
'className' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['className'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('mandatory' => false, 'maxlength' => 64, 'tl_class' => 'w50'),
'sql' => "varchar(64) NOT NULL default ''"
),
'active' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_popup']['active'],
'exclude' => true,
'inputType' => 'checkbox',
'filter' => true,
'sorting' => true,
'search' => false,
'flag' => 12,
'eval' => array('tl_class' => 'w50'),
'sql' => "char(1) NOT NULL default ''"
),
),
);

View File

@@ -54,6 +54,13 @@ $GLOBALS['TL_DCA']['tl_leaflet_style'] = array
'icon' => 'system/modules/leaflet/assets/img/icons.png', 'icon' => 'system/modules/leaflet/assets/img/icons.png',
'attributes' => 'onclick="Backend.getScrollOffset();"' 'attributes' => 'onclick="Backend.getScrollOffset();"'
), ),
'popups' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_style']['popups'],
'href' => 'table=tl_leaflet_popup',
'icon' => 'system/modules/leaflet/assets/img/popup.png',
'attributes' => 'onclick="Backend.getScrollOffset();"'
),
'all' => array 'all' => array
( (
'label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'label' => &$GLOBALS['TL_LANG']['MSC']['all'],

View File

@@ -56,7 +56,13 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
'icon' => 'system/modules/leaflet/assets/img/style.png', 'icon' => 'system/modules/leaflet/assets/img/style.png',
'attributes' => 'onclick="Backend.getScrollOffset();"' 'attributes' => 'onclick="Backend.getScrollOffset();"'
), ),
'popups' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popups'],
'href' => 'table=tl_leaflet_popup',
'icon' => 'system/modules/leaflet/assets/img/popup.png',
'attributes' => 'onclick="Backend.getScrollOffset();"'
),
'all' => array 'all' => array
( (
'label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'label' => &$GLOBALS['TL_LANG']['MSC']['all'],

View File

@@ -9,6 +9,8 @@ $GLOBALS['TL_LANG']['tl_leaflet_icon']['layersBtn'][0] = 'Manage layers';
$GLOBALS['TL_LANG']['tl_leaflet_icon']['layersBtn'][1] = 'Manage leaflet layers'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['layersBtn'][1] = 'Manage leaflet layers';
$GLOBALS['TL_LANG']['tl_leaflet_icon']['styles'][0] = 'Manage styles'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['styles'][0] = 'Manage styles';
$GLOBALS['TL_LANG']['tl_leaflet_icon']['styles'][1] = 'Manage vector styles'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['styles'][1] = 'Manage vector styles';
$GLOBALS['TL_LANG']['tl_leaflet_icon']['popups'][0] = 'Manage popups';
$GLOBALS['TL_LANG']['tl_leaflet_icon']['popups'][1] = 'Manage popups icons';
$GLOBALS['TL_LANG']['tl_leaflet_icon']['new'][0] = 'Create icon'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['new'][0] = 'Create icon';
$GLOBALS['TL_LANG']['tl_leaflet_icon']['new'][1] = 'Create new icon'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['new'][1] = 'Create new icon';
$GLOBALS['TL_LANG']['tl_leaflet_icon']['edit'][0] = 'Edit icon'; $GLOBALS['TL_LANG']['tl_leaflet_icon']['edit'][0] = 'Edit icon';

View File

@@ -9,6 +9,8 @@ $GLOBALS['TL_LANG']['tl_leaflet_layer']['map'][0] = 'Manage maps';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['map'][1] = 'Manage leaflet maps'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['map'][1] = 'Manage leaflet maps';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['icons'][0] = 'Manage icons'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['icons'][0] = 'Manage icons';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['icons'][1] = 'Manage marker icons'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['icons'][1] = 'Manage marker icons';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['popups'][0] = 'Manage popups';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['popups'][1] = 'Manage popups icons';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['styles'][0] = 'Manage styles'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['styles'][0] = 'Manage styles';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['styles'][1] = 'Manage vector styles'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['styles'][1] = 'Manage vector styles';
$GLOBALS['TL_LANG']['tl_leaflet_layer']['new'][0] = 'Create layer'; $GLOBALS['TL_LANG']['tl_leaflet_layer']['new'][0] = 'Create layer';

View File

@@ -21,6 +21,8 @@ $GLOBALS['TL_LANG']['tl_leaflet_marker']['toggle'][0] = 'Toggle activation';
$GLOBALS['TL_LANG']['tl_leaflet_marker']['toggle'][1] = 'Toggle marker ID %s activation'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['toggle'][1] = 'Toggle marker ID %s activation';
$GLOBALS['TL_LANG']['tl_leaflet_marker']['icons'][0] = 'Manage icons'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['icons'][0] = 'Manage icons';
$GLOBALS['TL_LANG']['tl_leaflet_marker']['icons'][1] = 'Manage marker icons.'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['icons'][1] = 'Manage marker icons.';
$GLOBALS['TL_LANG']['tl_leaflet_marker']['popups'][0] = 'Manage popups';
$GLOBALS['TL_LANG']['tl_leaflet_marker']['popups'][1] = 'Manage popups icons';
$GLOBALS['TL_LANG']['tl_leaflet_marker']['title'][0] = 'Title'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['title'][0] = 'Title';
$GLOBALS['TL_LANG']['tl_leaflet_marker']['title'][1] = 'Title of the map.'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['title'][1] = 'Title of the map.';

View File

@@ -0,0 +1,58 @@
<?php
$GLOBALS['TL_LANG']['tl_leaflet_popup']['title_legend'] = 'Title';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['config_legend'] = 'Configuration';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['size_legend'] = 'Popup size';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['active_legend'] = 'Activation';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['layersBtn'][0] = 'Manage layers';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['layersBtn'][1] = 'Manage leaflet layers';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['styles'][0] = 'Manage styles';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['styles'][1] = 'Manage vector styles';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['icons'][0] = 'Manage popups';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['icons'][1] = 'Manage marker popups';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['new'][0] = 'Create popup';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['new'][1] = 'Create new popup';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['edit'][0] = 'Edit popup';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['edit'][1] = 'Edit popup ID %s';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['copy'][0] = 'Copy popup';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['copy'][1] = 'Copy popup ID %s';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['controls'][0] = 'Manage controls';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['controls'][1] = 'Manage controls of popup ID %s';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['map'][0] = 'Manage maps';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['map'][1] = 'Manage leaflet maps.';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['delete'][0] = 'Delete popup';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['delete'][1] = 'Delete popup ID %s';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['show'][0] = 'Show details';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['show'][1] = 'Show popup ID %s details';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['toggle'][0] = 'Toggle activation';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['toggle'][1] = 'Toggle popup ID %s activation';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['title'][0] = 'Title';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['title'][1] = 'Title of the icon.';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['alias'][0] = 'Alias';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['alias'][1] = 'Alias of the icon.';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['maxWidth'][0] = 'Max width';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['maxWidth'][1] = 'Max width of the popup.';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['minWidth'][0] = 'Min width';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['minWidth'][1] = 'Min width of the popup.';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['maxHeight'][0] = 'Min width';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['maxHeight'][1] = 'Min width of the popup.';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['closeButton'][0] = 'Close button';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['closeButton'][1] = 'Controls the presense of a close button in the popup.';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['closeOnClick'][0] = 'Close on map click';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['closeOnClick'][1] = 'Disable it if you want to override the default behavior of the popup closing when user clicks the map ';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['offset'][0] = 'Offset';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['offset'][1] = 'The offset of the popup position as comma separated point (e.g. 5,2)';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['keepInView'][0] = 'Keep in view';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['keepInView'][1] = 'Set it to true if you want to prevent users from panning the popup off of the screen while it is open.';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['zoomAnimation'][0] = 'Animate on zoom';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['zoomAnimation'][1] = 'Whether to animate the popup on zoom. Disable it if you have problems with Flash content inside popups.';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['className'][0] = 'Class name';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['className'][1] = 'A custom class name to assign to the popup.';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['autoPanPadding'][0] = 'Auto pan padding';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['autoPanPadding'][1] = 'The margin between the popup and the top left (first input) and the bottom right (second input) of the map view. Each value as comma separated point (e.g. 5,5)';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['autoPan'][0] = 'Pan map';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['autoPan'][1] = 'Automatically pan the map to display the popup.';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['active'][0] = 'Activate popup';
$GLOBALS['TL_LANG']['tl_leaflet_popup']['active'][1] = 'Only activated popups are assigned to the map object.';

View File

@@ -8,6 +8,8 @@ $GLOBALS['TL_LANG']['tl_leaflet_style']['layersBtn'][0] = 'Manage layers';
$GLOBALS['TL_LANG']['tl_leaflet_style']['layersBtn'][1] = 'Manage leaflet layers'; $GLOBALS['TL_LANG']['tl_leaflet_style']['layersBtn'][1] = 'Manage leaflet layers';
$GLOBALS['TL_LANG']['tl_leaflet_style']['icons'][0] = 'Manage icons'; $GLOBALS['TL_LANG']['tl_leaflet_style']['icons'][0] = 'Manage icons';
$GLOBALS['TL_LANG']['tl_leaflet_style']['icons'][1] = 'Manage marker icons'; $GLOBALS['TL_LANG']['tl_leaflet_style']['icons'][1] = 'Manage marker icons';
$GLOBALS['TL_LANG']['tl_leaflet_style']['popups'][0] = 'Manage popups';
$GLOBALS['TL_LANG']['tl_leaflet_style']['popups'][1] = 'Manage popups icons';
$GLOBALS['TL_LANG']['tl_leaflet_style']['new'][0] = 'Create style'; $GLOBALS['TL_LANG']['tl_leaflet_style']['new'][0] = 'Create style';
$GLOBALS['TL_LANG']['tl_leaflet_style']['new'][1] = 'Create new style'; $GLOBALS['TL_LANG']['tl_leaflet_style']['new'][1] = 'Create new style';
$GLOBALS['TL_LANG']['tl_leaflet_style']['edit'][0] = 'Edit style'; $GLOBALS['TL_LANG']['tl_leaflet_style']['edit'][0] = 'Edit style';

View File

@@ -24,6 +24,8 @@ $GLOBALS['TL_LANG']['tl_leaflet_vector']['toggle'][0] = 'Toggle activation';
$GLOBALS['TL_LANG']['tl_leaflet_vector']['toggle'][1] = 'Toggle vector ID %s activation'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['toggle'][1] = 'Toggle vector ID %s activation';
$GLOBALS['TL_LANG']['tl_leaflet_vector']['styles'][0] = 'Manage styles'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['styles'][0] = 'Manage styles';
$GLOBALS['TL_LANG']['tl_leaflet_vector']['styles'][1] = 'Manage vector styles'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['styles'][1] = 'Manage vector styles';
$GLOBALS['TL_LANG']['tl_leaflet_vector']['popups'][0] = 'Manage popups';
$GLOBALS['TL_LANG']['tl_leaflet_vector']['popups'][1] = 'Manage popups icons';
$GLOBALS['TL_LANG']['tl_leaflet_vector']['title'][0] = 'Title'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['title'][0] = 'Title';
$GLOBALS['TL_LANG']['tl_leaflet_vector']['title'][1] = 'Title of the vector.'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['title'][1] = 'Title of the vector.';

View File

@@ -13,6 +13,7 @@ namespace Netzmacht\Contao\Leaflet\Dca;
use Netzmacht\Contao\DevTools\Dca\Options\OptionsBuilder; use Netzmacht\Contao\DevTools\Dca\Options\OptionsBuilder;
use Netzmacht\Contao\Leaflet\Model\IconModel; use Netzmacht\Contao\Leaflet\Model\IconModel;
use Netzmacht\Contao\Leaflet\Model\PopupModel;
/** /**
* 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.
@@ -52,6 +53,19 @@ class Marker
return $builder->getOptions(); return $builder->getOptions();
} }
/**
* Get all popups.
*
* @return array
*/
public function getPopups()
{
$collection = PopupModel::findAll(array('order' => 'title'));
$builder = OptionsBuilder::fromCollection($collection, 'id', 'title');
return $builder->getOptions();
}
/** /**
* Save the coordinates. * Save the coordinates.
* *

View File

@@ -15,10 +15,12 @@ use Netzmacht\Contao\Leaflet\Filter\Filter;
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\Model\IconModel; use Netzmacht\Contao\Leaflet\Model\IconModel;
use Netzmacht\Contao\Leaflet\Model\PopupModel;
use Netzmacht\Contao\Leaflet\ServiceContainerTrait; use Netzmacht\Contao\Leaflet\ServiceContainerTrait;
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;
use Netzmacht\LeafletPHP\Definition\UI\Popup;
/** /**
* Class MarkerMapper maps the marker model to the marker definition. * Class MarkerMapper maps the marker model to the marker definition.
@@ -53,7 +55,7 @@ class MarkerMapper extends AbstractMapper
$elementId = null $elementId = null
) { ) {
$arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId); $arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId);
$arguments[] = $model->coordinates ?: null; $arguments[] = array($model->latitude, $model->longitude, $model->altitude ?: null) ?: null;
return $arguments; return $arguments;
} }
@@ -82,12 +84,25 @@ class MarkerMapper extends AbstractMapper
) { ) {
if ($definition instanceof Marker) { if ($definition instanceof Marker) {
if ($model->addPopup) { if ($model->addPopup) {
$popup = null;
$content = $this $content = $this
->getServiceContainer() ->getServiceContainer()
->getFrontendValueFilter() ->getFrontendValueFilter()
->filter($model->popupContent); ->filter($model->popupContent);
$definition->bindPopup($content); 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);
}
} }
if ($model->customIcon) { if ($model->customIcon) {

View File

@@ -0,0 +1,117 @@
<?php
/**
* @package dev
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2015 netzmacht creative David Molineus
* @license LGPL 3.0
* @filesource
*
*/
namespace Netzmacht\Contao\Leaflet\Mapper\UI;
use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Model\PopupModel;
use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Definition\UI\Popup;
/**
* Class PopupMapper.
*
* @package Netzmacht\Contao\Leaflet\Mapper\UI
*/
class PopupMapper extends AbstractMapper
{
/**
* The definition class.
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\UI\Popup';
/**
* The model class.
*
* @var string
*/
protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\PopupModel';
/**
* {@inheritdoc}
*/
protected function initialize()
{
parent::initialize();
$this->optionsBuilder
->addConditionalOption('maxWidth')
->addConditionalOption('minWidth')
->addConditionalOption('maxHeight')
->addConditionalOption('className')
->addOptions('autoPan', 'keepInView', 'closeButton', 'zoomAnimation');
}
/**
* {@inheritdoc}
*/
protected function build(
Definition $definition,
\Model $model,
DefinitionMapper $mapper,
Filter $filter = null,
Definition $parent = null
) {
parent::build($definition, $model, $mapper, $filter, $parent);
/** @var Popup $definition */
/** @var PopupModel $model */
$this->deserializePoint('offset', $definition, $model);
if ($model->autoPan) {
$padding = array_map(
function ($value) {
return array_map('intval', trimsplit(',', $value));
},
deserialize($model->autoPanPadding, true)
);
if ($padding[0] === $padding[1]) {
$definition->setAutoPanPadding($padding[0]);
} else {
if ($padding[0]) {
$definition->setAutoPanPaddingTopLeft($padding[0]);
}
if ($padding[1]) {
$definition->setAutoPanPaddingBottomRight($padding[1]);
}
}
}
if (!$model->closeOnClick) {
$definition->setCloseOnClick(false);
}
}
/**
* Deserialize point value and add it as option.
*
* @param string $option The option name.
* @param Popup $definition The popup definition.
* @param PopupModel $model The popup model.
*
* @return $this
*/
protected function deserializePoint($option, Popup $definition, PopupModel $model)
{
if ($model->$option) {
$setter = 'set' . ucfirst($option);
$definition->$setter(array_map('intval', explode(',', $model->$option, 2)));
}
return $this;
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* @package dev
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2015 netzmacht creative David Molineus
* @license LGPL 3.0
* @filesource
*
*/
namespace Netzmacht\Contao\Leaflet\Model;
/**
* Class PopupModel.
*
* @property mixed|null offset
*
* @package Netzmacht\Contao\Leaflet\Model
*/
class PopupModel extends AbstractActiveModel
{
/**
* The table name.
*
* @var string
*/
protected static $strTable = 'tl_leaflet_popup';
}

View File

@@ -63,6 +63,10 @@ class GeoJsonSubscriber implements EventSubscriberInterface
if ($definition->getPopupContent()) { if ($definition->getPopupContent()) {
$feature->setProperty('popupContent', $definition->getPopupContent()); $feature->setProperty('popupContent', $definition->getPopupContent());
} }
if ($definition->getPopupOptions()) {
$feature->setProperty('popupOptions', $definition->getPopupOptions());
}
} }
} }