function google_appliance_preprocess_search_results in Google Search Appliance 6.2
Process variables for search-results.tpl.php. See search-results.tpl.php
File
- ./
google_appliance.module, line 416 - Google Search Appliance (GSA) / Google Mini integration
Code
function google_appliance_preprocess_search_results(&$variables) {
$results = $variables['results'];
// Only preprocess the results of a Google Appliance search.
if (empty($results[0]['google_appliance'])) {
// theme('search_results') is not called if there are no results.
return;
}
// Pager needs to use the correct number of results per-page
$element = 0;
$limit = variable_get('google_appliance_limit_per_page', GOOGLE_APPLIANCE_RESULTS_PER_PAGE_DEFAULT);
$variables['pager'] = theme('pager', NULL, $limit, $element);
// Provide the range and total
global $pager_total_items;
$variables['total_results'] = $pager_total_items[$element];
$range_from = (int) $results[0]['attributes']['N'];
$range_to = (int) $results[count($results) - 1]['attributes']['N'];
$substitutions = array(
'@from' => $range_from,
'@to' => $range_to,
'@total' => $pager_total_items[$element],
);
if ($range_from != $range_to) {
$range = t("Showing results @from to @to of @total", $substitutions);
}
else {
$range = t("Showing result @from of @total", $substitutions);
}
$variables['range_from'] = $range_from;
$variables['range_to'] = $range_to;
$variables['range'] = $range;
// Theme the results
if (empty($variables['search_results'])) {
$variables['search_results'] = '';
foreach ($results as $result) {
$variables['search_results'] .= theme('search_result', $result, $variables['type']);
}
}
// Allow optional search-results-google-appliance.tpl.php in theme.
$variables['template_files'][] = 'search-results-google-appliance';
}