diff --git a/includes/view.inc b/includes/view.inc index d8c0c1f..7dd93db 100644 --- a/includes/view.inc +++ b/includes/view.inc @@ -411,18 +411,8 @@ class view extends views_db_object { * Figure out what the exposed input for this view is. */ function get_exposed_input() { - // Fill our input either from $_GET or from something previously set on the - // view. if (empty($this->exposed_input)) { - $this->exposed_input = $_GET; - // unset items that are definitely not our input: - foreach (array('page', 'q') as $key) { - if (isset($this->exposed_input[$key])) { - unset($this->exposed_input[$key]); - } - } - - // If we have no input at all, check for remembered input via session. + $this->exposed_input = array(); // If filters are not overridden, store the 'remember' settings on the // default display. If they are, store them on this display. This way, @@ -430,9 +420,17 @@ class view extends views_db_object { // remember settings. $display_id = ($this->display_handler->is_defaulted('filters')) ? 'default' : $this->current_display; - if (empty($this->exposed_input) && !empty($_SESSION['views'][$this->name][$display_id])) { + // Start with remembered input via session. + if (!empty($_SESSION['views'][$this->name][$display_id])) { $this->exposed_input = $_SESSION['views'][$this->name][$display_id]; } + + // Fetch exposed input values from $_GET. Overwrite if clashing. + foreach ($_GET as $key => $value) { + if (!in_array($key, array('page', 'q'))) { + $this->exposed_input[$key] = $value; + } + } } return $this->exposed_input; diff --git a/tests/views_exposed_form.test b/tests/views_exposed_form.test index 72baf2c..0308541 100644 --- a/tests/views_exposed_form.test +++ b/tests/views_exposed_form.test @@ -29,7 +29,7 @@ class ViewsExposedFormTest extends ViewsSqlTest { /** * Tests, whether and how the reset button can be renamed. */ - public function testRenameResetButton() { + public function dtestRenameResetButton() { $account = $this->drupalCreateUser(); $this->drupalLogin($account); // Create some random nodes. @@ -57,14 +57,48 @@ class ViewsExposedFormTest extends ViewsSqlTest { } /** + * Tests that exposed values are correctly stored. + */ + public function testRemember() { + $account = $this->drupalCreateUser(); + $this->drupalLogin($account); + // Create some random nodes. + for ($i = 0; $i < 5; $i++) { + $this->drupalCreateNode(); + } + // Rename the label of the reset button. + $view = views_get_view('test_exposed_admin_ui'); + $view->set_display('default'); + $view->display_handler->display->display_options['filters']['type']['exposed'] = 1; + $view->display_handler->display->display_options['filters']['type']['expose']['operator'] = 'type_op'; + $view->display_handler->display->display_options['filters']['type']['expose']['identifier'] = 'type'; + $view->display_handler->display->display_options['filters']['type']['expose']['remember'] = 1; + $view->display_handler->display->display_options['filters']['type']['expose']['remember_roles'] = array('authenticated'); + $view->save(); + + // Set the exposed filter. + $this->drupalGet('test_exposed_admin_ui', array('query' => array('type' => 'page'))); + + // Request the page again, should still be set. + $this->drupalGet('test_exposed_admin_ui'); + $this->assertFieldByName('type', 'page'); + + // Request the page with a GET argument, filter should still be set. + $this->drupalGet('test_exposed_admin_ui', array('query' => array('argument' => 'value'))); + $this->assertFieldByName('type', 'page'); + } + + /** * Tests the admin interface of exposed filter and sort items. */ - function testExposedAdminUi() { + function dtestExposedAdminUi() { $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration')); $this->drupalLogin($admin_user); menu_rebuild(); $edit = array(); + //options[expose][remember] + $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'); // Be sure that the button is called exposed. $this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose filter'));