function apachesolr_search_conditions_default in Apache Solr Search 7
Same name and namespace in other branches
- 8 apachesolr_search.module \apachesolr_search_conditions_default()
- 6.3 apachesolr_search.module \apachesolr_search_conditions_default()
4 calls to apachesolr_search_conditions_default()
- apachesolr_search_conditions in ./apachesolr_search.module
- Implementation of a search_view() conditions callback.
- apachesolr_search_custom_page in ./apachesolr_search.pages.inc
- Returns search results on user defined search pages.
- apachesolr_search_init in ./apachesolr_search.module
- Implements hook_init().
- apachesolr_search_search_results in ./apachesolr_search.module
- Executes search depending on the conditions given.
See apachesolr_search.pages.inc for another use of this function
File
- ./apachesolr_search.module, line 958
- Provides a content search implementation for node content for use with the
Apache Solr search application.
Code
function apachesolr_search_conditions_default($search_page) {
$conditions = array();
$search_type = isset($search_page['settings']['apachesolr_search_search_type']) ? $search_page['settings']['apachesolr_search_search_type'] : '';
$allow_user_input = isset($search_page['settings']['apachesolr_search_allow_user_input']) ? $search_page['settings']['apachesolr_search_allow_user_input'] : FALSE;
$path_replacer = isset($search_page['settings']['apachesolr_search_path_replacer']) ? $search_page['settings']['apachesolr_search_path_replacer'] : '';
$set_custom_filter = isset($search_page['settings']['apachesolr_search_custom_enable']) ? $search_page['settings']['apachesolr_search_custom_enable'] : '';
$search_page_fq = !empty($search_page['settings']['fq']) ? $search_page['settings']['fq'] : '';
$conditions['fq'] = array();
if ($allow_user_input) {
if (!empty($_GET['fq']) && is_array($_GET['fq'])) {
$conditions['fq'] = $_GET['fq'];
}
foreach ($conditions['fq'] as $condition_id => $condition) {
$test_query = apachesolr_drupal_subquery('Test');
if (!$test_query
->validFilterValue($condition)) {
unset($conditions['fq'][$condition_id]);
}
}
}
if (!empty($search_page_fq) && !empty($set_custom_filter)) {
if (!empty($path_replacer)) {
$conditions['fq'][] = str_replace('%', $path_replacer, $search_page_fq);
}
else {
$conditions['fq'][] = $search_page_fq;
}
}
if (!empty($path_replacer) && !empty($search_type) && $search_type != 'custom') {
$conditions['fq'][] = $search_type . ':' . $path_replacer;
}
if (!empty($_GET['f']) && is_array($_GET['f'])) {
if (module_exists('facetapi')) {
$conditions['f'] = $_GET['f'];
}
}
$sort = isset($_GET['solrsort']) ? $_GET['solrsort'] : '';
$conditions['apachesolr_search_sort'] = $sort;
return $conditions;
}