diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-06-15 07:40:57 +0800 |
---|---|---|
committer | <unostar@danalan.info> | 2009-06-15 17:31:17 +0800 |
commit | 3b684655e2afcb6d24885c98a7821db4d6db4e07 (patch) | |
tree | 4ece424ef273b93cbb4ef75cc2ef63f5891057bb /modules/gallery/helpers | |
parent | 2ecb00c492c1312e7214c5bb1c2d256225cf2c73 (diff) |
Refactor feed code to use stdClass everywhere. Fix bugs in the
max-pages calculation code. Move feed related data into the $feed
variable and only pass that to the view.
Signed-off-by: <unostar@danalan.info>
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/gallery_rss.php | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php index 6535d29d..413d12a4 100644 --- a/modules/gallery/helpers/gallery_rss.php +++ b/modules/gallery/helpers/gallery_rss.php @@ -21,23 +21,27 @@ class gallery_rss_Core { static function available_feeds($item) { return array(array("description" => t("New photos or movies"), - "type" => "block", "uri" => "updates"), array("description" => t("Album feed"), - "type" => "head", "uri" => "albums")); } static function updates($offset, $limit) { - $feed["children"] = ORM::factory("item") + $feed->children = ORM::factory("item") ->viewable() ->where("type !=", "album") ->orderby("created", "DESC") ->find_all($limit, $offset); - $feed["max_pages"] = ceil($feed["children"]->count() / $limit); - $feed["title"] = t("Recent Updates"); - $feed["link"] = url::abs_site("albums/1"); - $feed["description"] = t("Recent Updates"); + + $all_children = ORM::factory("item") + ->viewable() + ->where("type !=", "album") + ->orderby("created", "DESC"); + + $feed->max_pages = ceil($all_children->find_all()->count() / $limit); + $feed->title = t("Recent Updates"); + $feed->link = url::abs_site("albums/1"); + $feed->description = t("Recent Updates"); return $feed; } @@ -46,13 +50,13 @@ class gallery_rss_Core { $item = ORM::factory("item", $id); access::required("view", $item); - $feed["children"] = $item + $feed->children = $item ->viewable() ->descendants($limit, $offset, "photo"); - $feed["max_pages"] = ceil($item->viewable()->descendants_count("photo") / $limit); - $feed["title"] = $item->title; - $feed["link"] = url::abs_site("albums/{$item->id}"); - $feed["description"] = $item->description; + $feed->max_pages = ceil($item->viewable()->descendants_count("photo") / $limit); + $feed->title = $item->title; + $feed->link = url::abs_site("albums/{$item->id}"); + $feed->description = $item->description; return $feed; } |