diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-07-26 06:48:03 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-07-26 06:48:03 +0000 |
commit | bec12a215d52a391f7e2a625092f5d0e33cba28f (patch) | |
tree | 0358e83e425b1ea2fddd82a7a3c4eff57ad96f28 | |
parent | 9299b401071cef4601c01776a743726c0f4dab06 (diff) | |
download | brdo-bec12a215d52a391f7e2a625092f5d0e33cba28f.tar.gz brdo-bec12a215d52a391f7e2a625092f5d0e33cba28f.tar.bz2 |
- Patch #158536 by dvessel: some more gentle massaging of template files. Trying to make it easier to discover the different template files.
-rw-r--r-- | modules/forum/forum-submitted.tpl.php (renamed from modules/forum/forum-format-topic.tpl.php) | 16 | ||||
-rw-r--r-- | modules/forum/forum.module | 46 | ||||
-rw-r--r-- | modules/forum/forum.pages.inc | 2 | ||||
-rw-r--r-- | modules/forum/forums.tpl.php (renamed from modules/forum/forum-display.tpl.php) | 10 |
4 files changed, 33 insertions, 41 deletions
diff --git a/modules/forum/forum-format-topic.tpl.php b/modules/forum/forum-submitted.tpl.php index f7eddf3b4..79580c3aa 100644 --- a/modules/forum/forum-format-topic.tpl.php +++ b/modules/forum/forum-submitted.tpl.php @@ -1,10 +1,10 @@ -<?php +<?php // $Id$ /** - * @file forum-format-topic.tpl.php + * @file forum-submitted.tpl.php * Default theme implementation to format a simple string indicated when and - * by whom a topic was posted. - * + * by whom a topic was submitted. + * * Available variables: * * - $author: The author of the post. @@ -12,14 +12,14 @@ * - $topic: An object with the raw data of the post. Unsafe, be sure * to clean this data before printing. * - * @see template_preprocess_forum_format_topic() - * @see theme_forum_format_topic() + * @see template_preprocess_forum_submitted() + * @see theme_forum_submitted() */ ?> -<?php if ($topic->timestamp): ?> +<?php if ($time): ?> <?php print t( '@time ago<br />by !author', array( - '@time' => $time, + '@time' => $time, '!author' => $author, )); ?> <?php else: ?> diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 2e7bddd64..0f306e104 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -33,8 +33,8 @@ function forum_help($path, $arg) { */ function forum_theme() { return array( - 'forum_display' => array( - 'file' => 'forum-display', + 'forums' => array( + 'file' => 'forums', 'arguments' => array('forums' => NULL, 'topics' => NULL, 'parents' => NULL, 'tid' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL), ), 'forum_list' => array( @@ -53,8 +53,8 @@ function forum_theme() { 'file' => 'forum-topic-navigation', 'arguments' => array('node' => NULL), ), - 'forum_format_topic' => array( - 'file' => 'forum-format-topic', + 'forum_submitted' => array( + 'file' => 'forum-submitted', 'arguments' => array('topic' => NULL), ), ); @@ -587,7 +587,7 @@ function _forum_new($tid) { } /** - * Process variables for forum-display.tpl.php + * Process variables for forums.tpl.php * * The $variables array contains the following arguments: * - $forums @@ -597,9 +597,9 @@ function _forum_new($tid) { * - $sortby * - $forum_per_page * - * @see forum-display.tpl.php + * @see forums.tpl.php */ -function template_preprocess_forum_display(&$variables) { +function template_preprocess_forums(&$variables) { global $user; // forum list, topics list, topic browser and 'add new topic' link @@ -675,12 +675,12 @@ function template_preprocess_forum_display(&$variables) { // Provide separate template suggestions based on what's being output. Topic id is also accounted for. // Check both variables to be safe. if ($variables['forums'] && !$variables['topics']) { - $variables['template_files'][] = 'forum-display-container'; - $variables['template_files'][] = 'forum-display-container-'. $variables['tid']; + $variables['template_files'][] = 'forums-containers'; + $variables['template_files'][] = 'forums-containers-'. $variables['tid']; } else { - $variables['template_files'][] = 'forum-display-topics'; - $variables['template_files'][] = 'forum-display-topics-'. $variables['tid']; + $variables['template_files'][] = 'forums-topics'; + $variables['template_files'][] = 'forums-topics-'. $variables['tid']; } } @@ -720,7 +720,7 @@ function template_preprocess_forum_list(&$variables) { $variables['forums'][$id]->new_topics = 0; $variables['forums'][$id]->old_topics = $forum->num_topics; } - $variables['forums'][$id]->last_reply = theme('forum_format_topic', $forum->last_post); + $variables['forums'][$id]->last_reply = theme('forum_submitted', $forum->last_post); } } @@ -765,8 +765,8 @@ function template_preprocess_forum_topic_list(&$variables) { $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_format_topic', $topic); - $variables['topics'][$id]->last_reply = theme('forum_format_topic', isset($topic->last_reply) ? $topic->last_reply : NULL); + $variables['topics'][$id]->created = theme('forum_submitted', $topic); + $variables['topics'][$id]->last_reply = theme('forum_submitted', $topic->last_reply); } } } @@ -844,22 +844,16 @@ function template_preprocess_forum_topic_navigation(&$variables) { } /** - * Process variables to format a topic for display in the forum list and topic list. + * Process variables to format submission info for display in the forum list and topic list. * * $variables will contain: $topic * - * @see forum-format-topic.tpl.php - * @see theme_forum_format_topic + * @see forum-submitted.tpl.php + * @see theme_forum_submitted */ -function template_preprocess_forum_format_topic(&$variables) { - if (empty($variables['topic']) || empty($variables['topic']->timestamp)) { - $variables['topic'] = new stdClass(); - $variables['topic']->timestamp = 0; - } - else { - $variables['time'] = format_interval(time() - $variables['topic']->timestamp); - $variables['author'] = theme('username', $variables['topic']); - } +function template_preprocess_forum_submitted(&$variables) { + $variables['author'] = isset($variables['topic']->uid) ? theme('username', $variables['topic']) : ''; + $variables['time'] = isset($variables['topic']->timestamp) ? format_interval(time() - $variables['topic']->timestamp) : ''; } function _forum_user_last_visit($nid) { diff --git a/modules/forum/forum.pages.inc b/modules/forum/forum.pages.inc index c508eaea8..d1fa160c8 100644 --- a/modules/forum/forum.pages.inc +++ b/modules/forum/forum.pages.inc @@ -20,5 +20,5 @@ function forum_page($tid = 0) { $topics = forum_get_topics($tid, $sortby, $forum_per_page); } - return theme('forum_display', $forums, $topics, $parents, $tid, $sortby, $forum_per_page); + return theme('forums', $forums, $topics, $parents, $tid, $sortby, $forum_per_page); } diff --git a/modules/forum/forum-display.tpl.php b/modules/forum/forums.tpl.php index e8ef8c1ea..1b8264a72 100644 --- a/modules/forum/forum-display.tpl.php +++ b/modules/forum/forums.tpl.php @@ -1,6 +1,6 @@ -<?php // $Id$ +<?php // $Id$ /** - * @file forum-display.tpl.php + * @file forums.tpl.php * Default theme implementation to display a forum, which may contain forum * containers as well as forum topics. * @@ -12,14 +12,12 @@ * - $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) * - * @see template_preprocess_forum_display() - * @see theme_forum_display() + * @see template_preprocess_forums() + * @see theme_forums() * */ ?> - <?php if ($forums_defined): ?> - <div id="forum"> <?php print theme('links', $links); ?> <?php print $forums; ?> |