--- drupal-cvs/modules/forum.module 2006-01-10 05:00:02.000000000 -0800 +++ drupal/modules/forum.module 2006-01-23 10:23:12.000000000 -0800 @@ -966,9 +966,62 @@ function theme_forum_topic_list($tid, $t ); } else { + // find number of comments per page + $comments_per_page = $_GET['comments_per_page']; + if (empty($comments_per_page)) { + $comments_per_page = $user->comments_per_page ? $user->comments_per_page : ($_SESSION ['comment_comments_per_page'] ? $_SESSION['comment_comments_per_page'] : variable_get('comment_default_per_page', '50')); + } + // compute page_links + $page_links = ''; // clear html output + if ($topic->num_comments > $comments_per_page) { + $num_comment_pages = ceil( $topic->num_comments / $comments_per_page ); + // five or more pages + if ($num_comment_pages > 4) { + // link to first page + $page_links .= l("1", + "node/$topic->nid", + null, + 'page=0'. + '&comments_per_page='.$comments_per_page + ); + $page_links .= ' ... '; + $runOnce = false; + for ($page_number = $num_comment_pages - 2; $page_number <= $num_comment_pages; $page_number++) { + if ($runOnce) { + $page_links .= ', '; // comma + } + $page_links .= l($page_number, + "node/$topic->nid", + null, + 'page='.($page_number - 1). + '&comments_per_page='.$comments_per_page + ); + $runOnce = true; + } + } + // four or fewer pages + else { + $runOnce = false; + for ($page_number = 1; $page_number <= $num_comment_pages; $page_number++) { + if ($runOnce) { + $page_links .= ', '; // comma + } + $page_links .= l($page_number, + "node/$topic->nid", + null, + 'page='.($page_number - 1). + '&comments_per_page='.$comments_per_page + ); + $runOnce = true; + } + } + $page_links = '
[ Pages: '.$page_links.' ]'; // add brackets + } + + // organize topic row $rows[] = array( array('data' => theme('forum_icon', $topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'), - array('data' => l($topic->title, "node/$topic->nid"), 'class' => 'topic'), + array('data' => l($topic->title, "node/$topic->nid").$page_links, 'class' => 'topic'), array('data' => $topic->num_comments . ($topic->new_replies ? '
'. l(format_plural($topic->new_replies, '1 new', '%count new'), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'), array('data' => _forum_format($topic), 'class' => 'created'), array('data' => _forum_format($topic->last_reply), 'class' => 'last-reply')