From 2ef26430ec2968605058b5a2d6bbcc001edcb703 Mon Sep 17 00:00:00 2001 From: matt Date: Sat, 18 Nov 2006 06:52:01 +0000 Subject: [PATCH] Paging for comments git-svn-id: http://svn.automattic.com/wordpress/trunk@4479 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-comments.php | 86 ++++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 8 deletions(-) diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 6d3e92dad..426d2d666 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -83,19 +83,57 @@ if (isset($_GET['s'])) { comment_approved != 'spam' ORDER BY comment_date DESC"); } else { - if ( isset($_GET['offset']) ) - $offset = (int) $_GET['offset'] * 20; + if ( isset( $_GET['apage'] ) ) + $page = (int) $_GET['apage']; else - $offset = 0; + $page = 1; + $start = $offset = ( $page - 1 ) * 20; + $end = $start + 20; - $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $offset,20"); + $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $end" ); + $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1'" ); } +?> + 20 ) { +$total_pages = ceil( $total / 20 ); +$r = ''; +if ( 1 < $page ) { + $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1; + $r .= '' . "\n"; +} +if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) { + for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) : + if ( $page == $page_num ) : + $r .= "$page_num\n"; + else : + $p = false; + if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) : + $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num; + $r .= '' . ( $page_num ) . "\n"; + $in = true; + elseif ( $in == true ) : + $r .= "...\n"; + $in = false; + endif; + endif; + endfor; +} +if ( ( $page ) * 20 < $total || -1 == $total ) { + $args['apage'] = $page + 1; + $r .= '' . "\n"; +} +echo "

$r

"; +?> + + + + +"; $i = 0; @@ -203,6 +241,38 @@ $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; } // end if ($comments) } ?> + 20 ) { +$total_pages = ceil( $total / 20 ); +$r = ''; +if ( 1 < $page ) { + $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1; + $r .= '' . "\n"; +} +if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) { + for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) : + if ( $page == $page_num ) : + $r .= "$page_num\n"; + else : + $p = false; + if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) : + $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num; + $r .= '' . ( $page_num ) . "\n"; + $in = true; + elseif ( $in == true ) : + $r .= "...\n"; + $in = false; + endif; + endif; + endfor; +} +if ( ( $page ) * 20 < $total || -1 == $total ) { + $args['apage'] = $page + 1; + $r .= '' . "\n"; +} +echo "

$r

"; +?> + +