From b22d877ff84ad31b17d19090b8480ca2911ccef4 Mon Sep 17 00:00:00 2001 From: Neil Drumm <drumm@3064.no-reply.drupal.org> Date: Fri, 31 Mar 2006 04:57:49 +0000 Subject: [PATCH] #56457 by chx: The search box that can be displayed by some themes (e.g. bluemarine) was not working. --- modules/search.module | 25 ++++++++++++++----------- modules/search/search.module | 25 ++++++++++++++----------- modules/system.module | 3 +-- modules/system/system.module | 3 +-- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/modules/search.module b/modules/search.module index 647b856e082f..d7129c1e7968 100644 --- a/modules/search.module +++ b/modules/search.module @@ -969,7 +969,6 @@ function search_view() { * An HTML string containing the search form. */ function search_form($action = '', $keys = '', $type = NULL, $prompt = NULL) { - if (!$action) { $action = url('search/'. $type); } @@ -980,7 +979,6 @@ function search_form($action = '', $keys = '', $type = NULL, $prompt = NULL) { $form = array( '#action' => $action, '#attributes' => array('class' => 'search-form'), - '#redirect' => FALSE, ); $form['module'] = array('#type' => 'value', '#value' => $type); $form['basic'] = array('#type' => 'item', '#title' => $prompt); @@ -992,7 +990,8 @@ function search_form($action = '', $keys = '', $type = NULL, $prompt = NULL) { '#size' => $prompt ? 40 : 20, '#maxlength' => 255, ); - // processed_keys is used to coordinate keyword passing between other forms that hook into the basic search form. + // processed_keys is used to coordinate keyword passing between other forms + // that hook into the basic search form. $form['basic']['inline']['processed_keys'] = array('#type' => 'value', '#value' => array()); $form['basic']['inline']['submit'] = array('#type' => 'submit', '#value' => t('Search')); @@ -1000,27 +999,31 @@ function search_form($action = '', $keys = '', $type = NULL, $prompt = NULL) { } /** - * As the search form collates keys from other modules hooked in via hook_form_alter, the validation - * takes place in _submit. search_form_validate() is used solely to set the #ref property for the basic + * As the search form collates keys from other modules hooked in via + * hook_form_alter, the validation takes place in _submit. + * search_form_validate() is used solely to set the #ref property for the basic * search form. */ -function search_form_validate($form_id, $form_values) { - $form_values['processed_keys']['#ref'] = trim($form_values['keys']); +function search_form_validate($form_id, $form_values, $form) { + $form['basic']['inline']['processed_keys']['#ref'] = trim($form_values['keys']); } /** - * Process a search form submission. Uses a forms API #ref to accept processed search keys - * from forms that hook into the default search form. + * Process a search form submission. */ function search_form_submit($form_id, $form_values) { - $keys = $form_values['processed_keys']['#ref']; + $keys = $form_values['processed_keys']; if ($keys == '') { form_set_error('keys', t('Please enter some keywords.')); // Fall through to the drupal_goto() call. } $type = $form_values['module'] ? $form_values['module'] : 'node'; - drupal_goto('search/'. $type .'/'. $keys); + return 'search/'. $type .'/'. $keys; +} + +function search_box_submit($form_id, $form_values) { + return 'search/node/'. trim($form_values['keys']); } /** diff --git a/modules/search/search.module b/modules/search/search.module index 647b856e082f..d7129c1e7968 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -969,7 +969,6 @@ function search_view() { * An HTML string containing the search form. */ function search_form($action = '', $keys = '', $type = NULL, $prompt = NULL) { - if (!$action) { $action = url('search/'. $type); } @@ -980,7 +979,6 @@ function search_form($action = '', $keys = '', $type = NULL, $prompt = NULL) { $form = array( '#action' => $action, '#attributes' => array('class' => 'search-form'), - '#redirect' => FALSE, ); $form['module'] = array('#type' => 'value', '#value' => $type); $form['basic'] = array('#type' => 'item', '#title' => $prompt); @@ -992,7 +990,8 @@ function search_form($action = '', $keys = '', $type = NULL, $prompt = NULL) { '#size' => $prompt ? 40 : 20, '#maxlength' => 255, ); - // processed_keys is used to coordinate keyword passing between other forms that hook into the basic search form. + // processed_keys is used to coordinate keyword passing between other forms + // that hook into the basic search form. $form['basic']['inline']['processed_keys'] = array('#type' => 'value', '#value' => array()); $form['basic']['inline']['submit'] = array('#type' => 'submit', '#value' => t('Search')); @@ -1000,27 +999,31 @@ function search_form($action = '', $keys = '', $type = NULL, $prompt = NULL) { } /** - * As the search form collates keys from other modules hooked in via hook_form_alter, the validation - * takes place in _submit. search_form_validate() is used solely to set the #ref property for the basic + * As the search form collates keys from other modules hooked in via + * hook_form_alter, the validation takes place in _submit. + * search_form_validate() is used solely to set the #ref property for the basic * search form. */ -function search_form_validate($form_id, $form_values) { - $form_values['processed_keys']['#ref'] = trim($form_values['keys']); +function search_form_validate($form_id, $form_values, $form) { + $form['basic']['inline']['processed_keys']['#ref'] = trim($form_values['keys']); } /** - * Process a search form submission. Uses a forms API #ref to accept processed search keys - * from forms that hook into the default search form. + * Process a search form submission. */ function search_form_submit($form_id, $form_values) { - $keys = $form_values['processed_keys']['#ref']; + $keys = $form_values['processed_keys']; if ($keys == '') { form_set_error('keys', t('Please enter some keywords.')); // Fall through to the drupal_goto() call. } $type = $form_values['module'] ? $form_values['module'] : 'node'; - drupal_goto('search/'. $type .'/'. $keys); + return 'search/'. $type .'/'. $keys; +} + +function search_box_submit($form_id, $form_values) { + return 'search/node/'. trim($form_values['keys']); } /** diff --git a/modules/system.module b/modules/system.module index d5219765661f..a0dc4eb26ce4 100644 --- a/modules/system.module +++ b/modules/system.module @@ -1194,8 +1194,7 @@ function system_theme_settings($key = '') { * Output a search form. */ function search_box($path = NULL) { - $form['#action'] = is_null($path) ? url('search') : url($path); - $form['keys'] = array('#type' => 'textfield', '#size'=> 15, '#value' => '', '#attributes' => array('alt' => t('Enter the terms you wish to search for.'))); + $form['keys'] = array('#type' => 'textfield', '#size'=> 15, '#default_value' => '', '#attributes' => array('alt' => t('Enter the terms you wish to search for.'))); $form['submit'] = array('#type' => 'submit', '#value' => t('Search')); return drupal_get_form('search_box', $form); } diff --git a/modules/system/system.module b/modules/system/system.module index d5219765661f..a0dc4eb26ce4 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1194,8 +1194,7 @@ function system_theme_settings($key = '') { * Output a search form. */ function search_box($path = NULL) { - $form['#action'] = is_null($path) ? url('search') : url($path); - $form['keys'] = array('#type' => 'textfield', '#size'=> 15, '#value' => '', '#attributes' => array('alt' => t('Enter the terms you wish to search for.'))); + $form['keys'] = array('#type' => 'textfield', '#size'=> 15, '#default_value' => '', '#attributes' => array('alt' => t('Enter the terms you wish to search for.'))); $form['submit'] = array('#type' => 'submit', '#value' => t('Search')); return drupal_get_form('search_box', $form); } -- GitLab