'. t('The following are configuration options for the ShareThis web service. You can add the ShareThis button to nodes and links in the services tab.', array('@sharethis' => 'http://sharethis.com', '@services' => url('admin/settings/service_links/services'))) .'
';
}
}
/**
* Implementation of hook_menu().
*/
function sharethis_menu() {
$items['admin/settings/service_links/sharethis'] = array(
'title' => 'ShareThis',
'description' => 'Configuration options for the ShareThis web service.',
'page callback' => 'drupal_get_form',
'page arguments' => array('sharethis_admin_settings'),
'access arguments' => array('administer service links'),
'type' => MENU_LOCAL_TASK,
'weight' => 10,
'file' => 'sharethis.admin.inc',
);
return $items;
}
/**
* Implementation of hook_service_links().
*
* See the Service Links module.
*/
function sharethis_service_links() {
// The main ShareThis button.
$links['sharethis'] = array(
'name' => 'ShareThis',
'description' => t('ShareThis makes sharing easy!'),
'link' => 'http://sharethis.com/post?url=&title=',
'icon' => drupal_get_path('module', 'sharethis') .'/images/' . variable_get('sharethis_icon', 'sharethis.png'),
'javascript' => drupal_get_path('module', 'sharethis') .'/sharethis.js',
'callback' => 'sharethis_service_links_callback',
);
// Construct the individual chicklets.
$chicklets = array(
'email' => array(
'name' => 'Email',
'description' => t('Send this post to a friend via Email.'),
),
'twitter' => array(
'name' => 'Twitter',
'description' => t('Share this post on Twitter.'),
),
);
foreach ($chicklets as $name => $chicklet) {
$links['sharethis-'. $name] = array(
'name' => $chicklet['name'],
'description' => $chicklet['description'],
'link' => 'http://sharethis.com/post?url=&title=',
'icon' => drupal_get_path('module', 'sharethis') ."/images/$name.gif",
'attributes' => array(
'class' => $name,
),
'javascript' => drupal_get_path('module', 'sharethis') .'/sharethis.js',
'callback' => 'sharethis_service_links_callback',
);
}
return $links;
}
/**
* Callback function from Service Links.
*/
function sharethis_service_links_callback($service, $context) {
static $added = FALSE;
if ($added == FALSE) {
$added = TRUE;
$code = variable_get('sharethis_code', '');
if (empty($code)) {
$code = 'http://w.sharethis.com/button/sharethis.js#publisher=00000000-0000-0000-0000-000000000000&type=website';
}
else {
$code = str_replace(array(''), array('', ''), $code);
}
drupal_set_html_head('');
}
$settings = array(
$service['attributes']['id'] => array(
'title' => $context['title'],
'url' => $context['url'],
'chicklet' => isset($service['attributes']['class']) ? $service['attributes']['class'] : FALSE,
),
);
drupal_add_js(array('sharethis' => $settings), 'setting');
}