function ttext_field_formatter in Internationalization 5
Implementation of hook_field_formatter().
The $node argument is necessary so that filter access can be checked on node preview.
File
- experimental/
ttext.module, line 91 - Defines simple ttext field types.
Code
function ttext_field_formatter($field, $item, $formatter, $node) {
drupal_set_message('ttext_field_formatter: ' . $item['value']);
if (!isset($item['value'])) {
return '';
}
if ($allowed_values = ttext_allowed_values($field)) {
return $allowed_values[$item['value']];
}
if ($field['ttext_processing']) {
$ttext = check_markup($item['value'], $item['format'], is_null($node) || isset($node->in_preview));
}
else {
$ttext = check_plain($item['value']);
}
switch ($formatter) {
case 'plain':
return strip_tags($ttext);
case 'trimmed':
return node_teaser($ttext, $field['ttext_processing'] ? $item['format'] : NULL);
default:
return $ttext;
}
}