Index: modules/search/search.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/search/search.pages.inc,v retrieving revision 1.4 diff -u -p -r1.4 search.pages.inc --- modules/search/search.pages.inc 6 Dec 2007 09:51:01 -0000 1.4 +++ modules/search/search.pages.inc 18 Dec 2007 02:31:14 -0000 @@ -10,6 +10,8 @@ * Menu callback; presents the search form and/or search results. */ function search_view($type = 'node') { + global $pager_page_array, $pager_total_items, $search_timer; + // Search form submits with POST but redirects to GET. This way we can keep // the search query URL clean as a whistle: // search/type/keyword+keyword @@ -24,15 +26,31 @@ function search_view($type = 'node') { $keys = search_get_keys(); // Only perform search if there is non-whitespace search term: $results = ''; + $search_statistics = ''; if (trim($keys)) { - // Log the search keys: - watchdog('search', '%keys (@type).', array('%keys' => $keys, '@type' => module_invoke($type, 'search', 'name')), WATCHDOG_NOTICE, l(t('results'), 'search/'. $type .'/'. $keys)); + timer_start('search'); // Collect the search results: $results = search_data($keys, $type); + if (!isset($search_timer)){ + $search_timer = timer_stop('search'); + } + + // Log the search keys: + $message = '%keys (@type) - @result in @time sec'; + $variables = array('%keys' => $keys, '@type' => module_invoke($type, 'search', 'name'), '@result' => format_plural($pager_total_items[0], '1 match', '@count matches'), '@time' => round($search_timer['time'] / 1000, 2)); + watchdog('search', $message, $variables, WATCHDOG_NOTICE, l(t('results'), 'search/'. $type .'/'. $keys)); + if ($results) { $results = theme('box', t('Search results'), $results); + + $values['@pager_total'] = $pager_total_items[0]; + $values['@pager_start'] = ($pager_page_array[0] * 10) + 1; + $values['@pager_end'] = min(($pager_page_array[0] + 1) * 10, $values['@pager_total']); + $values['@time'] = round($search_timer['time'] / 1000, 2); + $values['%keys'] = search_get_keys(); + $search_statistics = t('Displaying @pager_start - @pager_end of @pager_total for %keys. ', $values) .'('. format_interval($values['@time']) .')'; } else { $results = theme('box', t('Your search yielded no results'), search_help('search#noresults', drupal_help_arg())); @@ -42,6 +60,7 @@ function search_view($type = 'node') { // Construct the search form. $output = drupal_get_form('search_form', NULL, $keys, $type); $output .= $results; + $output .= $search_statistics; return $output; }