public function indexAction() { // Start with row 0 at the beginning... $range = 0; /** * Feed Pagination */ if ($this->config->feed_pagination) { /** * If the config option, feed_pagination is set, we will spit up the feed into pages. */ // Get total number of publically available posts $sql = "SELECT count(`id`) FROM `pixelpost` WHERE `published` <= '{$this->config->current_time}'"; $this->total_posts = (int) Pixelpost_DB::get_var($sql); // Determine the total number of pages Pixelpost_Uri::$total_pages = (int) ceil($this->total_posts / $this->config->posts_per_page); // Verify that we're on a legitimate page to start with if (Pixelpost_Uri::$total_pages < Pixelpost_Uri::$page) { // @todo this error displays if the database call doesn't work. throw new Exception("Sorry, we don't have anymore pages to show!"); } // The database needs to know which row we need to start with: $range = (int) (Pixelpost_Uri::$page - 1) * $this->config->posts_per_page; } $posts_sql = "SELECT * FROM `pixelpost` WHERE `published` <= '{$this->config->current_time}' ORDER BY `published` DESC LIMIT {$range}, {$this->config->feed_items}"; // Grab the data object from the DB. $this->posts = (array) Pixelpost_DB::get_results($posts_sql); /** * The RSS feed can't have altered published dates, * so we need to completely nuke "filter_published" * before we can run processPosts(). */ Pixelpost_Plugin::removeFilterHook('filter_published'); /** * Run the posts through the Plugin system, and apply any * necessary data before sending the array to the view. */ $this->processPosts(); /** * If index is called, without specifying a feed type, * auto-run the default rss method. */ if (empty($this->feed_type) || !method_exists($this, $this->feed_type . 'Action')) { $this->rssAction(); } }