From 423222ecf8b80d6cc7b1991701b643b3cf7a25bc Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sun, 25 Jul 2010 23:15:16 +0200 Subject: [PATCH] added new plain text view (format=txt) --- backend/lib/Dispatcher.php | 11 ++++-- backend/lib/View/PlainText.php | 69 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 backend/lib/View/PlainText.php diff --git a/backend/lib/Dispatcher.php b/backend/lib/Dispatcher.php index 3e4649e..4dd977d 100644 --- a/backend/lib/Dispatcher.php +++ b/backend/lib/Dispatcher.php @@ -87,9 +87,11 @@ class Dispatcher { $this->em = Dispatcher::createEntityManager(); // starting debugging - if (($debug = $request->getParameter('debug')) && (int) $debug > 0) { - $this->debug = new Util\Debug($request->getParameter('debug')); - $this->em->getConnection()->getConfiguration()->setSQLLogger($this->debug); + if (($debug = $request->getParameter('debug')) !== FALSE || $debug = Util\Configuration::read('debug')) { + if ($debug > 0) { + $this->debug = new Util\Debug($debug); + $this->em->getConnection()->getConfiguration()->setSQLLogger($this->debug); + } } // TODO debug controll via configuration file @@ -110,7 +112,10 @@ class Dispatcher { } $this->view = new $viewClassName($request, $response); + break; + case 'txt': + $this->view = new View\PlainText($request, $response); break; default: diff --git a/backend/lib/View/PlainText.php b/backend/lib/View/PlainText.php new file mode 100644 index 0000000..e67386d --- /dev/null +++ b/backend/lib/View/PlainText.php @@ -0,0 +1,69 @@ +. + */ + +namespace Volkszaehler\View; + +use Volkszaehler\View\HTTP; +use Volkszaehler\Util; +use Volkszaehler\Model; + +/** + * Plain Text view + * + * @author Steffen Vogel + * @package default + */ +class PlainText extends View { + /** + * constructor + */ + public function __construct(HTTP\Request $request, HTTP\Response $response) { + parent::__construct($request, $response); + + echo 'source: volkszaehler.org' . PHP_EOL; + echo 'version: ' . \Volkszaehler\VERSION . PHP_EOL; + + $this->response->setHeader('Content-type', 'text/plain'); + } + + public function addChannel(Model\Channel $channel, array $data = NULL) { + var_dump($channel); + var_dump($data); + } + + public function addGroup(Model\Group $group) { + var_dump($group); + } + + public function addDebug(Util\Debug $debug) { + var_dump($debug); + } + + protected function addException(\Exception $exception) { + var_dump($exception); + } + + public function renderResponse() {} +} + +?> \ No newline at end of file