diff options
author | Jozef Selesi <jozefs@users.sourceforge.net> | 2008-11-18 15:48:08 +0000 |
---|---|---|
committer | Jozef Selesi <jozefs@users.sourceforge.net> | 2008-11-18 15:48:08 +0000 |
commit | b63ea2cdbf995d4648bc3c4a5f4eb51ed8da3a8d (patch) | |
tree | 63515fed283da26948282acb635dd3186f203204 /modules/comment/controllers/comments.php | |
parent | d4fc15f76c383be2ac77679ad2fcaa11bba93c05 (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/controllers/comments.php')
-rw-r--r-- | modules/comment/controllers/comments.php | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/modules/comment/controllers/comments.php b/modules/comment/controllers/comments.php index b51e7e4e..34557a83 100644 --- a/modules/comment/controllers/comments.php +++ b/modules/comment/controllers/comments.php @@ -22,10 +22,17 @@ class Comments_Controller extends REST_Controller { /** * Display comments based on criteria. - * @see Rest_Controller::_delete($resource) + * @see Rest_Controller::_index() */ - public function _index($query) { - throw new Exception("@todo Comment_Controller::_index NOT IMPLEMENTED"); + public function _index() { + $item_id = $this->input->get('item_id'); + + if (empty($item_id)) { + /* We currently do not support getting all comments from the entire gallery. */ + header("HTTP/1.1 400 Bad Request"); + return; + } + print comment::get_comments($item_id, $this->get_output_format()); } /** @@ -51,15 +58,18 @@ class Comments_Controller extends REST_Controller { /** * Display an existing comment. - * @see Rest_Controller::_show($resource, $format) + * @todo Set proper Content-Type in a central place (REST_Controller::dispatch?). + * @see Rest_Controller::_show($resource, $output_format) */ public function _show($comment, $output_format) { switch ($output_format) { case "xml": + header("Content-Type: application/xml"); print xml::to_xml($comment->as_array(), array("comment")); break; case "json": + header("Content-Type: application/json"); print json_encode($comment->as_array()); break; |