You are here

function views_limit_grouping_style_plugin::group_limit_recursive in Views Grouping Row Limit 7

Recursively limits the number of rows in nested groups.

@params int $level The current level we are gathering results for. Used for recursive operations; do not set directly.

Parameters

array $group_data: A single level of grouped records.

mixed $key: The key of the array being passed in. Used for when this function is called from array_walk() and the like. Do not set directly.

Return value

array An array with a "rows" property that is recursively grouped by the grouping fields.

File

./views_limit_grouping_style_plugin.inc, line 77
views_grouping_limit_style_plugin.inc Our handler.

Class

views_limit_grouping_style_plugin
@file views_grouping_limit_style_plugin.inc Our handler.

Code

function group_limit_recursive(&$group_data, $key = NULL, $level = 0) {
  $settings = $this
    ->grouping_limit_settings($level);

  // Slice up the rows according to the offset and limit.
  $group_data['rows'] = array_slice($group_data['rows'], $settings['grouping-offset'], $settings['grouping-limit'], TRUE);

  // For each row, if it appears to be another grouping, recurse again.
  foreach ($group_data['rows'] as &$data) {
    if (is_array($data) && isset($data['group']) && isset($data['rows'])) {
      $this
        ->group_limit_recursive($data, NULL, $level + 1);
    }
  }
}