Issue #2329783 by lauriii, jamesquinton | davidhernandez: Move comment classes from preprocess to templates.
parent
392522c083
commit
e3e70445ca
|
@ -698,6 +698,7 @@ function template_preprocess_comment(&$variables) {
|
|||
'#account' => $account,
|
||||
);
|
||||
$variables['author'] = drupal_render($username);
|
||||
$variables['author_id'] = $comment->getOwnerId();
|
||||
$variables['new_indicator_timestamp'] = $comment->getChangedTime();
|
||||
$variables['created'] = format_date($comment->getCreatedTime());
|
||||
// Avoid calling format_date() twice on the same timestamp.
|
||||
|
@ -790,28 +791,8 @@ function template_preprocess_comment(&$variables) {
|
|||
$variables['status'] = $comment->isPublished() ? 'published' : 'unpublished';
|
||||
}
|
||||
|
||||
// Gather comment classes.
|
||||
$variables['attributes']['class'][] = 'comment';
|
||||
// 'published' class is not needed, it is either 'preview' or 'unpublished'.
|
||||
if ($variables['status'] != 'published') {
|
||||
$variables['attributes']['class'][] = $variables['status'];
|
||||
}
|
||||
if (!$comment->getOwnerId()) {
|
||||
$variables['attributes']['class'][] = 'by-anonymous';
|
||||
}
|
||||
else {
|
||||
// @todo Use $entity->getAuthorId() after https://drupal.org/node/2078387
|
||||
if ($commented_entity instanceof EntityOwnerInterface && $comment->getOwnerId() == $commented_entity->getOwnerId()) {
|
||||
$variables['attributes']['class'][] = 'by-' . $commented_entity->getEntityTypeId() . '-author';
|
||||
}
|
||||
}
|
||||
// Add clearfix class.
|
||||
$variables['attributes']['class'][] = 'clearfix';
|
||||
|
||||
// Add comment author user ID. Necessary for the comment-by-viewer library.
|
||||
$variables['attributes']['data-comment-user-id'] = $comment->getOwnerId();
|
||||
|
||||
$variables['content_attributes']['class'][] = 'content';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,7 +66,16 @@
|
|||
* @ingroup themeable
|
||||
*/
|
||||
#}
|
||||
<article{{ attributes }}>
|
||||
{%
|
||||
set classes = [
|
||||
'comment',
|
||||
status != 'published' ? status,
|
||||
not author_id ? 'by-anonymous',
|
||||
author_id and author_id == commented_entity.getOwnerId() ? 'by-' ~ commented_entity.getEntityTypeId() ~ '-author',
|
||||
'clearfix',
|
||||
]
|
||||
%}
|
||||
<article{{ attributes.addClass(classes) }}>
|
||||
{% if title %}
|
||||
{{ title_prefix }}
|
||||
{% endif %}
|
||||
|
@ -100,7 +109,7 @@
|
|||
{{ permalink }}
|
||||
</footer>
|
||||
|
||||
<div{{ content_attributes }}>
|
||||
<div{{ content_attributes.addClass('content') }}>
|
||||
{{ content|without('links') }}
|
||||
|
||||
{% if signature %}
|
||||
|
|
|
@ -64,7 +64,16 @@
|
|||
* @see template_preprocess_comment()
|
||||
*/
|
||||
#}
|
||||
<article class="{{ attributes.class }} clearfix" role="article"{{ attributes|without('class', 'role') }}>
|
||||
{%
|
||||
set classes = [
|
||||
'comment',
|
||||
status != 'published' ? status,
|
||||
not author_id ? 'by-anonymous',
|
||||
author_id and author_id == commented_entity.getOwnerId() ? 'by-' ~ commented_entity.getEntityTypeId() ~ '-author',
|
||||
'clearfix',
|
||||
]
|
||||
%}
|
||||
<article role="article"{{ attributes.addClass(classes)|without('role') }}>
|
||||
|
||||
<header class="comment-header">
|
||||
<div class="attribution">
|
||||
|
@ -110,7 +119,7 @@
|
|||
{{ title_suffix }}
|
||||
{% endif %}
|
||||
|
||||
<div{{ content_attributes }}>
|
||||
<div{{ content_attributes.addClass('content') }}>
|
||||
{{ content|without('links') }}
|
||||
</div> <!-- /.content -->
|
||||
|
||||
|
|
Loading…
Reference in New Issue