You are here

function theme_addthis_button in AddThis 6.2

Same name and namespace in other branches
  1. 6.3 addthis.module \theme_addthis_button()
  2. 7.2 addthis.module \theme_addthis_button()

Theme the AddThis button.

1 theme call to theme_addthis_button()
_addthis_create_button in ./addthis.module
Internal function to generate code for AddThis button

File

./addthis.module, line 182
Stand alone module file to handle AddThis button integration

Code

function theme_addthis_button($node, $teaser) {
  global $_addthis_counter;
  if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
    $secure = TRUE;
    $image_url = addslashes(check_plain(variable_get('addthis_image_secure', 'https://secure.addthis.com/button1-share.gif')));
  }
  else {
    $secure = FALSE;
    $image_url = addslashes(check_plain(variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif')));
  }

  // Fix IE's bug.
  if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
    $protocol = $secure ? 'https://' : 'http://';
    drupal_add_link(array(
      'rel' => 'stylesheet',
      'type' => 'text/css',
      'href' => $protocol . "s7.addthis.com/static/r07/widget02.css",
    ));
  }
  if (variable_get('addthis_dropdown_disabled', '0')) {
    $button = sprintf('
      <a class="addthis-button" href="http://www.addthis.com/bookmark.php"
        onclick="addthis_url   = location.href; addthis_title = document.title; return addthis_click(this);">
      <img src="%s" width="%d" height="%d" alt="%s" class="%s" /></a>', $image_url, variable_get('addthis_image_width', '125'), variable_get('addthis_image_height', '16'), trim(check_plain(strip_tags(variable_get('addthis_image_attributes_alt', 'share')))), trim(check_plain(strip_tags(variable_get('addthis_image_attributes_class', 'addthisimage')))));
  }
  else {
    $button = sprintf('
      <a class="addthis-button" href="http://www.addthis.com/bookmark.php"
        onfocus="return addthis_open(this, \'\', \'%s\', \'%s\')"
        onmouseover="return addthis_open(this, \'\', \'%s\', \'%s\')"
        onblur="addthis_close()"
        onmouseout="addthis_close()"
        onclick="return addthis_sendto()"><img src="%s" width="%d" height="%d" alt="%s" class="%s" /></a>', $teaser ? url('node/' . $node->nid, array(
      'absolute' => 1,
    )) : '[URL]', $teaser ? addslashes($node->title) : '[TITLE]', $teaser ? url('node/' . $node->nid, array(
      'absolute' => 1,
    )) : '[URL]', $teaser ? addslashes($node->title) : '[TITLE]', $image_url, variable_get('addthis_image_width', '125'), variable_get('addthis_image_height', '16'), trim(check_plain(strip_tags(variable_get('addthis_image_attributes_alt', 'share')))), trim(check_plain(strip_tags(variable_get('addthis_image_attributes_class', 'addthisimage')))));
    if ($_addthis_counter == 1) {
      $button .= sprintf('<script type="text/javascript" src="%s/js/%d/addthis_widget.js">', $secure ? 'https://secure.addthis.com' : 'http://s7.addthis.com', variable_get('addthis_widget_version', '152'));
      $button .= '</script>';
    }
  }
  return $button;
}