From f8a73a559d609b34d522379eaa1ba7aef27f1531 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Mon, 10 Apr 2017 15:39:15 -0300 Subject: [PATCH] changed title and atitle to textareas and updated some comments --- includes/db.inc | 7 +++++++ includes/doi.inc | 28 +++++++++++++++++++++++----- includes/form.inc | 7 ++++--- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/includes/db.inc b/includes/db.inc index 2b9d52a..353fa94 100644 --- a/includes/db.inc +++ b/includes/db.inc @@ -5,6 +5,13 @@ */ +/** + * Log an ILL request + * @param array $request + * The request sent to Relais as an array (before it is encoded as JSON) + * @param array $response + * The response from Relais. + */ function upei_roblib_ill_log_request($request, $response) { $time_submitted = isset($request['RequestInfo']['DateSubmitted']) ? $request['RequestInfo']['DateSubmitted'] : ''; $relais_message = isset($response['ConfirmMessage']) ? $response['ConfirmMessage'] : $response['Problem']['Message']; diff --git a/includes/doi.inc b/includes/doi.inc index ab46960..3a85cbd 100644 --- a/includes/doi.inc +++ b/includes/doi.inc @@ -6,7 +6,15 @@ * all the dependancies it would require. */ - +/** + * Gets the XML as crossref associated with the supplied DOI. Updates the drupal form with the data. + * @param array $form + * The Drupal form + * @param string $doi + * The DOI + * @return array + * A Drupal form with updated values. + */ function upei_roblib_ill_doi_get_data($form, $doi) { if (empty($doi)) { $doi = 'Empty DOI'; @@ -34,9 +42,19 @@ 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; +/** + * A convenience function for retrieving individual nodes from the Crossref XML without throwing notices. + * + * @param DomDocument $crossref_xml + * The Crossref XML + * @param string $node_name + * The node we want a value for, we are assuming the xml only has one node with the given name. + * @return string + * Returns the value of the element + */ +function upei_roblib_ill_get_xml_node($crossref_xml, $node_name) { + return empty($crossref_xml->getElementsbyTagName($node_name)->item(0)) ? '' : + $crossref_xml->getElementsbyTagName($node_name)->item(0)->nodeValue; } @@ -47,7 +65,7 @@ function upei_roblib_ill_get_xml_node($crossref_xml, $element_name) { * @param array $form * Drupal form * @return mixed - * A Drupal form + * An updated Drupal form */ function upei_roblib_ill_populate_form_doi($crossref_xml, $form) { $full_title = upei_roblib_ill_get_xml_node($crossref_xml, 'full_title'); diff --git a/includes/form.inc b/includes/form.inc index 40ded94..976262f 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -267,7 +267,8 @@ function upei_roblib_ill_request_form($form, &$form_state) { '#required' => FALSE, ); $form['Title'] = array( - '#type' => 'textfield', + '#type' => 'textarea', + '#rows' => 2, '#title' => t('Source Title'), '#default_value' => upei_roblib_ill_get_request_variable('title'), '#description' => 'Journal or Book Title', @@ -275,7 +276,8 @@ function upei_roblib_ill_request_form($form, &$form_state) { '#required' => FALSE, ); $form['ArticleTitle'] = array( - '#type' => 'textfield', + '#type' => 'textarea', + '#rows' => 2, '#title' => t('Title'), '#default_value' => upei_roblib_ill_get_request_variable('atitle'), '#description' => 'Article or Chapter Title', @@ -411,7 +413,6 @@ function upei_roblib_ill_request_form($form, &$form_state) { '#type' => 'submit', '#value' => t('Next') ); - $form_state['stage'] = 'upei_roblib_ill_auth'; return $form; }