function comment_goodness_comment_view in Comment goodness 7
Implements hook_comment_view().
File
- ./
comment_goodness.module, line 254 - Comment goodness provides newest to oldest comment sorting
Code
function comment_goodness_comment_view($comment, $view_mode, $langcode) {
// We only need to add the delete link if it's not there.
if (!isset($comment->content['links']['comment']['#links']['comment-delete']) && comment_goodness_delete_comment_access($comment)) {
$comment->content['links']['comment']['#links']['comment-delete'] = array(
'title' => t('delete'),
'href' => "comment/{$comment->cid}/delete-own",
'html' => TRUE,
);
}
$node = node_load($comment->nid);
if (variable_get('comment_expose_fields_' . $node->type, FALSE)) {
$account = user_load($comment->uid);
$uri = entity_uri('comment', $comment);
$uri['options'] += array(
'attributes' => array(
'class' => 'permalink',
'rel' => 'bookmark',
),
);
if (variable_get('comment_subject_field_' . $node->type, 1) == 1) {
if (!isset($comment->content['subject'])) {
$comment->content['subject'] = array(
'#type' => 'link',
'#title' => $comment->subject,
'#href' => $uri['path'],
'#options' => $uri['options'],
);
}
}
if (!isset($comment->content['author'])) {
$comment->content['author'] = array(
'#type' => 'item',
'#theme' => 'username',
'#account' => $account,
);
}
if (variable_get('user_signatures', 1) == 1 && !isset($comment->content['signature'])) {
$comment->content['signature'] = array(
'#type' => 'item',
'#markup' => !empty($comment->signature_format) ? check_markup($comment->signature, $comment->signature_format, $langcode) : check_plain($comment->signature),
);
}
if (theme_get_setting('toggle_comment_user_picture') && !isset($comment->content['picture'])) {
$comment->content['picture'] = array(
'#type' => 'item',
'#theme' => 'user_picture',
'#account' => $account,
);
}
if (!isset($comment->content['created'])) {
$comment->content['created'] = array(
'#type' => 'item',
'#markup' => format_date($comment->created, variable_get('comment_created_date_format_' . $node->type, 'medium')),
);
}
if (!isset($comment->content['changed'])) {
$comment->content['changed'] = array(
'#type' => 'item',
'#markup' => format_date($comment->created, variable_get('comment_changed_date_format_' . $node->type, 'medium')),
);
}
if (!isset($comment->content['new'])) {
$comment->content['new'] = array(
'#type' => 'item',
'#markup' => !empty($comment->new) ? t('new') : '',
);
}
if (!isset($comment->content['permalink'])) {
$comment->content['permalink'] = array(
'#type' => 'link',
'#title' => t('Permalink'),
'#href' => $uri['path'],
'#options' => $uri['options'],
);
}
if (!isset($comment->content['submitted'])) {
$date_type = variable_get('comment_created_date_format_' . $node->type, 'medium');
$submitted_string = _comment_goodness_get_submitted_string($date_type);
$comment->content['submitted'] = array(
'#type' => 'item',
'#markup' => t($submitted_string, array(
'!username' => theme('username', array(
'account' => $account,
)),
'!datetime' => format_date($comment->created, $date_type),
)),
);
}
}
}