Browse Source

eliminate more notices

9.x-1.0
Paul Pound 8 years ago
parent
commit
31b0c2d645
  1. 38
      includes/doi.inc

38
includes/doi.inc

@ -34,6 +34,11 @@ function upei_roblib_ill_doi_get_data($form, $doi) {
} }
} }
function upei_roblib_ill_get_xml_node($crossref_xml, $element_name) {
return empty($crossref_xml->getElementsbyTagName($element_name)->item(0)) ? '' :
$crossref_xml->getElementsbyTagName($element_name)->item(0)->nodeValue;
}
/** /**
* Parse the response from Crossref and populate the request form * Parse the response from Crossref and populate the request form
@ -45,36 +50,25 @@ function upei_roblib_ill_doi_get_data($form, $doi) {
* A Drupal form * A Drupal form
*/ */
function upei_roblib_ill_populate_form_doi($crossref_xml, $form) { function upei_roblib_ill_populate_form_doi($crossref_xml, $form) {
$full_title = $crossref_xml->getElementsbyTagName('full_title') $full_title = upei_roblib_ill_get_xml_node($crossref_xml, 'full_title');
->item(0)->nodeValue; if (empty($full_title)) {
if(empty($full_title)) { $full_title = upei_roblib_ill_get_xml_node($crossref_xml, 'conference_name');
$full_title = $crossref_xml->getElementsbyTagName('conference_name')
->item(0)->nodeValue;
} }
$form['Title']['#value'] = $full_title; $form['Title']['#value'] = $full_title;
$form['ISSN']['#value'] = $crossref_xml->getElementsbyTagName('issn') $form['ISSN']['#value'] = upei_roblib_ill_get_xml_node($crossref_xml, 'issn');
->item(0)->nodeValue; $form['Date']['#value'] = upei_roblib_ill_get_xml_node($crossref_xml, 'year');
$form['Date']['#value'] = $crossref_xml->getElementsbyTagName('year') $form['ArticleTitle']['#value'] = upei_roblib_ill_get_xml_node($crossref_xml, 'title');
->item(0)->nodeValue; $form['ImageOrPageNumber']['#value'] = upei_roblib_ill_get_xml_node($crossref_xml, 'first_page');
$form['ArticleTitle']['#value'] = $crossref_xml->getElementsbyTagName('title') $form['PagesRequested']['#value'] = upei_roblib_ill_get_xml_node($crossref_xml, 'last_page');
->item(0)->nodeValue; $form['Volume']['#value'] = upei_roblib_ill_get_xml_node($crossref_xml, 'volume');
$form['ImageOrPageNumber']['#value'] = $crossref_xml->getElementsbyTagName('first_page') $form['Issue']['#value'] = upei_roblib_ill_get_xml_node($crossref_xml, 'issue');
->item(0)->nodeValue;
$form['PagesRequested']['#value'] = $crossref_xml->getElementsbyTagName('last_page')
->item(0)->nodeValue;
$form['Volume']['#value'] = $crossref_xml->getElementsbyTagName('volume')
->item(0)->nodeValue;
$form['Issue']['#value'] = $crossref_xml->getElementsbyTagName('issue')
->item(0)->nodeValue;
foreach ($crossref_xml->getElementsbyTagName('person_name') as $person) { foreach ($crossref_xml->getElementsbyTagName('person_name') as $person) {
$role = $person->getAttribute('contributor_role'); $role = $person->getAttribute('contributor_role');
$sequence = $person->getAttribute('sequence'); $sequence = $person->getAttribute('sequence');
if ($person->getAttribute('contributor_role') == 'author' && if ($person->getAttribute('contributor_role') == 'author' &&
$person->getAttribute('sequence') == 'first' $person->getAttribute('sequence') == 'first'
) { ) {
$author = $person->getElementsbyTagName('surname') $author = upei_roblib_ill_get_xml_node($crossref_xml, 'surname') . ',' . upei_roblib_ill_get_xml_node($crossref_xml, 'given_name');
->item(0)->nodeValue . ',' . $person->getElementsbyTagName('given_name')
->item(0)->nodeValue;
} }
} }
$form['ArticleAuthor']['#value'] = $author; $form['ArticleAuthor']['#value'] = $author;

Loading…
Cancel
Save