function tripal_pub_remote_search_AGL_get_author

2.x tripal_pub.AGL.inc tripal_pub_remote_search_AGL_get_author($xml, $ind1)
3.x tripal_chado.pub_importer_AGL.inc tripal_pub_remote_search_AGL_get_author($xml, $ind1)
1.x AGL.inc tripal_pub_remote_search_AGL_get_author($xml, $ind1)

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

Parameters

$xml: The XML object to read

$ind1: Indicates how an author record is stored; 0 means given name is first 1 means surname is first, 3 means a family name is given

1 call to tripal_pub_remote_search_AGL_get_author()
tripal_pub_AGL_parse_pubxml in tripal_chado/includes/loaders/tripal_chado.pub_importer_AGL.inc
Parse publication XML for a single publication

File

tripal_chado/includes/loaders/tripal_chado.pub_importer_AGL.inc, line 980
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…

Code

function tripal_pub_remote_search_AGL_get_author($xml, $ind1) {
  $author = array();
  $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
  foreach ($codes as $code => $value) {
    switch ($code) {
      case 'a':
        // remove any trailing commas
        $value = preg_replace('/,$/', '', $value);
        if ($ind1 == 0) { // Given Name is first
          $author['Given Name'] = $names[0];
        }
        if ($ind1 == 1) { // Surname is first
          // split the parts of the name using a comma
          $names = explode(',', $value);
          $author['Surname'] = $names[0];
          $author['Given Name'] = '';
          unset($names[0]);
          foreach ($names as $index => $name) {
            $author['Given Name'] .= $name . ' ';
          }
          $first_names = explode(' ', $author['Given Name']);
          $author['First Initials'] = '';
          foreach ($first_names as $index => $name) {
            $author['First Initials'] .= substr($name, 0, 1);
          }
        }
        if ($ind1 == 3) { // A family name

        }
        break;
    }
  }
  return $author;
}