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(); } }
public function indexAction() { if (!is_array($this->posts)) { // Page Title $this->view->title = 'The Past'; if ($this->config->posts_per_page > 0) { /** * If the config option, posts_per_page is set, we will spit up the archive 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) { 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; $sql = "SELECT * FROM `pixelpost` WHERE `published` <= '{$this->config->current_time}' ORDER BY `published` DESC LIMIT {$range}, {$this->config->posts_per_page}"; } else { /** * the config option, posts_per_page, isn't set, so display ALL the posts */ $sql = "SELECT * FROM `pixelpost` WHERE `published` <= '{$this->config->current_time}' ORDER BY `published` DESC"; } /** * The posts to list: */ $this->posts = (array) Pixelpost_DB::get_results($sql); } // !is_array($this->posts) /** * Run the posts through the Plugin system, and apply any * necessary data before sending the array to the view. */ $this->processPosts(); /** * Assign the variables to be used in the view * $this->view->myVar can be accessed in the template as $myVar */ $this->view->thumbnails = $this->_thumbnails(); $this->view->posts = $this->posts; }
/** * Get or set the total number of pages * * Possible ways to get the total pages: * * Pixelpost_Uri::$total_pages; * Pixelpost_Uri::totalPages(); * * @param int $total_pages (optional) override the total pages * @return int self::$total_pages total pages */ public static function totalPages(int $total_pages = NULL) { if (!empty($total_pages)) { self::$total_pages = (int) $total_pages; } return self::$total_pages; }