You are here

function views_aggregator_row_filter in Views Aggregator Plus 8

Same name and namespace in other branches
  1. 7 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.

1 call to views_aggregator_row_filter()
Table::applyRowFilters in src/Plugin/views/style/Table.php
Filters out rows from the table based on a field cell matching a regexp.
3 string references to 'views_aggregator_row_filter'
Table::applyRowFilters in src/Plugin/views/style/Table.php
Filters out rows from the table based on a field cell matching a regexp.
Table::collectAggregationFunctions in src/Plugin/views/style/Table.php
Collect the aggregation functions from the Views UI.
Table::validateOptionsForm in src/Plugin/views/style/Table.php
Validate the options form.

File

./views_aggregator_functions.inc, line 103
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]);
    }
  }
}