function search_log_preprocess_search_results in Search Log 7
Same name and namespace in other branches
- 6 search_log.module \search_log_preprocess_search_results()
 
Process search results.
The $variables array contains the following arguments:
- $results
 - $type
 
Search does not have a hook to obtain the number of search results. This theme function is called only if a module has not implemented search_page. The logic is changed from D6 since this function is called on empty results.
See also
search_view(), search_data(), template_preprocess_search_results()
File
- ./
search_log.module, line 270  - Replaces default report of top search phrases.
 
Code
function search_log_preprocess_search_results(&$variables) {
  if (!variable_get('search_log_preprocess', TRUE) || !empty($variables['results'])) {
    return;
  }
  global $language;
  $keys = _search_log_normalize_keys(urldecode(arg(2)));
  $module = $variables['module'];
  $today = _search_log_get_time();
  if ($qid = db_query("SELECT qid FROM {search_log} WHERE q = :q AND module = :module AND language = :language AND day = :day", array(
    ':q' => $keys,
    ':module' => $module,
    ':language' => $language->language,
    ':day' => $today,
  ))
    ->fetchField()) {
    db_update('search_log')
      ->fields(array(
      'result' => SEARCH_LOG_RESULT_FAILED,
    ))
      ->condition('qid', $qid)
      ->execute();
  }
}