Add an wizard callback listener for the radius field.

Fix readme markup.

Add missing wizard class.
This commit is contained in:
David Molineus
2018-02-08 22:23:42 +01:00
parent be820179de
commit 617a996e0e
5 changed files with 107 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
<?php
/**
* Geocode backend widget based on Leaflet.
*
* @package netzmacht
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2016-2018 netzmacht David Molineus. All rights reserved.
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-geocode-widget/blob/master/LICENSE
* @filesource
*/
namespace Netzmacht\Contao\Leaflet\GeocodeWidget\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
/**
* Class LeafletGeocodeWidgetExtension
*/
class LeafletGeocodeWidgetExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$loader = new YamlFileLoader(
$container,
new FileLocator(dirname(__DIR__) . '/Resources/config')
);
$loader->load('listeners.yml');
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* Geocode backend widget based on Leaflet.
*
* @package netzmacht
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2016-2018 netzmacht David Molineus. All rights reserved.
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-geocode-widget/blob/master/LICENSE
* @filesource
*/
namespace Netzmacht\Contao\Leaflet\GeocodeWidget\EventListener;
use Contao\DataContainer;
/**
* Class RadiusWizardCallbackListener
*
* @package Netzmacht\Contao\Leaflet\GeocodeWidget\EventListener
*/
class RadiusWizardCallbackListener
{
/**
* Generate the wizard for the radius widget.
*
* @param DataContainer $dataContainer Data container driver.
*
* @return string
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
public function generateWizard($dataContainer)
{
if (!isset($GLOBALS['TL_DCA'][$dataContainer->table]['fields'][$dataContainer->field]['eval']['coordinates'])) {
return '';
}
return sprintf(
'<a href="#" onclick="$(\'ctrl_%s_toggle\').fireEvent(\'click\');return false;"><img src="%s"></a>',
$GLOBALS['TL_DCA'][$dataContainer->table]['fields'][$dataContainer->field]['eval']['coordinates'],
'bundles/leafletgeocodewidget/img/map.png'
);
}
}

View File

@@ -10,7 +10,6 @@
* @filesource
*/
namespace Netzmacht\Contao\Leaflet\GeocodeWidget;
use Netzmacht\Contao\Leaflet\GeocodeWidget\Widget\GeocodeWidget as BaseWidget;

View File

@@ -0,0 +1,3 @@
services:
netzmacht.contao_leaflet_geocode.listeners.radius_wizard:
class: Netzmacht\Contao\Leaflet\GeocodeWidget\EventListener\RadiusWizardCallbackListener