You are here

function theme_google_appliance_search_result_array in Google Search Appliance 6.2

Same name and namespace in other branches
  1. 5 google_appliance.module \theme_google_appliance_search_result_array()

Theme the search results for hook_search().

Parameters

$result: A single GSA search result (SimpleXMLElement object)

$total_results: The number of results returned for the search.

Return value

An array, usable by the search module. @see template_preprocess_search_result()

1 theme call to theme_google_appliance_search_result_array()
_google_appliance_search in ./google_appliance.module
Perform the search

File

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

Code

function theme_google_appliance_search_result_array($result, $keys) {
  $result = $result->result;

  // Attributes
  $attributes = array();
  foreach ($result
    ->attributes() as $name => $value) {
    $attributes[$name] = (string) $value;
  }

  // Meta data (from <meta> tags)
  $meta_data = array();
  if (isset($result->MT)) {
    foreach ($result->MT as $meta) {
      $value = (string) $meta['V'];
      $name = (string) $meta['N'];
      $names = explode(':', $name, 2);
      if (count($names) == 2) {
        $meta_data[$names[0]][$names[1]][] = $value;
      }
      else {
        $meta_data[$name][] = $value;
      }
    }
  }
  $link = (string) $result->U;

  // Identifier of a document in the GSA cache
  $cid = (string) $result->HAS->C
    ->attributes()->CID;

  // These fields are processed by *_preprocess_search_result()
  // functions, including:
  // - template_preprocess_search_result()
  // - google_appliance_preprocess_search_result()
  return array(
    // Google Appliance-specific items:
    'google_appliance' => TRUE,
    // A flag for the pre-process functions.
    'attributes' => $attributes,
    'meta_data' => $meta_data,
    // Standard search result items:
    'link' => $link,
    'title' => strip_tags($result->T),
    'snippet' => decode_entities((string) $result->S),
    'type' => $meta_data['type'][0],
    'user' => $meta_data['author'][0],
    'date' => strtotime($meta_data['modified'][0]),
    'extra' => array(
      'cached_link' => theme('google_appliance_cached_link', $link, $cid, $keys),
    ),
  );
}