mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-30 12:03:44 +01:00
80 lines
2.5 KiB
PHP
80 lines
2.5 KiB
PHP
<?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
|
|
{
|
|
private $layers;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->layers = &$GLOBALS['LEAFLET_LAYERS'];
|
|
}
|
|
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();
|
|
}
|
|
|
|
// Call paste_button_callback (&$dc, $row, $table, $cr, $childs, $previous, $next)
|
|
public function getPasteButtons($dataContainer, $row, $table, $whatever, $children)
|
|
{
|
|
$pasteAfterUrl = \Controller::addToUrl(
|
|
'act='.$children['mode'].'&mode=1&pid='.$row['id']
|
|
.(!is_array($children['id']) ? '&id='.$children['id'] : '')
|
|
);
|
|
|
|
$buffer = sprintf(
|
|
'<a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a> ',
|
|
$pasteAfterUrl,
|
|
specialchars(sprintf($GLOBALS['TL_LANG'][$table]['pasteafter'][1], $row['id'])),
|
|
\Image::getHtml(
|
|
'pasteafter.gif',
|
|
sprintf($GLOBALS['TL_LANG'][$table]['pasteafter'][1], $row['id'])
|
|
)
|
|
);
|
|
|
|
if (!empty($this->layers[$row['type']]['children'])) {
|
|
$pasteIntoUrl = \Controller::addToUrl(
|
|
sprintf(
|
|
'act=%s&mode=2&pid=%s%s',
|
|
$children['mode'],
|
|
$row['id'],
|
|
!is_array($children['id']) ? '&id='.$children['id'] : ''
|
|
)
|
|
);
|
|
|
|
$buffer .= sprintf(
|
|
'<a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a> ',
|
|
$pasteIntoUrl,
|
|
specialchars(sprintf($GLOBALS['TL_LANG'][$table]['pasteinto'][1], $row['id'])),
|
|
\Image::getHtml(
|
|
'pasteinto.gif',
|
|
sprintf($GLOBALS['TL_LANG'][$table]['pasteinto'][1], $row['id'])
|
|
)
|
|
);
|
|
|
|
} elseif ($row['id'] > 0) {
|
|
$buffer .= \Image::getHtml('pasteinto_.gif');
|
|
}
|
|
|
|
return $buffer;
|
|
}
|
|
}
|