diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2010-04-16 15:28:35 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2010-04-16 15:28:35 -0700 |
commit | 027312596c29c1986d3480c7dda48533e6dd3ca8 (patch) | |
tree | 3df364364de585e6d91ec3f31b1461a7ef19ab93 | |
parent | 009b47262b9b81dc996459119af822e2e7306255 (diff) |
Don't show the member element for non-collection elements in the response. Having a members sidebar element indicates to the rest clients that this is a resource collection.
-rw-r--r-- | modules/gallery/helpers/items_rest.php | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 48839dc9..37ebb088 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -24,19 +24,20 @@ class items_rest_Core { $items = array(); if (isset($request->params->url)) { - foreach ($request->params->url as $url) { + foreach (json_decode($request->params->url) as $url) { $item = rest::resolve($url); if (access::can("view", $item)) { - $members = array(); + $item_rest = array("url" => $url, + "entity" => $item->as_restful_array(), + "relationship" => rest::relationships("item", $item)); if ($item->type == "album") { + $members = array(); foreach ($item->children() as $child) { $members[] = rest::url("item", $child); } + $item_rest["members"] = $members; } - $items[] = array("url" => $url, - "entity" => $item->as_restful_array(), - "members" => $members, - "relationship" => rest::relationships("item", $item)); + $items[] = $item_rest; } } } |