source: sipes/modules_contrib/views/plugins/views_plugin_exposed_form_input_required.inc @ a8b1f3f

stableversion-3.0
Last change on this file since a8b1f3f was 65dadeb, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agregaron los archivos de la nueva version del modulo

  • Propiedad mode establecida a 100644
File size: 2.8 KB
Línea 
1<?php
2
3/**
4 * Exposed form plugin that provides basic exposed form
5 */
6class views_plugin_exposed_form_input_required extends views_plugin_exposed_form {
7
8  function summary_title() {
9    return t('Input required');
10  }
11
12  function option_definition() {
13    $options = parent::option_definition();
14
15    $options['text_input_required'] = array('default' => t('Select any filter and click on Apply to see results'), 'translatable' => TRUE);
16    $options['text_input_required_format'] = array('default' => FILTER_FORMAT_DEFAULT);
17    return $options;
18  }
19
20  function options_form(&$form, &$form_state) {
21    parent::options_form($form, $form_state);
22
23    $form['text_input_required'] = array(
24      '#type' => 'textarea',
25      '#title' => t('Text on demand'),
26      '#description' => t('Text to display instead of results until the user selects and applies an exposed filter.'),
27      '#default_value' => $this->options['text_input_required'],
28    );
29
30    $form['text_input_required_format'] = filter_form($this->options['text_input_required_format'], NULL, array('text_input_required_format'));
31  }
32
33  function options_submit($form, &$form_state) {
34    $form_state['values']['exposed_form_options']['text_input_required_format'] = $form_state['values']['text_input_required_format'];
35
36    parent::options_submit($form, $form_state);
37  }
38
39  function exposed_filter_applied() {
40    static $cache = NULL;
41    if (!isset($cache)) {
42      $view = $this->view;
43      if (is_array($view->filter) && count($view->filter)) {
44        foreach ($view->filter as $filter_id => $filter) {
45          if ($filter->is_exposed()) {
46            $identifier = $filter->options['expose']['identifier'];
47            if (isset($view->exposed_input[$identifier])) {
48              $cache = TRUE;
49              return $cache;
50            }
51          }
52        }
53      }
54      $cache = FALSE;
55    }
56
57    return $cache;
58  }
59
60  function pre_render(&$values) {
61    if (!$this->exposed_filter_applied()) {
62      $options = array(
63        'id' => 'area',
64        'table' => 'views',
65        'field' => 'area',
66        'label' => '',
67        'relationship' => 'none',
68        'group_type' => 'group',
69        'content' => $this->options['text_input_required'],
70        'format' => $this->options['text_input_required_format'],
71      );
72      $handler = views_get_handler('views', 'area', 'area');
73      $handler->init($this->view, $options);
74      $this->display->handler->handlers['empty'] = array(
75        'area' => $handler,
76      );
77      $this->display->handler->set_option('empty', array('text' => $options));
78    }
79  }
80
81  function query() {
82    if (!$this->exposed_filter_applied()) {
83      // We return with no query; this will force the empty text.
84      $this->view->built = TRUE;
85      $this->view->executed = TRUE;
86      $this->view->result = array();
87    }
88    else {
89      parent::query();
90    }
91  }
92
93}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.