You are here

function phone_field_formatter_view in Phone 7

Same name and namespace in other branches
  1. 7.2 phone.module \phone_field_formatter_view()

Implements hook_field_formatter_view().

File

./phone.module, line 197

Code

function phone_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  foreach ($items as $delta => $item) {
    $text = '';
    if (isset($item['value'])) {
      $text = check_plain($item['value']);

      // iPhone Support
      if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== FALSE) {
        $text = '<a href="tel:' . $text . '">' . $text . '</a>';
      }
    }
    $element[$delta]['#markup'] = $text;
  }
  return $element;
}