diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/comment/helpers/comment_rss.php | 19 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_rss.php | 26 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_theme.php | 4 | ||||
-rw-r--r-- | modules/rss/controllers/rss.php | 21 | ||||
-rw-r--r-- | modules/rss/helpers/rss.php | 19 | ||||
-rw-r--r-- | modules/rss/helpers/rss_theme.php | 14 | ||||
-rw-r--r-- | modules/tag/helpers/tag_rss.php | 13 | ||||
-rw-r--r-- | modules/tag/helpers/tag_theme.php | 6 |
8 files changed, 56 insertions, 66 deletions
diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index b191c326..56de4284 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -21,15 +21,14 @@ 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}")); } 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 6e722ff6..6535d29d 100644 --- a/modules/gallery/helpers/gallery_rss.php +++ b/modules/gallery/helpers/gallery_rss.php @@ -21,24 +21,23 @@ class gallery_rss_Core { static function available_feeds($item) { return array(array("description" => t("New photos or movies"), - "sidebar" => true, + "type" => "block", "uri" => "updates"), array("description" => t("Album feed"), - "sidebar" => false, + "type" => "head", "uri" => "albums")); } 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/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index f955e8f7..290434ed 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -42,6 +42,10 @@ 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") . "\" />"; diff --git a/modules/rss/controllers/rss.php b/modules/rss/controllers/rss.php index 164803cb..80803dfd 100644 --- a/modules/rss/controllers/rss.php +++ b/modules/rss/controllers/rss.php @@ -20,21 +20,24 @@ class Rss_Controller extends Controller { public static $page_size = 30; - public function __call($method, $arguments) { - $id = empty($arguments) ? null : $arguments[0]; + public function feed($method, $id=null) { $page = $this->input->get("page", 1); - $feed_uri = "rss/$method" . (empty($id) ? "" : "/$id"); + $feed_uri = "rss/feed/$method" . (empty($id) ? "" : "/$id"); if ($page < 1) { url::redirect($feed_uri); } - $feed = rss::process_feed($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}"); + $feed = rss::feed_data($method, ($page - 1) * self::$page_size, self::$page_size, $id); + $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); @@ -44,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/rss/helpers/rss.php b/modules/rss/helpers/rss.php index 1d30425f..403ee225 100644 --- a/modules/rss/helpers/rss.php +++ b/modules/rss/helpers/rss.php @@ -19,28 +19,23 @@ */ class rss_Core { - static function item_feed($item) { - $id = $item->is_album() ? $item->id : $item->parent_id; - return url::site("rss/albums/$id"); - } - - static function tag_feed($tag) { - return url::site("rss/tags/$tag->id}"); + static function feed_link($uri) { + $url = url::site("rss/feed/$uri"); + return "<link rel=\"alternate\" type=\"" . rest::RSS . "\" href=\"$url\" />"; } /** * Get all available rss feeds */ - static function get_feeds($item, $sidebar_only=true) { + static function available_feeds($item) { $feeds = array(); foreach (module::active() as $module) { $class_name = "{$module->name}_rss"; if (method_exists($class_name, "available_feeds")) { foreach (call_user_func(array($class_name, "available_feeds"), $item) as $feed) { - if ($sidebar_only && !$feed["sidebar"]) { - continue; + if ($feed["type"] == "block") { + $feeds[$feed["description"]] = url::site("rss/feed/{$feed['uri']}"); } - $feeds[$feed["description"]] = url::site("rss/{$feed['uri']}"); } } } @@ -48,7 +43,7 @@ class rss_Core { return $feeds; } - static function process_feed($feed, $offset, $limit, $id) { + static function feed_data($feed, $offset, $limit, $id) { foreach (module::active() as $module) { $class_name = "{$module->name}_rss"; if (method_exists($class_name, $feed)) { diff --git a/modules/rss/helpers/rss_theme.php b/modules/rss/helpers/rss_theme.php index b82133bd..52d988bf 100644 --- a/modules/rss/helpers/rss_theme.php +++ b/modules/rss/helpers/rss_theme.php @@ -18,18 +18,6 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class rss_theme_Core { - static function head($theme) { - if ($theme->item()) { - $url = rss::item_feed($theme->item()); - } else if ($theme->tag()) { - $url = rss::tag_feed($theme->tag()); - } - - if (!empty($url)) { - return "<link rel=\"alternate\" type=\"" . rest::RSS . "\" href=\"$url\" />"; - } - } - static function sidebar_blocks($theme) { // @todo this needs to be data driven if (!$theme->item()) { @@ -40,7 +28,7 @@ class rss_theme_Core { $block->css_id = "gRss"; $block->title = t("Available RSS Feeds"); $block->content = new View("rss_block.html"); - $block->content->feeds = rss::get_feeds($theme->item()); + $block->content->feeds = rss::available_feeds($theme->item()); return $block; } diff --git a/modules/tag/helpers/tag_rss.php b/modules/tag/helpers/tag_rss.php index ace7fd6a..3d6399ca 100644 --- a/modules/tag/helpers/tag_rss.php +++ b/modules/tag/helpers/tag_rss.php @@ -21,7 +21,7 @@ class tag_rss_Core { static function available_feeds($item) { return array(array("description" => t("Tag Album feed"), - "sidebar" => false, + "type" => "head", "uri" => "tags")); } @@ -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; } diff --git a/modules/tag/helpers/tag_theme.php b/modules/tag/helpers/tag_theme.php index a32d71b6..45f55986 100644 --- a/modules/tag/helpers/tag_theme.php +++ b/modules/tag/helpers/tag_theme.php @@ -20,7 +20,11 @@ class tag_theme_Core { static function head($theme) { $url = url::file("modules/tag/js/tag.js"); - return "<script src=\"$url\" type=\"text/javascript\"></script>"; + $head[] = "<script src=\"$url\" type=\"text/javascript\"></script>"; + if ($theme->tag() && module::is_active("rss")) { + $head[] = rss::feed_link("tags/{$theme->tag()->id}"); + } + return implode("\n", $head); } static function sidebar_blocks($theme) { |