function extended_file_field_celldata in Extended File Field 7
Generate the value for a given cell based on the column and $item displayed.
Parameters
string $column: The name of the column (i.e. $items property key) being generated.
array $item: The file being rendered within this row.
array $context: Associative array of context for the table of files being altered, with the following keys:
- field: The field definition array.
- instance: The field instance definition array.
- entity: The entity object the file field is attached to.
- entity_type: String with the type of entity the field is attached to.
- langcode: The language associated with $item.
- display: The display settings to use, as found in the 'display' entry of the instance definition. Notable keys include the name of the formatter (in 'type') and the array of formatter settings (in 'settings').
Return value
The render array or HTML value for inclusion in this cell.
Related topics
2 calls to extended_file_field_celldata()
- extended_file_field_generate_rows in ./
extended_file_field.module - Generates individual table rows for each file item
- extended_file_field_preprocess_extended_file_field_widget_multiple in ./
extended_file_field.module - Implements hook_preprocess_TEMPLATE().
File
- ./
extended_file_field.module, line 974 - Extends the core File field widget and provides a new formatter.
Code
function extended_file_field_celldata($column, $item, $context) {
$metadata = extended_file_field_metadata_types();
if (!empty($metadata[$column]['formatter']) && function_exists($metadata[$column]['formatter'])) {
$data = $metadata[$column]['formatter']($item, $context);
}
else {
switch ($column) {
case 'filename':
// If description is set, the theme function will use it by default
if ($context['display']['settings']['usedescriptionforfilename'] == 0) {
// We want to use the actual filename for the filename column
unset($item['description']);
}
$data = theme('file_link', array(
'file' => (object) $item,
));
break;
case 'filesize':
$data = format_size($item['filesize']);
break;
case 'uid':
$data = theme('username', array(
'account' => user_load($item['uid']),
));
break;
case 'timestamp':
$data = format_date($item['timestamp'], 'short');
break;
default:
$data = check_plain($item[$column]);
break;
}
}
return $data;
}