|
@@ -122,20 +122,22 @@ function chado_pub_form($node, $form_state) {
|
|
|
'#default_value' => $d_pyear,
|
|
|
'#required' => TRUE,
|
|
|
'#size' => 5,
|
|
|
+ '#description' => t('Enter the year of publication. Also, if available, please add a <b>Publication Date</b> property to specify the full date of publication.'),
|
|
|
);
|
|
|
$form['uniquename'] = array(
|
|
|
'#type' => 'textarea',
|
|
|
'#title' => t('Citation'),
|
|
|
'#default_value' => $d_uniquename,
|
|
|
- '#description' => t('All publications must have a unique citation. Please enter the full citation for this publication.
|
|
|
- For PubMed style citations list
|
|
|
+ '#description' => t('All publications must have a unique citation.
|
|
|
+ <b>Please enter the full citation for this publication or leave blank and one will be generated
|
|
|
+ automatically if possible</b>. For PubMed style citations list
|
|
|
the last name of the author followed by initials. Each author should be separated by a comma. Next comes
|
|
|
the title, followed by the series title (e.g. journal name), publication date (4 digit year, 3 character Month, day), volume, issue and page numbers. You may also use HTML to provide a link in the citation.
|
|
|
Below is an example: <pre>Medeiros PM, Ladio AH, Santos AM, Albuquerque UP. <a href="http://www.ncbi.nlm.nih.gov/pubmed/23462414" target="_blank">Does the selection of medicinal plants by Brazilian local populations
|
|
|
suffer taxonomic influence?</a> J Ethnopharmacol. 2013 Apr 19; 146(3):842-52.</pre>'),
|
|
|
- '#required' => TRUE,
|
|
|
);
|
|
|
|
|
|
+
|
|
|
// add in the properties that are actually stored in the pub table fields.
|
|
|
$num_properties = chado_pub_node_form_add_pub_table_props($form, $form_state, $properties_list,
|
|
|
$d_properties, $d_removed, $d_volume, $d_volumetitle, $d_issue, $d_pages, $d_series_name);
|
|
@@ -195,11 +197,14 @@ function chado_pub_validate($node, &$form) {
|
|
|
$pub_id = $node->pub_id;
|
|
|
$num_properties = $node->num_properties;
|
|
|
$num_new = $node->num_new;
|
|
|
+
|
|
|
+ $pub = array();
|
|
|
|
|
|
// if this is a delete then don't validate
|
|
|
if($node->op == 'Delete') {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
|
|
|
// make sure the year is four digits
|
|
|
if(!preg_match('/^\d{4}$/', $pyear)){
|
|
@@ -215,9 +220,9 @@ function chado_pub_validate($node, &$form) {
|
|
|
$message = t('Invalid publication type.');
|
|
|
form_set_error('type_id', $message);
|
|
|
return;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- // get the media name looking at the properties
|
|
|
+ // get the media name looking at the properties
|
|
|
foreach ($node as $element => $value) {
|
|
|
// if this is an existing property (either previously in the database or
|
|
|
// added via AHAH/AJAX callback)
|
|
@@ -230,6 +235,7 @@ function chado_pub_validate($node, &$form) {
|
|
|
if($prop_type->name == 'Citation') {
|
|
|
$uniquename = $value;
|
|
|
}
|
|
|
+ $pub[$prop_type->name] = $value;
|
|
|
}
|
|
|
// if this is a new property (added by this submit of the form)
|
|
|
elseif ($element = 'new_id') {
|
|
@@ -240,6 +246,17 @@ function chado_pub_validate($node, &$form) {
|
|
|
if($prop_type->name == 'Citation') {
|
|
|
$uniquename = $value;
|
|
|
}
|
|
|
+ $pub[$prop_type->name] = $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // if the citation is missing then try to generate one
|
|
|
+ if (!$uniquename) {
|
|
|
+ $pub['Title'] = $title;
|
|
|
+ $pub['Publication Type'][0] = $cvterm[0]->name;
|
|
|
+ $pub['Year'] = $pyear;
|
|
|
+ $uniquename = tripal_pub_create_citation($pub);
|
|
|
+ if (!$uniquename) {
|
|
|
+ form_set_error('uniquename', 'Cannot automatically generate a citation for this publication type. Please add one manually.');
|
|
|
}
|
|
|
}
|
|
|
|