diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-06-14 21:51:54 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-06-14 21:51:54 -0700 |
commit | 32ea4406c87049b25d3d82351097e69f13168311 (patch) | |
tree | 43c12a5dcf25b3414772b0bfe88fca27318a7ed9 /modules/tag/helpers | |
parent | 00fad54c0babfb0643c2ab9da98b4b74af84d466 (diff) |
Refactor the way that the rss module works so that we're not allowing
the url to dictate arbitrary static method calls.
* Each xxx_rss helper has a single feed() call which takes an id as the argument
* xxx_rss::available_feedS() only returns feeds when they're applicable (ie
if you're viewing a tag, it won't show you an item feed).
* Feed urls are now in the module/feed_id form so that we can bind a
feed id to a given module
* Tightened up the Rss_Controller by using url::merge and some other tricks.
* Made the slideshow module express its own feed.
Diffstat (limited to 'modules/tag/helpers')
-rw-r--r-- | modules/tag/helpers/tag_rss.php | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/modules/tag/helpers/tag_rss.php b/modules/tag/helpers/tag_rss.php index dbef3914..f94508cf 100644 --- a/modules/tag/helpers/tag_rss.php +++ b/modules/tag/helpers/tag_rss.php @@ -19,23 +19,28 @@ */ class tag_rss_Core { - static function available_feeds($item) { - return array(array("description" => t("Tag Album feed"), - "uri" => "tags")); - } - - static function tags($offset, $limit, $id) { - $tag = ORM::factory("tag", $id); - if (!$tag->loaded) { - return Kohana::show_404(); + static function available_feeds($item, $tag) { + if ($tag) { + $feeds["tag/tag/{$tag->id}"] = + t("Tag feed for %tag_name", array("tag_name" => p::clean($tag->name))); + return $feeds; } + return array(); + } - $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)); + static function feed($feed_id, $offset, $limit, $id) { + if ($feed_id == "tag") { + $tag = ORM::factory("tag", $id); + if (!$tag->loaded) { + Kohana::show_404(); + } + $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; + return $feed; + } } } |