addthis_displays.addthis.inc in AddThis 7.4
Implements AddThis markup functions.
File
addthis_displays/addthis_displays.addthis.incView source
<?php
/**
* @file
* Implements AddThis markup functions.
*/
function addthis_displays_addthis_display_markup($display, $variables = NULL) {
return NULL;
}
/**
* Implements hook_addthis_display_markup__[display]().
*/
function addthis_displays_addthis_display_markup__addthis_basic_toolbox($options = array()) {
$addthis = AddThis::getInstance();
// Create a render array for the widget.
$element = array(
// Use #theme_wrappers to include the rendered children. Otherwise the
// result is an empty element like <div></div>.
'#theme' => 'addthis_wrapper',
'#tag' => 'div',
'#attributes' => array(
'class' => array(
'addthis_toolbox',
'addthis_default_style',
$options['#display']['settings']['buttons_size'],
$options['#display']['settings']['extra_css'],
),
),
);
$element['#attributes'] += $addthis
->getAddThisAttributesMarkup($options);
// Add the widget script.
$script_manager = AddThisScriptManager::getInstance();
$script_manager
->attachJsToElement($element);
$services = trim($options['#display']['settings']['share_services']);
$services = str_replace(' ', '', $services);
$services = explode(',', $services);
// All service elements
$items = array();
foreach ($services as $service) {
$items[$service] = array(
'#theme' => 'addthis_element',
'#tag' => 'a',
'#value' => '',
'#attributes' => array(
'class' => array(
'addthis_button_' . $service,
),
),
'#addthis_service' => $service,
);
// Add individual counters.
if (strpos($service, 'counter_') === 0) {
$items[$service]['#attributes']['class'] = array(
"addthis_{$service}",
);
}
// Basic implementations of bubble counter orientation.
// @todo Figure all the bubbles out and add them.
// Still missing: tweetme, hyves and stubleupon, google_plusone_badge.
//
$orientation = $options['#display']['settings']['counter_orientation'] == 'horizontal' ? TRUE : FALSE;
switch ($service) {
case 'linkedin_counter':
$items[$service]['#attributes'] += array(
'li:counter' => $orientation ? '' : 'top',
);
break;
case 'facebook_like':
$items[$service]['#attributes'] += array(
'fb:like:layout' => $orientation ? 'button_count' : 'box_count',
);
break;
case 'facebook_share':
$items[$service]['#attributes'] += array(
'fb:share:layout' => $orientation ? 'button_count' : 'box_count',
);
break;
case 'google_plusone':
$items[$service]['#attributes'] += array(
'g:plusone:size' => $orientation ? 'standard' : 'tall',
);
break;
case 'tweet':
$items[$service]['#attributes'] += array(
'tw:count' => $orientation ? 'horizontal' : 'vertical',
'tw:via' => AddThis::getInstance()
->getTwitterVia(),
);
break;
case 'bubble_style':
$items[$service]['#attributes']['class'] = array(
'addthis_counter',
'addthis_bubble_style',
);
break;
case 'pill_style':
$items[$service]['#attributes']['class'] = array(
'addthis_counter',
'addthis_pill_style',
);
break;
}
}
$element += $items;
return $element;
}
/**
* Implements hook_addthis_display_markup__[display]().
*/
function addthis_displays_addthis_display_markup__addthis_basic_button($options = array()) {
$addthis = AddThis::getInstance();
$settings = $options['#display']['settings'];
$addthis_image = variable_get('addthis_image_upload', '');
if ($addthis_image) {
$addthis_file = file_load($addthis_image);
$imguri = image_style_url("thumbnail", $addthis_file->uri);
$imgpath = file_create_url($imguri);
}
$button_img = 'http://s7.addthis.com/static/btn/sm-share-en.gif';
if (isset($settings['buttons_size']) && $settings['buttons_size'] == 'big') {
$button_img = 'http://s7.addthis.com/static/btn/v2/lg-share-en.gif';
}
$button_img = $addthis
->transformToSecureUrl($button_img);
if (isset($imgpath)) {
$button_img = $imgpath;
}
$extra_css = isset($settings['extra_css']) ? $settings['extra_css'] : '';
$element = array(
'#theme' => 'addthis_wrapper',
'#tag' => 'a',
'#attributes' => array(
'class' => array(
'addthis_button',
$extra_css,
),
),
);
$element['#attributes'] += $addthis
->getAddThisAttributesMarkup($options);
// Add the widget script.
$script_manager = AddThisScriptManager::getInstance();
$script_manager
->attachJsToElement($element);
// Create img button.
$image = array(
'#theme' => 'addthis_element',
'#tag' => 'img',
'#attributes' => array(
'src' => $button_img,
'alt' => t('Share page with AddThis'),
),
);
$element[] = $image;
return $element;
}
Functions
Name | Description |
---|---|
addthis_displays_addthis_display_markup | @file Implements AddThis markup functions. |
addthis_displays_addthis_display_markup__addthis_basic_button | Implements hook_addthis_display_markup__[display](). |
addthis_displays_addthis_display_markup__addthis_basic_toolbox | Implements hook_addthis_display_markup__[display](). |