66c81580b92aaad6fa3b46c58af324233f189d00
6 * Stand alone module file to handle AddThis button integration
10 * Implementation of hook_perm().
12 function addthis_perm() {
13 $perms[] = 'administer addthis';
14 $perms[] = 'view addthis';
19 * Implementation of hook_link().
21 function addthis_link($type, $node=NULL
, $teaser = FALSE
) {
24 if ($type === 'node' && user_access('view addthis')) {
25 if (($teaser && variable_get('addthis_display_in_teasers', '0')) ||
26 (!$teaser && variable_get('addthis_display_in_links', '0'))) {
27 $links['addthis'] = array(
28 'title' => _addthis_create_button($node, $teaser),
37 * Implementation of hook_menu().
39 function addthis_menu() {
42 $items['admin/settings/addthis'] = array(
43 'title' => t('AddThis'),
44 'description' => t('Set username and customize look and feel for <a href="http://www.addthis.com/">AddThis</a> button.'),
45 'page callback' => 'drupal_get_form',
46 'page arguments' => array('addthis_admin_settings'),
47 'access arguments' => array('administer addthis'),
48 'file' => 'addthis.admin.inc',
55 * Implementation of hook_block().
57 function addthis_block($op = 'list', $delta = 0) {
59 $blocks[0]['info'] = t('AddThis button');
62 else if ($op == 'view' && user_access('view addthis')) {
63 $block['subject'] = t('AddThis');
64 $block['content'] = _addthis_create_button();
70 * Internal function to generate code for AddThis button
73 * String containing html code for the button
75 function _addthis_create_button($node=NULL
, $teaser = FALSE
) {
76 global $_addthis_counter;
78 if ($_addthis_counter == 1) {
79 drupal_add_css((drupal_get_path('module', 'addthis') .
'/addthis.css'));
80 drupal_add_js(sprintf('
82 addthis_logo = \'%s\';
83 addthis_logo_background = \'%s\';
84 addthis_logo_color = \'%s\';
85 addthis_brand = \'%s\';
86 addthis_options = \'%s\';
88 variable_get('addthis_username', 'my-username'),
89 variable_get('addthis_logo', 'http://www.addthis.com/images/yourlogo.png'),
90 variable_get('addthis_logo_background', 'EFEFFF'),
91 variable_get('addthis_logo_color', '666699'),
92 variable_get('addthis_brand', 'Your Site'),
93 variable_get('addthis_options', 'favorites, email, digg, delicious, myspace, facebook, google, live, more')
97 if (variable_get('addthis_dropdown_disabled', '0')) {
99 <div class="addthis"><a href="http://www.addthis.com/bookmark.php"
100 onclick="addthis_url = location.href; addthis_title = document.title; return addthis_click(this);">
101 <img src="%s" width="%d" height="%d" %s /></a></div>
103 variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif'),
104 variable_get('addthis_image_width', '125'),
105 variable_get('addthis_image_height', '16'),
106 variable_get('addthis_image_attributes', 'alt=""')
111 <div class="addthis"><a href="http://www.addthis.com/bookmark.php"
112 onmouseover="return addthis_open(this, \'\', \'%s\', \'%s\')"
113 onmouseout="addthis_close()"
114 onclick="return addthis_sendto()"><img src="%s" width="%d" height="%d" %s /></a></div>
115 <script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
117 $teaser ?
url('node/'.
$node->nid
, array('absolute' => 1) ) : '[URL]',
118 $teaser ?
addslashes($node->title
) : '[TITLE]',
119 variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif'),
120 variable_get('addthis_image_width', '125'),
121 variable_get('addthis_image_height', '16'),
122 variable_get('addthis_image_attributes', 'alt=""')