You are here

class autocomplete_widgets_basic_exposed_form_plugin in Autocomplete Widgets for Text and Number Fields 6

@file Views exposed form plugin for Autocomplete Widgets module.

Hierarchy

Expanded class hierarchy of autocomplete_widgets_basic_exposed_form_plugin

1 string reference to 'autocomplete_widgets_basic_exposed_form_plugin'
autocomplete_widgets_views_plugins in views/autocomplete_widgets.views.inc
Implementation of hook_views_plugins().

File

views/autocomplete_widgets_basic_exposed_form_plugin.inc, line 7
Views exposed form plugin for Autocomplete Widgets module.

View source
class autocomplete_widgets_basic_exposed_form_plugin extends views_plugin_exposed_form_basic {

  /**
   * Return a string to display as the clickable title for the control.
   */
  function summary_title() {
    return t('Autocomplete widgets');
  }

  /**
   * Declare custom plugin options.
   */
  function option_definition() {
    $options = parent::option_definition();
    $options['make_autocompletable'] = array(
      'default' => array(),
    );
    return $options;
  }

  /**
   * Generate form elements for custom plugin options.
   */
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $relationships = $this->view->relationship;
    $options = array();
    foreach ($this->display->handler
      ->get_handlers('filter') as $filter => $handler) {
      if ($handler
        ->is_exposed() && $handler->content_field['widget']['module'] == 'autocomplete_widgets') {
        $options[$filter] = $handler
          ->ui_name();
        if (!empty($handler->options['relationship'])) {
          $relationship = $handler->options['relationship'];
          if (!empty($relationships[$relationship])) {
            $options[$filter] = '(' . $relationships[$relationship] . ') ' . $options[$filter];
          }
        }
      }
    }
    if (!empty($options)) {
      $form['make_autocompletable'] = array(
        '#type' => 'checkboxes',
        '#title' => t('Convert into a autocomplete widget'),
        '#options' => $options,
        '#default_value' => $this->options['make_autocompletable'],
        '#description' => t('This list contains only exposed filters for CCK Text and Number fields.'),
      );
    }
  }

  /**
   * Alter the exposed filters based on plugin options.
   */
  function exposed_form_alter(&$form, &$form_state) {
    parent::exposed_form_alter($form, $form_state);
    if (!empty($this->options['make_autocompletable'])) {
      foreach ($this->options['make_autocompletable'] as $filter) {
        $field_name = $this->view->filter[$filter]->content_field['field_name'];
        $type_name = $this->view->filter[$filter]->content_field['type_name'];
        $form[$filter]['#autocomplete_path'] = 'autocomplete_widgets/' . $type_name . '/' . $field_name;
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
autocomplete_widgets_basic_exposed_form_plugin::exposed_form_alter function Alter the exposed filters based on plugin options. Overrides views_plugin_exposed_form::exposed_form_alter
autocomplete_widgets_basic_exposed_form_plugin::options_form function Generate form elements for custom plugin options. Overrides views_plugin_exposed_form::options_form
autocomplete_widgets_basic_exposed_form_plugin::option_definition function Declare custom plugin options. Overrides views_plugin_exposed_form::option_definition
autocomplete_widgets_basic_exposed_form_plugin::summary_title function Return a string to display as the clickable title for the control. Overrides views_plugin_exposed_form_basic::summary_title
views_object::$definition property Handler's definition
views_object::$options property Except for displays, options for the object will be held here. 1
views_object::construct function Views handlers use a special construct function so that we can more easily construct them with variable arguments. 6
views_object::destroy function 2
views_object::export_option function 1
views_object::export_options function
views_object::options function Set default options on this object. Called by the constructor in a complex chain to deal with backward compatibility. 1
views_object::set_default_options function Set default options. For backward compatibility, it sends the options array; this is a feature that will likely disappear at some point.
views_object::set_definition function Let the handler know what its full definition is.
views_object::unpack_options function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.
views_object::unpack_translatable function Unpack a single option definition.
views_object::unpack_translatables function Unpacks each handler to store translatable texts.
views_object::_set_option_defaults function
views_plugin::$display property The current used views display.
views_plugin::$plugin_type property The plugin type of this plugin, for example style or query.
views_plugin::$view property The top object of a view. Overrides views_object::$view 1
views_plugin::additional_theme_functions function Provide a list of additional theme functions for the theme information page
views_plugin::options_submit function Handle any special handling on the validate form. 9
views_plugin::options_validate function Validate the options form. 8
views_plugin::theme_functions function Provide a full list of possible theme templates used by this style.
views_plugin::validate function Validate that the plugin is correct and can be saved. 2
views_plugin_exposed_form::exposed_form_submit function This function is executed when exposed form is submited.
views_plugin_exposed_form::exposed_form_validate function
views_plugin_exposed_form::init function Initialize the plugin.
views_plugin_exposed_form::post_render function
views_plugin_exposed_form::pre_execute function
views_plugin_exposed_form::pre_render function 1
views_plugin_exposed_form::query function Add anything to the query that we might need to. Overrides views_plugin::query 1
views_plugin_exposed_form::render_exposed_form function Render the exposed filter form.
views_plugin_exposed_form::reset_form function Provide a reset form if one was requested.