| 1 |
<?php |
<?php |
| 2 |
// $Id: luceneapi.module,v 1.18.2.6 2009/02/27 16:15:54 cpliakas Exp $ |
// $Id: luceneapi.module,v 1.18.2.7 2009/02/27 16:24:35 cpliakas Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 1212 |
$type = $form_values['module']; |
$type = $form_values['module']; |
| 1213 |
} |
} |
| 1214 |
else { |
else { |
| 1215 |
if (!$type = luceneapi_default_search()) { |
if (!$type = luceneapi_setting_get('default_search')) { |
| 1216 |
$type = 'node'; |
$type = 'node'; |
| 1217 |
} |
} |
| 1218 |
} |
} |
| 1228 |
} |
} |
| 1229 |
|
|
| 1230 |
/** |
/** |
| 1231 |
* 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 |
| 1232 |
* when hook_luceneapi_index('default search') is invoked. |
* pulls out extra form elements places them in the query string so they can be |
| 1233 |
|
* retrieved by luceneapi_facet_value(). |
| 1234 |
* |
* |
| 1235 |
* NOTE: We refer to this as "hijacking the search box". |
* NOTE: We refer to this as "hijacking the search box". |
| 1236 |
* |
* |
| 1244 |
function luceneapi_search_box_form_submit($form_id, $form_values) { |
function luceneapi_search_box_form_submit($form_id, $form_values) { |
| 1245 |
if ($module = luceneapi_setting_get('default_search')) { |
if ($module = luceneapi_setting_get('default_search')) { |
| 1246 |
if (in_array($module, luceneapi_module_list())) { |
if (in_array($module, luceneapi_module_list())) { |
| 1247 |
|
|
| 1248 |
|
// gets facets from $_POST |
| 1249 |
|
$strip = array( |
| 1250 |
|
'search_theme_form_keys', 'op', 'submit', 'form_token', 'form_id', 'search_theme_form' |
| 1251 |
|
); |
| 1252 |
|
$facets = array(); |
| 1253 |
|
foreach ($form_values as $element => $value) { |
| 1254 |
|
if (!in_array($element, $strip)) { |
| 1255 |
|
$facets[$element] = $value; |
| 1256 |
|
} |
| 1257 |
|
} |
| 1258 |
|
|
| 1259 |
|
// returns search path |
| 1260 |
$keys = trim($form_values[$form_id .'_keys']); |
$keys = trim($form_values[$form_id .'_keys']); |
| 1261 |
return sprintf('search/%s/%s', $module, $keys); |
$path = sprintf('search/%s/%s', $module, $keys); |
| 1262 |
|
if (empty($facets)) { |
| 1263 |
|
return $path; |
| 1264 |
|
} |
| 1265 |
|
else { |
| 1266 |
|
return array($path, drupal_query_string_encode($facets)); |
| 1267 |
|
} |
| 1268 |
} |
} |
| 1269 |
else { |
else { |
| 1270 |
luceneapi_throw_error(_luceneapi_get_hook_error($module), NULL); |
luceneapi_throw_error(_luceneapi_get_hook_error($module), NULL); |