summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVesa Palmu2009-11-13 22:25:54 (GMT)
committer Vesa Palmu2009-11-13 22:25:54 (GMT)
commitd222a229ed913e5bcfbcba80b307e15c980d31b9 (patch)
treecb965645e8fbbb2fa8d3b9970e9b1f0447232099
parent17c2ae5dcac5d793fff861ff8b5487360a314ff7 (diff)
Bringing HEAD up to date with D6 branch
-rw-r--r--README.txt56
-rw-r--r--addthis.admin.inc151
-rw-r--r--addthis.css7
-rw-r--r--addthis.info4
-rw-r--r--addthis.module248
-rw-r--r--addthis.views.inc38
-rw-r--r--addthis_handler_field_service_links.inc42
7 files changed, 393 insertions, 153 deletions
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..a299a92
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,56 @@
+/* $Id$ */
+
+-- SUMMARY --
+
+Add This module provides Drupal integration to addthis.com link sharing service.
+
+Description from addthis.com:
+The AddThis button spreads your content across the Web by making it easier for your visitors to bookmark and
+share it with other people, again... and again... and again. This simple yet powerful button is very easy to
+install and provides valuable Analytics about the bookmarking and sharing activity of your users. AddThis helps
+your visitors create a buzz for your site and increase its popularity and ranking.
+
+AddThis is already on hundreds of thousands of websites including SAP, TIME Magazine, Oracle, Freewebs,
+Entertainment Weekly, Topix, Lonely Planet, MapQuest, MySpace, PGA Tour, Tower Records, Squidoo, Zappos, Funny
+or Die, FOX, ABC, CBS, Glamour, PostSecret, WebMD, American Idol, and ReadWriteWeb, just to name a few. Each
+month our button is displayed 20 billion times.
+
+-- REQUIREMENTS --
+
+None.
+
+-- INSTALLATION --
+
+Normal Drupal module installation, see http://drupal.org/node/70151 for further information.
+
+For link sharing statistics registration at http://addthis.com/ is required, but the module will work even without registration.
+
+-- CONFIGURATION --
+
+There are two ways of using the module:
+
+1) Display AddThis button in node links.
+* Go to Administer / Site configuration / AddThis.
+* Check Display on node pages.
+* Optionally check Display in node teasers.
+* If you want to limit AddThis visibility by content type go to Administer / Content management / Content types and choose a content type. Visibility can be set for each content type under Workflow settings.
+
+2) Use AddThis as a block.
+* Go to Site building / Blocks and make AddThis button block visible.
+
+-- CUSTOMIZATION --
+
+You have a number of options available at Administer / Site configuration / Addthis under Button image settings
+ and Widget settings. Image settings control the button image and widget controls the drop down and window that is opened when user clicks on a link sharing service. More information on how to customize your AddThis button can be found at http://addthis.com/help/customize/custom-button/
+
+If configuration options are not flexible enough for you it is also possible to override theme_addthis_button in your own theme.
+
+-- ROADMAP --
+
+Future development of this module will include at least RSS support. CCK and Views integration may be included in future releases. Drupal 5.x version will no longer get any new features. Drupal 7.x version will be released soon after D7 code freeze.
+
+-- CONTACT --
+
+Current maintainers:
+* Vesa Palmu (wesku) - http://drupal.org/user/75070
+
diff --git a/addthis.admin.inc b/addthis.admin.inc
new file mode 100644
index 0000000..005dc65
--- /dev/null
+++ b/addthis.admin.inc
@@ -0,0 +1,151 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Administration settings for AddThis button integration
+ */
+
+/**
+ * Administration settings form.
+ *
+ * @return
+ * The completed form definition.
+ */
+function addthis_admin_settings() {
+ $form = array();
+
+ $form['addthis_general_settings'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('General settings'),
+ );
+ $form['addthis_general_settings']['addthis_username'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Username'),
+ '#default_value' => variable_get('addthis_username', 'my-username'),
+ '#description' => t('Your username for <a href="http://www.addthis.com/">addthis.com</a>. Example: my-username'),
+ );
+ $form['addthis_general_settings']['addthis_display_in_links'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Display on node pages'),
+ '#default_value' => variable_get('addthis_display_in_links', '0'),
+ '#description' => t('Display an AddThis button always on a node page\'s links section.'),
+ );
+ $form['addthis_general_settings']['addthis_display_in_teasers'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Display in node teasers'),
+ '#default_value' => variable_get('addthis_display_in_teasers', '0'),
+ '#description' => t('Display an AddThis button in the node teasers.'),
+ );
+
+ $form['addthis_button_settings'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Button image settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['addthis_button_settings']['addthis_image'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Button image url'),
+ '#default_value' => variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif'),
+ '#description' => t('URL for small image in the button. Example: http://s9.addthis.com/button1-share.gif'),
+ );
+ $form['addthis_button_settings']['addthis_image_secure'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Button image url for secure https connection'),
+ '#default_value' => variable_get('addthis_image_secure', 'https://secure.addthis.com/button1-share.gif'),
+ '#description' => t('This is only required if your site uses secure https connections. Example: https://secure.addthis.com/button1-share.gif'),
+ );
+ $form['addthis_button_settings']['addthis_image_width'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Button image width'),
+ '#default_value' => variable_get('addthis_image_width', '125'),
+ '#description' => t('Width for button image. Example: 125'),
+ );
+ $form['addthis_button_settings']['addthis_image_height'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Button image height'),
+ '#default_value' => variable_get('addthis_image_height', '16'),
+ '#description' => t('Height for button image. Example: 16'),
+ );
+ $form['addthis_button_settings']['addthis_image_attributes'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Button image HTML attributes'),
+ '#default_value' => variable_get('addthis_image_attributes', 'alt=""'),
+ '#description' => t('Extra HTML attributes for img tag. Example: alt=""'),
+ );
+
+ $form['addthis_widget_settings'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Widget settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['addthis_widget_settings']['addthis_dropdown_disabled'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Disable dropdown'),
+ '#default_value' => variable_get('addthis_dropdown_disabled', '0'),
+ '#description' => t('You can disable the dropdown for selecting where to share your link and use a pop-up window instead. This can be useful if the button is for example located next to a flash object.'),
+ );
+ $form['addthis_widget_settings']['addthis_logo'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Logo url'),
+ '#default_value' => variable_get('addthis_logo', 'http://www.addthis.com/images/yourlogo.png'),
+ '#description' => t('The logo to display on the popup window (about 200x50 pixels). The popup window is show when the user selects the \'More\' choice. Example: http://www.your-website.com/img/mylogo.gif'),
+ );
+ $form['addthis_widget_settings']['addthis_logo_background'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Logo background color'),
+ '#default_value' => variable_get('addthis_logo_background', 'EFEFFF'),
+ '#description' => t('The color to use as a background around the logo in the popup. Example: EFEFEF'),
+ );
+ $form['addthis_widget_settings']['addthis_logo_color'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Logo text color'),
+ '#default_value' => variable_get('addthis_logo_color', '666699'),
+ '#description' => t('The color to use for the text next to the logo in the popup. Example: 666666'),
+ );
+ $form['addthis_widget_settings']['addthis_brand'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Brand text'),
+ '#default_value' => variable_get('addthis_brand', ''),
+ '#description' => t('The brand name to display in the drop-down (top right). Example: My Website. Leave blank to use the site_name variable, currently set to !site_name', array('!site_name' => variable_get('site_name', 'Drupal'))),
+ );
+ $form['addthis_widget_settings']['addthis_options'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Options'),
+ '#default_value' => variable_get('addthis_options', 'favorites, email, digg, delicious, myspace, facebook, google, live, more'),
+ '#description' => t('A comma-separated ordered list of options to include in the drop-down. Example: favorites, email, digg, delicious, more<br/>Currently supported options:<br/>
+ aim, aolfav, ask, backflip, ballhype, blinklist, blogmarks, bluedot, buzz, delicious, digg, diigo, email, facebook, favorites, fark, feedmelinks, friendfeed, furl, google, kaboodle, kirtsy, linkedin, live, magnolia, misterwong, mixx, multiply, myweb, myspace, netvous, newsvine, pownce, propeller, reddit, segnalo, sharedstuff, slashdot, spurl, stumbleupon, stylehive, tailrank, technorati, thisnext, twitter, yardbarker, yahoobkm, more<br />
+ The most up-to-date list can be found <a href="!url">here</a>.', array('!url' => url('http://addthis.com/customization.php'))),
+ );
+ $form['addthis_widget_settings']['addthis_offset_top'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Offset top'),
+ '#default_value' => variable_get('addthis_offset_top', '2'),
+ '#description' => t('Vertical offset for the drop-down window (in pixels). Example: 2'),
+ );
+ $form['addthis_widget_settings']['addthis_offset_left'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Offset top'),
+ '#default_value' => variable_get('addthis_offset_left', '2'),
+ '#description' => t('Horizontal offset for the drop-down window (in pixels). Example: 2'),
+ );
+ $form['addthis_widget_settings']['addthis_disable_flash'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Disable Flash cookie'),
+ '#default_value' => variable_get('addthis_disable_flash', '0'),
+ '#description' => t('AddThis.com uses Flash cookies by default to <a href="http://www.addthis.com/blog/2009/01/05/the-addthis-flash-cookie-we-need-your-feedback/">provide more accurate tracking information</a>. Some people consider this <a href="http://drupal.org/node/364078">a privacy concern</a> and Flash cookies can be replaced with normal ones by checking this checkbox.'),
+ );
+ $form['addthis_widget_settings']['addthis_widget_version'] = array(
+ '#type' => 'select',
+ '#title' => t('Widget Version'),
+ '#default_value' => variable_get('addthis_widget_version', '152'),
+ '#options' => array(
+ 152 => t('152 - Uses a popup window for the more option'),
+ 200 => t('200 - Adds lightbox support for the more option')
+ ),
+ '#description' => t('The version of the addthis widget to use.'),
+ );
+ return system_settings_form($form);
+} \ No newline at end of file
diff --git a/addthis.css b/addthis.css
index ea9c07c..ff64292 100644
--- a/addthis.css
+++ b/addthis.css
@@ -2,6 +2,9 @@
.addthis {
display:inline;
- position:relative;
- top:2px;
+}
+
+.addthis img {
+ vertical-align: bottom;
+ margin-bottom: 2px;
} \ No newline at end of file
diff --git a/addthis.info b/addthis.info
index 4876bef..e255e29 100644
--- a/addthis.info
+++ b/addthis.info
@@ -1,6 +1,4 @@
; $Id$
name = AddThis
-package = Other
description = Creates AddThis button as a block, to be used in themes and to node links.
-core = 7.x
-files[] = addthis.module \ No newline at end of file
+core = 6.x \ No newline at end of file
diff --git a/addthis.module b/addthis.module
index 2c42757..c715a8d 100644
--- a/addthis.module
+++ b/addthis.module
@@ -22,7 +22,9 @@ function addthis_link($type, $node=NULL, $teaser = FALSE) {
$links = array();
if ($type === 'node' && user_access('view addthis')) {
- if (! $teaser || variable_get('addthis_display_in_teasers', '1')) {
+ if (($node && variable_get('addthis_nodetype_' . $node->type, 1)) &&
+ (($teaser && variable_get('addthis_display_in_teasers', '0')) ||
+ (!$teaser && variable_get('addthis_display_in_links', '0')))) {
$links['addthis'] = array(
'title' => _addthis_create_button($node, $teaser),
'html' => TRUE,
@@ -39,12 +41,12 @@ function addthis_menu() {
$items = array();
$items['admin/settings/addthis'] = array(
- 'title' => 'AddThis module settings',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('addthis_admin_settings'),
- 'description' => 'Set username and customize look and feel for <a href="http://www.addthis.com/">AddThis</a> button.',
- 'access arguments' => array('addthis_admin_settings'),
- 'menu_name' => 'settings',
+ 'title' => 'AddThis',
+ 'description' => 'Set username and customize look and feel for <a href="http://www.addthis.com/">AddThis</a> button.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('addthis_admin_settings'),
+ 'access arguments' => array('administer addthis'),
+ 'file' => 'addthis.admin.inc',
);
return $items;
@@ -66,6 +68,44 @@ function addthis_block($op = 'list', $delta = 0) {
}
/**
+ * Implementation of hook_form_alter().
+ */
+function addthis_form_alter(&$form, $form_state, $form_id) {
+ if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
+ $form['workflow']['addthis_nodetype'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Show AddThis button on this type of node'),
+ '#default_value' => variable_get('addthis_nodetype_' . $form['#node_type']->type, 1),
+ '#description' => t('Select whether the AddThis button should be shown or not on this type of node.'),
+ );
+ }
+}
+
+/**
+ * Implementation of hook_theme().
+ */
+function addthis_theme() {
+ return array(
+ 'addthis_button' => array(
+ 'arguments' => array(
+ 'node' => NULL,
+ 'teaser' => NULL,
+ ),
+ ),
+ );
+}
+
+/**
+ * Implementation of hook_views_api().
+ */
+function addthis_views_api() {
+ return array(
+ 'api' => 2,
+ 'path' => drupal_get_path('module', 'addthis'),
+ );
+}
+
+/**
* Internal function to generate code for AddThis button
*
* @return
@@ -74,6 +114,10 @@ function addthis_block($op = 'list', $delta = 0) {
function _addthis_create_button($node=NULL, $teaser = FALSE) {
global $_addthis_counter;
$_addthis_counter++;
+ $brand = variable_get('addthis_brand', '');
+ if ($brand == '') {
+ $brand = variable_get('site_name', 'Drupal');
+ }
if ($_addthis_counter == 1) {
drupal_add_css((drupal_get_path('module', 'addthis') .'/addthis.css'));
drupal_add_js(sprintf('
@@ -83,153 +127,61 @@ function _addthis_create_button($node=NULL, $teaser = FALSE) {
addthis_logo_color = \'%s\';
addthis_brand = \'%s\';
addthis_options = \'%s\';
- addthis_offset_top = \'%d\';
- addthis_offset_left = \'%d\';
+ addthis_disable_flash = \'%s\';
',
- variable_get('addthis_username', 'my-username'),
- variable_get('addthis_logo', 'http://www.addthis.com/images/yourlogo.png'),
- variable_get('addthis_logo_background', 'EFEFFF'),
- variable_get('addthis_logo_color', '666699'),
- variable_get('addthis_brand', 'Your Site'),
- variable_get('addthis_options', 'favorites, email, digg, delicious, myspace, facebook, google, live, more'),
- variable_get('addthis_offset_top', '2'),
- variable_get('addthis_offset_left', '2')
+ addslashes(variable_get('addthis_username', 'my-username')),
+ addslashes(variable_get('addthis_logo', 'http://www.addthis.com/images/yourlogo.png')),
+ addslashes(variable_get('addthis_logo_background', 'EFEFFF')),
+ addslashes(variable_get('addthis_logo_color', '666699')),
+ addslashes($brand),
+ addslashes(variable_get('addthis_options', 'favorites, email, digg, delicious, myspace, facebook, google, live, more')),
+ variable_get('addthis_options', FALSE) ? 'true' : 'false'
), 'inline');
}
- return ( sprintf('
- <div class="addthis"><a href="http://www.addthis.com/bookmark.php"
- onmouseover="return addthis_open(this, \'\', \'%s\', \'%s\')"
- onmouseout="addthis_close()"
- onclick="return addthis_sendto()"><img src="%s" width="%d" height="%d" %s /></a></div>
- <script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
- ',
- $teaser ? url('node/'. $node->nid, NULL, NULL, TRUE) : '[URL]',
- $teaser ? addslashes($node->title) : '[TITLE]',
- variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif'),
- variable_get('addthis_image_width', '125'),
- variable_get('addthis_image_height', '16'),
- variable_get('addthis_image_attributes', 'alt=""')
- ));
+ return theme('addthis_button', $node, $teaser);
}
/**
- * Administration settings form.
- *
- * @return
- * The completed form definition.
+ * Theme the AddThis button.
*/
-function addthis_admin_settings() {
- $form = array();
-
- $form['addthis_general_settings'] = array(
- '#type' => 'fieldset',
- '#title' => t('General settings'),
- );
- $form['addthis_general_settings']['addthis_username'] = array(
- '#type' => 'textfield',
- '#title' => t('Username'),
- '#default_value' => variable_get('addthis_username', 'my-username'),
- '#description' => t('Your username for <a href="http://www.addthis.com/">addthis.com</a>. Example: my-username'),
- );
- $form['addthis_general_settings']['addthis_display_in_links'] = array(
- '#type' => 'checkbox',
- '#title' => t('Display on node pages'),
- '#default_value' => variable_get('addthis_display_in_links', '0'),
- '#description' => t('Display an AddThis button always on a node page\'s links section.'),
- );
- $form['addthis_general_settings']['addthis_display_in_teasers'] = array(
- '#type' => 'checkbox',
- '#title' => t('Display in node teasers'),
- '#default_value' => variable_get('addthis_display_in_teasers', '0'),
- '#description' => t('Display an AddThis button in the node teasers.'),
- );
-
- $form['addthis_button_settings'] = array(
- '#type' => 'fieldset',
- '#title' => t('Button image settings'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- );
- $form['addthis_button_settings']['addthis_image'] = array(
- '#type' => 'textfield',
- '#title' => t('Button image url'),
- '#default_value' => variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif'),
- '#description' => t('URL for small image in the button. Example: http://s9.addthis.com/button1-share.gif'),
- );
- $form['addthis_button_settings']['addthis_image_width'] = array(
- '#type' => 'textfield',
- '#title' => t('Button image width'),
- '#default_value' => variable_get('addthis_image_width', '125'),
- '#description' => t('Width for button image. Example: 125'),
- );
- $form['addthis_button_settings']['addthis_image_height'] = array(
- '#type' => 'textfield',
- '#title' => t('Button image height'),
- '#default_value' => variable_get('addthis_image_height', '16'),
- '#description' => t('Height for button image. Example: 16'),
- );
- $form['addthis_button_settings']['addthis_image_attributes'] = array(
- '#type' => 'textfield',
- '#title' => t('Button image HTML attributes'),
- '#default_value' => variable_get('addthis_image_attributes', 'alt=""'),
- '#description' => t('Extra HTML attributes for img tag. Example: alt=""'),
- );
+function theme_addthis_button($node, $teaser) {
+ // Fix IE's bug.
+ if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
+ drupal_add_link(array(
+ 'rel' => 'stylesheet',
+ 'type' => 'text/css',
+ 'href' => "http://s7.addthis.com/static/r07/widget02.css",
+ ));
+ }
- $form['addthis_widget_settings'] = array(
- '#type' => 'fieldset',
- '#title' => t('Widget settings'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- );
- $form['addthis_widget_settings']['addthis_dropdown_disabled'] = array(
- '#type' => 'checkbox',
- '#title' => t('Disable dropdown'),
- '#default_value' => variable_get('addthis_dropdown_disabled', '0'),
- '#description' => t('You can disable the dropdown for selecting where to share your link and use a pop-up window instead. This can be useful if the button is for example located next to a flash object.'),
- );
- $form['addthis_widget_settings']['addthis_logo'] = array(
- '#type' => 'textfield',
- '#title' => t('Logo url'),
- '#default_value' => variable_get('addthis_logo', 'http://www.addthis.com/images/yourlogo.png'),
- '#description' => t('The logo to display on the popup window (about 200x50 pixels). The popup window is show when the user selects the \'More\' choice. Example: http://www.your-website.com/img/mylogo.gif'),
- );
- $form['addthis_widget_settings']['addthis_logo_background'] = array(
- '#type' => 'textfield',
- '#title' => t('Logo background color'),
- '#default_value' => variable_get('addthis_logo_background', 'EFEFFF'),
- '#description' => t('The color to use as a background around the logo in the popup. Example: EFEFEF'),
- );
- $form['addthis_widget_settings']['addthis_logo_color'] = array(
- '#type' => 'textfield',
- '#title' => t('Logo text color'),
- '#default_value' => variable_get('addthis_logo_color', '666699'),
- '#description' => t('The color to use for the text next to the logo in the popup. Example: 666666'),
- );
- $form['addthis_widget_settings']['addthis_brand'] = array(
- '#type' => 'textfield',
- '#title' => t('Brand text'),
- '#default_value' => variable_get('addthis_brand', 'Your Site'),
- '#description' => t('The brand name to display in the drop-down (top right). Example: My Website'),
- );
- $form['addthis_widget_settings']['addthis_options'] = array(
- '#type' => 'textfield',
- '#title' => t('Options'),
- '#default_value' => variable_get('addthis_options', 'favorites, email, digg, delicious, myspace, facebook, google, live, more'),
- '#description' => t('A comma-separated ordered list of options to include in the drop-down. Example: favorites, email, digg, delicious, more<br/>Currently supported options:<br/>
- delicious, digg, email, favorites, facebook, fark, furl, google, live, myweb, myspace, newsvine, reddit, slashdot, stumbleupon, technorati, twitter, more'),
- );
- $form['addthis_widget_settings']['addthis_offset_top'] = array(
- '#type' => 'textfield',
- '#title' => t('Offset top'),
- '#default_value' => variable_get('addthis_offset_top', '2'),
- '#description' => t('Vertical offset for the drop-down window (in pixels). Example: 2'),
- );
- $form['addthis_widget_settings']['addthis_offset_left'] = array(
- '#type' => 'textfield',
- '#title' => t('Offset top'),
- '#default_value' => variable_get('addthis_offset_left', '2'),
- '#description' => t('Horizontal offset for the drop-down window (in pixels). Example: 2'),
- );
- return system_settings_form($form);
-} \ No newline at end of file
+ if (variable_get('addthis_dropdown_disabled', '0')) {
+ return ( 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" %s /></a>
+ ',
+ $_SERVER['HTTPS'] == 'on' ? addslashes(variable_get('addthis_image_secure', 'https://secure.addthis.com/button1-share.gif')) : addslashes(variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif')),
+ addslashes(variable_get('addthis_image_width', '125')),
+ addslashes(variable_get('addthis_image_height', '16')),
+ addslashes(variable_get('addthis_image_attributes', 'alt=""'))
+ ));
+ }
+ else {
+ return ( sprintf('
+ <a class="addthis-button" href="http://www.addthis.com/bookmark.php"
+ onmouseover="return addthis_open(this, \'\', \'%s\', \'%s\')"
+ onmouseout="addthis_close()"
+ onclick="return addthis_sendto()"><img src="%s" width="%d" height="%d" %s /></a>
+ <script type="text/javascript" src="%s/js/' . variable_get('addthis_widget_version', '152') . '/addthis_widget.js"></script>
+ ',
+ $teaser ? url('node/'. $node->nid, array('absolute' => 1) ) : '[URL]',
+ $teaser ? addslashes($node->title) : '[TITLE]',
+ $_SERVER['HTTPS'] == 'on' ? addslashes(variable_get('addthis_image_secure', 'https://secure.addthis.com/button1-share.gif')) : addslashes(variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif')),
+ addslashes(variable_get('addthis_image_width', '125')),
+ addslashes(variable_get('addthis_image_height', '16')),
+ variable_get('addthis_image_attributes', 'alt=""'),
+ $_SERVER['HTTPS'] == 'on' ? 'https://secure.addthis.com' : 'http://s7.addthis.com'
+ ));
+ }
+}
diff --git a/addthis.views.inc b/addthis.views.inc
new file mode 100644
index 0000000..9cb8ef1
--- /dev/null
+++ b/addthis.views.inc
@@ -0,0 +1,38 @@
+<?php
+// $Id$
+/**
+ * @file
+ * Provide views data and handlers for addthis.module
+ */
+
+/**
+ * Implementation of hook_views_data().
+ */
+function addthis_views_data() {
+ // We're registering the 'custom_teasers' table.
+ $data['node']['addthis'] = array(
+ 'title' => t('AddThis'),
+ 'help' => t('An <a href="http://www.addthis.com/">AddThis</a> button.'),
+ 'field' => array(
+ 'handler' => 'addthis_handler_field_service_links',
+ ),
+ );
+
+ return $data;
+}
+
+/**
+ * Implementation of hook_views_handlers().
+ */
+function addthis_views_handlers() {
+ return array(
+ 'info' => array(
+ 'path' => drupal_get_path('module', 'addthis'),
+ ),
+ 'handlers' => array(
+ 'addthis_handler_field_service_links' => array(
+ 'parent' => 'views_handler_field',
+ ),
+ ),
+ );
+} \ No newline at end of file
diff --git a/addthis_handler_field_service_links.inc b/addthis_handler_field_service_links.inc
new file mode 100644
index 0000000..02ac426
--- /dev/null
+++ b/addthis_handler_field_service_links.inc
@@ -0,0 +1,42 @@
+<?php
+// $Id$
+
+/**
+ * A handler to provide an AddThis field for a particular node.
+ *
+ * @ingroup views_field_handlers
+ */
+class addthis_handler_field_service_links extends views_handler_field {
+ function construct() {
+ parent::construct();
+ $this->additional_fields['nid'] = 'nid';
+ $this->additional_fields['title'] = 'title';
+ }
+
+ function query() {
+ $this->ensure_my_table();
+ $this->add_additional_fields();
+ }
+
+ function option_definition() {
+ $options = parent::option_definition();
+
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+
+ // Remove the alteration stuff
+ unset($form['alter']);
+ }
+
+ function render($values) {
+ if (user_access('view addthis')) {
+ $node = new stdClass();
+ $node->nid = $values->{$this->aliases['nid']};
+ $node->title = $values->{$this->aliases['title']};
+ return _addthis_create_button($node, TRUE);
+ }
+ }
+} \ No newline at end of file