You are here

function apachesolr_search_custom_page_search_form_submit in Apache Solr Search 6.3

Same name and namespace in other branches
  1. 8 apachesolr_search.pages.inc \apachesolr_search_custom_page_search_form_submit()
  2. 7 apachesolr_search.pages.inc \apachesolr_search_custom_page_search_form_submit()

Processes apachesolr_search_custom_page_search_form submissions.

File

./apachesolr_search.pages.inc, line 98
Provides the page callback for user defined search pages.

Code

function apachesolr_search_custom_page_search_form_submit(&$form, &$form_state) {
  $search_page = $form['#search_page'];
  $redirect = $search_page['search_path'];
  if (strlen($form_state['values']['keys'])) {

    // Replace keys with their rawurlencoded value
    $keys = str_replace("/", "%2f", $form_state['values']['keys']);
    $redirect .= '/' . $keys;
  }
  $get = array();
  if (isset($form_state['values']['get'])) {
    $get = json_decode($form_state['values']['get'], TRUE);
  }
  if (!empty($form_state['values']['retain-filters'])) {

    // Add our saved values
    $get['retain-filters'] = '1';
  }
  else {

    // Remove all filters
    if (!empty($search_page['settings']['apachesolr_search_allow_user_input'])) {
      unset($get['fq']);
    }
    if (module_exists('facetapi')) {
      unset($get['f']);
    }
  }

  // Add the query values into the redirect.
  $form_state['redirect'] = array(
    $redirect,
    $get,
  );
}