summaryrefslogtreecommitdiff
path: root/modules/search.module
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2006-04-06 13:07:22 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2006-04-06 13:07:22 +0000
commitcfe001af7a26926f02672275dcd516841fc1b985 (patch)
tree938e2bde84787a01e8d5932cf587a1dccb77b30a /modules/search.module
parentbe0b774cbcae15a664eff0f308b436aabd6f3dd0 (diff)
downloadbrdo-cfe001af7a26926f02672275dcd516841fc1b985.tar.gz
brdo-cfe001af7a26926f02672275dcd516841fc1b985.tar.bz2
#56457: Allow different search forms to coexist without breaking validation
Diffstat (limited to 'modules/search.module')
-rw-r--r--modules/search.module44
1 files changed, 40 insertions, 4 deletions
diff --git a/modules/search.module b/modules/search.module
index 59972ef0b..97897c0ca 100644
--- a/modules/search.module
+++ b/modules/search.module
@@ -137,8 +137,8 @@ function search_block($op = 'list', $delta = 0) {
$blocks[0]['info'] = t('Search form');
return $blocks;
}
- else if ($op == 'view' && user_access('search content') && arg(0) != 'search') {
- $block['content'] = search_form('', '', null, '');
+ else if ($op == 'view' && user_access('search content')) {
+ $block['content'] = search_box('search_block_form');
$block['subject'] = t('Search');
return $block;
}
@@ -1023,8 +1023,44 @@ function search_form_submit($form_id, $form_values) {
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>';
}
/**