function commerce_file_field_formatter_view in Commerce File 7
Same name and namespace in other branches
- 7.2 commerce_file.module \commerce_file_field_formatter_view()
Implements hook_field_formatter_view().
File
- ./
commerce_file.module, line 866 - Provides integration of file licenses with Commerce
Code
function commerce_file_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
global $user;
$element = array();
switch ($display['type']) {
case 'commerce_file_access_link':
$field_item_theme = 'commerce_file_file_link_plain';
$access = _commerce_file_field_view_access($entity_type, $entity, $field, $instance, $langcode, $items, $display, $user);
if ($access) {
$field_item_theme = 'file_link';
}
// process each field item
foreach ($items as $delta => $item) {
$element[$delta] = array(
'#theme' => $field_item_theme,
'#file' => (object) $item,
);
}
break;
}
return $element;
}