You are here

function GoogleMini::resultFactory in Google Search Appliance 5

Same name and namespace in other branches
  1. 6.2 GoogleMini.php \GoogleMini::resultFactory()
2 calls to GoogleMini::resultFactory()
DrupalGoogleMini::query in ./DrupalGoogleMini.php
GoogleMini::query in ./GoogleMini.php

File

./GoogleMini.php, line 313

Class

GoogleMini

Code

function resultFactory($resultXML, $className = 'GoogleMiniResultIterator') {
  $results = array();
  $payload = simplexml_load_string($resultXML);
  $totalResults = $payload->RES->M;
  if ($totalResults == 0) {
    if (!$payload->GM) {
      throw new GoogleMiniResultException("No Results found", '1');
    }
  }
  else {
    foreach ($payload
      ->xpath('//R') as $res) {
      $results[] = $res;
    }
  }
  $iterator = new $className($results);
  $iterator->payload = $payload;
  $iterator->time = $payload->TM;
  $iterator->totalResults = $totalResults;
  return $iterator;
}