You are here

function template_preprocess_views_view_summary_unformatted in Views (for Drupal 7) 8.3

Same name and namespace in other branches
  1. 6.3 theme/theme.inc \template_preprocess_views_view_summary_unformatted()
  2. 6.2 theme/theme.inc \template_preprocess_views_view_summary_unformatted()
  3. 7.3 theme/theme.inc \template_preprocess_views_view_summary_unformatted()

Template preprocess theme function to print summary basically unformatted.

File

theme/theme.inc, line 404
Preprocessors and helper functions to make theming easier.

Code

function template_preprocess_views_view_summary_unformatted(&$vars) {
  $view = $vars['view'];
  $argument = $view->argument[$view->build_info['summary_level']];
  $vars['row_classes'] = array();
  $url_options = array();
  if (!empty($view->exposed_raw_input)) {
    $url_options['query'] = $view->exposed_raw_input;
  }
  $count = 0;
  $active_urls = drupal_map_assoc(array(
    url(current_path(), array(
      'alias' => TRUE,
    )),
    // force system path
    url(current_path()),
  ));

  // Collect all arguments foreach row, to be able to alter them for example by the validator.
  // This is not done per single argument value, because this could cause performance problems.
  $row_args = array();
  foreach ($vars['rows'] as $id => $row) {
    $row_args[$id] = $argument
      ->summary_argument($row);
  }
  $argument
    ->process_summary_arguments($row_args);
  foreach ($vars['rows'] as $id => $row) {

    // only false on first time:
    if ($count++) {
      $vars['rows'][$id]->separator = filter_xss_admin($vars['options']['separator']);
    }
    $vars['rows'][$id]->link = $argument
      ->summary_name($row);
    $args = $view->args;
    $args[$argument->position] = $row_args[$id];
    $base_path = NULL;
    if (!empty($argument->options['summary_options']['base_path'])) {
      $base_path = $argument->options['summary_options']['base_path'];
    }
    $vars['rows'][$id]->url = url($view
      ->getUrl($args, $base_path), $url_options);
    $vars['rows'][$id]->count = intval($row->{$argument->count_alias});
    if (isset($active_urls[$vars['rows'][$id]->url])) {
      $vars['row_classes'][$id] = 'active';
    }
  }
}