function mvf_field_formatter_prepare_view in Measured Value Field 7
Implements hook_field_formatter_prepare_view().
File
- ./
mvf.module, line 991 - Define a field type of measured value.
Code
function mvf_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
$mocked_view_mode = 'mvf_mocked_view_mode';
// Before we proceed we have to convert all $items to necessary output unit
// measure. Necessary output unit measure should be suggested by MVF Unit
// suggesters.
foreach ($entities as $entity_id => $entity) {
$instance = $instances[$entity_id];
$instance['display'][$mocked_view_mode] = $displays[$entity_id];
$output_unit = mvf_unit_suggest($items[$entity_id], $field, $instance, $entity, $mocked_view_mode);
$items[$entity_id] = mvf_items_convert($field, $items[$entity_id], $output_unit);
}
foreach ($field['settings']['meta_info'] as $subfield => $meta_info) {
$mocked_field = mvf_field_mockup($field, $subfield);
foreach ($instances as $k => $v) {
$mocked_instances = array(
$k => array(),
);
$mocked_displays = array(
$k => array(),
);
$v['display'][$mocked_view_mode] = $displays[$k];
$mocked_instances[$k] = mvf_instance_mockup($field, $v, $subfield);
$displays[$k] = $mocked_instances[$k]['display'][$mocked_view_mode];
unset($mocked_instances[$k]['display'][$mocked_view_mode]);
$function = $displays[$k]['module'] . '_field_formatter_prepare_view';
if (function_exists($function)) {
$function($entity_type, $entities, $mocked_field, $mocked_instances, $langcode, $items, $mocked_displays);
}
}
}
}