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');
$form['#prefix'] = '<div id="upei-roblib-ill-request-form">';
$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'] = [
'#type' => 'select',
'#title' => t('Item Type'),
@ -331,6 +332,9 @@ function upei_roblib_ill_request_form($form, &$form_state) {
],
'#required' => TRUE,
];
if(!empty($type)) {
$form['Genre']['#default_value'] = $type;
}
$form['doi'] = [
'#type' => 'textfield',
'#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) {
if ($variable == 'author' && empty($_REQUEST[$variable])) {
//google scholar usually sends auinit aulast instead of author
$initial = isset($_REQUEST['auinit']) ? $_REQUEST['auinit'] : NULL;
$last_name = isset($_REQUEST['aulast']) ? $_REQUEST['aulast'] : NULL;
$initial = isset($_REQUEST['auinit']) ? check_plain($_REQUEST['auinit']) : NULL;
$last_name = isset($_REQUEST['aulast']) ? check_plain($_REQUEST['aulast']) : NULL;
return !empty($last_name) ? $last_name . ',' . $initial : '';
}
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.
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
if (($variable == 'genre' && !empty($_REQUEST[$variable])) && $_REQUEST[$variable] == 'bookitem') {
return 'chapter';
}
return isset($_REQUEST[$variable]) ? $_REQUEST[$variable] : '';
return isset($_REQUEST[$variable]) ? check_plain($_REQUEST[$variable]) : '';
}
function upei_roblib_ill_get_doi_from_request() {
return (!empty($_REQUEST['doi'])) ? $_REQUEST['doi'] : upei_roblib_ill_get_doi_from_id();
}

Loading…
Cancel
Save