Fix code style.

This commit is contained in:
David Molineus
2015-01-12 19:03:29 +01:00
parent 74c786c24b
commit 037c6c907d
77 changed files with 1068 additions and 398 deletions

View File

@@ -11,13 +11,18 @@
namespace Netzmacht\Contao\Leaflet\Model;
/**
* Class AbstractActiveModel is the base model for models with an active field.
*
* @package Netzmacht\Contao\Leaflet\Model
*/
abstract class AbstractActiveModel extends \Model
{
/**
* Find an active model by its model id.
*
* @param int $modelId
* @param array $options
* @param int $modelId The model id.
* @param array $options The query options.
*
* @return \Model|null
*/
@@ -27,18 +32,33 @@ abstract class AbstractActiveModel extends \Model
}
/**
* Find active models by a defined column.
*
* @param int $value
* @param array $options
* @param string|array $column The query columns.
* @param mixed $value The column value.
* @param array $options The options.
*
* @return \Model|null
*/
public static function findActiveBy($column, $value, $options = array())
{
return static::findBy('active=1 AND ' . $column, $value, $options);
if (is_array($column)) {
$column[] = 'active=1';
} else {
$column = 'active=1 AND ' . $column;
}
return static::findBy($column, $value, $options);
}
public static function findActivated($options = array())
/**
* Find collection activated models.
*
* @param array $options The query options.
*
* @return \Model\Collection|null
*/
public static function findActives($options = array())
{
return static::findBy('active', '1', $options);
}

View File

@@ -11,33 +11,70 @@
namespace Netzmacht\Contao\Leaflet\Model;
use Model\Collection;
/**
* Class ControlModel for the tl_leaflet_vector table.
*
* @package Netzmacht\Contao\Leaflet\Model
*/
class ControlModel extends AbstractActiveModel
{
/**
* Model table.
*
* @var string
*/
protected static $strTable = 'tl_leaflet_control';
/**
* @return \Model\Collection
* Find all related layers.
*
* @return Collection|null
*/
public function findLayers()
{
$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=?';
$query = <<<SQL
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=?
SQL;
$result = \Database::getInstance()
->prepare($query)
->execute($this->id);
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
if ($result->numRows < 1) {
return null;
}
return Collection::createFromDbResult($result, 'tl_leaflet_layer');
}
/**
* @return \Model\Collection
* Find active layers.
*
* @return Collection|null
*/
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';
$query = <<<SQL
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
SQL;
$result = \Database::getInstance()
->prepare($query)
->execute($this->id);
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
if ($result->numRows < 1) {
return null;
}
return Collection::createFromDbResult($result, 'tl_leaflet_layer');
}
}

View File

@@ -11,8 +11,9 @@
namespace Netzmacht\Contao\Leaflet\Model;
/**
* IconModel class for the tl_leaflet_icon table.
*
* @property mixed|null iconImage
* @property mixed|null iconAnchor
* @property mixed|null popupAnchor
@@ -23,5 +24,10 @@ namespace Netzmacht\Contao\Leaflet\Model;
*/
class IconModel extends AbstractActiveModel
{
/**
* Model table.
*
* @var string
*/
protected static $strTable = 'tl_leaflet_icon';
}

View File

@@ -11,11 +11,30 @@
namespace Netzmacht\Contao\Leaflet\Model;
use Model\Collection;
/**
* Class LayerModel for the tl_leaflet_layer table.
*
* @package Netzmacht\Contao\Leaflet\Model
*/
class LayerModel extends AbstractActiveModel
{
/**
* Model table.
*
* @var string
*/
protected static $strTable = 'tl_leaflet_layer';
/**
* Find multiple layers by given type.
*
* @param array $types List of layer types.
* @param array $options Query options.
*
* @return Collection|null
*/
public static function findMultipleByTypes(array $types, $options = array())
{
if (empty($types)) {
@@ -29,7 +48,8 @@ class LayerModel extends AbstractActiveModel
)
);
$options['value'] = $types;
$options['value'] = $types;
$options['return'] = 'Collection';
return static::find($options);
}

View File

@@ -11,13 +11,26 @@
namespace Netzmacht\Contao\Leaflet\Model;
use Model\Collection;
/**
* Class MapModel for the tl_leaflet_map table.
*
* @package Netzmacht\Contao\Leaflet\Model
*/
class MapModel extends \Model
{
/**
* Model table.
*
* @var string
*/
protected static $strTable = 'tl_leaflet_map';
/**
* @return \Model\Collection
* Find all related layers.
*
* @return Collection|null
*/
public function findLayers()
{
@@ -26,19 +39,34 @@ class MapModel extends \Model
->prepare($query)
->execute($this->id);
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
if ($result->numRows < 1) {
return null;
}
return Collection::createFromDbResult($result, 'tl_leaflet_layer');
}
/**
* @return \Model\Collection
* Find all active layers.
*
* @return Collection|null
*/
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);
$query = <<<SQL
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
SQL;
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
$result = \Database::getInstance()->prepare($query)->execute($this->id);
if ($result->numRows) {
return Collection::createFromDbResult($result, 'tl_leaflet_layer');
}
return null;
}
}

View File

@@ -11,9 +11,17 @@
namespace Netzmacht\Contao\Leaflet\Model;
/**
* Class MarkerModel for the tl_leaflet_marker table.
*
* @package Netzmacht\Contao\Leaflet\Model
*/
class MarkerModel extends AbstractActiveModel
{
/**
* Model table.
*
* @var string
*/
protected static $strTable = 'tl_leaflet_marker';
}

View File

@@ -11,8 +11,17 @@
namespace Netzmacht\Contao\Leaflet\Model;
/**
* Class StyleModel for the tl_leaflet_style table.
*
* @package Netzmacht\Contao\Leaflet\Model
*/
class StyleModel extends AbstractActiveModel
{
/**
* Model table.
*
* @var string
*/
protected static $strTable = 'tl_leaflet_style';
}

View File

@@ -11,7 +11,11 @@
namespace Netzmacht\Contao\Leaflet\Model;
/**
* Class VectorModel for the tl_leaflet_vector table.
*
* @package Netzmacht\Contao\Leaflet\Model
*/
class VectorModel extends AbstractActiveModel
{
/**