Move Contao integration into a separate file.

This commit is contained in:
David Molineus
2015-01-20 09:39:15 +01:00
parent e83e2c5482
commit f71376a628
2 changed files with 35 additions and 43 deletions

View File

@@ -1,20 +0,0 @@
<?php
/**
* @package dev
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014 netzmacht creative David Molineus
* @license LGPL 3.0
* @filesource
*
*/
use Netzmacht\Contao\Leaflet\Frontend\DataController;
define('TL_MODE', 'FE');
require(dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])))) . '/system/initialize.php');
$container = $GLOBALS['container'];
$controller = new DataController($container['leaflet.map.service'], $container['input']);
$controller->execute();

View File

@@ -1,4 +1,9 @@
L.contao = new (L.Class.extend({ /**
* Leaflet integration into contao.
*
* This class provides some helpers for loading layer data manages maps and map objects.
*/
L.Contao = L.Class.extend({
includes: L.Mixin.Events, includes: L.Mixin.Events,
/** /**
@@ -124,6 +129,7 @@ L.contao = new (L.Class.extend({
map.fire('dataloading', {layer: layer}); map.fire('dataloading', {layer: layer});
layer.on('ready', function () { layer.on('ready', function () {
map.calculateFeatureBounds(layer);
map.fire('dataload', {layer: layer}); map.fire('dataload', {layer: layer});
}); });
@@ -148,6 +154,8 @@ L.contao = new (L.Class.extend({
var marker = null; var marker = null;
if (feature.properties) { if (feature.properties) {
feature.properties.bounds = true;
if (feature.properties.type) { if (feature.properties.type) {
type = feature.properties.type; type = feature.properties.type;
} }
@@ -242,7 +250,9 @@ L.contao = new (L.Class.extend({
if (params == '') { if (params == '') {
return document.location.pathname + '?' + [key, value].join('='); return document.location.pathname + '?' + [key, value].join('=');
} else { } else {
var i = params.length; var x; while (i--) { var i = params.length;
var x;
while (i--) {
x = params[i].split('='); x = params[i].split('=');
if (x[0] == key) { if (x[0] == key) {
@@ -259,4 +269,6 @@ L.contao = new (L.Class.extend({
return document.location.pathname + params.join('&'); return document.location.pathname + params.join('&');
} }
} }
}))(); });
L.contao = new L.Contao();