function email_field_formatter_view in Email Field 7
Implements hook_field_formatter_view().
File
- ./
email.module, line 104 - Module file for the email module, which creates a email address field.
Code
function email_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'email_default':
foreach ($items as $delta => $item) {
$output = l($item['email'], 'mailto:' . $item['email']);
$element[$delta] = array(
'#markup' => $output,
);
}
break;
case 'email_contact':
$ids = entity_extract_ids($object_type, $object);
foreach ($items as $delta => $item) {
$element[$delta] = array(
'#markup' => l(t('Contact person by email'), 'email/' . $object_type . '/' . $ids[0] . '/' . $instance['field_name']),
);
// Since email is always sent to first item's email, break after any email address found.
break;
}
break;
case 'email_plain':
foreach ($items as $delta => $item) {
$element[$delta] = array(
'#markup' => check_plain($item['email']),
);
}
break;
case 'email_spamspan':
foreach ($items as $delta => $item) {
if (module_exists('spamspan')) {
$element[$delta] = array(
'#markup' => spamspan($item['email']),
);
}
else {
$output = l($item['email'], 'mailto:' . $item['email']);
$element[$delta] = array(
'#markup' => $output,
);
}
}
break;
}
return $element;
}