Example #1
0
 /** 
  * REQUIRED! This is where you prepare your data for display. This method will
  * usually be used to query the database, sort and filter the data, and generally
  * get it ready to be displayed. At a minimum, we should set $this->items and
  * $this->set_pagination_args(), although the following properties and methods
  * are frequently interacted with here...
  * 
  * @uses $this->_column_headers
  * @uses $this->items
  * @uses $this->get_columns()
  * @uses $this->get_sortable_columns()
  * @uses $this->get_pagenum()
  * @uses $this->set_pagination_args()
  */
 public function prepare_items()
 {
     // The the 3 types of columns
     $this->_column_headers = array($this->get_columns(), $this->get_hidden_columns(), $this->get_sortable_columns());
     // Process the current bulk action, if enabled
     if ($this->definition->enableBulkActions() && $this->getCurrentBulkAction()) {
         $this->definition->processBulkAction($this->getCurrentBulkAction());
     }
     // Calculate the total number of items
     $total_items = count($this->definition->getItems());
     // Determine how many items to show on a page
     $per_page = $this->definition->itemsPerPage();
     // Calculate the total number of pages
     $total_pages = ceil($total_items / $per_page);
     // Set the current page items
     $this->items = $this->definition->getPagedItems($this->getCurrentPageNum());
     // Set the pagination arguments
     $this->set_pagination_args(compact('total_items', 'per_page', 'total_pages'));
 }