2010-06-06 16:05:46 +02:00
|
|
|
<?php
|
2010-07-21 12:44:01 +02:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2010, The volkszaehler.org project
|
2010-07-22 18:37:14 +02:00
|
|
|
* @package default
|
2010-07-21 12:44:01 +02:00
|
|
|
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
|
2010-07-22 16:21:26 +02:00
|
|
|
*/
|
|
|
|
/*
|
2010-07-21 12:44:01 +02:00
|
|
|
* This file is part of volkzaehler.org
|
2010-06-06 16:05:46 +02:00
|
|
|
*
|
2010-07-21 12:44:01 +02:00
|
|
|
* volkzaehler.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* volkzaehler.org is distributed in the hope that it will be useful,
|
2010-06-06 16:05:46 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2010-07-21 12:44:01 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-06-06 16:05:46 +02:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2010-07-21 12:44:01 +02:00
|
|
|
* along with volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
|
2010-06-06 16:05:46 +02:00
|
|
|
*/
|
|
|
|
|
2010-07-18 17:12:00 +02:00
|
|
|
namespace Volkszaehler\Controller;
|
|
|
|
|
|
|
|
use \Volkszaehler\Model;
|
|
|
|
|
2010-07-21 12:44:01 +02:00
|
|
|
/**
|
|
|
|
* channel controller
|
|
|
|
*
|
2010-07-22 11:13:11 +02:00
|
|
|
* @author Steffen Vogel <info@steffenvogel.de>
|
2010-07-22 18:37:14 +02:00
|
|
|
* @package default
|
2010-07-21 12:44:01 +02:00
|
|
|
*/
|
2010-07-22 16:10:08 +02:00
|
|
|
class ChannelController extends Controller {
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-24 13:03:34 +02:00
|
|
|
/**
|
|
|
|
* get channels by filter
|
|
|
|
*
|
|
|
|
* @todo authentification/indentification
|
|
|
|
*/
|
2010-06-07 21:48:49 +02:00
|
|
|
public function get() {
|
2010-07-20 00:32:52 +02:00
|
|
|
$dql = 'SELECT c FROM Volkszaehler\Model\Channel c';
|
2010-07-19 18:55:18 +02:00
|
|
|
|
2010-07-24 13:03:34 +02:00
|
|
|
if ($uuid = $this->view->request->getParameter('uuid')) {
|
2010-07-20 00:32:52 +02:00
|
|
|
// TODO add conditions
|
2010-07-19 18:55:18 +02:00
|
|
|
}
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-24 13:03:34 +02:00
|
|
|
if ($ugid = $this->view->request->getParameter('ugid')) {
|
2010-07-20 00:32:52 +02:00
|
|
|
// TODO add conditions
|
2010-07-19 18:55:18 +02:00
|
|
|
}
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-24 13:03:34 +02:00
|
|
|
if ($indicator = $this->view->request->getParameter('indicator')) {
|
2010-07-20 00:32:52 +02:00
|
|
|
// TODO add conditions
|
2010-07-19 18:55:18 +02:00
|
|
|
}
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-19 18:55:18 +02:00
|
|
|
$q = $this->em->createQuery($dql);
|
|
|
|
$channels = $q->getResult();
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-06-08 15:39:31 +02:00
|
|
|
foreach ($channels as $channel) {
|
2010-07-24 13:03:34 +02:00
|
|
|
$this->view->addChannel($channel);
|
2010-06-08 15:39:31 +02:00
|
|
|
}
|
2010-06-06 16:05:46 +02:00
|
|
|
}
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-21 12:44:01 +02:00
|
|
|
/**
|
|
|
|
* add channel
|
2010-07-22 11:13:11 +02:00
|
|
|
*
|
2010-07-21 12:44:01 +02:00
|
|
|
* @todo validate input and throw exceptions
|
|
|
|
*/
|
2010-06-08 15:39:31 +02:00
|
|
|
public function add() {
|
2010-07-24 13:03:34 +02:00
|
|
|
$channel = new Model\Channel($this->view->request->getParameter('indicator'));
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-18 17:12:00 +02:00
|
|
|
$channel->setName($this->view->request->getParameter('name'));
|
|
|
|
$channel->setDescription($this->view->request->getParameter('description'));
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-19 18:55:18 +02:00
|
|
|
$channel->setResolution($this->view->request->getParameter('resolution'));
|
2010-07-18 17:12:00 +02:00
|
|
|
$channel->setCost($this->view->request->getParameter('cost'));
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-18 17:12:00 +02:00
|
|
|
$this->em->persist($channel);
|
|
|
|
$this->em->flush();
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-24 13:03:34 +02:00
|
|
|
$this->view->addChannel($channel);
|
2010-06-08 15:39:31 +02:00
|
|
|
}
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-21 12:44:01 +02:00
|
|
|
/**
|
|
|
|
* delete channel
|
2010-07-22 11:13:11 +02:00
|
|
|
*
|
2010-07-21 12:44:01 +02:00
|
|
|
* @todo authentification/indentification
|
|
|
|
*/
|
2010-07-09 23:50:20 +02:00
|
|
|
public function delete() {
|
2010-07-18 17:12:00 +02:00
|
|
|
$ucid = $this->view->request->getParameter('ucid');
|
2010-07-24 13:03:34 +02:00
|
|
|
$channel = $this->em->getRepository('Volkszaehler\Model\Channel')->findOneBy(array('uuid' => $ucid));
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-18 17:12:00 +02:00
|
|
|
$this->em->remove($channel);
|
|
|
|
$this->em->flush();
|
2010-06-08 15:39:31 +02:00
|
|
|
}
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-21 12:44:01 +02:00
|
|
|
/**
|
|
|
|
* edit channel properties
|
2010-07-22 11:13:11 +02:00
|
|
|
*
|
2010-07-21 12:44:01 +02:00
|
|
|
* @todo authentification/indentification
|
|
|
|
* @todo to be implemented
|
|
|
|
*/
|
2010-07-09 23:50:20 +02:00
|
|
|
public function edit() {
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-09 23:50:20 +02:00
|
|
|
}
|
2010-06-06 16:05:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|