diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-02-12 04:53:26 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-02-12 04:53:26 -0800 |
commit | ce71ea6aa7eac72e54b1a9d7722c87beb61327de (patch) | |
tree | 408e96382d1cdf782ea6e2a0afbfd92770cfb9ad /modules/gallery/models | |
parent | 3439671bcfb99c1884285e4b4e53295f044e688f (diff) |
Revert "1) Add a depth parameter to retrieving an item thru the rest api"
This reverts commit 3439671bcfb99c1884285e4b4e53295f044e688f.
Diffstat (limited to 'modules/gallery/models')
-rw-r--r-- | modules/gallery/models/item.php | 41 |
1 files changed, 7 insertions, 34 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index a1be4fbc..dbd56fa2 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -918,49 +918,22 @@ class Item_Model extends ORM_MPTT { /** * Same as ORM::as_array() but convert id fields into their RESTful form. */ - public function as_restful_array($depth=0, $level=0) { + public function as_restful_array() { // Convert item ids to rest URLs for consistency - $data = array("url" => rest::url("item", $this), - "entity" => $this->as_array(), - "members" => array(), - "relationships" => array()); - + $data = $this->as_array(); if ($tmp = $this->parent()) { - $data["entity"]["parent"] = rest::url("item", $tmp); + $data["parent"] = rest::url("item", $tmp); } - unset($data["entity"]["parent_id"]); + unset($data["parent_id"]); if ($tmp = $this->album_cover()) { - $data["entity"]["album_cover"] = rest::url("item", $tmp); + $data["album_cover"] = rest::url("item", $tmp); } - unset($data["entity"]["album_cover_item_id"]); + unset($data["album_cover_item_id"]); // Elide some internal-only data that is going to cause confusion in the client. foreach (array("relative_path_cache", "relative_url_cache", "left_ptr", "right_ptr") as $key) { - unset($data["entity"][$key]); - } - - // check that we have given enough information. At this point we don't - // return relationships and we give enough information to determine how to handle - // the children. - $summarize = $depth < $level; - if (!$summarize) { - $data["relationships"] = rest::relationships("item", $this); - } - - $next_level = $level + 1; - foreach ($this->children() as $child) { - if ($summarize) { - $data["members"][] = array("url" => rest::url("item", $child), - "entity" => array("title" => $child->title, - "type" => $child->type), - "members" => array(), - "summary" => true, - "relationships" => array()); - } else { - $data["members"][] = $child->as_restful_array($depth, $next_level); - } + unset($data[$key]); } - $data["summary"] = $summarize; return $data; } } |