function sharerich_get_buttons in Sharerich 7
Same name and namespace in other branches
- 7.3 sharerich.module \sharerich_get_buttons()
- 7.2 sharerich.module \sharerich_get_buttons()
Returns markup with list of share buttons.
2 calls to sharerich_get_buttons()
- sharerich_block_view in ./
sharerich.module - Implements hook_block_view().
- sharerich_node_view in ./
sharerich.module - Implements hook_node_view().
File
- ./
sharerich.module, line 105
Code
function sharerich_get_buttons($node = NULL) {
$key = 0;
if (!is_null($node)) {
$key = $node->nid;
}
$buttons =& drupal_static(__FUNCTION__ . $key, array());
if (empty($buttons)) {
$services = sharerich_get_services();
foreach ($services as $service_name) {
$content = sharerich_get_service_content($service_name);
if (!empty($content)) {
$buttons[$service_name] = array(
'data' => $content,
'class' => array(
$service_name,
),
);
}
}
$buttons = sharerich_reorder_buttons($buttons);
// Allow other modules to alter the buttons markup.
drupal_alter('sharerich_buttons', $buttons, $node);
// Tokens replacements.
foreach ($buttons as $key => $button) {
$buttons[$key]['data'] = token_replace($button['data'], array(
'node' => $node,
));
}
}
$attributes = array(
'class' => array(
'sharerich-buttons',
'rrssb-buttons',
'clearfix',
),
);
if (count($buttons) > 0) {
// Create an item list for the button links.
$item_list = array(
'#theme' => 'item_list',
'#items' => $buttons,
'#type' => 'ul',
'#attributes' => $attributes,
);
// Output using the sharerich_buttons theme.
$sharerich_buttons = array(
'#theme' => 'sharerich_buttons',
'#item_list' => $item_list,
'#title' => variable_get('sharerich_title', t('Share This')),
);
return $sharerich_buttons;
}
}