function apachesolr_search_search_box_form_submit in Apache Solr Search 6.3
Same name and namespace in other branches
- 5.2 apachesolr_search.module \apachesolr_search_search_box_form_submit()
- 6 apachesolr_search.module \apachesolr_search_search_box_form_submit()
- 6.2 apachesolr_search.module \apachesolr_search_search_box_form_submit()
Process a block search form submission.
See also
1 string reference to 'apachesolr_search_search_box_form_submit'
- apachesolr_search_form_search_block_form_alter in ./
apachesolr_search.module - Implements hook_form_[form_id]_alter().
File
- ./
apachesolr_search.module, line 825 - Provides a content search implementation for node content for use with the Apache Solr search application.
Code
function apachesolr_search_search_box_form_submit($form, &$form_state) {
global $language;
// The search form relies on control of the redirect destination for its
// functionality, so we override any static destination set in the request,
// for example by drupal_access_denied() or drupal_not_found()
// (see http://drupal.org/node/292565).
if (isset($_REQUEST['destination'])) {
unset($_REQUEST['destination']);
}
if (isset($_REQUEST['edit']['destination'])) {
unset($_REQUEST['edit']['destination']);
}
$form_id = $form['form_id']['#value'];
$keys = $form_state['values'][$form_id];
// Replace keys with their rawurlencoded value
$keys = str_replace("/", "%2f", $keys);
// Handle Apache webserver clean URL quirks.
if (variable_get('clean_url', '0')) {
$keys = str_replace('+', '%2B', $keys);
}
$path = $form['#action'];
// Create a regular expression string to find the base_path at the beginning
// of the string.
$base_path_regex = '#^' . base_path() . '#';
// Find the base_path in the path()
if (preg_match($base_path_regex, $path)) {
// Replace the beginning of the string with nothing. The regular expression
// avoids that we replace too much
$path = preg_replace($base_path_regex, '', $path);
}
if (!empty($language->prefix)) {
// Create a regular expression string to find a language prefix at the
// beginning of the string
$lang_prefix_regex = '#^' . $language->prefix . '/#';
// Find the language prefix in the path.
if (preg_match($lang_prefix_regex, $path)) {
// Replace the beginning of the string with nothing. The regular expression
// avoids that we replace too much.
$path = preg_replace($lang_prefix_regex, '', $path);
}
}
// Set our path to the correct search page
$form_state['redirect'] = $path . '/' . trim($keys);
}