function extended_file_field_generate_rows in Extended File Field 7
Generates individual table rows for each file item
Parameters
array $items: An array of file items.
array $context: Associative array of contextual information which is passed down through each of the table generation functions (rows, row, & celldata), so that it can be made available to custom data formatters defined by external modules (via hook invocation in extended_file_field_generate_celldata()). Contains the following keys:
- field: The field definition array.
- instance: The field instance definition array.
- entity: An object representing the entity the file field is attached to.
- entity_type: String with the type of entity the field is attached to.
- langcode: The language associated with $items.
- 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 array A nested array of rows to be included in each table within the field formatter file listings, keyed by file display type ('visible' and 'hidden').
See also
extended_file_field_generate_celldata()
Related topics
1 call to extended_file_field_generate_rows()
File
- ./
extended_file_field.module, line 914 - Extends the core File field widget and provides a new formatter.
Code
function extended_file_field_generate_rows($items, $context) {
$rows = array(
'visible' => array(),
'hidden' => array(),
);
foreach ($items as $item) {
$row = [
'data' => [],
'class' => [
'extended-file-field-table-row',
],
'name' => 'issue-file-summary-table-row-' . $item['fid'],
];
foreach ($context['display']['settings']['columns'] as $column) {
$row['data'][$column] = [
'data' => extended_file_field_celldata($column, $item, $context),
'name' => 'extended-file-field-table-' . $column . '-' . $item['fid'],
'class' => 'extended-file-field-table-' . $column,
];
}
// Enforce the file's 'hidden field' handling.
// Display property.
if (!empty($item['hide-display'])) {
$row['class'][] = 'hidden-property';
}
// File extension filter.
if (!empty($item['hide-extension'])) {
$row['class'][] = 'hidden-extension';
}
// Limit to 'n' items.
if (!empty($item['hide-count'])) {
$row['class'][] = 'hidden-count';
}
// Add the row to the appropriate $rows array.
$rows[empty($item['separate-table']) ? 'visible' : 'hidden'][$item['fid']] = $row;
}
return $rows;
}