Changeset 1170

Show
Ignore:
Timestamp:
12/04/07 16:12:51 (1 year ago)
Author:
donncha
Message:

Pagination, props ktlee, fixes #518

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/wpmu-users.php

    r1122 r1170  
    4040<div class="wrap"> 
    4141        <?php 
    42         $start = isset( $_GET['start'] ) ? intval( $_GET['start'] ) : 0
    43         $num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 30
     42        $apage = isset( $_GET['apage'] ) ? intval( $_GET['apage'] ) : 1
     43        $num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 15
    4444 
    4545        $query = "SELECT * FROM {$wpdb->users}"; 
     
    6868        $query .= ( $_GET['order'] == 'DESC' ) ? 'DESC' : 'ASC'; 
    6969 
    70         $query .= " LIMIT " . intval( $start ) . ", " . intval( $num ); 
     70        if( !empty($_GET['s'])) { 
     71                $user_list = $wpdb->get_results( $query, ARRAY_A ); 
     72                $total = count($user_list);      
     73        } else { 
     74                $total = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->users}"); 
     75        } 
     76         
     77        $query .= " LIMIT " . intval( ( $apage - 1 ) * $num) . ", " . intval( $num ); 
     78         
    7179        $user_list = $wpdb->get_results( $query, ARRAY_A ); 
    72          
    73         $next = ( count( $user_list ) < $num ) ? false : true; 
     80 
     81        // Pagination 
     82        $user_navigation = paginate_links( array( 
     83                'base' => add_query_arg( 'apage', '%#%' ), 
     84                'format' => '', 
     85                'total' => ceil($total / $num), 
     86                'current' => $apage 
     87        )); 
    7488        ?> 
    7589        <h2><?php _e("Users"); ?></h2> 
    76         <div style="float:right; padding:0 20px; margin-top:10px;">  
    77                 <h4 style="margin:0 0 4px;"><?php _e('User Navigation') ?></h4>  
    78                 <?php  
    79                 $url2 = "order=" . $_GET['order'] . "&sortby=" . $_GET['sortby'] . "&s=" .$_GET['s']; 
    80                 if( $start == 0 ) {  
    81                         _e('Previous&nbsp;Users'); 
    82                 } elseif( $start <= 30 ) {  
    83                         echo '<a href="wpmu-users.php?start=0' . $url2 . '">'.__('Previous&nbsp;Users').'</a>'; 
    84                 } else { 
    85                         echo '<a href="wpmu-users.php?start=' . ( $start - $num ) . '&' . $url2 . '">'.__('Previous&nbsp;Users').'</a>'; 
    86                 }  
    87                 if ( $next ) { 
    88                         echo '&nbsp;||&nbsp;<a href="wpmu-users.php?start=' . ( $start + $num ) . '&' . $url2 . '">'.__('Next&nbsp;Users').'</a>'; 
    89                 } else { 
    90                         echo '&nbsp;||&nbsp;'.__('Next&nbsp;Users'); 
    91                 } 
    92                 ?> 
     90         
     91        <div style="float:right; padding:0 20px; margin-top:20px;">  
     92                <?php if ( $user_navigation ) echo "<p class='pagenav'>$user_navigation</p>"; ?> 
    9393        </div> 
    9494         
     
    159159                                                        _e('Blogs'); 
    160160                                                } else { ?> 
    161                                                         <a href="wpmu-users.php?sortby=<?php echo $column_id ?>&amp;<?php if( $_GET['sortby'] == $column_id ) { if( $_GET['order'] == 'DESC' ) { echo "order=ASC&amp;" ; } else { echo "order=DESC&amp;"; } } ?>start=<?php echo $start ?>"><?php echo $column_display_name; ?></a> 
     161                                                        <a href="wpmu-users.php?sortby=<?php echo $column_id ?>&amp;<?php if( $_GET['sortby'] == $column_id ) { if( $_GET['order'] == 'DESC' ) { echo "order=ASC&amp;" ; } else { echo "order=DESC&amp;"; } } ?>apage=<?php echo $apage ?>"><?php echo $column_display_name; ?></a> 
    162162                                                <?php } ?> 
    163163                                        </th> 
     
    250250                </table> 
    251251                 
     252                <div style="float:right; padding:0 20px; margin-top:20px;">  
     253                        <?php if ( $user_navigation ) echo "<p class='pagenav'>$user_navigation</p>"; ?> 
     254                </div> 
     255         
    252256                <p><input class="button" type="button" value="<?php _e('Check All') ?>" onclick="this.value=check_all_rows()" /></p> 
    253257