function tweetbutton_field_formatter_view in Tweet Button 7.2
Implements hook_field_formatter_view().
File
- ./
tweetbutton.module, line 196
Code
function tweetbutton_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, &$items, $display) {
$settings = $display['settings'];
$delta = 0;
switch ($display['type']) {
case 'tweetbutton_formatter_button_vertical':
$button_type = 'vertical';
break;
case 'tweetbutton_formatter_button_horizontal':
$button_type = 'horizontal';
break;
case 'tweetbutton_formatter_button_none':
$button_type = 'none';
break;
}
if (empty($items)) {
$items[$delta] = array(
'text' => '',
'account' => '',
);
}
$uri = entity_uri($entity_type, $entity);
$element[$delta] = array(
'#theme' => 'tweetbutton_tweet_display',
'#options' => array(
'size' => $settings['size'],
'type' => $button_type,
'account' => $items[$delta]['account'],
'tweet_text' => $items[$delta]['text'],
'url' => url($uri['path'], array(
'absolute' => TRUE,
)),
),
'#entity' => $entity,
'#entity_type' => $entity_type,
);
return $element;
}