/** * Loads the posts and shows them. */ function perform() { if ($this->_mode == SUMMARY_RSS_TYPE_MOST_COMMENTED || $this->_mode == SUMMARY_RSS_TYPE_MOST_READ || $this->_mode == SUMMARY_RSS_TYPE_DEFAULT) { // RSS feeds for posts stuff $this->_view = new SummaryRssView($this->_profile, array("summary" => "rss", "mode" => $this->_mode, "profile" => $this->_profile)); if ($this->_view->isCached()) { return true; } $blogs = new Blogs(); $stats = new SummaryStats(); if ($this->_mode == SUMMARY_RSS_TYPE_MOST_COMMENTED) { $posts = $stats->getMostCommentedArticles($this->_numPosts); } elseif ($this->_mode == SUMMARY_RSS_TYPE_MOST_READ) { $posts = $stats->getMostReadArticles($this->_numPosts); } else { // load the most recent posts, filtering out all those registration messages... $registerTopic = $this->_locale->tr("register_default_article_topic"); $registerText = $this->_locale->tr("register_default_article_text"); $posts = $stats->getRecentArticles($this->_numPosts, $registerTopic, $registerText); } if (!$posts) { $posts = array(); } $this->_view->setValue("posts", $posts); } elseif ($this->_mode == SUMMARY_RSS_TYPE_MOST_ACTIVE_BLOGS || $this->_mode == SUMMARY_RSS_TYPE_NEWEST_BLOGS) { // RSS feeds for blogs, need different template sets... $this->_view = new SummaryRssView("blogs_" . $this->_profile, array("summary" => "rss", "mode" => $this->_mode, "profile" => $this->_profile)); if ($this->_view->isCached()) { return true; } // load the stuff $stats = new SummaryStats(); if ($this->_mode == SUMMARY_RSS_TYPE_MOST_ACTIVE_BLOGS) { $blogs = $stats->getMostActiveBlogs($this->_numPosts); } else { $blogs = $stats->getRecentBlogs($this->_numPosts); } // in case there is really no data to fetch... if (!$blogs) { $blogs = array(); } // this 'url' object is just a dummy one... But we cannot get it from the list // of blogs that we fetched because it could potentially be null! Besides, we only // need it to generate the base url to rss.css and to summary.php, so no need to // have a fully-featured object $this->_view->setValue("url", new RawRequestGenerator(null)); $this->_view->setValue("blogs", $blogs); } $this->_view->setValue("type", $this->_mode); $this->_view->setValue("summary", true); $this->setCommonData(); return true; }
/** * Loads the posts and shows them. */ function perform() { $this->_view = new SummaryCachedView("index", array("summary" => "default", "locale" => $this->_locale->getLocaleCode())); if ($this->_view->isCached()) { // if the view is already cached... move along! nothing to see here return true; } $blogs = new Blogs(); $stats = new SummaryStats(); // load the posts, filtering out all those registration messages... $registerTopic = $this->_locale->tr("register_default_article_topic"); $registerText = $this->_locale->tr("register_default_article_text"); $recentPosts = $stats->getRecentArticles($this->_numPosts, $registerTopic, $registerText); // get all the blogs $siteBlogs = $blogs->getAllBlogs(true); $recentBlogs = $stats->getRecentBlogs($this->_numPosts); $activeBlogs = $stats->getMostActiveBlogs($this->_numPosts); $commentedPosts = $stats->getMostCommentedArticles($this->_numPosts, $registerTopic, $registerText); $readestBlogs = $stats->getMostReadArticles($this->_numPosts, $registerTopic, $registerText); // export all these things to the view $this->_view->setValue("posts", $recentPosts); $this->_view->setValue("recentBlogs", $recentBlogs); $this->_view->setValue("activeBlogs", $activeBlogs); $this->_view->setValue("commentedPosts", $commentedPosts); $this->_view->setValue("readestBlogs", $readestBlogs); $this->_view->setValue("blogs", $siteBlogs); // // :KLUDGE: // we just need a random blog so... we'll get one :) // $randomBlog = array_pop($siteBlogs); $url = $randomBlog->getBlogRequestGenerator(); $this->_view->setValue("url", $url); $this->setCommonData(); return true; }