Tripal
Functions
tripal_chado.pub_importer_AGL.inc File Reference

Functions

 tripal_pub_remote_alter_form_AGL ($form, $form_state, $num_criteria=1)
 
 tripal_pub_remote_validate_form_AGL ($form, $form_state)
 
 tripal_pub_remote_search_AGL ($search_array, $num_to_retrieve, $page)
 
 tripal_pub_AGL_range ($yazc, $search_str, $start, $num_to_retrieve, $total_records, $startyear, $endyear)
 
 tripal_pub_AGL_count ($yazc, $search_str)
 
 tripal_pub_AGL_decode ($text)
 
 tripal_pub_AGL_parse_pubxml ($pub_xml)
 
 tripal_pub_remote_search_AGL_get_subfield ($xml)
 
 tripal_pub_remote_search_AGL_get_author ($xml, $ind1)
 

Detailed Description

This file provides support for importing and parsing of results from the USDA National Agricultural Library (AGL) database. The functions here are used by both the publication importer setup form and the publication importer. The USDA AGL database uses a YAZ protocol for querying and retrieving records.

Function Documentation

◆ tripal_pub_AGL_count()

tripal_pub_AGL_count (   $yazc,
  $search_str 
)

Retrieves the total number of publications that match the search string.

Parameters
$yazcThe YAZC connection object.
$search_strThe search string to use for searching.
Returns
a count of the total number of publications that match the search string

◆ tripal_pub_AGL_decode()

tripal_pub_AGL_decode (   $text)

Decode the unusal text encoding returned from our call to yaz_record(..., 'xml; charset=marc-8,utf-8') Some characters are in UTF-8, some are encoded as HTML entities, and some HTML entities are double-encoded, for example ‘ A straight call to mb_convert_encoding() will corrupt any UTF-8 characters, so only convert what appears to be an HTML entity

Parameters
$textThe string to be decoded to "pure" UTF-8
Returns
The decoded string

◆ tripal_pub_AGL_parse_pubxml()

tripal_pub_AGL_parse_pubxml (   $pub_xml)

Parse publication XML for a single publication

Description of XML format: http://www.loc.gov/marc/bibliographic/bdsummary.html

Parameters
$pub_xmlA string containing the XML for a single publications
Returns
An array containing the details of the publication

◆ tripal_pub_AGL_range()

tripal_pub_AGL_range (   $yazc,
  $search_str,
  $start,
  $num_to_retrieve,
  $total_records,
  $startyear,
  $endyear 
)

Retrieves a range of publications from AGL

Parameters
$yazcThe YAZC connection object.
$search_strThe search string to use for searching.
$startThe start of the range
$num_to_retrieveThe number of publications to retrieve
$total_recordsThe total number of records in the dataset. This value should have been retrieved by tripal_pub_AGL_count() function.
Returns
An array containing the total_records in the dataset, the search string and an array of the publications that were retrieved.

◆ tripal_pub_remote_alter_form_AGL()

tripal_pub_remote_alter_form_AGL (   $form,
  $form_state,
  $num_criteria = 1 
)

A hook for altering the publication importer form. It Changes the 'Days' element to 'Year' and removes the 'Journal Name' filter.

Parameters
$formThe Drupal form array
$form_stateThe form state array
$num_criteriaThe number of criteria the user currently has added to the form
Returns
The form (drupal form api)

◆ tripal_pub_remote_search_AGL()

tripal_pub_remote_search_AGL (   $search_array,
  $num_to_retrieve,
  $page 
)

A hook for performing the search on the AGL database.

Parameters
$search_arrayAn array containing the search criteria for the search
$num_to_retrieveIndicates the maximum number of publications to retrieve from the remote database
$pageIndicates the page to retrieve. This corresponds to a paged table, where each page has $num_to_retrieve publications.
Returns
An array of publications.

◆ tripal_pub_remote_search_AGL_get_author()

tripal_pub_remote_search_AGL_get_author (   $xml,
  $ind1 
)

Used for parsing of the XML results to get details about an author

Parameters
$xmlThe XML object to read
$ind1Indicates how an author record is stored; 0 means given name is first 1 means surname is first, 3 means a family name is given
Returns

◆ tripal_pub_remote_search_AGL_get_subfield()

tripal_pub_remote_search_AGL_get_subfield (   $xml)

Used for parsing of the XML results to get a set of subfields

Parameters
$xmlThe XMl object to read
Returns
An array of codes and their values

◆ tripal_pub_remote_validate_form_AGL()

tripal_pub_remote_validate_form_AGL (   $form,
  $form_state 
)

A hook for providing additional validation of importer setup form.

Parameters
$formThe Drupal form array
$form_stateThe form state array
Returns
The form (drupal form api)