You are here

function tweetbutton_field_presave in Tweet Button 7.2

Implements hook_field_presave().

File

./tweetbutton.module, line 124

Code

function tweetbutton_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if ($field['type'] == 'tweetbutton') {
    foreach ($items as $delta => $item) {
      $data = array(
        $entity_type => $entity,
      );
      $option = array(
        'clear' => TRUE,
      );
      $items[$delta]['text'] = !empty($items[$delta]['text']) ? token_replace($items[$delta]['text'], $data, $option) : substr($entity->title, 0, 128);
      $items[$delta]['account'] = !empty($items[$delta]['account']) ? token_replace($items[$delta]['account'], $data, $option) : '';
    }
  }
}