Index: modules/forum/forum-list.tpl.php =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum-list.tpl.php,v retrieving revision 1.1 diff -u -p -r1.1 forum-list.tpl.php --- modules/forum/forum-list.tpl.php 22 Jul 2007 07:01:07 -0000 1.1 +++ modules/forum/forum-list.tpl.php 2 Aug 2007 17:32:50 -0000 @@ -2,15 +2,16 @@ // $Id /** * @file forum-list.tpl.php - * Default theme implementation to display a list of forums. + * Default theme implementation to display a list of forums and containers. * * Available variables: - * - $forums: An array of forums to display. + * - $forums: An array of forums and containers to display. * * Each $forum in $forums contains: * - $forum->is_container: Is TRUE if the forum can contain other forums. Is * FALSE if the forum can contain only topics. * - $forum->depth: How deep the forum is in the current hierarchy. + * - $forum->zebra: 'even' or 'odd' string used for row class. * - $forum->name: The name of the forum. * - $forum->link: The URL to link to this forum. * - $forum->description: The description of this forum. @@ -36,28 +37,20 @@ - - - - is_container): ?> - - - - - - - depth; $i++): ?> -
- '; ?> - + + is_container ? 'colspan="4" class="container"' : 'class="forum"'; ?>> + + ', $forum->depth); ?>
name; ?>
-
description; ?>
- - + description): ?> +
description; ?>
+ + ', $forum->depth); ?> + is_container): ?> num_topics ?> @@ -70,8 +63,6 @@ last_reply ?> - - Index: modules/forum/forum-topic-list.tpl.php =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum-topic-list.tpl.php,v retrieving revision 1.1 diff -u -p -r1.1 forum-topic-list.tpl.php --- modules/forum/forum-topic-list.tpl.php 22 Jul 2007 07:01:07 -0000 1.1 +++ modules/forum/forum-topic-list.tpl.php 2 Aug 2007 17:32:50 -0000 @@ -2,24 +2,22 @@ // $Id: forum-topic-list.tpl.php,v 1.1 2007/07/22 07:01:07 dries Exp $ /** * @file forum-topic-list.tpl.php - * * Theme implementation to display a list of forum topics. * * Available variables: - * * - $header: The table header. This is pre-generated with click-sorting * information. If you need to change this, @see template_preprocess_forum_topic_list(). * - $pager: The pager to display beneath the table. * - $topics: An array of topics to be displayed. * - * Each topic contains: - * + * Each $topic in $topics contains: * - $topic->icon: The icon to display. * - $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->description: If the topic has been moved, this contains an + * - $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. * - $topic->num_comments: The number of replies on this topic. * - $topic->new_replies: A flag to indicate whether there are unread comments. * - $topic->new_url: If there are unread replies, this is a link to them. @@ -38,13 +36,12 @@ - - + icon; ?> title; ?> moved): ?> - description; ?> + message; ?> num_comments; ?> @@ -57,7 +54,6 @@ last_reply; ?> - Index: modules/forum/forum.module =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v retrieving revision 1.411 diff -u -p -r1.411 forum.module --- modules/forum/forum.module 26 Jul 2007 06:48:03 -0000 1.411 +++ modules/forum/forum.module 2 Aug 2007 17:32:51 -0000 @@ -601,7 +601,6 @@ function _forum_new($tid) { */ function template_preprocess_forums(&$variables) { global $user; - // forum list, topics list, topic browser and 'add new topic' link $vid = variable_get('forum_nav_vocabulary', ''); $vocabulary = taxonomy_vocabulary_load($vid); @@ -630,8 +629,7 @@ function template_preprocess_forums(&$va $breadcrumb[] = array('path' => $_GET['q']); menu_set_location($breadcrumb); - $variables['forums_defined'] = count($variables['forums']) || count($variables['parents']); - if ($variables['forums_defined']) { + if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) { // Format the "post new content" links listing. $forum_types = array(); @@ -673,19 +671,27 @@ function template_preprocess_forums(&$va } // Provide separate template suggestions based on what's being output. Topic id is also accounted for. - // Check both variables to be safe. + // Check both variables to be safe then the inverse. Forums with topic ID's take precedence. if ($variables['forums'] && !$variables['topics']) { $variables['template_files'][] = 'forums-containers'; + $variables['template_files'][] = 'forums-'. $variables['tid']; $variables['template_files'][] = 'forums-containers-'. $variables['tid']; } - else { + elseif (!$variables['forums'] && $variables['topics']) { $variables['template_files'][] = 'forums-topics'; + $variables['template_files'][] = 'forums-'. $variables['tid']; $variables['template_files'][] = 'forums-topics-'. $variables['tid']; } + else { + $variables['template_files'][] = 'forums-'. $variables['tid']; + } } else { drupal_set_title(t('No forums defined')); + $variables['links'] = array(); + $variables['forums'] = ''; + $variables['topics'] = ''; } } @@ -702,24 +708,28 @@ function template_preprocess_forums(&$va */ function template_preprocess_forum_list(&$variables) { global $user; + $row = 0; // Sanitize each forum so that the template can safely print the data. foreach ($variables['forums'] as $id => $forum) { $variables['forums'][$id]->description = !empty($forum->description) ? filter_xss_admin($forum->description) : ''; $variables['forums'][$id]->link = url("forum/$forum->tid"); $variables['forums'][$id]->name = check_plain($forum->name); $variables['forums'][$id]->is_container = !empty($forum->container); + $variables['forums'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even'; + $row++; + + $variables['forums'][$id]->new_text = ''; + $variables['forums'][$id]->new_url = ''; + $variables['forums'][$id]->new_topics = 0; + $variables['forums'][$id]->old_topics = $forum->num_topics; if ($user->uid) { $variables['forums'][$id]->new_topics = _forum_topics_unread($forum->tid, $user->uid); if ($variables['forums'][$id]->new_topics) { - $variables['forums'][$id]->new_text = format_plural($variables['forums'][$id]->new_topics, '1 new', '@count new'); + $variables['forums'][$id]->new_text = t('!count new', array('!count' => $variables['forums'][$id]->new_topics)); $variables['forums'][$id]->new_url = url("forum/$forum->tid", array('fragment' => 'new')); } $variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics; } - else { - $variables['forums'][$id]->new_topics = 0; - $variables['forums'][$id]->old_topics = $forum->num_topics; - } $variables['forums'][$id]->last_reply = theme('forum_submitted', $forum->last_post); } } @@ -748,25 +758,30 @@ function template_preprocess_forum_topic } $variables['header'] = $header; - $rows = array(); if (!empty($variables['topics'])) { + $row = 0; foreach ($variables['topics'] as $id => $topic) { $variables['topics'][$id]->icon = theme('forum_icon', $topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky); + $variables['topics'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even'; + $row++; + $variables['topics'][$id]->title = l($topic->title, "node/$topic->nid"); + $variables['topics'][$id]->created = theme('forum_submitted', $topic); + $variables['topics'][$id]->last_reply = theme('forum_submitted', isset($topic->last_reply) ? $topic->last_reply : NULL); + + $variables['topics'][$id]->new_text = ''; + $variables['topics'][$id]->new_url = ''; + if ($topic->new_replies) { + $variables['topics'][$id]->new_text = t('!count new', array('!count' => $variables['forums'][$id]->new_topics)); + $variables['topics'][$id]->new_url = url("node/$topic->nid", array('fragment' => 'new')); + } + + $variables['topics'][$id]->moved = FALSE; + $variables['topics'][$id]->message = ''; if ($topic->tid != $variables['tid']) { $variables['topics'][$id]->moved = TRUE; $variables['topics'][$id]->title = check_plain($topic->title); - $variables['topics'][$id]->description = l(t('This topic has been moved'), "forum/$topic->tid"); - } - else { - $variables['topics'][$id]->moved = FALSE; - $variables['topics'][$id]->title = l($topic->title, "node/$topic->nid"); - if ($topic->new_replies) { - $variables['topics'][$id]->new_text = format_plural($topic->new_replies, '1 new', '@count new'); - $variables['topics'][$id]->new_url = url("node/$topic->nid", array('fragment' => 'new')); - } - $variables['topics'][$id]->created = theme('forum_submitted', $topic); - $variables['topics'][$id]->last_reply = theme('forum_submitted', $topic->last_reply); + $variables['topics'][$id]->message = l(t('This topic has been moved'), "forum/$topic->tid"); } } } Index: modules/forum/forums.tpl.php =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forums.tpl.php,v retrieving revision 1.2 diff -u -p -r1.2 forums.tpl.php --- modules/forum/forums.tpl.php 29 Jul 2007 17:28:23 -0000 1.2 +++ modules/forum/forums.tpl.php 2 Aug 2007 17:32:51 -0000 @@ -1,20 +1,19 @@