summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/gallery_rss.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-06-14 16:40:57 -0700
committerBharat Mediratta <bharat@menalto.com>2009-06-14 16:40:57 -0700
commit00fad54c0babfb0643c2ab9da98b4b74af84d466 (patch)
treea9f863c0139c2c2e5b7e4356e780f7aca37423c7 /modules/gallery/helpers/gallery_rss.php
parent47bc53eb5c328254d431caebf8acfd2636969bb4 (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.
Diffstat (limited to 'modules/gallery/helpers/gallery_rss.php')
-rw-r--r--modules/gallery/helpers/gallery_rss.php28
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;
}