Browse Source

fixes for redmine ticket 7973 populate the type select with genre from openurl if it exists

9.x-1.0
ppound 5 years ago
parent
commit
5c9740e387
  1. 6
      includes/form.inc
  2. 9
      includes/utilities.inc

6
includes/form.inc

@ -320,7 +320,8 @@ function upei_roblib_ill_request_form($form, &$form_state) {
module_load_include('inc', 'upei_roblib_ill', 'includes/utilities'); module_load_include('inc', 'upei_roblib_ill', 'includes/utilities');
$form['#prefix'] = '<div id="upei-roblib-ill-request-form">'; $form['#prefix'] = '<div id="upei-roblib-ill-request-form">';
$form['#suffix'] = '<div class="roblib-required">* = Required Field</div></div>'; $form['#suffix'] = '<div class="roblib-required">* = Required Field</div></div>';
$genre = empty(upei_roblib_ill_get_request_variable('genre')) ? 'article' : upei_roblib_ill_get_request_variable('genre'); $type = upei_roblib_ill_get_request_variable('genre');
$genre = empty($type) ? 'article' : $type;
$form['Genre'] = [ $form['Genre'] = [
'#type' => 'select', '#type' => 'select',
'#title' => t('Item Type'), '#title' => t('Item Type'),
@ -331,6 +332,9 @@ function upei_roblib_ill_request_form($form, &$form_state) {
], ],
'#required' => TRUE, '#required' => TRUE,
]; ];
if(!empty($type)) {
$form['Genre']['#default_value'] = $type;
}
$form['doi'] = [ $form['doi'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t("DOI (ex: 10.1016/j.ypmed.2019.01.018) <a href='https://library.upei.ca/doi'>more info</a>"), '#title' => t("DOI (ex: 10.1016/j.ypmed.2019.01.018) <a href='https://library.upei.ca/doi'>more info</a>"),

9
includes/utilities.inc

@ -80,21 +80,22 @@ function upei_roblib_ill_clean_array($values) {
function upei_roblib_ill_get_request_variable($variable) { function upei_roblib_ill_get_request_variable($variable) {
if ($variable == 'author' && empty($_REQUEST[$variable])) { if ($variable == 'author' && empty($_REQUEST[$variable])) {
//google scholar usually sends auinit aulast instead of author //google scholar usually sends auinit aulast instead of author
$initial = isset($_REQUEST['auinit']) ? $_REQUEST['auinit'] : NULL; $initial = isset($_REQUEST['auinit']) ? check_plain($_REQUEST['auinit']) : NULL;
$last_name = isset($_REQUEST['aulast']) ? $_REQUEST['aulast'] : NULL; $last_name = isset($_REQUEST['aulast']) ? check_plain($_REQUEST['aulast']) : NULL;
return !empty($last_name) ? $last_name . ',' . $initial : ''; return !empty($last_name) ? $last_name . ',' . $initial : '';
} }
if ($variable == 'issn' && !empty($_REQUEST[$variable])) { if ($variable == 'issn' && !empty($_REQUEST[$variable])) {
// ebsco sometimes sends garbage as issns verify this is a valid issn before displaying the value in the form. // ebsco sometimes sends garbage as issns verify this is a valid issn before displaying the value in the form.
return preg_match('/^\d{4}-?\d{3}[\dxX]$/', $_REQUEST[$variable]) ? $_REQUEST[$variable] : ''; return preg_match('/^\d{4}-?\d{3}[\dxX]$/', $_REQUEST[$variable]) ? check_plain($_REQUEST[$variable]) : '';
} }
// ebsco sometimes returns bookitem we only understand chapter // ebsco sometimes returns bookitem we only understand chapter
if (($variable == 'genre' && !empty($_REQUEST[$variable])) && $_REQUEST[$variable] == 'bookitem') { if (($variable == 'genre' && !empty($_REQUEST[$variable])) && $_REQUEST[$variable] == 'bookitem') {
return 'chapter'; return 'chapter';
} }
return isset($_REQUEST[$variable]) ? $_REQUEST[$variable] : ''; return isset($_REQUEST[$variable]) ? check_plain($_REQUEST[$variable]) : '';
} }
function upei_roblib_ill_get_doi_from_request() { function upei_roblib_ill_get_doi_from_request() {
return (!empty($_REQUEST['doi'])) ? $_REQUEST['doi'] : upei_roblib_ill_get_doi_from_id(); return (!empty($_REQUEST['doi'])) ? $_REQUEST['doi'] : upei_roblib_ill_get_doi_from_id();
} }

Loading…
Cancel
Save