? .DS_Store
? d7-f_forum_topic_pager.patch
? includes/.DS_Store
? modules/.DS_Store
? modules/comment/.DS_Store
? modules/system/.DS_Store
? sites/default/files
? sites/default/settings.php
? themes/.DS_Store
? themes/garland/.DS_Store
Index: modules/forum/forum-topic-list.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum-topic-list.tpl.php,v
retrieving revision 1.4
diff -u -p -r1.4 forum-topic-list.tpl.php
--- modules/forum/forum-topic-list.tpl.php 30 Aug 2007 18:58:12 -0000 1.4
+++ modules/forum/forum-topic-list.tpl.php 18 May 2008 21:40:44 -0000
@@ -17,6 +17,7 @@
* - $topic->moved: A flag to indicate whether the topic has been moved to
* another forum.
* - $topic->title: The title of the topic. Safe to output.
+ * - $topic->pager: If there are multiple reply pages, this is a themed pager for them.
* - $topic->message: If the topic has been moved, this contains an
* explanation and a link.
* - $topic->zebra: 'even' or 'odd' string used for row class.
@@ -41,7 +42,7 @@
| icon; ?> |
- title; ?> |
+ pager; ?>title; ?> |
moved): ?>
message; ?> |
@@ -52,7 +53,6 @@
new_text; ?>
- created; ?>
| last_reply; ?>
|
Index: modules/forum/forum.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.css,v
retrieving revision 1.5
diff -u -p -r1.5 forum.css
--- modules/forum/forum.css 22 Jul 2007 07:01:07 -0000 1.5
+++ modules/forum/forum.css 18 May 2008 21:40:44 -0000
@@ -40,3 +40,18 @@
float: right; /* LTR */
width: 46%;
}
+
+#forum .item-list .forum-pager {
+ clear: both;
+ float: right;
+ margin: 0;
+}
+
+#forum .item-list .forum-pager li {
+ background-image: none;
+ display: inline;
+ font-size: 90%;
+ list-style-image: none;
+ list-style-type: none;
+ padding: 0;
+}
Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.456
diff -u -p -r1.456 forum.module
--- modules/forum/forum.module 6 May 2008 12:18:47 -0000 1.456
+++ modules/forum/forum.module 18 May 2008 21:40:44 -0000
@@ -61,6 +61,9 @@ function forum_theme() {
'template' => 'forum-submitted',
'arguments' => array('topic' => NULL),
),
+ 'forum_pager' => array(
+ 'arguments' => array('node' => NULL),
+ ),
);
}
@@ -818,6 +821,7 @@ function template_preprocess_forum_topic
$variables['topics'][$id]->title = l($topic->title, "node/$topic->nid");
$variables['topics'][$id]->message = '';
}
+ $variables['topics'][$id]->pager = theme('forum_pager', $topic);
$variables['topics'][$id]->created = theme('forum_submitted', $topic);
$variables['topics'][$id]->last_reply = theme('forum_submitted', isset($topic->last_reply) ? $topic->last_reply : NULL);
@@ -827,7 +831,6 @@ function template_preprocess_forum_topic
$variables['topics'][$id]->new_text = format_plural($topic->new_replies, '1 new', '@count new');
$variables['topics'][$id]->new_url = url("node/$topic->nid", array('query' => comment_new_page_count($topic->num_comments, $topic->new_replies, $topic), 'fragment' => 'new'));
}
-
}
}
else {
@@ -842,6 +845,38 @@ function template_preprocess_forum_topic
}
/**
+* Generate topic pagination
+*
+* @param $node
+* An object containing node data.
+*/
+function theme_forum_pager($node) {
+ $comments_per_page = _comment_get_display_setting('comments_per_page', $node);
+ $num_comments = $node->num_comments;
+
+ if (($num_comments) >= $comments_per_page) {
+ $total_pages = ceil(($num_comments) / $comments_per_page);
+
+ for ($i = 0; $i < $num_comments; $i += $comments_per_page) {
+ $items[] = array(
+ 'class' => 'forum-pager-item',
+ 'data' => ($i == 0 ? t('Pages: ') . '[ ' : '')
+ . l(t($i + 1), "node/$node->nid", array('query' => array('page' => $i)))
+ . ($i + $comments_per_page > $num_comments - 1 ? ' ]' : ''),
+ );
+
+ if ($i == 0 && $total_pages > 5) {
+ $items[] = array('data' => '...');
+ $i += ($total_pages - 4) * $comments_per_page;
+ }
+ }
+ // adding css again, no idea why it's not included already as in forum_init()!!
+ drupal_add_css(drupal_get_path('module', 'forum') . '/forum.css');
+ return theme('item_list', $items, NULL, 'ul', array('class' => 'forum-pager'));
+ }
+}
+
+/**
* Process variables to format the icon for each individual topic.
*
* $variables contains the following data: