|
|
|
@ -27,18 +27,6 @@ class RoblibIllLoanForm extends FormBase {
|
|
|
|
|
return $this->ill_auth_form($form, $form_state); |
|
|
|
|
} |
|
|
|
|
return $this->ill_request_form($form, $form_state); |
|
|
|
|
|
|
|
|
|
/* $values = $form_state->getValues(); |
|
|
|
|
if (empty($values)) { |
|
|
|
|
$form_name = 'upei_roblib_ill_request_form'; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
$form_name = 'upei_roblib_ill_auth_form'; |
|
|
|
|
} |
|
|
|
|
$form_state->setValue('step', $from_name); |
|
|
|
|
return $form_name === 'upei_roblib_ill_request_form' ? $this->ill_request_form($form, $form_state) : |
|
|
|
|
$this->ill_auth_form($form, $form_state); |
|
|
|
|
* */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -72,22 +60,23 @@ class RoblibIllLoanForm extends FormBase {
|
|
|
|
|
$form_state->set('aid', $aid); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//if (empty($form_state->get('step')) && $form_state['triggering_element']['#value'] !== 'Lookup DOI' && empty($form_state->get('Title'))) { |
|
|
|
|
// form_set_error('Title', t('Journal/Book Title is required.')); |
|
|
|
|
//} |
|
|
|
|
$trigger = $form_state->getTriggeringElement(); |
|
|
|
|
if (empty($form_state->get('step')) && $trigger['#value'] !== 'Lookup DOI' && empty($form_state->getValue('Title'))) { |
|
|
|
|
$form_state->setErrorByName('Title', t('Journal/Book Title is required.')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param string $id |
|
|
|
|
* The users campus id |
|
|
|
|
* |
|
|
|
|
* @return mixed |
|
|
|
|
* the campus id with leading zeros and leading/trailing whitespace removed. |
|
|
|
|
*/ |
|
|
|
|
function ill_form_message_id($id) { |
|
|
|
|
$id = ltrim($id, '0'); |
|
|
|
|
return trim($id); |
|
|
|
|
} |
|
|
|
|
* @param string $id |
|
|
|
|
* The users campus id |
|
|
|
|
* |
|
|
|
|
* @return mixed |
|
|
|
|
* the campus id with leading zeros and leading/trailing whitespace removed. |
|
|
|
|
*/ |
|
|
|
|
function ill_form_message_id($id) { |
|
|
|
|
$id = ltrim($id, '0'); |
|
|
|
|
return trim($id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param array $form |
|
|
|
@ -96,10 +85,13 @@ function ill_form_message_id($id) {
|
|
|
|
|
* The current state of the form. |
|
|
|
|
*/ |
|
|
|
|
public function submitStepOne(array &$form, FormStateInterface $form_state) { |
|
|
|
|
$form_state |
|
|
|
|
->set('step', 2) |
|
|
|
|
->set('request', $form_state->getValues()) |
|
|
|
|
->setRebuild(TRUE); |
|
|
|
|
$trigger = $form_state->getTriggeringElement(); |
|
|
|
|
if ($trigger['#value'] != 'Lookup DOI') { |
|
|
|
|
$form_state |
|
|
|
|
->set('step', 2) |
|
|
|
|
->set('request', $form_state->getValues()) |
|
|
|
|
->setRebuild(TRUE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -122,6 +114,13 @@ function ill_form_message_id($id) {
|
|
|
|
|
]; */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function doiCallback(array &$form, FormStateInterface $form_state) { |
|
|
|
|
module_load_include('inc', 'upei_roblib_ill', 'includes/doi'); |
|
|
|
|
$doi = $form_state->getValue('doi'); |
|
|
|
|
$form = upei_roblib_ill_doi_get_data($form, $doi); |
|
|
|
|
return $form; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* The bibliographic portion of the ILL form. |
|
|
|
|
* |
|
|
|
@ -177,7 +176,7 @@ function ill_form_message_id($id) {
|
|
|
|
|
'#type' => 'submit', |
|
|
|
|
'#value' => 'Lookup DOI', |
|
|
|
|
'#ajax' => [ |
|
|
|
|
'callback' => 'upei_roblib_ill_doi_callback', |
|
|
|
|
'callback' => '::doiCallback', |
|
|
|
|
'method' => 'replace', |
|
|
|
|
'wrapper' => 'upei-roblib-ill-request-form', |
|
|
|
|
'effect' => 'fade', |
|
|
|
|