You are here

function views_aggregator_row_filter in Views Aggregator Plus 7

Same name and namespace in other branches
  1. 8 views_aggregator_functions.inc \views_aggregator_row_filter()

Keeps only the groups that match the regular expression filter.

Matching takes place on the raw values (1000, rather than "$ 1,000").

Parameters

object $views_plugin_style: An array of groups of rows, each group indexed by group value.

object $field_handler: The handler for the view column to count groups members in.

string $regexp: If empty all result rows are kept.

Return value

array A subset of the original array of groups.

1 call to views_aggregator_row_filter()
views_aggregator_plugin_style_table::apply_row_filters in views/views_aggregator_plugin_style_table.inc
Filters out rows from the table based on a field cell matching a regexp.
3 string references to 'views_aggregator_row_filter'
views_aggregator_plugin_style_table::apply_row_filters in views/views_aggregator_plugin_style_table.inc
Filters out rows from the table based on a field cell matching a regexp.
views_aggregator_plugin_style_table::collect_aggregation_functions in views/views_aggregator_plugin_style_table.inc
Collect the aggregation functions from the Views UI.
views_aggregator_plugin_style_table::options_validate in views/views_aggregator_plugin_style_table.inc
Overrides options_validate().

File

./views_aggregator_functions.inc, line 106
views_aggregator_functions.inc

Code

function views_aggregator_row_filter($views_plugin_style, $field_handler, $regexp = NULL) {
  if (empty($regexp)) {
    return;
  }
  if (preg_match('/[a-zA-Z0-9_]+/', $regexp)) {

    // Interpret omitted brace chars in the regexp as a verbatim text match.
    $regexp = "/{$regexp}/";
  }
  foreach ($views_plugin_style->view->result as $num => $row) {
    $field_value = views_aggregator_get_cell($field_handler, $num, FALSE);
    if (!preg_match($regexp, $field_value)) {
      unset($views_plugin_style->rendered_fields[$num]);
      unset($views_plugin_style->view->result[$num]);
    }
  }
}