mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-12-01 04:24:02 +01:00
Add frontend module (Close #7).
This commit is contained in:
64
src/Netzmacht/Contao/Leaflet/Dca/Module.php
Normal file
64
src/Netzmacht/Contao/Leaflet/Dca/Module.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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;
|
||||
|
||||
use Netzmacht\Contao\DevTools\Dca\Options\OptionsBuilder;
|
||||
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
||||
|
||||
/**
|
||||
* Class Module
|
||||
* @package Netzmacht\Contao\Leaflet\Dca
|
||||
*/
|
||||
class Module
|
||||
{
|
||||
/**
|
||||
* Get all leaflet maps.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMaps()
|
||||
{
|
||||
$collection = MapModel::findAll();
|
||||
|
||||
return OptionsBuilder::fromCollection($collection, 'id', 'title')->getOptions();
|
||||
}
|
||||
|
||||
public function getEditMapLink($dataContainer)
|
||||
{
|
||||
if ($dataContainer->value < 1) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'<a href="%s%s&popup=1&rt=%s" %s>%s</a>',
|
||||
'contao/main.php?do=leaflet&table=tl_leaflet_map&act=edit&id=',
|
||||
$dataContainer->value,
|
||||
\RequestToken::get(),
|
||||
sprintf(
|
||||
'title="%s" style="padding-left: 3px" '
|
||||
. 'onclick="Backend.openModalIframe({\'width\':768,\'title\':\'%s\',\'url\':this.href});return false"',
|
||||
specialchars(sprintf($GLOBALS['TL_LANG']['tl_content']['editalias'][1], $dataContainer->value)),
|
||||
specialchars(
|
||||
str_replace(
|
||||
"'",
|
||||
"\\'",
|
||||
sprintf($GLOBALS['TL_LANG']['tl_content']['editalias'][1], $dataContainer->value)
|
||||
)
|
||||
)
|
||||
),
|
||||
\Image::getHtml(
|
||||
'alias.gif',
|
||||
$GLOBALS['TL_LANG']['tl_content']['editalias'][0], 'style="vertical-align:top"'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user