diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/forum/forum-list.tpl.php | 39 | ||||
-rw-r--r-- | modules/forum/forum-topic-list.tpl.php | 14 | ||||
-rw-r--r-- | modules/forum/forum.module | 59 | ||||
-rw-r--r-- | modules/forum/forums.tpl.php | 5 |
4 files changed, 59 insertions, 58 deletions
diff --git a/modules/forum/forum-list.tpl.php b/modules/forum/forum-list.tpl.php index 70cf597a2..27419f838 100644 --- a/modules/forum/forum-list.tpl.php +++ b/modules/forum/forum-list.tpl.php @@ -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 @@ </tr> </thead> <tbody> - <?php // Keep a row count for striping. ?> - <?php $row = 0; ?> <?php foreach ($forums as $forum): ?> - <tr class="<?php print $row % 2 == 0 ? 'odd' : 'even';?>"> - <?php if ($forum->is_container): ?> - <td colspan="4" class="container"> - <?php else: ?> - <td class="forum"> - <?php endif; ?> - <?php /* Enclose the contents of this cell with X divs, where X is the - * depth this forum resides at. This will allow us to use CSS - * left-margin for indenting. - */ ?> - <?php $end_divs = ''; ?> - <?php for ($i = 0; $i < $forum->depth; $i++): ?> - <div class="indent"> - <?php $end_divs .= '</div>'; ?> - <?php endfor; ?> + <tr class="<?php print $forum->zebra; ?>"> + <td <?php print $forum->is_container ? 'colspan="4" class="container"' : 'class="forum"'; ?>> + <?php /* Enclose the contents of this cell with X divs, where X is the + * depth this forum resides at. This will allow us to use CSS + * left-margin for indenting. + */ ?> + <?php print str_repeat('<div class="indent">', $forum->depth); ?> <div class="name"><a href="<?php print $forum->link; ?>"><?php print $forum->name; ?></a></div> - <div class="description"><?php print $forum->description; ?></div> - <?php print $end_divs; ?> - </td> + <?php if ($forum->description): ?> + <div class="description"><?php print $forum->description; ?></div> + <?php endif; ?> + <?php print str_repeat('</div>', $forum->depth); ?> + </td> <?php if (!$forum->is_container): ?> <td class="topics"> <?php print $forum->num_topics ?> @@ -70,8 +63,6 @@ <td class="last-reply"><?php print $forum->last_reply ?></td> <?php endif; ?> </tr> - - <?php $row++; ?> <?php endforeach; ?> </tbody> </table> diff --git a/modules/forum/forum-topic-list.tpl.php b/modules/forum/forum-topic-list.tpl.php index 9da332d10..4b2aa48fc 100644 --- a/modules/forum/forum-topic-list.tpl.php +++ b/modules/forum/forum-topic-list.tpl.php @@ -2,24 +2,22 @@ // $Id$ /** * @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 @@ <tr><?php print $header; ?></tr> </thead> <tbody> - <?php $row = 0; ?> <?php foreach ($topics as $topic): ?> - <tr class="<?php print $row % 2 == 0 ? 'odd' : 'even';?>"> + <tr class="<?php print $topic->zebra;?>"> <td class="icon"><?php print $topic->icon; ?></td> <td class="title"><?php print $topic->title; ?></td> <?php if ($topic->moved): ?> - <td colspan="3"><?php print $topic->description; ?></td> + <td colspan="3"><?php print $topic->message; ?></td> <?php else: ?> <td class="replies"> <?php print $topic->num_comments; ?> @@ -57,7 +54,6 @@ <td class="last-reply"><?php print $topic->last_reply; ?> <?php endif; ?> </tr> - <?php $row++; ?> <?php endforeach; ?> </tbody> </table> diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 0f306e104..96b5c42ab 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -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(&$variables) { $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(&$variables) { } // 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(&$variables) { */ 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_list(&$variables) { } $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"); } } } diff --git a/modules/forum/forums.tpl.php b/modules/forum/forums.tpl.php index 0b8e1dfb6..28917ba4f 100644 --- a/modules/forum/forums.tpl.php +++ b/modules/forum/forums.tpl.php @@ -1,20 +1,19 @@ <?php // $Id$ /** * @file forums.tpl.php - * Default theme implementation to display a forum, which may contain forum + * Default theme implementation to display a forum which may contain forum * containers as well as forum topics. * * Variables available: - * * - $links: An array of links that allow a user to post new forum topics. * It may also contain a string telling a user they must log in in order * to post. * - $forums: The forums to display (as processed by forum-list.tpl.php) * - $topics: The topics to display (as processed by forum-topic-list.tpl.php) + * - $forums_defined: A flag to indicate that the forums are configured. * * @see template_preprocess_forums() * @see theme_forums() - * */ ?> <?php if ($forums_defined): ?> |