diff --git a/core/modules/forum/forum.admin.inc b/core/modules/forum/forum.admin.inc index 5171850..dc5405d 100644 --- a/core/modules/forum/forum.admin.inc +++ b/core/modules/forum/forum.admin.inc @@ -122,19 +122,10 @@ function forum_form_submit($form, &$form_state) { } /** - * Returns HTML for a forum form. - * - * By default this does not alter the appearance of a form at all, but is - * provided as a convenience for themers. - * - * @param $variables - * An associative array containing: - * - form: A render element representing the form. - * - * @ingroup themeable + * Preprocess variables for a forum form. */ -function theme_forum_form($variables) { - return drupal_render_children($variables['form']); +function template_preprocess_forum_form(&$variables) { + $variables['form'] = drupal_render_children($variables['form']); } /** diff --git a/core/modules/forum/templates/forum-form.html.twig b/core/modules/forum/templates/forum-form.html.twig new file mode 100644 index 0000000..63f13a0 --- /dev/null +++ b/core/modules/forum/templates/forum-form.html.twig @@ -0,0 +1,18 @@ +{# +/** + * @see + * Default theme implementation for a forum form. + * + * By default this does not alter the appearance of a form at all, but is + * provided as a convenience for themers. + * + * Available variables: + * - form: A render element representing the form. + * + * @see template_preprocess() + * @see template_preprocess_forum_form() + * + * @ingroup themeable + */ +#} +{{ form }} 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..ff14630 --- /dev/null +++ b/core/modules/forum/templates/forum-icon.html.twig @@ -0,0 +1,25 @@ +{# +/** + * @file + * Default theme implementation to display an appropriate 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: @TODO + * - first_new: Indicates whether this is the first topic with new posts. + * + * @see template_preprocess() + * @see template_preprocess_forum_icon() + * + * @ingroup themeable + */ +#} +
+ {% if first_new %}{% endif %} + + {{ icon_title }} + +
+ 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..46afb09 --- /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: An array of forums and containers to display. It is keyed to the + * numeric IDs of all child forums and containers. Each forum in forums + * contains: + * - forum.is_container: TRUE if the forum can contain other forums. 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.icon_class: 'default' or 'new' string used for forum icon class. + * - forum.icon_title: Text alternative for the forum icon. + * - forum.name: The name of the forum. + * - forum.link: The URL to link to this forum. + * - forum.description: The description of this forum. + * - forum.new_topics: TRUE if the forum contains unread posts. + * - forum.new_url: A URL to the forum's unread posts. + * - forum.new_text: Text for the above URL, which tells how many new posts. + * - forum.old_topics: A count of posts that have already been read. + * - forum.num_posts: The total number of posts in the forum. + * - 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. + * + * @TODO Replace this with existing theme functions: http://drupal.org/node/1812684 + * + * @see template_preprocess() + * @see template_preprocess_forum_list() + * + * @ingroup themeable + */ +#} + + + + + + + + + + + {% for child_id, forum in forums %} + + + {% if forum.is_container == false %} + + + + {% endif %} + + {% endfor %} + +
{{ '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 0..forum.depth %}
{% endfor %} +
+ {{ forum.icon_title }} +
+ + {% if forum.description %} +
{{ forum.description }}
+ {% endif %} + {% for i in 0..forum.depth %}
{% endfor %} +
+ {{ forum.num_topics }} + {% if forum.new_topics == true %} +
+ {{ forum.new_text }} + {% endif %} +
{{ forum.num_posts }}{{ forum.last_reply }}
diff --git a/core/modules/forum/templates/forum-list.tpl.php b/core/modules/forum/templates/forum-list.tpl.php deleted file mode 100644 index b169493..0000000 --- a/core/modules/forum/templates/forum-list.tpl.php +++ /dev/null @@ -1,77 +0,0 @@ -is_container: TRUE if the forum can contain other forums. 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->icon_class: 'default' or 'new' string used for forum icon class. - * - $forum->icon_title: Text alternative for the forum icon. - * - $forum->name: The name of the forum. - * - $forum->link: The URL to link to this forum. - * - $forum->description: The description of this forum. - * - $forum->new_topics: TRUE if the forum contains unread posts. - * - $forum->new_url: A URL to the forum's unread posts. - * - $forum->new_text: Text for the above URL, which tells how many new posts. - * - $forum->old_topics: A count of posts that have already been read. - * - $forum->num_posts: The total number of posts in the forum. - * - $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_forum_list() - * @see theme_forum_list() - * - * @ingroup themeable - */ -?> - - - - - - - - - - - $forum): ?> - - - is_container): ?> - - - - - - - -
is_container ? 'colspan="4" class="container"' : 'class="forum"'; ?>> - - ', $forum->depth); ?> -
- icon_title; ?> -
- - description): ?> -
description; ?>
- - ', $forum->depth); ?> -
- num_topics ?> - new_topics): ?> -
- new_text; ?> - -
num_posts ?>last_reply ?>
diff --git a/core/modules/forum/templates/forum-submitted.html.twig b/core/modules/forum/templates/forum-submitted.html.twig new file mode 100644 index 0000000..558904f --- /dev/null +++ b/core/modules/forum/templates/forum-submitted.html.twig @@ -0,0 +1,25 @@ +{# +/** + * @file + * Default theme implementation formats a forum post submission string. + * + * The submission string indicates when and by whom a topic was submitted. + * + * Available variables: + * - author: The author of the post. + * - time: How long ago the post was created. + * - topic: An object with the raw data of the post. Potentially unsafe. Be + * sure to clean this data before printing. + * + * @see template_preprocess() + * @see template_preprocess_forum_submitted() + * + * @ingroup themeable + */ +#} +{% if time %} + {{ 'By !author @time ago' | t({'@time': time, '!author': author}) }} +{% else %} + {{ 'n/a' | t }} +{% endif %} + diff --git a/core/modules/forum/templates/forum-submitted.tpl.php b/core/modules/forum/templates/forum-submitted.tpl.php deleted file mode 100644 index 18fea8f..0000000 --- a/core/modules/forum/templates/forum-submitted.tpl.php +++ /dev/null @@ -1,30 +0,0 @@ - - - - $time, - '!author' => $author, - )); ?> - - - - diff --git a/core/modules/forum/templates/forum-topic-list.html.twig b/core/modules/forum/templates/forum-topic-list.html.twig new file mode 100644 index 0000000..f81ca70 --- /dev/null +++ b/core/modules/forum/templates/forum-topic-list.html.twig @@ -0,0 +1,71 @@ +{# +/** + * @file + * Default 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 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.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.comment_count: 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. + * - topic.new_text: Text containing the translated, properly pluralized + * count. + * - topic.created: A string representing when the topic was posted. Safe + * to output. + * - topic.last_reply: An outputtable string representing when the topic was + * last replied to. + * - topic.timestamp: The raw timestamp this topic was posted. + * - topic_id: Numeric ID for the current forum topic. + * + * @see template_preprocess() + * @see template_preprocess_forum_topic_list() + * + * @ingroup themeable + */ +#} + + + {{ header }} + + + {% for topic in topics %} + + + + {% if topic.moved %} + + {% else %} + + + {% endif %} + + {% endfor %} + +
{{ topic.icon }} +
+ {{ topic.title }} +
+
+ {{ topic.created }} +
+
{{ topic.message }} + {{ topic.comment_count }} + {% if topic.new_replies %} +
+ {{ topic.new_text }} + {% endif %} +
{{ topic.last_reply }}
+{{ pager }} diff --git a/core/modules/forum/templates/forum-topic-list.tpl.php b/core/modules/forum/templates/forum-topic-list.tpl.php deleted file mode 100644 index 5130ed6..0000000 --- a/core/modules/forum/templates/forum-topic-list.tpl.php +++ /dev/null @@ -1,74 +0,0 @@ -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->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->comment_count: 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. - * - $topic->new_text: Text containing the translated, properly pluralized - * count. - * - $topic->created: A string representing when the topic was posted. Safe - * to output. - * - $topic->last_reply: An outputtable string representing when the topic was - * last replied to. - * - $topic->timestamp: The raw timestamp this topic was posted. - * - $topic_id: Numeric ID for the current forum topic. - * - * @see template_preprocess_forum_topic_list() - * @see theme_forum_topic_list() - * - * @ingroup themeable - */ -?> - - - - - - - - - moved): ?> - - - - - - - - -
- icon; ?> -
-
- title; ?> -
-
- created; ?> -
-
-
message; ?> - comment_count; ?> - new_replies): ?> -
- new_text; ?> - -
last_reply; ?>
- diff --git a/core/modules/forum/templates/forums.html.twig b/core/modules/forum/templates/forums.html.twig new file mode 100644 index 0000000..67a4539 --- /dev/null +++ b/core/modules/forum/templates/forums.html.twig @@ -0,0 +1,24 @@ +{# +/** + * @file + * Default theme implementation to display a forum. + * + * May contain forum containers as well as forum topics. + * + * Available variables: + * - forums: The forums to display (as processed by forum-list.html.twig). + * - topics: The topics to display (as processed by forum-topic-list.html.twig). + * - forums_defined: A flag to indicate that the forums are configured. + * + * @see template_preprocess() + * @see template_preprocess_forums() + * + * @ingroup themeable + */ +#} +{% if forums_defined %} +
+ {{ forums }} + {{ topics }} +
+{% endif %} diff --git a/core/modules/forum/templates/forums.tpl.php b/core/modules/forum/templates/forums.tpl.php deleted file mode 100644 index 6a0e02e..0000000 --- a/core/modules/forum/templates/forums.tpl.php +++ /dev/null @@ -1,24 +0,0 @@ - - -
- - -
-