mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-06-09 21:19:11 -04:00
- 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
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user