function tripal_pub_AGL_range

2.x tripal_pub.AGL.inc tripal_pub_AGL_range($yazc, $search_str, $start, $num_to_retrieve, $total_records)
3.x tripal_chado.pub_importer_AGL.inc tripal_pub_AGL_range($yazc, $search_str, $start, $num_to_retrieve, $total_records)
1.x AGL.inc tripal_pub_AGL_range($search_array, $start = 0, $limit = 10)

Retreives a range of publications from AGL.

Parameters

$yazc: The YAZC connection object.

$search_str: The search string to use for searching.

$start: The start of the range

$num_to_retrieve: The number of publications to retrieve

$total_records: The total number of records in the dataset. This value should have been retrieved by tripal_pub_AGL_count() function.

Return value

An array containing the total_records in the dataaset, the search string and an array of the publications that were retreived.

Related topics

1 call to tripal_pub_AGL_range()
tripal_pub_remote_search_AGL in tripal_pub/includes/importers/tripal_pub.AGL.inc
A hook for performing the search on the AGL database.

File

tripal_pub/includes/importers/tripal_pub.AGL.inc, line 437
Importer for the USDA Agricultural Library (Agricola).

Code

function tripal_pub_AGL_range($yazc, $search_str, $start, $num_to_retrieve, $total_records) {

  yaz_range($yazc, 1, $total_records);
  if (!yaz_present($yazc)) {
    $error_no = yaz_errno($yazc);
    $error_msg = yaz_error($yazc);
    $additional = yaz_addinfo($yazc);
    if ($additional != $error_msg) {
      $error_msg .= " $additional";
    }
    drupal_set_message("ERROR waiting on search at AGL: ($error_no) $error_msg", "error");
    watchdog('tpub_import', "ERROR waiting on search at AGL: (%error_no) %error_msg", 
    array('%error_no' => $error_no, '%error_msg' => $error_msg), WATCHDOG_ERROR);
    return array(
      'total_records' => 0,
      'search_str' => $search_str,
      'pubs' => array(),
    );
  }
  if ($start + $num_to_retrieve > $total_records) {
    $num_to_retrieve = $total_records - $start;
  }

  $pubs = array();
  for ($i = $start; $i < $start + $num_to_retrieve; $i++) {
    // retrieve the XML results
    $pub_xml = yaz_record($yazc, $i + 1, 'xml; charset=marc-8,utf-8');
    if (!$pub_xml) {
      $error_no = yaz_errno($yazc);
      $error_msg = yaz_error($yazc);
      drupal_set_message("ERROR retrieving records from AGL: ($error_no) $error_msg", "error");
      watchdog('tpub_import', "ERROR retrieving records from AGL: (%error_no) %error_msg", 
      array('%error_no' => $error_no, '%error_msg' => $error_msg), WATCHDOG_ERROR);
      return array(
        'total_records' => 0,
        'search_str' => $search_str,
        'pubs' => array(),
      );
    }

    // parse the pub XML
    $pub = tripal_pub_AGL_parse_pubxml($pub_xml);
    $pubs[] = $pub;
  }
  return array(
    'total_records' => $total_records,
    'search_str' => $search_str,
    'pubs' => $pubs,
  );
}