function apachesolr_multisitesearch_process_response in Apache Solr Multisite Search 6
Same name and namespace in other branches
- 6.2 apachesolr_multisitesearch.module \apachesolr_multisitesearch_process_response()
1 call to apachesolr_multisitesearch_process_response()
- apachesolr_multisitesearch_execute in ./
apachesolr_multisitesearch.module - Execute a search results based on keyword, filter, and sort strings.
File
- ./
apachesolr_multisitesearch.module, line 236 - Provides a multi-site search implementation for use with the Apache Solr module
Code
function apachesolr_multisitesearch_process_response($response, $query, $params) {
$results = array();
// We default to getting snippets from the body.
$hl_fl = is_null($params['hl.fl']) ? 'body' : $params['hl.fl'];
$total = $response->response->numFound;
apachesolr_pager_init($total, $params['rows']);
if ($total > 0) {
foreach ($response->response->docs as $doc) {
$extra = array();
// Find the nicest available snippet.
if (isset($response->highlighting->{$doc->id}->{$hl_fl})) {
$snippet = theme('apachesolr_search_snippets', $doc, $response->highlighting->{$doc->id}->{$hl_fl});
}
elseif (isset($doc->teaser)) {
$snippet = theme('apachesolr_search_snippets', $doc, array(
truncate_utf8($doc->teaser, 256, TRUE),
));
}
else {
$snippet = '';
}
if (!isset($doc->body)) {
$doc->body = $snippet;
}
$doc->created = strtotime($doc->created);
$doc->changed = strtotime($doc->changed);
// Allow modules to alter each document.
drupal_alter('apachesolr_search_result', $doc);
// Copy code from comment_nodeapi().
$extra[] = format_plural($doc->comment_count, '1 comment', '@count comments');
$results[] = array(
'link' => $doc->url,
'type' => $doc->type_name,
// template_preprocess_search_result() runs check_plain() on the title
// again. Decode to correct the display.
'title' => htmlspecialchars_decode($doc->title, ENT_QUOTES),
'user' => theme('apachesolr_multisitesearch_username', $doc),
'date' => $doc->created,
'node' => $doc,
'extra' => $extra,
'score' => $doc->score,
'snippet' => $snippet,
);
}
// Hook to allow modifications of the retrieved results
foreach (module_implements('apachesolr_process_results') as $module) {
$function = $module . '_apachesolr_process_results';
// 2nd param is a namespace for those modules which might use it.
$function($results, 'apachesolr_multisitesearch');
}
}
return $results;
}