示例#1
0
 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();
     }
 }
示例#2
0
 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;
 }
示例#3
0
 /**
  * @Delete a node and all its children
  * @access public
  * @param string $node_name
  */
 public function deleteNodeRecursive($node_permalink)
 {
     try {
         $sql = "SELECT left_node, right_node FROM " . $this->tablename . " \n\t\t\t\tWHERE permalink = '" . Pixelpost_DB::escape($node_permalink) . "'";
         $result = (array) Pixelpost_DB::get_results($sql);
         $result[0]->width_node = $result[0]->right_node - $result[0]->left_node + 1;
         Pixelpost_DB::query("DELETE FROM " . $this->tablename . " \n\t\t\t\tWHERE left_node BETWEEN " . $result[0]->left_node . " \n\t\t\t\tAND " . $result[0]->right_node);
         Pixelpost_DB::query("UPDATE " . $this->tablename . " \n\t\t\t\tSET right_node = right_node - " . $result[0]->width_node . " \n\t\t\t\tWHERE right_node > " . $result[0]->right_node);
         Pixelpost_DB::query("UPDATE " . $this->tablename . " \n\t\t\t \tSET left_node = left_node - " . $result[0]->width_node . " \n\t\t\t\t WHERE left_node > " . $result[0]->right_node);
     } catch (exception $e) {
         throw new Exception($e);
     }
 }