From 76b89556fc138dce694178fab9140a8242ea40ec Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 14 Jun 2009 12:09:47 -0700 Subject: Remove the sidebar flag from the feed definition returned by available_feeds and replace with a type field with one of two values (head and block). We need to do this to determine what fields go in the rss block so we can ignore the definitions that are related to the page head when creating the rss block that goes into the sidebar. --- modules/comment/helpers/comment_rss.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/comment/helpers/comment_rss.php') diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index b191c326..2e958eef 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -21,10 +21,10 @@ class comment_rss_Core { static function available_feeds($item) { return array(array("description" => t("All new comments"), - "sidebar" => true, + "type" => "block", "uri" => "comments"), array("description" => sprintf(t("Comments on %s"), $item->title), - "sidebar" => true, + "type" => "block", "uri" => "comments/{$item->id}")); } -- cgit v1.2.3 From 8b7f7a2fbe30c8e17f60177db7f371e1d1f2152c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 14 Jun 2009 12:38:57 -0700 Subject: Don't use stdClass to return the feed data. Just use an array. --- modules/comment/helpers/comment_rss.php | 15 +++++++-------- modules/gallery/helpers/gallery_rss.php | 22 ++++++++++------------ modules/rss/controllers/rss.php | 14 +++++++++----- modules/tag/helpers/tag_rss.php | 11 +++++------ 4 files changed, 31 insertions(+), 31 deletions(-) (limited to 'modules/comment/helpers/comment_rss.php') diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index 2e958eef..56de4284 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -29,7 +29,6 @@ class comment_rss_Core { } static function comments($offset, $limit, $id) { - $feed = new stdClass(); $orm = ORM::factory("comment") ->where("state", "published") ->orderby("created", "DESC"); @@ -37,12 +36,12 @@ class comment_rss_Core { $orm->where("item_id", $id); } - $feed->view = "comment.mrss"; + $feed["view"] = "comment.mrss"; $comments = $orm->find_all($limit, $offset); - $feed->data["children"] = array(); + $feed["children"] = array(); foreach ($comments as $comment) { $item = $comment->item(); - $feed->data["children"][] = array( + $feed["children"][] = array( "pub_date" => date("D, d M Y H:i:s T", $comment->created), "text" => htmlspecialchars($comment->text), "thumb_url" => $item->thumb_url(), @@ -55,10 +54,10 @@ class comment_rss_Core { ); } - $feed->max_pages = ceil($comments->count() / $limit); - $feed->data["title"] = htmlspecialchars(t("Recent Comments")); - $feed->data["link"] = url::abs_site("albums/" . (empty($id) ? "1" : $id)); - $feed->data["description"] = t("Recent Comments"); + $feed["max_pages"] = ceil($comments->count() / $limit); + $feed["title"] = htmlspecialchars(t("Recent Comments")); + $feed["link"] = url::abs_site("albums/" . (empty($id) ? "1" : $id)); + $feed["description"] = t("Recent Comments"); return $feed; } diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php index 455e210f..6535d29d 100644 --- a/modules/gallery/helpers/gallery_rss.php +++ b/modules/gallery/helpers/gallery_rss.php @@ -29,16 +29,15 @@ class gallery_rss_Core { } static function updates($offset, $limit) { - $feed = new stdClass(); - $feed->data["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->data["children"]->count() / $limit); - $feed->data["title"] = t("Recent Updates"); - $feed->data["link"] = url::abs_site("albums/1"); - $feed->data["description"] = t("Recent Updates"); + $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"); return $feed; } @@ -47,14 +46,13 @@ class gallery_rss_Core { $item = ORM::factory("item", $id); access::required("view", $item); - $feed = new stdClass(); - $feed->data["children"] = $item + $feed["children"] = $item ->viewable() ->descendants($limit, $offset, "photo"); - $feed->max_pages = ceil($item->viewable()->descendants_count("photo") / $limit); - $feed->data["title"] = $item->title; - $feed->data["link"] = url::abs_site("albums/{$item->id}"); - $feed->data["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; } diff --git a/modules/rss/controllers/rss.php b/modules/rss/controllers/rss.php index 8c3544e4..80803dfd 100644 --- a/modules/rss/controllers/rss.php +++ b/modules/rss/controllers/rss.php @@ -28,12 +28,16 @@ class Rss_Controller extends Controller { } $feed = rss::feed_data($method, ($page - 1) * self::$page_size, self::$page_size, $id); - if ($feed->max_pages && $page > $feed->max_pages) { - url::redirect("$feed_uri?page={$feed->max_pages}"); + $max_pages = $feed["max_pages"]; + if ($max_pages && $page > $max_pages) { + url::redirect("$feed_uri?page={$max_pages}"); } + unset($feed["max_pages"]); - $view = new View(empty($feed->view) ? "feed.mrss" : $feed->view); - foreach ($feed->data as $field => $value) { + $view = new View(empty($feed["view"]) ? "feed.mrss" : $feed["view"]); + unset($feed["view"]); + + foreach ($feed as $field => $value) { $view->$field = $value; } $view->feed_link = url::abs_site($feed_uri); @@ -43,7 +47,7 @@ class Rss_Controller extends Controller { $view->previous_page_link = url::site("$feed_uri?page={$previous_page}"); } - if ($page < $feed->max_pages) { + if ($page < $max_pages) { $next_page = $page + 1; $view->next_page_link = url::site("$feed_uri?page={$next_page}"); } diff --git a/modules/tag/helpers/tag_rss.php b/modules/tag/helpers/tag_rss.php index 7846edf6..3d6399ca 100644 --- a/modules/tag/helpers/tag_rss.php +++ b/modules/tag/helpers/tag_rss.php @@ -31,12 +31,11 @@ class tag_rss_Core { return Kohana::show_404(); } - $feed = new stdClass(); - $feed->data["children"] = $tag->items($limit, $offset, "photo"); - $feed->max_pages = ceil($tag->count / $limit); - $feed->data["title"] = $tag->name; - $feed->data["link"] = url::abs_site("tags/{$tag->id}"); - $feed->data["description"] = t("Photos related to %tag_name", array("tag_name" => $tag->name)); + $feed["children"] = $tag->items($limit, $offset, "photo"); + $feed["max_pages"] = ceil($tag->count / $limit); + $feed["title"] = $tag->name; + $feed["link"] = url::abs_site("tags/{$tag->id}"); + $feed["description"] = t("Photos related to %tag_name", array("tag_name" => $tag->name)); return $feed; } -- cgit v1.2.3