function views_aggregator_minimum in Views Aggregator Plus 7
Same name and namespace in other branches
- 8 views_aggregator_functions.inc \views_aggregator_minimum()
Aggregates a field group as the minimum across 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 the minimum groups member in.
Return value
array An array of values, one for each group, plus the 'column' group.
File
Code
function views_aggregator_minimum($groups, $field_handler) {
$values = array();
foreach ($groups as $group => $rows) {
$is_first = TRUE;
$minimum = NULL;
foreach ($rows as $num => $row) {
$value = views_aggregator_get_cell($field_handler, $num, FALSE);
// Ignore empty strings.
if (isset($value) && trim($value) != '') {
if ($is_first) {
$minimum = $value;
$is_first = FALSE;
}
elseif ($value < $minimum) {
$minimum = $value;
}
}
}
if (isset($minimum)) {
$values[$group] = $minimum;
if (!isset($minimum_column) || $minimum < $minimum_column) {
$minimum_column = $minimum;
}
}
}
if (isset($minimum_column)) {
$values['column'] = $minimum_column;
}
return $values;
}