summaryrefslogtreecommitdiff
path: root/modules/comment/helpers
diff options
context:
space:
mode:
authorJozef Selesi <jozefs@users.sourceforge.net>2008-11-18 15:48:08 +0000
committerJozef Selesi <jozefs@users.sourceforge.net>2008-11-18 15:48:08 +0000
commitb63ea2cdbf995d4648bc3c4a5f4eb51ed8da3a8d (patch)
tree63515fed283da26948282acb635dd3186f203204 /modules/comment/helpers
parentd4fc15f76c383be2ac77679ad2fcaa11bba93c05 (diff)
- All comments of an item can now be seen /comments?item_id=
- Return proper Content-Type header for GET /comments requests - Got rid of the query processing for index() in REST_Controller() - Small misc fixes
Diffstat (limited to 'modules/comment/helpers')
-rw-r--r--modules/comment/helpers/comment.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/modules/comment/helpers/comment.php b/modules/comment/helpers/comment.php
index e474bf65..e9628a01 100644
--- a/modules/comment/helpers/comment.php
+++ b/modules/comment/helpers/comment.php
@@ -105,17 +105,25 @@ class Comment_Core {
return $block;
}
- static function get_comments($item, $output_format) {
- $comments = ORM::factory('comment')->where('item_id', $item->id)
+ // @todo Set proper Content-Type in a central place (REST_Controller::dispatch?).
+ static function get_comments($item_id, $output_format) {
+ $comments = ORM::factory('comment')->where('item_id', $item_id)
->orderby('datetime', 'asc')
->find_all();
+ if (!$comments->count()) {
+ header("HTTP/1.1 400 Bad Request");
+ return;
+ }
+
switch ($output_format) {
case "xml":
+ header("Content-Type: application/xml");
return xml::to_xml($comments, array("comments", "comment"));
break;
case "json":
+ header("Content-Type: application/json");
foreach ($comments as $comment) {
$data[] = $comment->as_array();
}