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/gallery/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/gallery/helpers')
| -rw-r--r-- | modules/gallery/helpers/gallery_rss.php | 65 | ||||
| -rw-r--r-- | modules/gallery/helpers/gallery_theme.php | 4 | 
2 files changed, 32 insertions, 37 deletions
| diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php index 413d12a4..6e966bdb 100644 --- a/modules/gallery/helpers/gallery_rss.php +++ b/modules/gallery/helpers/gallery_rss.php @@ -19,45 +19,44 @@   */  class gallery_rss_Core { -  static function available_feeds($item) { -    return array(array("description" => t("New photos or movies"), -                       "uri" => "updates"), -                 array("description" => t("Album feed"), -                       "uri" => "albums")); +  static function available_feeds($item, $tag) { +    $feeds["gallery/latest"] = t("Latest photos and movies"); +    return $feeds;    } -  static function updates($offset, $limit) { -    $feed->children = ORM::factory("item") -      ->viewable() -      ->where("type !=", "album") -      ->orderby("created", "DESC") -      ->find_all($limit, $offset); +  static function feed($feed_id, $offset, $limit, $id) { +    switch ($feed_id) { +    case "latest": +      $feed->children = ORM::factory("item") +        ->viewable() +        ->where("type !=", "album") +        ->orderby("created", "DESC") +        ->find_all($limit, $offset); -    $all_children = ORM::factory("item") -      ->viewable() -      ->where("type !=", "album") -      ->orderby("created", "DESC"); +      $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"); +      $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; -    return $feed; -  } - -  static function albums($offset, $limit, $id) { -    $item = ORM::factory("item", $id); -    access::required("view", $item); +    case "album": +      $item = ORM::factory("item", $id); +      access::required("view", $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->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; -    return $feed; +      return $feed; +    }    }  } diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index 290434ed..f955e8f7 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -42,10 +42,6 @@ class gallery_theme_Core {        $buf .= html::script("modules/gallery/js/fullsize.js");      } -    if ($theme->item()) { -      $buf .= rss::feed_link("albums/{$theme->item()->id}"); -    } -      if ($session->get("l10n_mode", false)) {        $buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .          url::file("modules/gallery/css/l10n_client.css") . "\" />"; | 
