function biblio_pm_form_biblio_form_submit in Bibliography Module 7.2
1 string reference to 'biblio_pm_form_biblio_form_submit'
- biblio_pm_form_biblio_form_alter in modules/
pubmed/ biblio_pm.module
File
- modules/
pubmed/ biblio_pm.module, line 116
Code
function biblio_pm_form_biblio_form_submit($form, &$form_state) {
$node_data = array();
if (strlen($pmid = $form_state['values']['PMID'])) {
if (!($dup = biblio_pm_check_pmid($pmid))) {
module_load_include('php', 'biblio_pm', 'EntrezClient');
module_load_include('php', 'biblio_pm', 'EntrezPubmedArticle');
module_load_include('inc', 'biblio', 'includes/biblio.import.export');
$Eclient = new BiblioEntrezClient();
try {
$result = $Eclient
->fetch($pmid);
} catch (Exception $e) {
form_set_error($e
->getMessage());
}
if (!isset($result->PubmedArticle)) {
unset($form_state['values']['biblio_type']);
unset($form_state['post']['biblio_type']);
form_set_error('PMID', 'No data available for PubMed ID: ' . check_plain($pmid));
return;
}
$data = new BiblioEntrezPubmedArticle($result->PubmedArticle);
$node_data = $data
->getBiblio();
$biblio = biblio_create($node_data['biblio_type'], $node_data);
$biblio->biblio_keywords = $node_data['biblio_keywords'];
}
else {
$message = t('The PubMed ID that you are trying to import already exists in the database, see !url', array(
'!url' => l('node/' . $dup, 'node/' . $dup),
));
form_set_error('PMID', $message);
$form_state['rebuild'] = TRUE;
$form_state['submitted'] = FALSE;
unset($form_state['values']['biblio_type']);
}
}
if (!empty($node_data)) {
$form_state['values'] = array_merge($form_state['values'], $node_data);
$form_state['input']['biblio_type'] = $form_state['biblio_type'] = $node_data['biblio_type'];
$form_state['biblio_imported'] = $biblio;
$form_state['biblio_imported_contributors'] = $node_data['biblio_contributors'];
$form_state['rebuild'] = TRUE;
}
return;
}