| 1 |
<?php |
<?php |
| 2 |
// $Id: luceneapi.module,v 1.21.2.8 2009/02/27 16:24:24 cpliakas Exp $ |
// $Id: luceneapi.module,v 1.21.2.9 2009/02/27 16:30:37 cpliakas Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 1181 |
$type = $form_state['values']['module']; |
$type = $form_state['values']['module']; |
| 1182 |
} |
} |
| 1183 |
else { |
else { |
| 1184 |
if (!$type = luceneapi_default_search()) { |
if (!$type = luceneapi_setting_get('default_search')) { |
| 1185 |
$type = 'node'; |
$type = 'node'; |
| 1186 |
} |
} |
| 1187 |
} |
} |
| 1197 |
} |
} |
| 1198 |
|
|
| 1199 |
/** |
/** |
| 1200 |
* Submit handler, redirects search box to the first module that returns TRUE |
* Redirects the core search box to the selected Search Lucene API module. Also |
| 1201 |
* when hook_luceneapi_index('default search') is invoked. |
* pulls out extra form elements and places them in the query string so they can |
| 1202 |
|
* be retrieved by luceneapi_facet_value(). |
| 1203 |
* |
* |
| 1204 |
* NOTE: We refer to this as "hijacking the search box". |
* NOTE: We refer to this as "hijacking the search box". |
| 1205 |
* |
* |
| 1213 |
function luceneapi_search_box_form_submit($form, &$form_state) { |
function luceneapi_search_box_form_submit($form, &$form_state) { |
| 1214 |
if ($module = luceneapi_setting_get('default_search')) { |
if ($module = luceneapi_setting_get('default_search')) { |
| 1215 |
if (in_array($module, luceneapi_module_list())) { |
if (in_array($module, luceneapi_module_list())) { |
| 1216 |
|
|
| 1217 |
|
// gets facets from $_POST |
| 1218 |
|
$strip = array( |
| 1219 |
|
'search_theme_form', 'op', 'submit', 'form_build_id', 'form_token', 'form_id' |
| 1220 |
|
); |
| 1221 |
|
$facets = array(); |
| 1222 |
|
foreach ($form_state['values'] as $element => $value) { |
| 1223 |
|
if (!in_array($element, $strip)) { |
| 1224 |
|
$facets[$element] = $value; |
| 1225 |
|
} |
| 1226 |
|
} |
| 1227 |
|
|
| 1228 |
|
// returns search path with facet data appended to query string |
| 1229 |
$keys = trim($form_state['values']['search_theme_form']); |
$keys = trim($form_state['values']['search_theme_form']); |
| 1230 |
$form_state['redirect'] = sprintf('search/%s/%s', $module, $keys); |
$path = sprintf('search/%s/%s', $module, $keys); |
| 1231 |
|
if (empty($facets)) { |
| 1232 |
|
$form_state['redirect'] = $path; |
| 1233 |
|
} |
| 1234 |
|
else { |
| 1235 |
|
$form_state['redirect'] = array($path, drupal_query_string_encode($facets)); |
| 1236 |
|
} |
| 1237 |
} |
} |
| 1238 |
else { |
else { |
| 1239 |
luceneapi_throw_error(_luceneapi_get_hook_error($module), NULL); |
luceneapi_throw_error(_luceneapi_get_hook_error($module), NULL); |