From cfe001af7a26926f02672275dcd516841fc1b985 Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Thu, 6 Apr 2006 13:07:22 +0000 Subject: #56457: Allow different search forms to coexist without breaking validation --- modules/search.module | 44 ++++++++++++++++++++++++++++++++++++++++---- modules/search/search.module | 44 ++++++++++++++++++++++++++++++++++++++++---- modules/system.module | 19 ------------------- modules/system/system.module | 19 ------------------- 4 files changed, 80 insertions(+), 46 deletions(-) (limited to 'modules') 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 ''; +} + +/** + * Theme the block search form. + */ +function theme_search_block_form($form) { + return '
'. form_render($form) .'
'; } /** diff --git a/modules/search/search.module b/modules/search/search.module index 59972ef0b..97897c0ca 100644 --- a/modules/search/search.module +++ b/modules/search/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 ''; +} + +/** + * Theme the block search form. + */ +function theme_search_block_form($form) { + return '
'. form_render($form) .'
'; } /** diff --git a/modules/system.module b/modules/system.module index ae7d2580d..54182afaa 100644 --- a/modules/system.module +++ b/modules/system.module @@ -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 = ''; - return $output; -} - /** * Output a confirmation form * diff --git a/modules/system/system.module b/modules/system/system.module index ae7d2580d..54182afaa 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -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 = ''; - return $output; -} - /** * Output a confirmation form * -- cgit v1.2.3