summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-02-10 05:05:44 +0000
committerDries Buytaert <dries@buytaert.net>2006-02-10 05:05:44 +0000
commit91152ba7af96b8f7125cc54a268f0056435908a1 (patch)
tree4745cb26afeedc79d2c27241c5df2c9877872c47
parent1819de963f09f03a93be7c328a519475a8b45aee (diff)
downloadbrdo-91152ba7af96b8f7125cc54a268f0056435908a1.tar.gz
brdo-91152ba7af96b8f7125cc54a268f0056435908a1.tar.bz2
- Patch #46743 by m3avrck: clean up forum topic navigation. Bring it in line with book.module.
-rw-r--r--modules/forum.module92
-rw-r--r--modules/forum/forum.module92
2 files changed, 94 insertions, 90 deletions
diff --git a/modules/forum.module b/modules/forum.module
index 8e957fe74..0b77a8813 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -400,50 +400,6 @@ function forum_block($op = 'list', $delta = 0, $edit = array()) {
}
}
-/**
- * Implementation of hook_link().
- */
-function forum_link($type, $node = 0, $main = 0) {
- global $user;
-
- $links = array();
-
- if (!$main && $type == 'node' && $node->type == 'forum') {
- // get previous and next topic
-
- $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
- $sql = db_rewrite_sql($sql);
- $result = db_query($sql, $node->tid);
-
- while ($topic = db_fetch_object($result)) {
- if ($stop == 1) {
- $next = new StdClass();
- $next->nid = $topic->nid;
- $next->title = $topic->title;
- break;
- }
- if ($topic->nid == $node->nid) {
- $stop = 1;
- }
- else {
- $prev = new StdClass();
- $prev->nid = $topic->nid;
- $prev->title = $topic->title;
- }
- }
-
- if ($prev) {
- $links[] = l(t('previous forum topic'), "node/$prev->nid", array('title' => check_plain($prev->title)));
- }
-
- if ($next) {
- $links[] = l(t('next forum topic'), "node/$next->nid", array('title' => check_plain($next->title)));
- }
- }
-
- return $links;
-}
-
function forum_term_path($term) {
return 'forum/'. $term->tid;
}
@@ -497,7 +453,6 @@ function forum_menu($may_cache) {
* Implementation of hook_view().
*/
function forum_view(&$node, $teaser = FALSE, $page = FALSE) {
-
if ($page) {
$vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', ''));
// Breadcrumb navigation
@@ -514,6 +469,8 @@ function forum_view(&$node, $teaser = FALSE, $page = FALSE) {
}
$node = node_prepare($node, $teaser);
+
+ $node->body .= theme('forum_topic_navigation', $node);
}
/**
@@ -1007,6 +964,51 @@ function theme_forum_icon($new_posts, $num_posts = 0, $comment_mode = 0, $sticky
return $output;
}
+/**
+ * Format the next/previous forum topic navigation links.
+ *
+ * @ingroup themeable
+ */
+function theme_forum_topic_navigation($node) {
+ $output = '';
+
+ // get previous and next topic
+ $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
+ $result = db_query(db_rewrite_sql($sql), $node->tid);
+
+ while ($topic = db_fetch_object($result)) {
+ if ($stop == 1) {
+ $next = new StdClass();
+ $next->nid = $topic->nid;
+ $next->title = $topic->title;
+ break;
+ }
+ if ($topic->nid == $node->nid) {
+ $stop = 1;
+ }
+ else {
+ $prev = new StdClass();
+ $prev->nid = $topic->nid;
+ $prev->title = $topic->title;
+ }
+ }
+
+ if ($prev || $next) {
+ $output .= '<div class="forum-topic-navigation">';
+
+ if ($prev) {
+ $output .= l(t('‹ ') . check_plain($prev->title), 'node/'. $prev->nid, array('class' => 'topic-previous', 'title' => t('Go to previous forum topic')));
+ }
+ if ($next) {
+ $output .= l(check_plain($next->title) . t(' ›'), 'node/'. $next->nid, array('class' => 'topic-next', 'title' => t('Go to next forum topic')));
+ }
+
+ $output .= '</div>';
+ }
+
+ return $output;
+}
+
function _forum_user_last_visit($nid) {
global $user;
static $history = array();
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 8e957fe74..0b77a8813 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -400,50 +400,6 @@ function forum_block($op = 'list', $delta = 0, $edit = array()) {
}
}
-/**
- * Implementation of hook_link().
- */
-function forum_link($type, $node = 0, $main = 0) {
- global $user;
-
- $links = array();
-
- if (!$main && $type == 'node' && $node->type == 'forum') {
- // get previous and next topic
-
- $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
- $sql = db_rewrite_sql($sql);
- $result = db_query($sql, $node->tid);
-
- while ($topic = db_fetch_object($result)) {
- if ($stop == 1) {
- $next = new StdClass();
- $next->nid = $topic->nid;
- $next->title = $topic->title;
- break;
- }
- if ($topic->nid == $node->nid) {
- $stop = 1;
- }
- else {
- $prev = new StdClass();
- $prev->nid = $topic->nid;
- $prev->title = $topic->title;
- }
- }
-
- if ($prev) {
- $links[] = l(t('previous forum topic'), "node/$prev->nid", array('title' => check_plain($prev->title)));
- }
-
- if ($next) {
- $links[] = l(t('next forum topic'), "node/$next->nid", array('title' => check_plain($next->title)));
- }
- }
-
- return $links;
-}
-
function forum_term_path($term) {
return 'forum/'. $term->tid;
}
@@ -497,7 +453,6 @@ function forum_menu($may_cache) {
* Implementation of hook_view().
*/
function forum_view(&$node, $teaser = FALSE, $page = FALSE) {
-
if ($page) {
$vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', ''));
// Breadcrumb navigation
@@ -514,6 +469,8 @@ function forum_view(&$node, $teaser = FALSE, $page = FALSE) {
}
$node = node_prepare($node, $teaser);
+
+ $node->body .= theme('forum_topic_navigation', $node);
}
/**
@@ -1007,6 +964,51 @@ function theme_forum_icon($new_posts, $num_posts = 0, $comment_mode = 0, $sticky
return $output;
}
+/**
+ * Format the next/previous forum topic navigation links.
+ *
+ * @ingroup themeable
+ */
+function theme_forum_topic_navigation($node) {
+ $output = '';
+
+ // get previous and next topic
+ $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
+ $result = db_query(db_rewrite_sql($sql), $node->tid);
+
+ while ($topic = db_fetch_object($result)) {
+ if ($stop == 1) {
+ $next = new StdClass();
+ $next->nid = $topic->nid;
+ $next->title = $topic->title;
+ break;
+ }
+ if ($topic->nid == $node->nid) {
+ $stop = 1;
+ }
+ else {
+ $prev = new StdClass();
+ $prev->nid = $topic->nid;
+ $prev->title = $topic->title;
+ }
+ }
+
+ if ($prev || $next) {
+ $output .= '<div class="forum-topic-navigation">';
+
+ if ($prev) {
+ $output .= l(t('‹ ') . check_plain($prev->title), 'node/'. $prev->nid, array('class' => 'topic-previous', 'title' => t('Go to previous forum topic')));
+ }
+ if ($next) {
+ $output .= l(check_plain($next->title) . t(' ›'), 'node/'. $next->nid, array('class' => 'topic-next', 'title' => t('Go to next forum topic')));
+ }
+
+ $output .= '</div>';
+ }
+
+ return $output;
+}
+
function _forum_user_last_visit($nid) {
global $user;
static $history = array();