Issue #2329769 by lauriii, mortendk | davidhernandez: Move forum classes from preprocess to templates.

8.0.x
Alex Pott 2014-10-02 14:29:32 +02:00
parent 3bb1ac5885
commit a5d36eff66
2 changed files with 12 additions and 7 deletions

View File

@ -683,26 +683,24 @@ function template_preprocess_forum_icon(&$variables) {
$variables['hot_threshold'] = \Drupal::config('forum.settings')->get('topics.hot_threshold');
if ($variables['num_posts'] > $variables['hot_threshold']) {
$icon_status_class = $variables['new_posts'] ? 'hot-new' : 'hot';
$variables['icon_status'] = $variables['new_posts'] ? 'hot-new' : 'hot';
$variables['icon_title'] = $variables['new_posts'] ? t('Hot topic, new comments') : t('Hot topic');
}
else {
$icon_status_class = $variables['new_posts'] ? 'new' : 'default';
$variables['icon_status'] = $variables['new_posts'] ? 'new' : 'default';
$variables['icon_title'] = $variables['new_posts'] ? t('New comments') : t('Normal topic');
}
if ($variables['comment_mode'] == CommentItemInterface::CLOSED || $variables['comment_mode'] == CommentItemInterface::HIDDEN) {
$icon_status_class = 'closed';
$variables['icon_status'] = 'closed';
$variables['icon_title'] = t('Closed topic');
}
if ($variables['sticky'] == 1) {
$icon_status_class = 'sticky';
$variables['icon_status'] = 'sticky';
$variables['icon_title'] = t('Sticky topic');
}
$variables['attributes']['class'][] = 'icon';
$variables['attributes']['class'][] = 'topic-status-' . $icon_status_class;
$variables['attributes']['title'] = $variables['icon_title'];
}

View File

@ -11,13 +11,20 @@
* - icon_title: Text alternative for the forum icon, same as above.
* - new_posts: '1' when this topic contains new posts, otherwise '0'.
* - first_new: '1' when this is the first topic with new posts, otherwise '0'.
* - icon_status: Indicates which status icon should be used.
*
* @see template_preprocess_forum_icon()
*
* @ingroup themeable
*/
#}
<div{{ attributes }}>
{%
set classes = [
'icon',
'topic-status-' ~ icon_status,
]
%}
<div{{ attributes.addClass(classes) }}>
{% if first_new -%}
<a id="new"></a>
{%- endif %}