diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index af1330e..7251d5e 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -978,9 +978,11 @@ function forum_preprocess_block(&$variables) { } /** - * Preprocesses variables for forums.tpl.php. + * Prepares variables for forums templates. * - * @param $variables + * Default template: forums.html.twig. + * + * @param array $variables * An array containing the following elements: * - forums: An array of all forum objects to display for the given taxonomy * term ID. If tid = 0 then all the top-level forums are displayed. @@ -994,23 +996,32 @@ function forum_preprocess_block(&$variables) { * - 3: Posts with the most comments first. * - 4: Posts with the least comments first. * - forum_per_page: The maximum number of topics to display per page. - * - * @see forums.tpl.php */ function template_preprocess_forums(&$variables) { if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) { if (!empty($variables['forums'])) { - $variables['forums'] = theme('forum_list', $variables); + $variables['forums'] = array( + '#theme' => 'forum_list', + '#forums' => $variables['forums'], + '#parents' => $variables['parents'], + '#tid' => $variables['tid'], + ); } else { - $variables['forums'] = ''; + $variables['forums'] = array(); } if ($variables['tid'] && array_search($variables['tid'], config('forum.settings')->get('containers')) === FALSE) { - $variables['topics'] = theme('forum_topic_list', $variables); + $variables['topics'] = array( + '#theme' => 'forum_topic_list', + '#tid' => $variables['tid'], + '#topics' => $variables['topics'], + '#sortby' => $variables['sortby'], + '#forum_per_page' => $variables['forum_per_page'], + ); } else { - $variables['topics'] = ''; + $variables['topics'] = array(); } // Provide separate template suggestions based on what's being output. Topic id is also accounted for. @@ -1031,24 +1042,23 @@ function template_preprocess_forums(&$variables) { } else { - $variables['forums'] = ''; - $variables['topics'] = ''; + $variables['forums'] = array(); + $variables['topics'] = array(); } } /** - * Preprocesses variables for forum-list.tpl.php. + * Prepares variables for forum list templates. + * + * Default template: forum-list.html.twig. * - * @param $variables + * @param array $variables * An array containing the following elements: * - forums: An array of all forum objects to display for the given taxonomy * term ID. If tid = 0 then all the top-level forums are displayed. * - parents: An array of taxonomy term objects that are ancestors of the * current term ID. * - tid: Taxonomy term ID of the current forum. - * - * @see forum-list.tpl.php - * @see theme_forum_list() */ function template_preprocess_forum_list(&$variables) { global $user; @@ -1080,22 +1090,26 @@ function template_preprocess_forum_list(&$variables) { } $variables['forums'][$id]->last_reply = theme('forum_submitted', array('topic' => $forum->last_post)); } - // Give meaning to $tid for themers. $tid actually stands for term id. + + $variables['pager'] = array( + '#theme' => 'pager', + ); + + // Give meaning to $tid for themers. $tid actually stands for term ID. $variables['forum_id'] = $variables['tid']; unset($variables['tid']); } /** - * Preprocesses variables for forum-topic-list.tpl.php. + * Prepares variables for forum topic list templates. + * + * Default template: forum-topic-list.html.twig. * - * @param $variables + * @param array $variables * An array containing the following elements: * - tid: Taxonomy term ID of the current forum. * - topics: An array of all the topics in the current forum. * - forum_per_page: The maximum number of topics to display per page. - * - * @see forum-topic-list.tpl.php - * @see theme_forum_topic_list() */ function template_preprocess_forum_topic_list(&$variables) { global $forum_topic_list_header; @@ -1112,7 +1126,14 @@ function template_preprocess_forum_topic_list(&$variables) { if (!empty($variables['topics'])) { $row = 0; foreach ($variables['topics'] as $id => $topic) { - $variables['topics'][$id]->icon = theme('forum_icon', array('new_posts' => $topic->new, 'num_posts' => $topic->comment_count, 'comment_mode' => $topic->comment_mode, 'sticky' => $topic->sticky, 'first_new' => $topic->first_new)); + $variables['topics'][$id]->icon = array( + '#theme' => 'forum_icon', + '#new_posts' => $topic->new, + '#num_posts' => $topic->comment_count, + '#comment_mode' => $topic->comment_mode, + '#sticky' => $topic->sticky, + '#first_new' => $topic->first_new, + ); $variables['topics'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even'; $row++; @@ -1149,13 +1170,17 @@ function template_preprocess_forum_topic_list(&$variables) { $variables['topic_id'] = $variables['tid']; unset($variables['tid']); - $variables['pager'] = theme('pager'); + $variables['pager'] = array( + '#theme' => 'pager', + ); } /** - * Preprocesses variables for forum-icon.tpl.php. + * Prepares variables for forum icon templates. * - * @param $variables + * Default template: forum-icon.html.twig. + * + * @param array $variables * An array containing the following elements: * - new_posts: Indicates whether or not the topic contains new posts. * - num_posts: The total number of posts in all topics. @@ -1163,9 +1188,6 @@ function template_preprocess_forum_topic_list(&$variables) { * or hidden. * - sticky: Indicates whether the topic is sticky. * - first_new: Indicates whether this is the first topic with new posts. - * - * @see forum-icon.tpl.php - * @see theme_forum_icon() */ function template_preprocess_forum_icon(&$variables) { $variables['hot_threshold'] = config('forum.settings')->get('topics.hot_threshold'); @@ -1187,20 +1209,22 @@ function template_preprocess_forum_icon(&$variables) { $variables['icon_class'] = 'sticky'; $variables['icon_title'] = t('Sticky topic'); } + + $variables['attributes']['class'][] = 'icon'; + $variables['attributes']['class'][] = 'topic-status-' . $variables['icon_class']; } /** - * Preprocesses variables for forum-submitted.tpl.php. + * Prepares variables for forum submission information templates. * * The submission information will be displayed in the forum list and topic * list. * - * @param $variables + * Default template: forum-submitted.html.twig. + * + * @param array $variables * An array containing the following elements: * - topic: The topic object. - * - * @see forum-submitted.tpl.php - * @see theme_forum_submitted() */ function template_preprocess_forum_submitted(&$variables) { $variables['author'] = isset($variables['topic']->uid) ? theme('username', array('account' => $variables['topic'])) : ''; diff --git a/core/modules/forum/templates/forum-icon.html.twig b/core/modules/forum/templates/forum-icon.html.twig new file mode 100644 index 0000000..e624567 --- /dev/null +++ b/core/modules/forum/templates/forum-icon.html.twig @@ -0,0 +1,27 @@ +{# +/** + * @file + * Default theme implementation to display a status icon for a forum post. + * + * Available variables: + * - new_posts: Indicates whether or not the topic contains new posts. + * - icon_class: The icon to display. May be one of 'hot', 'hot-new', 'new', + * 'default', 'closed', or 'sticky'. + * - icon_title: Text alternative for the forum icon. + * - first_new: Indicates whether this is the first topic with new posts. + * - attributes.class: List of classes that can be used to style contextually + * through CSS. It can be manipulated through the + * $variables['attributes']['class'] from preprocess functions. + * + * @see template_preprocess() + * @see template_preprocess_forum_icon() + * + * @ingroup themeable + */ +#} +
diff --git a/core/modules/forum/templates/forum-icon.tpl.php b/core/modules/forum/templates/forum-icon.tpl.php deleted file mode 100644 index 8b70eb3..0000000 --- a/core/modules/forum/templates/forum-icon.tpl.php +++ /dev/null @@ -1,26 +0,0 @@ - - diff --git a/core/modules/forum/templates/forum-list.html.twig b/core/modules/forum/templates/forum-list.html.twig new file mode 100644 index 0000000..fd55a77 --- /dev/null +++ b/core/modules/forum/templates/forum-list.html.twig @@ -0,0 +1,82 @@ +{# +/** + * @file + * Default theme implementation to display a list of forums and containers. + * + * Available variables: + * - forums: A collection of forums and containers to display. It is keyed to + * the numeric IDs of all child forums and containers. Each forum in forums + * contains: + * - is_container: A flag indicating if the forum can contain other + * forums. Otherwise, the forum can only contain topics. + * - depth: How deep the forum is in the current hierarchy. + * - zebra: 'even' or 'odd', used for row class. + * - icon_class: 'default' or 'new', used for forum icon class. + * - icon_title: Text alternative for the forum icon. + * - name: The name of the forum. + * - link: The URL to link to this forum. + * - description: The description field for the forum, containing: + * - value: The descriptive text for the forum. + * - new_topics: A flag indicating if the forum contains unread posts. + * - new_url: A URL to the forum's unread posts. + * - new_text: Text for the above URL, which tells how many new posts. + * - old_topics: A count of posts that have already been read. + * - num_posts: The total number of posts in the forum. + * - last_reply: Text representing the last time a forum was posted or + * commented in. + * - forum_id: Forum ID for the current forum. Parent to all items within the + * forums array. + * + * @see template_preprocess() + * @see template_preprocess_forum_list() + * + * @ingroup themeable + */ +#} +{{ 'Forum'|t }} | +{{ 'Topics'|t }} | +{{ 'Posts'|t }} | +{{ 'Last post'|t }} | +|||
---|---|---|---|---|---|---|
+ {#
+ 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.
+ #}
+ {% for i in 1..forum.depth if forum.depth > 0 %} {% endfor %}
+ {% endfor %}
+
+ {{ forum.icon_title }}
+
+
+ {% if forum.description.value %}
+ {{ forum.description.value }}
+ {% endif %}
+ {% for i in 1..forum.depth if forum.depth > 0 %} |
+ {% if forum.is_container == false %}
+
+ {{ forum.num_topics }}
+ {% if forum.new_topics == true %}
+ + {{ forum.new_text }} + {% endif %} + |
+ {{ forum.num_posts }} | +{{ forum.last_reply }} | + {% endif %} +
- | - | - | - |
---|---|---|---|
is_container ? 'colspan="4" class="container"' : 'class="forum"'; ?>>
-
- ', $forum->depth); ?>
-
- icon_title; ?>
-
-
- description->value): ?>
- description->value; ?>
-
- ', $forum->depth); ?>
- |
- is_container): ?>
-
- num_topics ?>
- new_topics): ?>
- - new_text; ?> - - |
- num_posts ?> | -last_reply ?> | - -
+ {{ topic.icon }}
+
+
+
+ {{ topic.title }}
+
+
+ {{ topic.created }}
+
+ |
+ {% if topic.moved %}
+ {{ topic.message }} | + {% else %} +
+ {{ topic.comment_count }}
+ {% if topic.new_replies %}
+ + {{ topic.new_text }} + {% endif %} + |
+ {{ topic.last_reply }} | + {% endif %} +
- icon; ?>
-
-
-
- title; ?>
-
-
- created; ?>
-
- |
- moved): ?>
- message; ?> | - -
- comment_count; ?>
- new_replies): ?>
- - new_text; ?> - - |
- last_reply; ?> | - -