function _addtoany_create_button in AddToAny Share Buttons 6.2
Same name and namespace in other branches
- 5.2 addtoany.module \_addtoany_create_button()
- 5.0 addtoany.module \_addtoany_create_button()
- 6.3 addtoany.module \_addtoany_create_button()
- 7 addtoany.module \_addtoany_create_button()
- 7.3 addtoany.module \_addtoany_create_button()
Internal function to generate code for AddToAny button
Return value
String containing HTML code for the button
4 calls to _addtoany_create_button()
- addtoany_block in ./
addtoany.module - Implementation of hook_block().
- addtoany_handler_field_addtoany_link::render in views/
addtoany_handler_field_addtoany_link.inc - addtoany_link in ./
addtoany.module - Implementation of hook_link().
- addtoany_nodeapi in ./
addtoany.module - Implementation of hook_nodeapi().
File
- ./
addtoany.module, line 166 - Standalone module file to handle AddToAny button integration
Code
function _addtoany_create_button($node = NULL, $teaser = FALSE) {
global $_addtoany_counter, $base_path;
$_addtoany_counter++;
if ($_addtoany_counter == 1) {
drupal_add_css(drupal_get_path('module', 'addtoany') . '/addtoany.css');
}
$disable_dropdown = variable_get('addtoany_dropdown_disabled', '0');
if (is_object($node)) {
$link_name = module_exists('page_title') ? page_title_page_get_title() : $node->title;
$link_url = url('node/' . $node->nid, array(
'absolute' => 1,
));
}
else {
// Front page
$link_name = module_exists('page_title') ? page_title_page_get_title() : variable_get('site_name', '');
$link_url = url('<front>', array(
'absolute' => 1,
));
}
$javascript = $disable_dropdown ? '' : _addtoany_create_script($_addtoany_counter, $link_name, $link_url);
$button_setting = variable_get('addtoany_image', 'share_save_171_16.png|171|16');
if ($button_setting == "custom") {
$button_image = variable_get('addtoany_custom_image', '');
$button_width = '';
$button_height = '';
}
else {
$button = explode('|', $button_setting);
$button_filename = $button[0];
$button_width = ' width="' . $button[1] . '"';
$button_height = ' height="' . $button[2] . '"';
$button_image = $base_path . drupal_get_path('module', 'addtoany') . '/images/' . $button_filename;
}
return sprintf('
<a%s href="http://www.addtoany.com/share_save?linkurl=%s&linkname=%s" id="da2a_%s"><img src="%s"%s%s %s/></a>
%s
', $disable_dropdown ? '' : ' class="a2a_dd"', rawurlencode($link_url), rawurlencode($link_name), $_addtoany_counter, $button_image, $button_width, $button_height, variable_get('addtoany_image_attributes', 'alt="Share/Save"'), $javascript);
}