1 views_ui_base_views_wizard.php protected ViewsUiBaseViewsWizard::default_display_filters_user($form, $form_state)

File

core/modules/views_ui/wizards/views_ui_base_views_wizard.php, line 685
Provides the interface and base class for Views Wizard plugins.

Class

ViewsUiBaseViewsWizard
A very generic Views Wizard class - can be constructed for any base table.

Code

protected function default_display_filters_user($form, $form_state) {
  $filters = array();

  if (!empty($form_state['values']['show']['type']) && $form_state['values']['show']['type'] != 'all') {
    $entity_key = $this->entity_info['entity keys']['bundle'];
    $fields = views_fetch_fields($this->base_table, 'filter');
    if (isset($fields[$this->base_table . '.' . $entity_key])) {
      $table = $this->base_table;
    }
    else {
      foreach ($fields as $field_name => $value) {
        if ($pos = strpos($field_name, '.' . $entity_key)) {
          $table = substr($field_name, 0, $pos);
          break;
        }
      }
    }
    $table_data = views_fetch_data($table);
    // Check whether the entity key filter handler is or an child of it views_handler_filter_in_operator
    // If it's not just use a single value instead of an array.
    $handler = $table_data[$entity_key]['filter']['handler'];
    if ($handler == 'views_handler_filter_in_operator' || is_subclass_of($handler, 'views_handler_filter_in_operator')) {
      $value = backdrop_map_assoc(array($form_state['values']['show']['type']));
    }
    else {
      $value = $form_state['values']['show']['type'];
    }

    $filters[$entity_key] = array(
      'id' => $entity_key,
      'table' => $table,
      'field' => $entity_key,
      'value' => $value,
    );
  }

  // @todo: Figure out why this isn't part of node_views_wizard.
  if (!empty($form_state['values']['show']['tagged_with']['tids'])) {
    $filters['tid'] = array(
      'id' => 'tid',
      'table' => 'taxonomy_index',
      'field' => 'tid',
      'value' => $form_state['values']['show']['tagged_with']['tids'],
      'vocabulary' => $form_state['values']['show']['tagged_with']['vocabulary'],
    );
    // If the user entered more than one valid term in the autocomplete
    // field, they probably intended both of them to be applied.
    if (count($form_state['values']['show']['tagged_with']['tids']) > 1) {
      $filters['tid']['operator'] = 'and';
      // Sort the terms so the filter will be displayed as it normally would
      // on the edit screen.
      sort($filters['tid']['value']);
    }
  }

  return $filters;
}