function field_formatter_filter_field_formatter_view in Field Formatter Filter 7
Produces the result of stripping test to 'text_remainder_after_trimming'.
Implements hook_field_formatter_view().
File
- ./
field_formatter_filter.module, line 181 - Allows different text format filters to be applied as part of the field formatter settings for text fields.
Code
function field_formatter_filter_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'text_remainder_after_trimming':
// Produce the inverse of summary_or_trimmed.
foreach ($items as $delta => $item) {
if (!empty($item['summary'])) {
// This means a specific summary was defined.
// So the value is defined separate.
$output = _text_sanitize($instance, $langcode, $item, 'value');
}
else {
// Calculate the remainder.
$output = _text_sanitize($instance, $langcode, $item, 'value');
// First grab the calculated summary, but take care to avoid
// the htmlcorrector getting involved.
// So, do not pass in a text format.
$format = NULL;
$summary = text_summary($output, $format, $display['settings']['trim_length']);
$output = str_replace($summary, '', $output);
// Now may need to run htmlcorrector.
$format = $instance['settings']['text_processing'] ? $item['format'] : NULL;
$filters = filter_list_format($format);
// If the htmlcorrector filter is present, apply it to the generated
// summary.
if (isset($filters['filter_htmlcorrector'])) {
$summary = _filter_htmlcorrector($summary);
}
}
$element[$delta] = array(
'#markup' => $output,
);
}
break;
}
return $element;
}