protected $solrsort = array('#name' => 'score', '#direction' => 'desc');
// A flag to allow the search to be aborted.
public $abort_search = FALSE;
-
+
// A flag to check if need to retrieve another page of the result set
public $page = 0;
return $this->base_path . '/' . $this->getParam('q');
}
else {
- return $this->base_path;
+ // Return with empty query (the slash). The path for a facet
+ // becomes $this->base_path . '//facetinfo';
+ // We do this so we can have a consistent way of retrieving the query +
+ // additional parameters
+ return $this->base_path . '/';
}
}
'file path' => drupal_get_path('module', 'apachesolr_search'),
);
- $items[$search_page['search_path'] . '/%menu_tail'] = array(
+ // Not using menu tail because of inflexibility with clean urls
+ $items[$search_page['search_path'] . '/%'] = array(
'title' => $page_title,
'load arguments' => array('%map', '%index'),
'page callback' => 'apachesolr_search_custom_page',
$title_callback = $search_type['title callback'];
$items[$search_page['search_path']]['title callback'] = $title_callback;
$items[$search_page['search_path']]['title arguments'] = array($search_page['page_id'], $position);
- $items[$search_page['search_path'] . '/%menu_tail']['title callback'] = $title_callback;
- $items[$search_page['search_path'] . '/%menu_tail']['title arguments'] = array($search_page['page_id'], $position);
+ $items[$search_page['search_path'] . '/%']['title callback'] = $title_callback;
+ $items[$search_page['search_path'] . '/%']['title arguments'] = array($search_page['page_id'], $position);
}
// If we have additional searches in the search/* path
if ($core_search) {
- $items[$search_page['search_path'] . '/%menu_tail']['tab_root'] = 'search/' . $default_info['path'] . '/%';
- $items[$search_page['search_path'] . '/%menu_tail']['tab_parent'] = 'search/' . $default_info['path'];
+ $items[$search_page['search_path'] . '/%']['tab_root'] = 'search/' . $default_info['path'] . '/%';
+ $items[$search_page['search_path'] . '/%']['tab_parent'] = 'search/' . $default_info['path'];
}
if ($taxonomy_search) {
menu_rebuild();
}
-
+function apachesolr_search_form_search_block_form_alter(&$form, $form_state) {
+ if (variable_get('search_default_module') == 'apachesolr_search') {
+ $form['#submit'][] = 'apachesolr_search_form_search_submit';
+ }
+}
/**
* Implements hook_form_[form_id]_alter().
*
*/
function apachesolr_search_form_search_submit($form, &$form_state) {
$fv = $form_state['values'];
- $get = json_decode($fv['apachesolr_search']['get'], TRUE);
- if (!empty($fv['apachesolr_search']['retain-filters'])) {
- $get['retain-filters'] = '1';
- // Add the query values into the redirect.
- $form_state['redirect'] = array($form_state['redirect'], array('query' => $get));
+
+ if (isset($fv['apachesolr_search'])) {
+ $get = json_decode($fv['apachesolr_search']['get'], TRUE);
+ if (!empty($fv['apachesolr_search']['retain-filters'])) {
+ $get['retain-filters'] = '1';
+ // Add the query values into the redirect.
+ $form_state['redirect'] = array($form_state['redirect'], array('query' => $get));
+ }
+ }
+
+ // Replace keys with their rawurldecoded value
+ if (isset($fv['search_block_form'])) {
+ $raw_keys = rawurlencode($fv['search_block_form']);
+ $form_state['redirect'] = str_replace($fv['search_block_form'], $raw_keys, $form_state['redirect']);
}
}
$search_page->search_path = str_replace('%', $path_replacer, $search_page->search_path);
// Retrieve the conditions that apply to this page
$conditions = apachesolr_search_conditions_default($search_page);
+ // Process our keys so they are clean
+ $keys = rawurldecode($keys);
// Retrieve the results of the search
$results = apachesolr_search_search_results($keys, $conditions, $search_page);
// Initiate our build array
function apachesolr_search_custom_page_search_form_submit(&$form, &$form_state) {
$search_page = $form['#search_page'];
$redirect = $search_page->search_path;
+
+ // Also encode slashes so we don't get akward situations when obtaining the
+ // search key. We can't use drupal_encode_path because for "aestetic" reasons
+ // they don't encode slashes...
+ $redirect_value = rawurlencode($form_state['values']['keys']);
+
if (strlen($form_state['values']['keys'])) {
- $redirect .= '/' . $form_state['values']['keys'];
+ $redirect .= '/' . $redirect_value;
}
if (isset($form_state['values']['get'])) {
$get = json_decode($form_state['values']['get'], TRUE);