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; }
private function __construct() { /** * Set the controller */ $this->_controller = $this->_view = Pixelpost_Uri::fragment(0) ? ucfirst(Pixelpost_Uri::fragment(0)) : Pixelpost_Config::getInstance()->default_controller; /** * If the URI fragment points to an non existent controller, * we'll try the page controller. */ if (!$this->controllerExists()) { $this->_controller = Pixelpost_Config::getInstance()->static_controller; } /** * Set the Action */ $this->_action = Pixelpost_Uri::fragment(1) ? Pixelpost_Uri::fragment(1) . 'Action' : Pixelpost_Config::getInstance()->default_action; }
/** * Get the current uri string * * Possible ways to get the current page: * * Pixelpost_Uri::$uri; * Pixelpost_Uri::uri(); * * @param string $uri (optional) override the current uri string * @return string self::$uri current uri */ public static function uri(string $uri = NULL) { if (!empty($uri)) { self::$uri = $uri; } return self::$uri; }
*/ set_include_path(APPPATH . 'classes/'); require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->setFallbackAutoloader(true); // Load any namespace /** * Initialize Language and Model Autoloader */ $resourceLoader = new Zend_Loader_Autoloader_Module(array('basePath' => APPPATH, 'namespace' => '')); $resourceLoader->addResourceType('models', 'models', 'Model'); $resourceLoader->addResourceType('modules', 'modules', 'Module'); /** * Initialize Uri Class */ Pixelpost_Uri::getInstance(); /** * Initialize Config Class */ $config = Pixelpost_Config::getInstance(); /** * Initialize DB Class */ switch ($config->database['adapter']) { case 'sqlite': Pixelpost_DB::init('pdo'); Pixelpost_DB::connect('sqlite:' . $config->database['sqlite']); break; case 'mysql': default: Pixelpost_DB::init('mysql');
public function indexAction() { /** * Determine the image ID we need to lookup, and verify that it is a positive integer: */ $this->id = (int) Pixelpost_Uri::fragment(1); $this->id = $this->id > 0 ? $this->id : 0; /** * Check if there is a Current Image, else get Current image */ if (!is_object($this->posts['current'])) { if (empty($this->id)) { // If no ID is specified, grab the latest image: $sql = "SELECT * FROM `pixelpost` WHERE `published` <= '{$this->config->current_time}' ORDER BY `published` DESC LIMIT 0,1"; } else { $sql = "SELECT * FROM `pixelpost` WHERE `id` = '{$this->id}' AND `published` <= '{$this->config->current_time}' LIMIT 0,1"; } // Assign the current image to the $posts array $this->posts['current'] = Pixelpost_DB::get_row($sql); } /** * Verify that the image exists, either from a plugin or from the code above: */ if (!is_object($this->posts['current'])) { // Error? Splash Screen? throw new Exception("Whoops, we don't have anything to show on this page right now, please to back to the <a href=\"?\">home page</a>."); } /** * Check if Next Image exists, else get Next image */ if (!is_object($this->posts['next'])) { $sql = "SELECT * FROM `pixelpost` WHERE (`published` < '{$this->posts['current']->published}') and (`published` <= '{$this->config->current_time}') ORDER BY `published` DESC LIMIT 0,1"; $this->posts['next'] = Pixelpost_DB::get_row($sql); /** * If we are on the last image, there isn't a next image, * so we can wrap around to the first image: */ if (!is_object($this->posts['next'])) { $sql = "SELECT * FROM `pixelpost` WHERE `published` <= '{$this->config->current_time}' ORDER BY `published` DESC LIMIT 0,1"; $this->posts['next'] = Pixelpost_DB::get_row($sql); } } /** * Check if Previous Image exists, else get Previous image */ if (!is_object($this->posts['previous'])) { $sql = "SELECT * FROM `pixelpost` WHERE (`published` > '{$this->posts['current']->published}') and (`published` <= '{$this->config->current_time}') ORDER BY `published` ASC LIMIT 0,1"; $this->posts['previous'] = Pixelpost_DB::get_row($sql); /** * If the first image, we can't go back any further, * so we can wrap around to the last image: */ if (!is_object($this->posts['previous'])) { $sql = "SELECT * FROM `pixelpost` WHERE `published` <= '{$this->config->current_time}' ORDER BY `published` ASC LIMIT 0,1"; $this->posts['previous'] = Pixelpost_DB::get_row($sql); } } /** * 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->title = $this->posts['current']->title; $this->view->posts = $this->posts; /** * Inclusion of the actual template needed is handled in the destruct * function of the base controller. */ }