예제 #1
0
 /**
  * initializes and outputs the list for the backend
  */
 public static function initialize()
 {
     self::_setup_i18n();
     self::$options = Participants_Db::$plugin_options;
     get_currentuserinfo();
     // set up the user settings transient
     global $user_ID;
     self::$user_settings = Participants_Db::$prefix . self::$user_settings . '-' . $user_ID;
     self::set_list_limit();
     self::$registration_page_url = get_bloginfo('url') . '/' . (isset(self::$options['registration_page']) ? self::$options['registration_page'] : '');
     self::setup_display_columns();
     self::$sortables = Participants_Db::get_sortables();
     // set up the basic values
     $default_values = array('search_field' => self::get_admin_user_setting('search_field', 'none'), 'value' => '', 'operator' => self::get_admin_user_setting('search_op', 'LIKE'), 'sortBy' => self::get_admin_user_setting('sort_by', self::$options['admin_default_sort']), 'ascdesc' => self::get_admin_user_setting('sort_order', self::$options['admin_default_sort_order']), 'submit-button' => '');
     // merge the defaults with the $_REQUEST array so if there are any new values coming in, they're included
     self::$filter = shortcode_atts($default_values, $_REQUEST);
     self::set_admin_user_setting('search_field', self::$filter['search_field']);
     self::set_admin_user_setting('search_op', self::$filter['operator']);
     self::set_admin_user_setting('sort_by', self::$filter['sortBy']);
     self::set_admin_user_setting('sort_order', self::$filter['ascdesc']);
     //error_log(__METHOD__.' request:'.print_r($_REQUEST,1).' filter:'.print_r(self::$filter,1));
     // process delete and items-per-page form submissions
     self::_process_general();
     self::_process_search(self::$filter['submit-button']);
     if (WP_DEBUG) {
         error_log(__METHOD__ . ' list query= ' . self::$list_query);
     }
     // get the $wpdb object
     global $wpdb;
     // get the number of records returned
     self::$num_records = $wpdb->get_var(str_replace('*', 'COUNT(*)', self::$list_query));
     // set the pagination object
     self::$pagination = new PDb_Pagination(array('link' => self::prepare_page_link($_SERVER['REQUEST_URI']), 'page' => isset($_GET[self::$list_page]) ? $_GET[self::$list_page] : '1', 'size' => self::$page_list_limit, 'total_records' => self::$num_records, 'add_variables' => http_build_query(self::$filter) . '#pdb-list-admin'));
     // get the records for this page, adding the pagination limit clause
     self::$participants = $wpdb->get_results(self::$list_query . ' ' . self::$pagination->getLimitSql(), ARRAY_A);
     // ok, setup finished, start outputting the form
     // add the top part of the page for the admin
     self::_admin_top();
     // print the sorting/filtering forms
     self::_sort_filter_forms();
     // add the delete and items-per-page controls for the backend
     self::_general_list_form_top();
     // print the main table
     self::_main_table();
     // output the pagination controls
     echo '<div class="pdb-list">' . self::$pagination->links() . '</div>';
     // print the CSV export form (admin users only)
     if (current_user_can(Participants_Db::$plugin_options['plugin_admin_capability'])) {
         self::_print_export_form();
     }
     // print the plugin footer
     Participants_Db::plugin_footer();
 }
 /**
  * sets the sortables list
  * 
  * this func is only used in templates to set up a custom sort dropdown
  * 
  * @param array  $columns supplies a list of columns to use, defaults to sortable 
  *                        displayed columns
  * @param string $sort    'column' sorts by the display column order, 'order' uses 
  *                        the defined group/fields order, 'alpha' sorts the list 
  *                        alphabetically
  * @return NULL just sets the sortables property
  */
 public function set_sortables($columns = false, $sort = 'column')
 {
     if ($columns !== false or $sort != 'column') {
         $this->sortables = Participants_Db::get_sortables($columns, $sort);
     }
 }