You are here

function heartbeat_comments_widget in Heartbeat 6.4

Implementation of <attchement>_widget().

1 call to heartbeat_comments_widget()
heartbeat_comments_heartbeat_load in modules/heartbeat_comments/heartbeat_comments.module
Implementation of hook_heartbeat_load().

File

modules/heartbeat_comments/heartbeat_comments.module, line 316
heartbeat_comments.module Heartbeat comments can come with two possible

Code

function heartbeat_comments_widget($attachments, &$message) {
  $list = '<div id="heartbeat-comments-wrapper-' . $message->tuaid . '" class="heartbeat-comments-wrapper">';
  $extraCssClass = "heartbeat-comments-nocomments";
  if ($message->additions->comment_count > 0) {
    $extraCssClass = "heartbeat-comments-comments";
    $has_more = FALSE;
    $comments_per_page = HEARTBEAT_REACTIONS_PER_PAGE;
    if ($message->template->attachments['comment_comments'] && variable_get('comment_' . $message->additions->object_type, 2) > 0) {
      $comments_per_page = HEARTBEAT_NODE_COMMENTS_PER_PAGE;
    }
    if (!$message->additions->all_comments && $message->additions->comment_count > $comments_per_page) {
      $has_more = TRUE;
      $message->additions->reactions = array_slice($message->additions->reactions, 0, $comments_per_page);
    }
    if ($message->additions->comments_order == 'oldest_on_top') {
      $message->additions->reactions = array_reverse($message->additions->reactions);
    }
    $list .= theme('heartbeat_comments', $message->additions->reactions, $message->tuaid, $message->additions->node_comment, $has_more);
  }
  $list .= '</div>';
  $output = '';
  $output .= '<div class="heartbeat-comments heartbeat-comments-' . $message->additions->object_type . ' ' . $extraCssClass . '">';
  if ($message->additions->comments_position == 'up') {
    $output .= $list;
  }
  $output .= drupal_get_form('heartbeat_comments_form', $message->tuaid, $message->additions->node_comment, $message->nid);
  if ($message->additions->comments_position == 'down') {
    $output .= $list;
  }
  $output .= '</div>';
  return $output;
}