mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-28 11:04:08 +01:00
Work on the layers implementation.
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_leaflet_layer'] = array
|
||||
(
|
||||
'config' => array(
|
||||
'dataContainer' => 'Table',
|
||||
'enableVersioning' => true,
|
||||
'sql' => array
|
||||
(
|
||||
'keys' => array
|
||||
(
|
||||
'id' => 'primary'
|
||||
)
|
||||
)
|
||||
),
|
||||
'list' => array
|
||||
(
|
||||
'sorting' => array
|
||||
(
|
||||
'mode' => 5,
|
||||
'fields' => array('title'),
|
||||
'flag' => 1
|
||||
),
|
||||
'label' => array
|
||||
(
|
||||
'fields' => array('title'),
|
||||
'format' => '%s'
|
||||
),
|
||||
'global_operations' => array
|
||||
(
|
||||
'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_layer']['edit'],
|
||||
'href' => 'act=edit',
|
||||
'icon' => 'header.gif'
|
||||
),
|
||||
'copy' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['copy'],
|
||||
'href' => 'act=copy',
|
||||
'icon' => 'copy.gif'
|
||||
),
|
||||
'delete' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['delete'],
|
||||
'href' => 'act=delete',
|
||||
'icon' => 'delete.gif',
|
||||
'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'
|
||||
),
|
||||
'show' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['show'],
|
||||
'href' => 'act=show',
|
||||
'icon' => 'show.gif'
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
'metapalettes' => array(
|
||||
'default' => array(
|
||||
'title' => array('title', 'alias', 'type'),
|
||||
),
|
||||
),
|
||||
|
||||
'metasubselectpalettes' => array(
|
||||
'type' => array(
|
||||
'provider' => array('tile_provider', 'tile_provider_variant')
|
||||
),
|
||||
'tile_provider' => array(
|
||||
'MapBox' => array('tile_provider_key'),
|
||||
'HERE' => array('tile_provider_key', 'tile_provider_code'),
|
||||
),
|
||||
),
|
||||
|
||||
'fields' => array
|
||||
(
|
||||
'id' => array
|
||||
(
|
||||
'sql' => "int(10) unsigned NOT NULL auto_increment"
|
||||
),
|
||||
'pid' => array
|
||||
(
|
||||
'sql' => "int(10) unsigned NOT NULL default '0'"
|
||||
),
|
||||
'sorting' => array
|
||||
(
|
||||
'sql' => "int(10) unsigned NOT NULL default '0'"
|
||||
),
|
||||
'tstamp' => array
|
||||
(
|
||||
'sql' => "int(10) unsigned NOT NULL default '0'"
|
||||
),
|
||||
'title' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['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_layer']['alias'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'),
|
||||
'sql' => "varchar(255) NOT NULL default ''"
|
||||
),
|
||||
'type' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['type'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'select',
|
||||
'eval' => array(
|
||||
'mandatory' => true,
|
||||
'tl_class' => 'w50',
|
||||
'includeBlankOption' => true,
|
||||
'submitOnChange' => true,
|
||||
'chosen' => true,
|
||||
),
|
||||
'options' => &$GLOBALS['LEAFLET_LAYERS'],
|
||||
'sql' => "varchar(32) NOT NULL default ''"
|
||||
),
|
||||
'tile_provider' => array(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'select',
|
||||
'eval' => array(
|
||||
'mandatory' => true,
|
||||
'tl_class' => 'w50 clr',
|
||||
'includeBlankOption' => true,
|
||||
'submitOnChange' => true,
|
||||
'chosen' => true,
|
||||
),
|
||||
'options' => array_keys($GLOBALS['LEAFLET_TILE_PROVIDERS']),
|
||||
'sql' => "varchar(32) NOT NULL default ''"
|
||||
),
|
||||
'tile_provider_variant' => array(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider_variant'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'select',
|
||||
'eval' => array(
|
||||
'mandatory' => false,
|
||||
'tl_class' => 'w50',
|
||||
'submitOnChange' => true,
|
||||
'chosen' => false,
|
||||
),
|
||||
'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\Layer', 'getVariants'),
|
||||
'sql' => "varchar(32) NOT NULL default ''"
|
||||
),
|
||||
'tile_provider_key' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider_key'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'clr w50'),
|
||||
'sql' => "varchar(255) NOT NULL default ''"
|
||||
),
|
||||
'tile_provider_code' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['tile_provider_code'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'),
|
||||
'sql' => "varchar(255) NOT NULL default ''"
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -5,7 +5,6 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
|
||||
'config' => array(
|
||||
'dataContainer' => 'Table',
|
||||
'enableVersioning' => true,
|
||||
// 'ctable' => array('tl_leaflet'),
|
||||
'sql' => array
|
||||
(
|
||||
'keys' => array
|
||||
@@ -30,13 +29,20 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
|
||||
),
|
||||
'global_operations' => array
|
||||
(
|
||||
'layers' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['layers'],
|
||||
'href' => 'table=tl_leaflet_layer',
|
||||
'class' => 'header_edit_all',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"'
|
||||
),
|
||||
'all' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
|
||||
'href' => 'act=select',
|
||||
'class' => 'header_edit_all',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"'
|
||||
)
|
||||
),
|
||||
),
|
||||
'operations' => array
|
||||
(
|
||||
@@ -73,6 +79,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
|
||||
'title' => array('title', 'alias'),
|
||||
'zoom' => array('center', 'zoom', 'adjustZoomExtra'),
|
||||
'controls' => array('zoomControl', 'controls'),
|
||||
'layers' => array('layers'),
|
||||
'interaction' => array(
|
||||
'dragging',
|
||||
'touchZoom',
|
||||
@@ -87,10 +94,8 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
|
||||
'closeOnClick',
|
||||
'bounceAtZoomLimits'
|
||||
),
|
||||
'experts' => array(
|
||||
'expert' => array(
|
||||
'options',
|
||||
'detachLibraries',
|
||||
'cache'
|
||||
)
|
||||
),
|
||||
),
|
||||
@@ -123,7 +128,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['alias'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'),
|
||||
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'),
|
||||
'sql' => "varchar(255) NOT NULL default ''"
|
||||
),
|
||||
'center' => array
|
||||
@@ -144,6 +149,18 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
|
||||
),
|
||||
'sql' => "varchar(255) NULL"
|
||||
),
|
||||
'layers' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['layers'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkboxWizard',
|
||||
'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\Leaflet', 'getLayers'),
|
||||
'default' => '',
|
||||
'eval' => array(
|
||||
'multiple' => true,
|
||||
),
|
||||
'sql' => "mediumblob NULL"
|
||||
),
|
||||
'zoom' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoom'],
|
||||
@@ -226,7 +243,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
|
||||
'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'],
|
||||
'default' => true,
|
||||
'eval' => array('tl_class' => 'w50', 'helpwizard' => true,),
|
||||
'sql' => "char(1) NOT NULL default ''"
|
||||
'sql' => "char(6) NOT NULL default ''"
|
||||
),
|
||||
'doubleClickZoom' => array
|
||||
(
|
||||
@@ -237,7 +254,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
|
||||
'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'],
|
||||
'default' => true,
|
||||
'eval' => array('tl_class' => 'w50', 'helpwizard' => true,),
|
||||
'sql' => "char(1) NOT NULL default ''"
|
||||
'sql' => "char(6) NOT NULL default ''"
|
||||
),
|
||||
'boxZoom' => array
|
||||
(
|
||||
@@ -329,23 +346,5 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
|
||||
'eval' => array('tl_class' => 'clr lng', 'allowHtml'=>true, 'style' => 'min-height: 40px;'),
|
||||
'sql' => "char(1) NOT NULL default ''"
|
||||
),
|
||||
'detachLibraries' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['detachLibraries'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkbox',
|
||||
'default' => false,
|
||||
'eval' => array('tl_class' => 'w50'),
|
||||
'sql' => "char(1) NOT NULL default ''"
|
||||
),
|
||||
'cache' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['cache'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkbox',
|
||||
'default' => false,
|
||||
'eval' => array('tl_class' => 'w50', 'submitOnChange' => true),
|
||||
'sql' => "char(1) NOT NULL default '0'"
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
28
src/Netzmacht/Contao/Leaflet/Dca/Layer.php
Normal file
28
src/Netzmacht/Contao/Leaflet/Dca/Layer.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2014 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Dca;
|
||||
|
||||
|
||||
class Layer
|
||||
{
|
||||
public function getVariants($dataContainer)
|
||||
{
|
||||
if ($dataContainer->activeRecord
|
||||
&& $dataContainer->activeRecord->tile_provider
|
||||
&& !empty($GLOBALS['LEAFLET_TILE_PROVIDERS'][$dataContainer->activeRecord->tile_provider]['variants'])
|
||||
) {
|
||||
return $GLOBALS['LEAFLET_TILE_PROVIDERS'][$dataContainer->activeRecord->tile_provider]['variants'];
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,11 @@
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Map;
|
||||
use Netzmacht\LeafletPHP\Plugins\LeafletProviders\Provider;
|
||||
|
||||
class MapMapper extends AbstractMapper
|
||||
{
|
||||
@@ -102,5 +104,15 @@ class MapMapper extends AbstractMapper
|
||||
*/
|
||||
private function buildLayers(Map $map, MapModel $model, DefinitionMapper $mapper)
|
||||
{
|
||||
$ids = deserialize($model->layers, true);
|
||||
$collection = LayerModel::findMultipleByIds($ids);
|
||||
|
||||
if ($collection) {
|
||||
foreach ($collection as $layer) {
|
||||
/** @var Provider $layer */
|
||||
$layer = $mapper->handle($layer);
|
||||
$map->addLayer($layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
src/Netzmacht/Contao/Leaflet/Model/LayerModel.php
Normal file
19
src/Netzmacht/Contao/Leaflet/Model/LayerModel.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2014 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Model;
|
||||
|
||||
|
||||
class LayerModel extends \Model
|
||||
{
|
||||
protected static $strTable = 'tl_leaflet_layer';
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user