/**
  * Returns an associative array listing all the views that can be used with this table.
  * These are listed across the top of the page and managed by WordPress.
  *
  * @since 0.1
  * 
  * @return	array	View information,e.g., array ( id => link )
  */
 function get_views()
 {
     /*
      * Find current view
      */
     if ($this->detached) {
         $current_view = 'unattached';
     } elseif ($this->is_trash) {
         $current_view = 'trash';
     } elseif (empty($_REQUEST['post_mime_type'])) {
         if (isset($_REQUEST['meta_query'])) {
             $query = unserialize(stripslashes($_REQUEST['meta_query']));
             $current_view = $query['slug'];
         } else {
             $current_view = 'all';
         }
     } else {
         $current_view = $_REQUEST['post_mime_type'];
     }
     $mla_types = MLAMime::mla_query_view_items(array('orderby' => 'menu_order'), 0, 0);
     if (!is_array($mla_types)) {
         $mla_types = array();
     }
     /*
      * Filter the list, generate the views
      */
     $view_links = array();
     foreach ($mla_types as $value) {
         if ($value->table_view) {
             if ($current_view == $value->specification) {
                 $current_view = $value->slug;
             }
             if ($link = self::_get_view($value->slug, $current_view)) {
                 $view_links[$value->slug] = $link;
             }
         }
     }
     return $view_links;
 }
 /**
  * Retrieve views eligible for Media/Assistant table display
  *
  * @since 1.40
  *
  * @return	array	table views array ( specification => Plural Label )
  */
 public static function mla_pluck_table_views()
 {
     $mla_types = MLAMime::mla_query_view_items(array('orderby' => 'menu_order'), 0, 0);
     if (!is_array($mla_types)) {
         $mla_types = array();
     }
     /*
      * Filter the list, generate the list
      */
     $results = array();
     foreach ($mla_types as $value) {
         if (in_array($value->slug, array('all', 'trash', 'detached'))) {
             continue;
         }
         if ($value->table_view) {
             if (empty($value->specification)) {
                 $results[$value->slug] = $value->plural;
             } else {
                 $results[$value->specification] = $value->plural;
             }
         }
     }
     return $results;
 }
 /**
  * Prepares the list of items for displaying
  *
  * 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().
  *
  * @since 1.40
  *
  * @return	void
  */
 function prepare_items()
 {
     $this->_column_headers = array($this->get_columns(), $this->get_hidden_columns(), $this->get_sortable_columns());
     /*
      * REQUIRED for pagination.
      */
     $total_items = MLAMime::mla_count_view_items($_REQUEST);
     $user = get_current_user_id();
     $screen = get_current_screen();
     $option = $screen->get_option('per_page', 'option');
     if (is_string($option)) {
         $per_page = get_user_meta($user, $option, true);
     } else {
         $per_page = 10;
     }
     if (empty($per_page) || $per_page < 1) {
         $per_page = $screen->get_option('per_page', 'default');
     }
     /*
      * REQUIRED. We also have to register our pagination options & calculations.
      */
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
     $current_page = $this->get_pagenum();
     /*
      * REQUIRED. Assign sorted and paginated data to the items property, where 
      * it can be used by the rest of the class.
      */
     $this->items = MLAMime::mla_query_view_items($_REQUEST, ($current_page - 1) * $per_page, $per_page);
 }