Commit b22d877f authored by drumm's avatar drumm

#56457 by chx: The search box that can be displayed by some themes (e.g....

#56457 by chx: The search box that can be displayed by some themes (e.g. bluemarine) was not working.
parent a539a3aa
......@@ -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']);
}
/**
......
......@@ -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']);
}
/**
......
......@@ -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);
}
......
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment