function signature_forum_node_view in Signatures for Forums 7
Implementation of hook_node_view().
File
- ./
signature_forum.module, line 586 - Tweaks signatures in ways inspired by other traditional forum software:
Code
function signature_forum_node_view($node, $view_mode, $langcode) {
if (variable_get('user_signatures') && !empty($node->uid)) {
// Fast return if the signature is disabled per post.
if (isset($node->signature_forum_status) && !$node->signature_forum_status) {
return $node;
}
// Add signature_forum to the render array.
$user = user_load($node->uid);
$node->content['signature_forum'] = array(
'#signature' => check_markup($user->signature, $user->signature_format, '', TRUE),
'#theme' => 'user_signature',
'#pre_render' => array(
'signature_forum_pre_render_user_signature',
),
'#user' => $user,
);
$body = field_get_items('node', $node, 'body', $langcode);
if ($body) {
// Some body fields appear not to have a 'safe_value'.
if (!empty($body[0]['safe_value'])) {
$content = $body[0]['safe_value'];
}
else {
$content = $body[0]['value'];
}
$node->content['signature_forum']['#content_length'] = drupal_strlen(strip_tags($content));
}
else {
$node->content['signature_forum']['#content_length'] = 0;
}
$node->content['signature_forum']['#node'] = $node;
}
return $node;
}