function _views_aggregator_enumerate in Views Aggregator Plus 8
Same name and namespace in other branches
- 7 views_aggregator_functions.inc \_views_aggregator_enumerate()
Aggregates a field group as the enumeration of its members.
Parameters
array $groups: An array of groups of rows, each group indexed by group value.
object $field_handler: The handler for the view column to find members of the group.
string $separator_group: The separator to use in group enumerations, defaults to '<br/>'.
string $separator_column: The separator to use for the column enumeration, defaults to '<br/>'.
bool $sort: Whether or not to sort the enumeration.
bool $allow_duplicates: Whether or not to remoe duplicates from the enumeration.
Return value
array An array of values, one for each group.
2 calls to _views_aggregator_enumerate()
- views_aggregator_enumerate in ./
views_aggregator_functions.inc - Aggregates a field group as the enumeration of its members.
- views_aggregator_enumerate_raw in ./
views_aggregator_functions.inc - Aggregates a field group as the enumeration of its members.
File
Code
function _views_aggregator_enumerate(array $groups, $field_handler, $separator_group, $separator_column, $sort = TRUE, $allow_duplicates = FALSE) {
$separator_group = empty($separator_group) ? '<br/>' : $separator_group;
$separator_column = empty($separator_column) ? '<br/>' : $separator_column;
$values = [
'column' => [],
];
foreach ($groups as $group => $rows) {
$cell_values = [];
foreach ($rows as $num => $row) {
$cell = trim(views_aggregator_get_cell($field_handler, $num, TRUE));
if (!empty($cell)) {
if ($allow_duplicates || !in_array($cell, $cell_values)) {
$cell_values[] = $cell;
}
if ($allow_duplicates || !in_array($cell, $values['column'])) {
$values['column'][] = $cell;
}
}
}
if (count($cell_values) > 1) {
// After grouping the fields in the group no longer belong to one
// entity. Cannot easily support hyper-linking, so switch it off.
unset($field_handler->options['link_to_node']);
if ($sort) {
@sort($cell_values, SORT_NATURAL | SORT_FLAG_CASE);
}
}
if ($group != 'column') {
$values[$group] = implode($separator_group, $cell_values);
}
}
if ($sort) {
@sort($values['column'], SORT_NATURAL | SORT_FLAG_CASE);
}
$values['column'] = implode($separator_column, $values['column']);
return $values;
}