You are here

class global_filter_plugin_argument_default_global_filter_view in Views Global Filter 7

Same name and namespace in other branches
  1. 8 views/global_filter_plugin_argument_default_global_filter_view.inc \global_filter_plugin_argument_default_global_filter_view
  2. 6 views/global_filter_plugin_argument_default_global_filter_view.inc \global_filter_plugin_argument_default_global_filter_view

Default argument plugin to extract the View filter values set for this contextual filter.

Hierarchy

Expanded class hierarchy of global_filter_plugin_argument_default_global_filter_view

1 string reference to 'global_filter_plugin_argument_default_global_filter_view'
global_filter_views_plugins in views/global_filter.views.inc
Implements hook_views_plugins().

File

views/global_filter_plugin_argument_default_global_filter_view.inc, line 11
Contains the Global Filter default argument plugin (view).

View source
class global_filter_plugin_argument_default_global_filter_view extends views_plugin_argument_default {

  /**
   * Define the options.
   */
  public function option_definition() {
    $options = parent::option_definition();
    $options['global_filter_view'] = array(
      'default' => '',
    );
    $options['break_phrase_and'] = array(
      'default' => FALSE,
      'bool' => TRUE,
    );
    return $options;
  }

  /**
   * Build the options form.
   */
  public function options_form(&$form, &$form_state) {
    $form['global_filter_view'] = array(
      '#type' => 'select',
      '#title' => t('View providing default value'),
      '#options' => global_filter_get_used_view_names(),
      '#default_value' => $this->options['global_filter_view'],
      '#description' => t('Select the global filter view(s) that will provide the default value for this contextual filter.'),
      // See [#1618302].
      '#multiple' => TRUE,
    );
    $form['break_phrase_and'] = array(
      '#type' => 'checkbox',
      '#title' => t('Process multiple filter values in <em>all of</em> (AND) rather than <em>one of</em> (OR) mode.'),
      '#description' => t('Applies only when <strong>Allow multiple values</strong> is ticked in the <strong>More</strong> fieldset below.'),
      '#default_value' => !empty($this->options['break_phrase_and']),
    );
  }

  /**
   * Get argument.
   */
  public function get_argument() {
    $arg = $view_names = $this->options['global_filter_view'];
    if (!empty($view_names)) {
      if (!is_array($view_names)) {
        $view_names = array(
          $view_names,
        );
      }
      $arg = array();
      foreach ($view_names as $view_name) {
        $value = global_filter_get_session_value($view_name);
        if (isset($value)) {
          if (is_array($value)) {
            $arg = array_merge($arg, $value);
          }
          else {
            $arg[] = $value;
          }
        }
      }
      $arg = array_filter($arg);
    }
    if (empty($arg)) {
      $arg = $this->argument->options['exception']['value'];
    }

    // If the argument is multi-valued, i.e. multi-select box or check boxes,
    // string the values together separated by plus-signs.
    // Note this requires the user to tick "Allow multiple values" after
    // expanding the "More" fieldset on the Contextual Filter configuration
    // panel. Otherwise only the first of the values will used.
    $is_and = !empty($this->argument->options['break_phrase']) && !empty($this->options['break_phrase_and']);
    return is_array($arg) ? implode($is_and ? ',' : '+', $arg) : $arg;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
global_filter_plugin_argument_default_global_filter_view::get_argument public function Get argument. Overrides views_plugin_argument_default::get_argument
global_filter_plugin_argument_default_global_filter_view::options_form public function Build the options form. Overrides views_plugin_argument_default::options_form
global_filter_plugin_argument_default_global_filter_view::option_definition public function Define the options. Overrides views_plugin_argument_default::option_definition
views_object::$definition public property Handler's definition.
views_object::$options public property Except for displays, options for the object will be held here. 1
views_object::altered_option_definition function Collect this handler's option definition and alter them, ready for use.
views_object::construct public function Views handlers use a special construct function. 4
views_object::destroy public function Destructor. 2
views_object::export_option public function 1
views_object::export_options public function
views_object::export_option_always public function Always exports the option, regardless of the default value.
views_object::options Deprecated public function Set default options on this object. 1
views_object::set_default_options public function Set default options.
views_object::set_definition public function Let the handler know what its full definition is.
views_object::unpack_options public function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.
views_object::unpack_translatable public function Unpack a single option definition.
views_object::unpack_translatables public function Unpacks each handler to store translatable texts.
views_object::_set_option_defaults public function
views_plugin::$display public property The current used views display.
views_plugin::$plugin_name public property The plugin name of this plugin, for example table or full.
views_plugin::$plugin_type public property The plugin type of this plugin, for example style or query.
views_plugin::$view public property The top object of a view. Overrides views_object::$view 1
views_plugin::additional_theme_functions public function Provide a list of additional theme functions for the theme info page.
views_plugin::plugin_title public function Return the human readable name of the display.
views_plugin::query public function Add anything to the query that we might need to. 7
views_plugin::summary_title public function Returns the summary of the settings in the display. 8
views_plugin::theme_functions public function Provide a full list of possible theme templates used by this style.
views_plugin::validate public function Validate that the plugin is correct and can be saved. 3
views_plugin_argument_default::access public function Determine if the administrator has the privileges to use this plugin. 1
views_plugin_argument_default::check_access public function If we don't have access to the form but are showing it anyway, ensure that the form is safe and cannot be changed from user input.
views_plugin_argument_default::convert_options public function Convert options from the older style. 3
views_plugin_argument_default::init public function Initialize this plugin with the view and the argument it is linked to. 1
views_plugin_argument_default::options_submit public function Provide the default form form for submitting options. Overrides views_plugin::options_submit 1
views_plugin_argument_default::options_validate public function Provide the default form form for validating options. Overrides views_plugin::options_validate