function views_aggregator_maximum in Views Aggregator Plus 7
Same name and namespace in other branches
- 8 views_aggregator_functions.inc \views_aggregator_maximum()
Aggregates a field group as the maximum across its members.
Using numbers mixed with non-numeric strings is not recommended.
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 the maximum groups member in.
Return value
array An array of values, one for each group, plus the 'column' group.
File
Code
function views_aggregator_maximum($groups, $field_handler) {
$values = array();
foreach ($groups as $group => $rows) {
$is_first = TRUE;
$maximum = NULL;
foreach ($rows as $num => $row) {
$value = views_aggregator_get_cell($field_handler, $num, FALSE);
if (isset($value) && trim($value) != '') {
if ($is_first) {
$maximum = $value;
$is_first = FALSE;
}
elseif ($value > $maximum) {
$maximum = $value;
}
}
}
if (isset($maximum)) {
$values[$group] = $maximum;
if (!isset($maximum_column) || $maximum > $maximum_column) {
$maximum_column = $maximum;
}
}
}
if (isset($maximum_column)) {
$values['column'] = $maximum_column;
}
return $values;
}