diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-11-16 15:51:19 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-11-16 15:51:19 +0000 |
commit | 0310b98986de71f17a1a37a40659a585de5fd1a1 (patch) | |
tree | d2f0a5988c4997dea1bf4cec428a7aba66a46577 /wp-admin/wpmu-blogs.php | |
parent | aa53202959aac1441a80209d19cf8d7cf2e2dde1 (diff) | |
download | wordpress-mu-0310b98986de71f17a1a37a40659a585de5fd1a1.tar.gz wordpress-mu-0310b98986de71f17a1a37a40659a585de5fd1a1.tar.xz wordpress-mu-0310b98986de71f17a1a37a40659a585de5fd1a1.zip |
Better pagination, props ktlee, fixes #483
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1155 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/wpmu-blogs.php')
-rw-r--r-- | wp-admin/wpmu-blogs.php | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/wp-admin/wpmu-blogs.php b/wp-admin/wpmu-blogs.php index 6cc07e6..a130555 100644 --- a/wp-admin/wpmu-blogs.php +++ b/wp-admin/wpmu-blogs.php @@ -279,8 +279,8 @@ switch( $_GET['action'] ) { // List blogs default: - $start = isset( $_GET['start'] ) ? intval( $_GET['start'] ) : 0; - $num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 60; + $apage = isset( $_GET['apage'] ) ? intval( $_GET['apage'] ) : 1; + $num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 30; $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; @@ -307,6 +307,7 @@ switch( $_GET['action'] ) { if( isset( $_GET['sortby'] ) == false ) { $_GET['sortby'] = 'id'; } + if( $_GET['sortby'] == 'registered' ) { $query .= ' ORDER BY registered '; } elseif( $_GET['sortby'] == 'id' ) { @@ -320,27 +321,24 @@ switch( $_GET['action'] ) { $query .= ( $_GET['order'] == 'DESC' ) ? 'DESC' : 'ASC'; if ( $_GET['ip_address'] == '' ) - $query .= " LIMIT " . intval( $start ) . ", " . intval( $num ); + $query .= " LIMIT " . intval( ( $apage - 1 ) * $num) . ", " . intval( $num ); $blog_list = $wpdb->get_results( $query, ARRAY_A ); - $next = ( count( $blog_list ) < $num ) ? false : true; - - // Pagination - $url2 = "order=" . $_GET['order'] . "&sortby=" . $_GET['sortby'] . "&s=" . $_GET['s'] . "&ip_address=" . $_GET['ip_address']; - $blog_navigation = ''; - if( $start == 0 ) { - $blog_navigation .= __('Previous Blogs'); - } elseif( $start <= 30 ) { - $blog_navigation .= '<a href="wpmu-blogs.php?start=0&' . $url2 . ' ">' . __('Previous Blogs') . '</a>'; + if( !empty($_GET['s']) || !empty($_GET['blog_id']) || !empty($_GET['ip_address'])) { + $total = count($blog_list); } else { - $blog_navigation .= '<a href="wpmu-blogs.php?start=' . ( $start - $num ) . '&' . $url2 . '">' . __('Previous Blogs') . '</a>'; - } - if ( $next ) { - $blog_navigation .= ' || <a href="wpmu-blogs.php?start=' . ( $start + $num ) . '&' . $url2 . '">' . __('Next Blogs') . '</a>'; - } else { - $blog_navigation .= ' || ' . __('Next Blogs'); + $total = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "); } + + // Pagination + $url2 = "&order=" . $_GET['order'] . "&sortby=" . $_GET['sortby'] . "&s=" . $_GET['s'] . "&ip_address=" . $_GET['ip_address']; + $blog_navigation = paginate_links( array( + 'base' => add_query_arg( 'apage', '%#%' ).$url2, + 'format' => '', + 'total' => ceil($total / $num), + 'current' => $apage + )); ?> <script type="text/javascript"> <!-- @@ -376,8 +374,7 @@ switch( $_GET['action'] ) { <div class="wrap"> <h2><?php _e('Blogs') ?></h2> <div style="float:right; padding:0 20px; margin-top:20px;"> - <h4 style="margin:0 0 4px;"><?php _e('Blog Navigation') ?></h4> - <?php echo $blog_navigation; ?> + <?php if ( $blog_navigation ) echo "<p class='pagenav'>$blog_navigation</p>"; ?> </div> <form id="searchform" action="wpmu-blogs.php" method="get"> @@ -436,7 +433,7 @@ switch( $_GET['action'] ) { <thead> <tr> <?php foreach($posts_columns as $column_id => $column_display_name) : ?> - <th scope="col"><a href="wpmu-blogs.php?<?php echo $sortby_url ?>&sortby=<?php echo $column_id ?>&<?php if( $_GET['sortby'] == $column_id ) { if( $_GET['order'] == 'DESC' ) { echo "order=ASC&" ; } else { echo "order=DESC&"; } } ?>start=<?php echo $start ?>"><?php echo $column_display_name; ?></a></th> + <th scope="col"><a href="wpmu-blogs.php?<?php echo $sortby_url ?>&sortby=<?php echo $column_id ?>&<?php if( $_GET['sortby'] == $column_id ) { if( $_GET['order'] == 'DESC' ) { echo "order=ASC&" ; } else { echo "order=DESC&"; } } ?>apage=<?php echo $apage ?>"><?php echo $column_display_name; ?></a></th> <?php endforeach ?> </tr> </thead> @@ -594,8 +591,7 @@ switch( $_GET['action'] ) { </table> <div style="float:right; padding:0 20px; margin-top:20px;"> - <h4 style="margin:0 0 4px;"><?php _e('Blog Navigation') ?></h4> - <?php echo $blog_navigation;?> + <?php if ( $blog_navigation ) echo "<p class='pagenav'>$blog_navigation</p>"; ?> </div> <input style="margin:5px 0;" id="check_all2" type="button" class="button" value="<?php _e('Check All') ?>" onclick="check_all_rows()" /> |