From d0fe72e41e18a93c0dd288e14c27f1fe538cb393 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 20 Jul 2010 12:06:04 +0200 Subject: [PATCH] fixed some hidden bugs in our view components --- backend/lib/View/Csv/Csv.php | 6 +++--- backend/lib/View/JpGraph.php | 2 +- backend/lib/View/Json/Json.php | 6 +++--- backend/lib/View/Xml/Channel.php | 6 ++++++ backend/lib/View/Xml/Group.php | 7 +++++++ backend/lib/View/Xml/Xml.php | 8 +++----- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/backend/lib/View/Csv/Csv.php b/backend/lib/View/Csv/Csv.php index bc9365b..d10b7e3 100644 --- a/backend/lib/View/Csv/Csv.php +++ b/backend/lib/View/Csv/Csv.php @@ -21,7 +21,7 @@ namespace Volkszaehler\View\Csv; -class Csv extends \Volkszaehler\View\View { +abstract class Csv extends \Volkszaehler\View\View { protected $csv = array(); protected $header = array(); protected $footer = array(); @@ -40,8 +40,6 @@ class Csv extends \Volkszaehler\View\View { } public function render() { - parent::render(); - foreach ($this->header as $line) { echo $line . PHP_EOL; } @@ -57,6 +55,8 @@ class Csv extends \Volkszaehler\View\View { foreach ($this->footer as $line) { echo $line . PHP_EOL; } + + parent::render(); } public function addDebug() { diff --git a/backend/lib/View/JpGraph.php b/backend/lib/View/JpGraph.php index 8cbceb0..37db0bf 100644 --- a/backend/lib/View/JpGraph.php +++ b/backend/lib/View/JpGraph.php @@ -115,7 +115,7 @@ class JpGraph extends View { // Display the graph $this->graph->Stroke(); - $this->response->send(); + parent::render(); } } diff --git a/backend/lib/View/Json/Json.php b/backend/lib/View/Json/Json.php index 70d2ec0..25e1163 100644 --- a/backend/lib/View/Json/Json.php +++ b/backend/lib/View/Json/Json.php @@ -23,7 +23,7 @@ namespace Volkszaehler\View\Json; use Volkszaehler\Util; -class Json extends \Volkszaehler\View\View { +abstract class Json extends \Volkszaehler\View\View { protected $json = array(); /* @@ -39,9 +39,9 @@ class Json extends \Volkszaehler\View\View { } public function render() { - parent::render(); - echo self::format(json_encode($this->json)); + + parent::render(); } protected static function format($json) { diff --git a/backend/lib/View/Xml/Channel.php b/backend/lib/View/Xml/Channel.php index 07ca5f3..d78b2fb 100644 --- a/backend/lib/View/Xml/Channel.php +++ b/backend/lib/View/Xml/Channel.php @@ -58,4 +58,10 @@ class Channel extends Xml { $this->xml->appendChild($xmlChannel); } + + public function render() { + $this->xmlRoot->appendChild($this->xml); + + parent::render(); + } } \ No newline at end of file diff --git a/backend/lib/View/Xml/Group.php b/backend/lib/View/Xml/Group.php index 6eb5ead..ed62b06 100644 --- a/backend/lib/View/Xml/Group.php +++ b/backend/lib/View/Xml/Group.php @@ -22,6 +22,7 @@ namespace Volkszaehler\View\Xml; class Group extends Xml { + protected $xml; public function __construct(\Volkszaehler\View\Http\Request $request, \Volkszaehler\View\Http\Response $response) { parent::__construct($request, $response); @@ -39,4 +40,10 @@ class Group extends Xml { $this->xml->appendChild($xmlGroup); } + + public function render() { + $this->xmlRoot->appendChild($this->xml); + + parent::render(); + } } \ No newline at end of file diff --git a/backend/lib/View/Xml/Xml.php b/backend/lib/View/Xml/Xml.php index e19e505..d403c28 100644 --- a/backend/lib/View/Xml/Xml.php +++ b/backend/lib/View/Xml/Xml.php @@ -22,9 +22,8 @@ namespace Volkszaehler\View\Xml; // TODO outdated -class Xml extends \Volkszaehler\View\View { +abstract class Xml extends \Volkszaehler\View\View { protected $xmlDoc; - protected $xml; public function __construct(\Volkszaehler\View\Http\Request $request, \Volkszaehler\View\Http\Response $response) { parent::__construct($request, $response); @@ -40,11 +39,10 @@ class Xml extends \Volkszaehler\View\View { } public function render() { - parent::render(); - $this->xmlDoc->appendChild($this->xmlRoot); - $this->xmlRoot->appendChild($this->xml); echo $this->xmlDoc->saveXML(); + + parent::render(); } public function addException(\Exception $exception) {