Fix handling of inactive layers.

This commit is contained in:
David Molineus
2015-01-09 23:48:25 +01:00
parent 2201c5015e
commit 1ebd3ef49b
4 changed files with 28 additions and 2 deletions

View File

@@ -47,7 +47,7 @@ class LayersControlMapper extends AbstractControlMapper
$arguments[2] = array();
/** @var ControlModel $model */
$collection = $model->findLayers();
$collection = $model->findActiveLayers();
if ($collection) {
foreach ($collection as $layer) {

View File

@@ -127,7 +127,7 @@ class MapMapper extends AbstractMapper
*/
private function buildLayers(Map $map, MapModel $model, DefinitionMapper $mapper, LatLngBounds $bounds = null)
{
$collection = $model->findLayers();
$collection = $model->findActiveLayers();
if ($collection) {
foreach ($collection as $layer) {

View File

@@ -27,4 +27,17 @@ class ControlModel extends AbstractActiveModel
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
}
/**
* @return \Model\Collection
*/
public function findActiveLayers()
{
$query = 'SELECT l.*, c.mode as controlMode FROM tl_leaflet_layer l LEFT JOIN tl_leaflet_control_layer c ON l.id = c.lid WHERE c.cid=? AND l.active=1';
$result = \Database::getInstance()
->prepare($query)
->execute($this->id);
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
}
}

View File

@@ -28,4 +28,17 @@ class MapModel extends \Model
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
}
/**
* @return \Model\Collection
*/
public function findActiveLayers()
{
$query = 'SELECT l.* FROM tl_leaflet_layer l LEFT JOIN tl_leaflet_map_layer m ON l.id = m.lid WHERE m.mid=? AND l.active=1';
$result = \Database::getInstance()
->prepare($query)
->execute($this->id);
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
}
}