diff -u b/handler_filter_fulltext.inc b/handler_filter_fulltext.inc --- b/handler_filter_fulltext.inc +++ b/handler_filter_fulltext.inc @@ -16,6 +16,7 @@ parent::init($view, $options); $fields = $this->getFulltextFields(); $this->use_fields_op = $fields; + $options['expose']['fields_id'] = $this->options['id'] . '_fields_op'; if (!empty($options['exposed']) && !empty($options['expose']['fields_id']) && !isset($options['expose']['use_fields_id'])) { $this->options['expose']['use_fields_id'] = $options['expose']['use_fields_id'] = $options['expose']['fields_id']; } @@ -90,33 +91,61 @@ ); } } - - /** - * Provide default options for exposed filter. - */ - function expose_options() { - parent::expose_options(); - $this->options['expose']['use_fields'] = FALSE; - $this->options['expose']['fields_id'] = $this->options['id'] . '_fields_op'; - } /** * {@inheritdoc} */ function accept_exposed_input($input) { $rc = parent::accept_exposed_input($input); + $use_fields = $this->options['expose']['use_fields_id']; if (!empty($this->options['expose']['use_fields']) && isset($input[$use_fields])) { $this->use_fields_op = $input[$use_fields]; } return $rc; } + function store_exposed_input($input, $status) { + $var = parent::store_exposed_input($input, $status); + if (empty($this->options['expose']['use_fields']) || empty($this->options['expose']['identifier'])) { + return TRUE; + } + + // Figure out which display id is responsible for the filters, so we + // know where to look for session stored values. + $display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display; + + // shortcut test. + $use_fields_id = !empty($this->options['expose']['use_fields']) && !empty($this->options['expose']['use_fields_id']); + // false means that we got a setting that means to recuse ourselves, + // so we should erase whatever happened to be there. + if (!$status && isset($_SESSION['views'][$this->view->name][$display_id])) { + $session = &$_SESSION['views'][$this->view->name][$display_id]; + if ($use_fields_id && isset($session[$this->options['expose']['use_fields_id']])) { + unset($session[$this->options['expose']['use_fields_id']]); + } + + if (isset($session[$this->options['expose']['identifier']])) { + unset($session[$this->options['expose']['identifier']]); + } + } + + if ($status) { + if (!isset($_SESSION['views'][$this->view->name][$display_id])) { + $_SESSION['views'][$this->view->name][$display_id] = array(); + } + + $session = &$_SESSION['views'][$this->view->name][$display_id]; + + } + return $var; + } + /** * Render our chunk of the exposed filter form when selecting */ function exposed_form(&$form, &$form_state) { parent::exposed_form($form, $form_state); - if (!empty($this->options['expose']['use_fields'])) { + if (!empty($this->options['expose']['use_fields_id']) && !empty($this->options['expose']['use_fields'])) { $use_fields = $this->options['expose']['use_fields_id']; $this->fields_form($form, $form_state); $form[$use_fields] = $form['use_fields']; @@ -198,6 +227,15 @@ '#default_value' => $this->options['min_length'], ); } + + /** + * Provide default options for exposed filter. + */ + public function expose_options() { + parent::expose_options(); + $this->options['expose']['use_fields'] = FALSE; + $this->options['expose']['fields_id'] = $this->options['id'] . '_fields_op'; + } /** * {@inheritdoc}