Ongoing development.

This commit is contained in:
David Molineus
2015-01-06 14:55:53 +01:00
parent dfb558b655
commit e9d1ec7081
32 changed files with 1050 additions and 95 deletions

View File

@@ -12,6 +12,9 @@
namespace Netzmacht\Contao\Leaflet\Dca;
use Netzmacht\Contao\DevTools\Dca\Options\OptionsBuilder;
use Netzmacht\Contao\Leaflet\Model\LayerModel;
class Layer
{
private $layers;
@@ -19,7 +22,10 @@ class Layer
public function __construct()
{
$this->layers = &$GLOBALS['LEAFLET_LAYERS'];
\Controller::loadLanguageFile('leaflet_layer');
}
public function getVariants($dataContainer)
{
if ($dataContainer->activeRecord
@@ -32,6 +38,48 @@ class Layer
return array();
}
public function generateRow($row, $label)
{
$alt = empty($GLOBALS['TL_LANG']['leaflet_layer'][$row['type']][0])
? $row['type']
: $GLOBALS['TL_LANG']['leaflet_layer'][$row['type']][0];
$title = empty($GLOBALS['TL_LANG']['leaflet_layer'][$row['type']][1])
? $row['type']
: $GLOBALS['TL_LANG']['leaflet_layer'][$row['type']][1];
if (!empty($this->layers[$row['type']]['icon'])) {
$icon = \Image::getHtml($this->layers[$row['type']]['icon'], $alt, sprintf('title="%s"', $title));
} else {
$icon = \Image::getHtml('iconPLAIN.gif', $alt, sprintf('title="%s"', $title));
}
return $icon . ' ' . $label;
}
public function getMarkerClusterLayers()
{
$types = array_keys(
array_filter(
$GLOBALS['LEAFLET_LAYERS'],
function ($item) {
return !empty($item['markerCluster']);
}
)
);
$collection = LayerModel::findMultipleByTypes($types);
$builder = OptionsBuilder::fromCollection(
$collection,
'id',
function($row) {
return sprintf('%s [%s]', $row['title'], $row['type']);
}
);
return $builder->getOptions();
}
// Call paste_button_callback (&$dc, $row, $table, $cr, $childs, $previous, $next)
public function getPasteButtons($dataContainer, $row, $table, $whatever, $children)
{
@@ -76,4 +124,18 @@ class Layer
return $buffer;
}
public function generateMarkersButton($row, $href, $label, $title, $icon, $attributes)
{
if (empty($this->layers[$row['type']]['markers'])) {
return '';
}
return sprintf(
'<a href="%s" title="%s">%s</a> ',
\Backend::addToUrl($href . '&amp;id=' . $row['id']),
$title,
\Image::getHtml($icon, $label, $attributes)
);
}
}