Commit cfe001af authored by Steven Wittens's avatar Steven Wittens
Browse files

#56457: Allow different search forms to coexist without breaking validation

parent be0b774c
...@@ -137,8 +137,8 @@ function search_block($op = 'list', $delta = 0) { ...@@ -137,8 +137,8 @@ function search_block($op = 'list', $delta = 0) {
$blocks[0]['info'] = t('Search form'); $blocks[0]['info'] = t('Search form');
return $blocks; return $blocks;
} }
else if ($op == 'view' && user_access('search content') && arg(0) != 'search') { else if ($op == 'view' && user_access('search content')) {
$block['content'] = search_form('', '', null, ''); $block['content'] = search_box('search_block_form');
$block['subject'] = t('Search'); $block['subject'] = t('Search');
return $block; return $block;
} }
...@@ -1023,8 +1023,44 @@ function search_form_submit($form_id, $form_values) { ...@@ -1023,8 +1023,44 @@ function search_form_submit($form_id, $form_values) {
return 'search/'. $type .'/'. $keys; return 'search/'. $type .'/'. $keys;
} }
function search_box_submit($form_id, $form_values) { /**
return 'search/node/'. trim($form_values['keys']); * Output a search form for the search block and the theme's search box.
*/
function search_box($form_id = 'search_theme_form') {
// Use search_keys instead of keys to avoid ID conflicts with the search block.
$form[$form_id .'_keys'] = array(
'#type' => 'textfield',
'#size' => 15,
'#default_value' => '',
'#attributes' => array('title' => t('Enter the terms you wish to search for.')),
);
if ($form_id == 'search_theme_form') {
$form['#theme']['theme_search_theme_form'] = array();
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Search'));
return drupal_get_form($form_id, $form, 'search_box_form');
}
/**
* Process a block search form submission.
*/
function search_box_form_submit($form_id, $form_values) {
return 'search/node/'. trim($form_values[$form_id .'_keys']);
}
/**
* Theme the theme search form.
*/
function theme_search_theme_form($form) {
return '<div id="search" class="container-inline">'. form_render($form) .'</div>';
}
/**
* Theme the block search form.
*/
function theme_search_block_form($form) {
return '<div class="container-inline">'. form_render($form) .'</div>';
} }
/** /**
......
...@@ -137,8 +137,8 @@ function search_block($op = 'list', $delta = 0) { ...@@ -137,8 +137,8 @@ function search_block($op = 'list', $delta = 0) {
$blocks[0]['info'] = t('Search form'); $blocks[0]['info'] = t('Search form');
return $blocks; return $blocks;
} }
else if ($op == 'view' && user_access('search content') && arg(0) != 'search') { else if ($op == 'view' && user_access('search content')) {
$block['content'] = search_form('', '', null, ''); $block['content'] = search_box('search_block_form');
$block['subject'] = t('Search'); $block['subject'] = t('Search');
return $block; return $block;
} }
...@@ -1023,8 +1023,44 @@ function search_form_submit($form_id, $form_values) { ...@@ -1023,8 +1023,44 @@ function search_form_submit($form_id, $form_values) {
return 'search/'. $type .'/'. $keys; return 'search/'. $type .'/'. $keys;
} }
function search_box_submit($form_id, $form_values) { /**
return 'search/node/'. trim($form_values['keys']); * Output a search form for the search block and the theme's search box.
*/
function search_box($form_id = 'search_theme_form') {
// Use search_keys instead of keys to avoid ID conflicts with the search block.
$form[$form_id .'_keys'] = array(
'#type' => 'textfield',
'#size' => 15,
'#default_value' => '',
'#attributes' => array('title' => t('Enter the terms you wish to search for.')),
);
if ($form_id == 'search_theme_form') {
$form['#theme']['theme_search_theme_form'] = array();
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Search'));
return drupal_get_form($form_id, $form, 'search_box_form');
}
/**
* Process a block search form submission.
*/
function search_box_form_submit($form_id, $form_values) {
return 'search/node/'. trim($form_values[$form_id .'_keys']);
}
/**
* Theme the theme search form.
*/
function theme_search_theme_form($form) {
return '<div id="search" class="container-inline">'. form_render($form) .'</div>';
}
/**
* Theme the block search form.
*/
function theme_search_block_form($form) {
return '<div class="container-inline">'. form_render($form) .'</div>';
} }
/** /**
......
...@@ -1210,25 +1210,6 @@ function system_theme_settings($key = '') { ...@@ -1210,25 +1210,6 @@ function system_theme_settings($key = '') {
} }
/**
* Output a search form.
*/
function search_box($path = NULL) {
$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);
}
/**
* Theme a search form.
*/
function theme_search_box($form) {
$output = '<div id="search" class="container-inline">';
$output .= form_render($form);
$output .= '</div>';
return $output;
}
/** /**
* Output a confirmation form * Output a confirmation form
* *
......
...@@ -1210,25 +1210,6 @@ function system_theme_settings($key = '') { ...@@ -1210,25 +1210,6 @@ function system_theme_settings($key = '') {
} }
/**
* Output a search form.
*/
function search_box($path = NULL) {
$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);
}
/**
* Theme a search form.
*/
function theme_search_box($form) {
$output = '<div id="search" class="container-inline">';
$output .= form_render($form);
$output .= '</div>';
return $output;
}
/** /**
* Output a confirmation form * Output a confirmation 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