diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-06-15 12:51:54 +0800 |
---|---|---|
committer | <unostar@danalan.info> | 2009-06-15 17:31:22 +0800 |
commit | 0051c2c89b71128ff0aefaaa4a77df91dd078016 (patch) | |
tree | a31099fbc063843f8d89710209ed660614b41cc3 /modules/tag/helpers | |
parent | 0204a5c9e88f8cd257092e4a619ada02ffcd2821 (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.
Signed-off-by: <unostar@danalan.info>
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; + } } } |