Changeset 7158 for trunk/bp-groups/bp-groups-admin.php
- Timestamp:
- 06/05/2013 12:57:43 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-admin.php
r7146 r7158 714 714 // We'll also keep track of group members here to place them into a 715 715 // javascript variable, which will help with group member autocomplete 716 $member_ids = array(); 717 $members = array( 716 $members = array( 718 717 'admin' => array(), 719 718 'mod' => array(), … … 722 721 ); 723 722 723 $pagination = array( 724 'admin' => array(), 725 'mod' => array(), 726 'member' => array(), 727 'banned' => array(), 728 ); 729 724 730 foreach ( $members as $type => &$member_type_users ) { 731 $page_qs_key = $type . '_page'; 732 $current_type_page = isset( $_GET[ $page_qs_key ] ) ? absint( $_GET[ $page_qs_key ] ) : 1; 725 733 $member_type_query = new BP_Group_Member_Query( array( 726 734 'group_id' => $item->id, … … 728 736 'type' => 'alphabetical', 729 737 'per_page' => 10, 738 'page' => $current_type_page, 730 739 ) ); 731 740 732 741 $member_type_users = $member_type_query->results; 742 743 $pagination[ $type ] = bp_groups_admin_create_pagination_links( $member_type_query, $type ); 733 744 } 734 745 … … 749 760 endswitch; ?> 750 761 </h4> 762 763 <div class="bp-group-admin-pagination table-top"> 764 <?php echo $pagination[ $member_type ] ?> 765 </div> 751 766 752 767 <?php if ( !empty( $type_users ) ) : ?> … … 810 825 </table> 811 826 827 <div class="bp-group-admin-pagination table-bottom"> 828 <?php echo $pagination[ $member_type ] ?> 829 </div> 830 812 831 <?php else : ?> 813 832 … … 848 867 849 868 <?php 869 } 870 871 /** 872 * Create pagination links out of a BP_Group_Member_Query 873 * 874 * This function is intended to create pagination links for use under the 875 * Manage Members section of the Groups Admin Dashboard pages. It is a stopgap 876 * measure until a more general pagination solution is in place for BuddyPress. 877 * Plugin authors should not use this function, as it is likely to be 878 * deprecated soon. 879 * 880 * @since BuddyPress (1.8) 881 * @param object $query A BP_Group_Member_Query object 882 * @param string $member_type member|mod|admin|banned 883 */ 884 function bp_groups_admin_create_pagination_links( BP_Group_Member_Query $query, $member_type ) { 885 $pagination = ''; 886 887 if ( ! in_array( $member_type, array( 'admin', 'mod', 'member', 'banned' ) ) ) { 888 return $pagination; 889 } 890 891 // The key used to paginate this member type in the $_GET global 892 $qs_key = $member_type . '_page'; 893 $url_base = remove_query_arg( array( $qs_key, 'updated', 'success_modified' ), $_SERVER['REQUEST_URI'] ); 894 895 $page = isset( $_GET[ $qs_key ] ) ? absint( $_GET[ $qs_key ] ) : 1; 896 $per_page = 10; // @todo Make this customizable? 897 898 // Don't show anything if there's no pagination 899 if ( 1 === $page && $query->total_users <= $per_page ) { 900 return $pagination; 901 } 902 903 $current_page_start = ( ( $page - 1 ) * $per_page ) + 1; 904 $current_page_end = $page * $per_page > intval( $query->total_users ) ? $query->total_users : $page * $per_page; 905 906 $pag_links = paginate_links( array( 907 'base' => add_query_arg( $qs_key, '%#%', $url_base ), 908 'format' => '', 909 'prev_text' => __( '«' ), 910 'next_text' => __( '»' ), 911 'total' => ceil( $query->total_users / $per_page ), 912 'current' => $page, 913 ) ); 914 915 $viewing_text = sprintf( 916 __( 'Viewing %1$s - %2$s of %3$s', 'buddypress' ), 917 number_format_i18n( $current_page_start ), 918 number_format_i18n( $current_page_end ), 919 sprintf( _n( '%s member', '%s members', $query->total_users, 'buddypress' ), $query->total_users ) 920 ); 921 922 $pagination .= '<span class="bp-group-admin-pagination-viewing">' . $viewing_text . '</span>'; 923 $pagination .= '<span class="bp-group-admin-pagination-links">' . $pag_links . '</span>'; 924 925 return $pagination; 850 926 } 851 927
Note: See TracChangeset
for help on using the changeset viewer.