diff --git a/module/assets/css/backend.css b/module/assets/css/backend.css index 1ebc060..62c126d 100644 --- a/module/assets/css/backend.css +++ b/module/assets/css/backend.css @@ -22,3 +22,7 @@ .tl_listing_container.tree_view ul[class="level_1"] li.tl_file > .tl_left { padding-left: 20px !important; } + +.long .tl_text_2 { + width: 325px; +} diff --git a/module/config/config.php b/module/config/config.php index ba27cf0..0f1961f 100644 --- a/module/config/config.php +++ b/module/config/config.php @@ -56,6 +56,7 @@ $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonM $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'; +$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\RectangleMapper'; /* * Leaflet encoders. diff --git a/module/dca/tl_leaflet_vector.php b/module/dca/tl_leaflet_vector.php index 74458d9..d5a49c6 100644 --- a/module/dca/tl_leaflet_vector.php +++ b/module/dca/tl_leaflet_vector.php @@ -125,7 +125,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array 'multiPolygon extends multiPolyline' => array( ), - 'rectangle extends polygon' => array(), + 'rectangle extends polygon' => array( + 'data' => array('bounds'), + ), 'circle extends default' => array( '+data' => array('coordinates', 'radius'), @@ -388,6 +390,22 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array ) ), 'sql' => "longblob NULL" - ) + ), + 'bounds' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['bounds'], + 'exclude' => true, + 'inputType' => 'text', + 'save_callback' => array( + ), + 'eval' => array( + 'maxlength' => 255, + 'multiple'=>true, + 'size'=>2, + 'tl_class' => 'long clr', + 'nullIfEmpty' => true, + ), + 'sql' => "mediumblob NULL" + ), ), ); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/RectangleMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/RectangleMapper.php new file mode 100644 index 0000000..c41817f --- /dev/null +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/RectangleMapper.php @@ -0,0 +1,57 @@ + + * @copyright 2015 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + +namespace Netzmacht\Contao\Leaflet\Mapper\Vector; + + +use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; +use Netzmacht\LeafletPHP\Definition; +use Netzmacht\LeafletPHP\Definition\Type\LatLng; +use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; +use Netzmacht\LeafletPHP\Definition\Vector\Circle; +use Netzmacht\LeafletPHP\Definition\Vector\Rectangle; + +class RectangleMapper extends AbstractVectorMapper +{ + /** + * Class of the definition being created. + * + * @var string + */ + protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Rectangle'; + + /** + * Layer type. + * + * @var string + */ + protected static $type = 'rectangle'; + + protected function initialize() + { + parent::initialize(); + } + + protected function buildConstructArguments(\Model $model, DefinitionMapper $mapper, LatLngBounds $bounds = null) + { + $latLngs = array_map( + function($latLng) { + return LatLng::fromString($latLng); + }, + deserialize($model->bounds, true) + ); + + $arguments = parent::buildConstructArguments($model, $mapper, $bounds); + $arguments[] = new LatLngBounds($latLngs[0], $latLngs[1]); + + return $arguments; + } +}