You are here

spaces_handler_filter_spaces_current.inc in Spaces 6

File

includes/spaces_handler_filter_spaces_current.inc
View source
<?php

/**
 * Spaces view filter handler. 
 */
class spaces_handler_filter_spaces_current extends views_handler_filter {

  /**
   * Meta query handler which delegates query building to the
   * implementing spaces.
   */
  function query() {
    $space = spaces_get_space();
    if ($space) {
      $space
        ->views_filter(TRUE, $this->view->query);
    }
    else {
      if ($this->options['operator'] === 'all') {
        $types = spaces_types();
        foreach ($types as $type => $info) {
          call_user_func(array(
            $info['class'],
            'views_filter',
          ), FALSE, $this->view->query);
        }
      }
    }
  }

  /**
   * Provide a form for setting the operator.
   *
   * This may be overridden by child classes, and it must
   * define $form['operator'];
   */
  function operator_form(&$form, &$form_state) {
    $options = $this
      ->operator_options();
    if (!empty($options)) {
      $form['operator'] = array(
        '#type' => 'select',
        '#title' => t('When not in a space'),
        '#default_value' => $this->operator,
        '#options' => $options,
        '#description' => t('Helpful if you want to use this view both inside and out of spaces.'),
      );
    }
  }

  /**
   * Provide filter application conditions.
   */
  function operator_options() {
    return array(
      'all' => t('Hide all results'),
      'active' => t('Show all results'),
    );
  }

}

Classes

Namesort descending Description
spaces_handler_filter_spaces_current Spaces view filter handler.