You are here

function theme_google_appliance_search_view in Google Search Appliance 6.2

Theme the search results.

Parameters

array $search_view: Array of search parameters and results

Return value

Themed search results.

1 theme call to theme_google_appliance_search_view()
google_appliance_search_view in ./google_appliance.module
Search page results.

File

./google_appliance.module, line 1122
Google Search Appliance (GSA) / Google Mini integration

Code

function theme_google_appliance_search_view($search_view, $title = 'Search results') {
  $output = "";
  if (!empty($search_view['keys'])) {

    // Show the form
    $output .= theme('google_appliance_theme_form', $search_view['form']);

    // In some cases, Google Appliance returns a message instead of a result
    // array; for example, when results beyond 1,000 records are requested.
    if (!is_array($search_view['results'])) {
      $output .= $search_view['results'];
      return $output;
    }
    if ($search_view['results']) {
      foreach ($search_view['results'] as $key => $result) {
        $search_view['results'][$key]['title'] = drupal_html_to_text($result['title']);
      }

      // We can call theme('search_results') regardless of whether
      // search.module is enabled. See google_appliance_theme()
      // and google_appliance_preprocess_search_results()
      foreach ($search_view['results'] as $key => $result) {
        $search_view['results'][$key]['title'] = drupal_html_to_text($result['title']);
      }
      $search_results = theme('search_results', $search_view['results'], 'google-appliance');
      $results = theme('box', t($title), $search_results);
    }

    // Show any keymatches and/or synonyms found by the search.
    if ($search_view['keymatches']) {
      $output .= theme('google_appliance_keymatches', $search_view['keymatches']);
    }
    if ($search_view['synonyms']) {
      $output .= theme('google_appliance_synonyms', $search_view['synonyms']);
    }

    // Display the search results
    if ($results) {
      $output .= $results;
    }
    else {
      $message = variable_get('google_appliance_errorcode_1', t('Your search yielded no results'));
      $search_help = google_appliance_help('search#noresults', drupal_help_arg());
      $output .= theme('box', $message, $search_help);

      //theme_box()
    }
  }
  else {

    // No search term entered. Just show the form.
    $output .= $search_view['form'];
  }
  return $output;
}