You are here

class views_composite_exposed_form_plugin in Views Hacks 7

Same name and namespace in other branches
  1. 6 views_composite_exposed_form/views_composite_exposed_form_plugin.inc \views_composite_exposed_form_plugin

@file Contains the composite exposed form plugin.

Hierarchy

Expanded class hierarchy of views_composite_exposed_form_plugin

1 string reference to 'views_composite_exposed_form_plugin'
views_composite_exposed_form_views_plugins in views_composite_exposed_form/views_composite_exposed_form.views.inc
Implementation of hook_views_plugins()

File

views_composite_exposed_form/views_composite_exposed_form_plugin.inc, line 7
Contains the composite exposed form plugin.

View source
class views_composite_exposed_form_plugin extends views_plugin_exposed_form {
  var $plugins = array();
  function init(&$view, &$display, $options = array()) {
    parent::init($view, $display, $options);

    // Instantiate each of our contained plugins, just like views_plugin_display does.
    foreach ($this->options['plugins'] as $name) {
      $plugin = views_get_plugin('exposed_form', $name);
      if (empty($plugin)) {
        continue;
      }
      $options = isset($this->options[$name]) ? $this->options[$name] : array();
      $options += array_intersect_key($this->options, parent::option_definition());
      $plugin
        ->init($view, $display, $options);
      $this->plugins[$name] = $plugin;
    }
  }
  function summary_title() {
    $plugins = array_intersect_key(views_fetch_plugin_names('exposed_form'), array_flip($this->options['plugins']));
    if (empty($plugins)) {
      $plugins[] = t('(none)');
    }
    return t('Composite: !plugins', array(
      '!plugins' => implode(', ', $plugins),
    ));
  }
  function option_definition() {
    views_include('admin');
    $options = $parent_options = parent::option_definition();
    $options['plugins'] = array(
      'default' => array(),
    );
    foreach (array_keys(views_fetch_plugin_names('exposed_form')) as $name) {
      if ($name == 'composite') {
        continue;
      }
      $plugin = views_get_plugin('exposed_form', $name);
      $options[$name] = $plugin
        ->option_definition();
      $options[$name] = array_diff_key($options[$name], $parent_options);
    }
    return $options;
  }
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $parent_form = $form;
    $options = views_fetch_plugin_names('exposed_form');
    unset($options['composite']);
    $form['plugins'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Plugins'),
      '#options' => $options,
      '#default_value' => $this->options['plugins'],
      '#description' => t('When you choose new plugins, please click "Update" then edit again to select the new plugin settings.'),
    );
    foreach ($this->options['plugins'] as $name) {
      if (empty($name)) {
        continue;
      }
      $form[$name] = array(
        '#type' => 'fieldset',
        '#title' => $options[$name],
        '#tree' => TRUE,
      );
      $this->plugins[$name]
        ->options_form($form[$name], $form_state);
      $form[$name] = array_diff_key($form[$name], $parent_form);
    }
  }
  function options_validate(&$form, &$form_state) {
    foreach ($this->plugins as $name => $plugin) {
      $plugin
        ->options_validate($form[$name], $form_state);
    }
  }
  function options_submit(&$form, &$form_state) {
    foreach ($this->plugins as $name => $plugin) {
      $plugin
        ->options_submit($form[$name], $form_state);
    }
  }
  function exposed_form_alter(&$form, &$form_state) {
    foreach ($this->plugins as $name => $plugin) {
      $plugin
        ->exposed_form_alter($form, $form_state);
    }
  }
  function exposed_form_validate(&$form, &$form_state) {
    foreach ($this->plugins as $name => $plugin) {
      $plugin
        ->exposed_form_validate($form, $form_state);
    }
  }
  function exposed_form_submit(&$form, &$form_state, &$exclude) {
    foreach ($this->plugins as $name => $plugin) {
      $plugin
        ->exposed_form_submit($form, $form_state, $exclude);
    }
  }
  function pre_render($values) {
    foreach ($this->plugins as $name => $plugin) {
      $plugin
        ->pre_render($values);
    }
  }
  function post_render(&$output) {
    foreach ($this->plugins as $name => $plugin) {
      $plugin
        ->post_render($output);
    }
  }
  function pre_execute() {
    foreach ($this->plugins as $name => $plugin) {
      $plugin
        ->pre_execute();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
views_composite_exposed_form_plugin::$plugins property
views_composite_exposed_form_plugin::exposed_form_alter function Overrides views_plugin_exposed_form::exposed_form_alter
views_composite_exposed_form_plugin::exposed_form_submit function This function is executed when exposed form is submited. Overrides views_plugin_exposed_form::exposed_form_submit
views_composite_exposed_form_plugin::exposed_form_validate function Overrides views_plugin_exposed_form::exposed_form_validate
views_composite_exposed_form_plugin::init function Initialize the plugin. Overrides views_plugin_exposed_form::init
views_composite_exposed_form_plugin::options_form function Provide a form to edit options for this plugin. Overrides views_plugin_exposed_form::options_form
views_composite_exposed_form_plugin::options_submit function Handle any special handling on the validate form. Overrides views_plugin::options_submit
views_composite_exposed_form_plugin::options_validate function Validate the options form. Overrides views_plugin::options_validate
views_composite_exposed_form_plugin::option_definition function Information about options for all kinds of purposes will be held here. Overrides views_plugin_exposed_form::option_definition
views_composite_exposed_form_plugin::post_render function Overrides views_plugin_exposed_form::post_render
views_composite_exposed_form_plugin::pre_execute function Overrides views_plugin_exposed_form::pre_execute
views_composite_exposed_form_plugin::pre_render function Overrides views_plugin_exposed_form::pre_render
views_composite_exposed_form_plugin::summary_title function Returns the summary of the settings in the display. Overrides views_plugin::summary_title
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::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_exposed_form::post_execute public function
views_plugin_exposed_form::query public function Add anything to the query that we might need to. Overrides views_plugin::query 1
views_plugin_exposed_form::render_exposed_form public function Render the exposed filter form.
views_plugin_exposed_form::reset_form public function