/[drupal]/contributions/modules/views/plugins/views_plugin_exposed_form.inc
ViewVC logotype

Diff of /contributions/modules/views/plugins/views_plugin_exposed_form.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Wed Nov 11 01:42:53 2009 UTC revision 1.1.2.1, Wed Nov 11 01:42:53 2009 UTC
# Line 0  Line 1 
1    <?php
2    // $Id: views_plugin_exposed_form.inc, Exp $
3    
4    /**
5     * The base plugin to handle exposed filter forms.
6     */
7    class views_plugin_exposed_form extends views_plugin {
8    
9      /**
10       * Initialize the plugin.
11       *
12       * @param $view
13       *   The view object.
14       * @param $display
15       *   The display handler.
16       */
17      function init(&$view, &$display) {
18        $this->view = &$view;
19        $this->display = &$display;
20    
21        $exposed_form = $display->handler->get_option('exposed_form');
22        $this->unpack_options($this->options, $exposed_form['options']);
23      }
24    
25      /**
26       * Return a string to display as the clickable title for the
27       * control.
28       */
29      function summary_title() {
30        return t('Unknown');
31      }
32    
33      function option_definition() {
34        $options = parent::option_definition();
35        $options['submit_button'] = array('default' => t('Apply'), 'translatable' => TRUE);
36        return $options;
37      }
38    
39      function options_form(&$form, &$form_state) {
40        $form['submit_button'] = array(
41          '#type' => 'textfield',
42          '#title' => t('Submit button text'),
43          '#description' => t('Text to display in the submit button of the exposed form.'),
44          '#default_value' => $this->options['submit_button'],
45        );
46      }
47    
48      /**
49       * Render the exposed filter form.
50       *
51       * This actually does more than that; because it's using FAPI, the form will
52       * also assign data to the appropriate handlers for use in building the
53       * query.
54       */
55      function render_exposed_form($block = FALSE) {
56        // Deal with any exposed filters we may have, before building.
57        $form_state = array(
58          'view' => &$this->view,
59          'display' => &$this->display,
60          'method' => 'get',
61          'rerender' => TRUE,
62          'no_redirect' => TRUE,
63          'submit_button' => $this->options['submit_button'],
64        );
65    
66        // Some types of displays (eg. attachments) may wish to use the exposed
67        // filters of their parent displays instead of showing an additional
68        // exposed filter form for the attachment as well as that for the parent.
69        if (!$this->view->display_handler->displays_exposed() || (!$block && $this->view->display_handler->get_option('exposed_block'))) {
70          unset($form_state['rerender']);
71        }
72    
73        if (!empty($this->ajax)) {
74          $form_state['ajax'] = TRUE;
75        }
76    
77        $output = drupal_build_form('views_exposed_form', $form_state);
78        if (!empty($form_state['js settings'])) {
79          $this->view->js_settings = $form_state['js settings'];
80        }
81    
82        return $output;
83      }
84    
85      function query() { }
86    
87      function pre_render() { }
88    
89      function post_render(&$output) { }
90    
91      function pre_execute() { }
92    
93      function post_execute() { }
94    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2