You are here

function fblikebutton_link in Facebook Like Button 6.2

Implements of hook_link().

File

./fblikebutton.module, line 85
Adds Facebook's "Like" button to each selected node type. Adds a block with a global static value where users can "Like" the URL set by admins.

Code

function fblikebutton_link($type, $node = NULL, $teaser = FALSE) {
  global $user, $base_url, $language;
  $types = variable_get('fblikebutton_node_types', array());
  $fullnodedisplay = variable_get('fblikebutton_full_node_display', 0);
  $teaserdisplay = variable_get('fblikebutton_teaser_display', 0);
  $show = !empty($types[$node->type]) && user_access('access fblikebutton');

  // Thanks to corbacho for supplying the code for the $webpage_to_like variable...
  // (It was apparently throwing errors/notices the way I had it set up.)
  $webpage_to_like = url("node/{$node->nid}", array(
    'absolute' => TRUE,
  ));
  $likebutton_weight = variable_get('fblikebutton_weight', '0');
  $links = array();
  $conf = array(
    'layout' => variable_get('fblikebutton_layout', 'standard'),
    'action' => variable_get('fblikebutton_action', 'like'),
    'color_scheme' => variable_get('fblikebutton_color_scheme', 'light'),
    'show_faces' => variable_get('fblikebutton_show_faces', TRUE),
    'font' => variable_get('fblikebutton_font', 'arial'),
    'height' => variable_get('fblikebutton_iframe_height', '80'),
    'width' => variable_get('fblikebutton_iframe_width', '450'),
    'send' => variable_get('fblikebutton_send', 'true'),
    'other_css' => variable_get('fblikebutton_iframe_css', ''),
    'language' => variable_get('fblikebutton_language', 'en_US'),
  );

  // Link area
  if ($show && $teaser && $teaserdisplay == 2 || $show && !$teaser && $fullnodedisplay == 2) {
    $links['fblikebutton_field'] = array(
      'title' => _fblikebutton_field($webpage_to_like, $conf),
      'html' => TRUE,
    );
    return $links;
  }
}