You are here

function easy_social_comment_view in Easy Social 7.2

Implements hook_comment_view().

File

./easy_social.module, line 468
Easy social module.

Code

function easy_social_comment_view($comment, $view_mode, $langcode) {

  // Current node type for this comment.
  $node_type = str_replace('comment_node_', '', $comment->node_type);

  // Check if Easy Social is available for comments of this type.
  if (module_exists('comment') && variable_get_value("easy_social_{$node_type}_enable")) {
    if (variable_get_value("easy_social_comment_{$node_type}_enable")) {

      // Generate permalink for comment.
      $uri = entity_uri('comment', $comment);
      $uri['options'] += array(
        'absolute' => TRUE,
      );
      $permalink = url($uri['path'], $uri['options']);
      $node = node_load($comment->nid);

      // Load Easy Social stuff.
      $type = variable_get_value("easy_social_{$node_type}_type");
      $enabled_widgets = variable_get_value("easy_social_{$node_type}_widgets");
      $widgets = _easy_social_render_widgets($permalink, $comment->subject, $type, $enabled_widgets, $node->language);

      // Add Easy Social widgets.
      $comment->content["easy_social"] = array(
        '#theme' => 'easy_social_links',
        '#widgets' => $widgets,
        '#widget_type' => $type,
        '#lang' => $node->language,
        '#weight' => 100,
      );
    }
  }
}