summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addthis.css9
-rw-r--r--addthis.info6
-rw-r--r--addthis.module225
3 files changed, 207 insertions, 33 deletions
diff --git a/addthis.css b/addthis.css
index 80dd670..ea9c07c 100644
--- a/addthis.css
+++ b/addthis.css
@@ -1,6 +1,7 @@
-.addthis{
- display:inline;
- position:relative;
- top:2px;
+/* $Id$ */
+.addthis {
+ display:inline;
+ position:relative;
+ top:2px;
} \ No newline at end of file
diff --git a/addthis.info b/addthis.info
index 1d404a5..ffd7083 100644
--- a/addthis.info
+++ b/addthis.info
@@ -1,4 +1,4 @@
-; $ID$
+; $Id$
name = AddThis
-description = "Lets site users invite persons directly from their gmail, yahoo, hotmail or AOL address book."
-
+description = Lets site users invite persons directly from their gmail, yahoo, hotmail or AOL address book.
+core = 6.x \ No newline at end of file
diff --git a/addthis.module b/addthis.module
index ad1c985..8add799 100644
--- a/addthis.module
+++ b/addthis.module
@@ -1,37 +1,210 @@
<?php
+// $Id$
+/**
+* @file
+* Stand alone module file to handle AddThis button integration
+**/
+
+/**
+ * Implementation of hook_perm().
+ */
function addthis_perm() {
- //$perms = array('administer content types', 'administer nodes', 'access content', 'view revisions', 'revert revisions');
+ $perms[] = 'administer addthis';
+ $perms[] = 'view addthis';
+ return $perms;
+}
- foreach (node_get_types() as $type) {
- $name = check_plain($type->type);
- $perms[] = 'share '. $name .' content';
-
+/**
+ * Implementation of hook_nodeapi().
+ */
+function addthis_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
+ switch ($op) {
+ case 'view':
+ if (user_access('view addthis') and variable_get('addthis_display_in_links', '0')) {
+ $node->content['addthis'] = array(
+ '#value' => '<div class="addthis">'. _addthis_create_button() .'</div>',
+ '#weight' => 1,
+ );
+ }
+ break;
}
+}
- return $perms;
+/**
+ * Implementation of hook_menu().
+ */
+function addthis_menu() {
+ $items = array();
+
+ // Admin settings.
+ $items[] = array(
+ 'path' => 'admin/settings/addthis',
+ 'title' => t('AddThis module settings'),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('addthis_admin_settings'),
+ 'access' => user_access('administer addthis'),
+ 'description' => t('Set username and customize look and feel for <a href="http://www.addthis.com/">AddThis</a> button.'),
+ );
+
+ return $items;
}
-function addthis_link($type,$node=NULL, $teaser = FALSE) {
- global $base_url;
- $string = 'share '. $node->type .' content';
- drupal_add_css((drupal_get_path('module', 'addthis') .'/addthis.css'), $type = 'module', $media = 'all', $preprocess = TRUE);
- $links = array();
- $output .= '<script type="text/javascript">addthis_pub = "'.variable_get('addthis_user','tipzdigger').'";</script>
- <a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')" onmouseout="addthis_close()"
- onclick="return addthis_sendto()"><img
- src="http://s9.addthis.com/button1-share.gif" width="125" height="16"
- border="0" alt="" /></a><script type="text/javascript"
- src="http://s7.addthis.com/js/152/addthis_widget.js"></script>';
-
- if (!$teaser && user_access($string)) {
- $links['addthis'] = array(
- 'title' => '<div class="addthis" style="display:inline">'.$output.'</div>',
- 'href' => '#',
- 'html' => TRUE,
- );
- }
- return $links;
+/**
+ * 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 in node links'),
+ '#default_value' => variable_get('addthis_display_in_links', '0'),
+ '#description' => t('Display AddThis always at node links section.'),
+ );
+
+ $form['addthis_button_settings'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Button image settings'),
+ );
+ $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', 'border="0"'),
+ '#description' => t('Extra HTML attributes for img tag. Example: border="0"'),
+ );
+
+ $form['addthis_widget_settings'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Widget settings'),
+ );
+ $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);
}
+/**
+ * Implementation of hook_block().
+ */
+function addthis_block($op = 'list', $delta = 0) {
+ if ($op == 'list') {
+ $blocks[0]['info'] = t('AddThis button');
+ return $blocks;
+ }
+ else if ($op == 'view' && user_access('view addthis')) {
+ $block['subject'] = t('AddThis');
+ $block['content'] = _addthis_create_button();
+ return $block;
+ }
+}
+
+/**
+ * Internal function to generate code for AddThis button
+ *
+ * @return
+ * String containing html code for the button
+ */
+function _addthis_create_button() {
+ return ( sprintf('
+ <script type="text/javascript">
+ addthis_pub = \'%s\';
+ addthis_logo = \'%s\';
+ addthis_logo_background = \'%s\';
+ addthis_logo_color = \'%s\';
+ addthis_brand = \'%s\';
+ addthis_options = \'%s\';
+ addthis_offset_top = \'%d\';
+ addthis_offset_left = \'%d\';
+ </script>
+ <a href="http://www.addthis.com/bookmark.php"
+ onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')"
+ onmouseout="addthis_close()"
+ onclick="return addthis_sendto()"><img src="%s" width="%d" height="%d" %s /></a>
+ <script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
+ ',
+ variable_get('addthis_user', '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'),
+ 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', 'border="0"')
+ ));
+}