You are here

function email_field_formatter in Email Field 5

Same name and namespace in other branches
  1. 6.2 email.module \email_field_formatter()

File

./email.module, line 64

Code

function email_field_formatter($field, $item, $formatter, $node) {
  if (empty($item['email'])) {
    return '';
  }
  else {
    if ($formatter == 'contact') {
      $mailto = l(t('Email Contact Form'), 'email/' . $node->nid . '/' . $field['field_name']);
    }
    elseif ($formatter == 'invisi' && module_exists('invisimail')) {
      $format = $GLOBALS['invisimail_format'];
      if (!variable_get('invisimail_link_' . $format, TRUE)) {
        variable_set('invisimail_link_' . $format, TRUE);
        variable_set('invisimail_js_' . $format, TRUE);
      }
      $mailto = invisimail_ascii_encode($item['email']);
    }
    else {
      $mailto = '<a href="mailto:' . $item['email'] . '">' . check_plain($item['email']) . '</a>';
    }
    return $mailto;
  }
}