|
@@ -6,126 +6,149 @@
|
|
|
*/
|
|
|
|
|
|
function chado_pub_form($node, $form_state) {
|
|
|
- tripal_core_ahah_init_form();
|
|
|
$form = array();
|
|
|
-
|
|
|
- $pub = $node->pub;
|
|
|
- $pub_id = $pub->pub_id;
|
|
|
-
|
|
|
- $d_title = $form_state['values']['pubtitle'] ? $form_state['values']['pubtitle'] : $pub->title;
|
|
|
- $d_uniquename = $form_state['values']['uniquename'] ? $form_state['values']['uniquename'] : $pub->uniquename;
|
|
|
- $d_type_id = $form_state['values']['type_id'] ? $form_state['values']['type_id'] : $pub->type_id->cvterm_id;
|
|
|
- $d_volume = $form_state['values']['volume'] ? $form_state['values']['volume'] : $pub->volume;
|
|
|
- $d_volumetitle = $form_state['values']['volumetitle'] ? $form_state['values']['volumetitle'] : $pub->volumetitle;
|
|
|
- $d_series_name = $form_state['values']['series_name'] ? $form_state['values']['series_name'] : $pub->series_name;
|
|
|
- $d_issue = $form_state['values']['issue'] ? $form_state['values']['issue'] : $pub->issue;
|
|
|
- $d_pyear = $form_state['values']['pyear'] ? $form_state['values']['pyear'] : $pub->pyear;
|
|
|
- $d_pages = $form_state['values']['pages'] ? $form_state['values']['pages'] : $pub->pages;
|
|
|
- $d_miniref = $form_state['values']['miniref'] ? $form_state['values']['miniref'] : $pub->miniref;
|
|
|
- $d_publisher = $form_state['values']['publisher'] ? $form_state['values']['publisher'] : $pub->publisher;
|
|
|
- $d_pubplace = $form_state['values']['pubplace'] ? $form_state['values']['pubplace'] : $pub->pubplace;
|
|
|
- $d_is_obsolete = $form_state['values']['is_obsolete'] ? $form_state['values']['is_obsolete'] : $pub->is_obsolete;
|
|
|
-
|
|
|
- // if the obsolete value is set by the database then it is in the form of
|
|
|
- // 't' or 'f', we need to convert to 1 or 0
|
|
|
- $d_is_obsolete = $d_is_obsolete == 't' ? 1 : $d_is_obsolete;
|
|
|
- $d_is_obsolete = $d_is_obsolete == 'f' ? 0 : $d_is_obsolete;
|
|
|
-
|
|
|
- // on AHAH callbacks we want to keep a list of all the properties that have been removed
|
|
|
- // we'll store this info in a hidden field and retrieve it here
|
|
|
- $d_removed = $form_state['values']['removed'];
|
|
|
-
|
|
|
- // get the number of new fields that have been aded via AHAH callbacks
|
|
|
- $num_new = $form_state['values']['num_new'] ? $form_state['values']['num_new'] : 0;
|
|
|
-
|
|
|
- // initialze default properties array. This is where we store the property defaults
|
|
|
- $d_properties = array();
|
|
|
-
|
|
|
+
|
|
|
+ // Default values can come in the following ways:
|
|
|
+ //
|
|
|
+ // 1) as elements of the $node object. This occurs when editing an existing pub
|
|
|
+ // 2) in the $form_state['values'] array which occurs on a failed validation or
|
|
|
+ // ajax callbacks from non submit form elements
|
|
|
+ // 3) in the $form_state['input'[ array which occurs on ajax callbacks from submit
|
|
|
+ // form elements and the form is being rebuilt
|
|
|
+ //
|
|
|
+ // set form field defaults
|
|
|
+ $pub_id = null;
|
|
|
+ $title = '';
|
|
|
+ $volumetitle = '';
|
|
|
+ $volume = '';
|
|
|
+ $series_name = '';
|
|
|
+ $issue = '';
|
|
|
+ $pyear = '';
|
|
|
+ $pages = '';
|
|
|
+ $miniref = '';
|
|
|
+ $uniquename = '';
|
|
|
+ $type_id = '';
|
|
|
+ $is_obsolete = '';
|
|
|
+ $publisher = '';
|
|
|
+ $pubplace = '';
|
|
|
+
|
|
|
+
|
|
|
+ // if we are editing an existing node then the pub is already part of the node
|
|
|
+ if (property_exists($node, 'pub')) {
|
|
|
+ $pub = $node->pub;
|
|
|
+ $pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.title');
|
|
|
+ $pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.volumetitle');
|
|
|
+ $pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.uniquename');
|
|
|
+ $pub_id = $pub->pub_id;
|
|
|
+
|
|
|
+ $title = $node->title;
|
|
|
+ $volumetitle = $node->volumetitle;
|
|
|
+ $volume = $node->volume;
|
|
|
+ $series_name = $node->series_name;
|
|
|
+ $issue = $node->issue;
|
|
|
+ $pyear = $node->pyear;
|
|
|
+ $pages = $node->pages;
|
|
|
+ $miniref = $node->miniref;
|
|
|
+ $uniquename = $node->uniquename;
|
|
|
+ $type_id = $node->type_id;
|
|
|
+ $is_obsolete = $node->is_obsolete;
|
|
|
+ $publisher = $node->publisher;
|
|
|
+ $pubplace = $node->pubplace;
|
|
|
+
|
|
|
+ // if the obsolete value is set by the database then it is in the form of
|
|
|
+ // 't' or 'f', we need to convert to 1 or 0
|
|
|
+ $is_obsolete = $is_obsolete == 't' ? 1 : $is_obsolete;
|
|
|
+ $is_obsolete = $is_obsolete == 'f' ? 0 : $is_obsolete;
|
|
|
+
|
|
|
+ // set the organism_id in the form
|
|
|
+ $form['pub_id'] = array(
|
|
|
+ '#type' => 'value',
|
|
|
+ '#value' => $pub->pub_id,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ // if we are re constructing the form from a failed validation or ajax callback
|
|
|
+ // then use the $form_state['values'] values
|
|
|
+ if (array_key_exists('values', $form_state)) {
|
|
|
+ $title = $form_state['values']['pubtitle'];
|
|
|
+ $volumetitle = $form_state['values']['volumetitle'];
|
|
|
+ $volume = $form_state['values']['volume'];
|
|
|
+ $series_name = $form_state['values']['series_name'];
|
|
|
+ $issue = $form_state['values']['issue'];
|
|
|
+ $pyear = $form_state['values']['pyear'];
|
|
|
+ $pages = $form_state['values']['pages'];
|
|
|
+ $miniref = $form_state['values']['miniref'];
|
|
|
+ $uniquename = $form_state['values']['uniquename'];
|
|
|
+ $type_id = $form_state['values']['type_id'];
|
|
|
+ $is_obsolete = $form_state['values']['is_obsolete'];
|
|
|
+ $publisher = $form_state['values']['publisher'];
|
|
|
+ $pubplace = $form_state['values']['pubplace'];
|
|
|
+ }
|
|
|
+ // if we are re building the form from after submission (from ajax call) then
|
|
|
+ // the values are in the $form_state['input'] array
|
|
|
+ if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
|
|
|
+ $title = $form_state['input']['pubtitle'];
|
|
|
+ $volumetitle = $form_state['input']['volumetitle'];
|
|
|
+ $volume = $form_state['input']['volume'];
|
|
|
+ $series_name = $form_state['input']['series_name'];
|
|
|
+ $issue = $form_state['input']['issue'];
|
|
|
+ $pyear = $form_state['input']['pyear'];
|
|
|
+ $pages = $form_state['input']['pages'];
|
|
|
+ $miniref = $form_state['input']['miniref'];
|
|
|
+ $uniquename = $form_state['input']['uniquename'];
|
|
|
+ $type_id = $form_state['input']['type_id'];
|
|
|
+ $is_obsolete = $form_state['input']['is_obsolete'];
|
|
|
+ $publisher = $form_state['input']['publisher'];
|
|
|
+ $pubplace = $form_state['input']['pubplace'];
|
|
|
+ }
|
|
|
+
|
|
|
+ // a drupal title can only be 255 characters, but the Chado title can be much longer.
|
|
|
+ // we use the publication title as the drupal title, but we'll need to truncate it.
|
|
|
+ $form['title'] = array(
|
|
|
+ '#type' => 'hidden',
|
|
|
+ '#value' => substr($title, 0, 255),
|
|
|
+ );
|
|
|
+ $form['pubtitle'] = array(
|
|
|
+ '#type' => 'textarea',
|
|
|
+ '#title' => t('Publication Title'),
|
|
|
+ '#default_value' => $title,
|
|
|
+ '#required' => TRUE,
|
|
|
+ );
|
|
|
// get the list of publication types. In the Tripal publication
|
|
|
// ontologies these are all grouped under the term 'Publication Type'
|
|
|
// we want the default to be 'Journal Article'
|
|
|
$sql = "
|
|
|
- SELECT
|
|
|
+ SELECT
|
|
|
CVTS.cvterm_id, CVTS.name
|
|
|
FROM {cvtermpath} CVTP
|
|
|
INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
|
|
|
INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
|
|
|
INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
|
|
|
- WHERE
|
|
|
- CV.name = 'tripal_pub' AND CVTO.name = 'Publication Type' AND
|
|
|
+ WHERE
|
|
|
+ CV.name = 'tripal_pub' AND CVTO.name = 'Publication Type' AND
|
|
|
NOT CVTS.is_obsolete = 1
|
|
|
- ORDER BY CVTS.name ASC
|
|
|
+ ORDER BY CVTS.name ASC
|
|
|
";
|
|
|
$results = chado_query($sql);
|
|
|
$pub_types = array();
|
|
|
while ($pub_type = $results->fetchObject()) {
|
|
|
$pub_types[$pub_type->cvterm_id] = $pub_type->name;
|
|
|
// if we don't have a default type then set the default to be 'Journal Article'
|
|
|
- if (strcmp($pub_type->name,"Journal Article") == 0 and !$d_type_id) {
|
|
|
- $d_type_id = $pub_type->cvterm_id;
|
|
|
+ if (strcmp($pub_type->name,"Journal Article") == 0 and !$type_id) {
|
|
|
+ $type_id = $pub_type->cvterm_id;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // reset the default to use the stored variable if one exists
|
|
|
- $d_type_id = variable_get('tripal_pub_default_type', $d_type_id);
|
|
|
-
|
|
|
- // get publication properties list
|
|
|
- $properties_select = array();
|
|
|
- $properties_select[] = 'Select a Property';
|
|
|
- $properties_list = array();
|
|
|
- $sql = "
|
|
|
- SELECT
|
|
|
- DISTINCT CVTS.cvterm_id, CVTS.name, CVTS.definition
|
|
|
- FROM {cvtermpath} CVTP
|
|
|
- INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
|
|
|
- INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
|
|
|
- INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
|
|
|
- WHERE CV.name = 'tripal_pub' and
|
|
|
- (CVTO.name = 'Publication Details' OR CVTS.name = 'Publication Type') AND
|
|
|
- NOT CVTS.is_obsolete = 1
|
|
|
- ORDER BY CVTS.name ASC
|
|
|
- ";
|
|
|
- $prop_types = chado_query($sql);
|
|
|
- while ($prop = $prop_types->fetchObject()) {
|
|
|
- // the 'Citation' term is special because it serves
|
|
|
- // both as a property and as the uniquename for the publiation table
|
|
|
- if ($prop->name != "Citation") {
|
|
|
- $properties_select[$prop->cvterm_id] = $prop->name;
|
|
|
- }
|
|
|
- $properties_list[$prop->cvterm_id] = $prop;
|
|
|
- }
|
|
|
-
|
|
|
- $form['pub_id'] = array(
|
|
|
- '#type' => 'hidden',
|
|
|
- '#value' => $pub_id,
|
|
|
- );
|
|
|
-
|
|
|
- // a drupal title can only be 255 characters, but the Chado title can be much longer.
|
|
|
- // we use the publication title as the drupal title, but we'll need to truncate it.
|
|
|
- $form['title'] = array(
|
|
|
- '#type' => 'hidden',
|
|
|
- '#value' => substr($d_title, 0, 255),
|
|
|
- );
|
|
|
-
|
|
|
- $form['pubtitle'] = array(
|
|
|
- '#type' => 'textarea',
|
|
|
- '#title' => t('Publication Title'),
|
|
|
- '#default_value' => $d_title,
|
|
|
- '#required' => TRUE,
|
|
|
- );
|
|
|
-
|
|
|
$form['type_id'] = array(
|
|
|
'#type' => 'select',
|
|
|
'#title' => t('Publication Type'),
|
|
|
'#options' => $pub_types,
|
|
|
'#required' => TRUE,
|
|
|
- '#default_value' => $d_type_id,
|
|
|
+ '#default_value' => $type_id,
|
|
|
);
|
|
|
-
|
|
|
$form['pyear'] = array(
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Publication Year'),
|
|
|
- '#default_value' => $d_pyear,
|
|
|
+ '#default_value' => $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.'),
|
|
@@ -133,7 +156,7 @@ function chado_pub_form($node, $form_state) {
|
|
|
$form['uniquename'] = array(
|
|
|
'#type' => 'textarea',
|
|
|
'#title' => t('Citation'),
|
|
|
- '#default_value' => $d_uniquename,
|
|
|
+ '#default_value' => $uniquename,
|
|
|
'#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
|
|
@@ -142,76 +165,71 @@ function chado_pub_form($node, $form_state) {
|
|
|
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>'),
|
|
|
);
|
|
|
-
|
|
|
-
|
|
|
- // 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);
|
|
|
-
|
|
|
- // add in the properties from the pubprop table
|
|
|
- $num_properties += chado_pub_node_form_add_pubprop_table_props($form, $form_state, $pub_id, $d_properties, $d_removed);
|
|
|
-
|
|
|
- // add in any new properties that have been added by the user through an AHAH callback
|
|
|
- $num_new = chado_pub_node_form_add_new_props($form, $form_state, $d_properties, $d_removed);
|
|
|
-
|
|
|
- // add an empty row of field to allow for addition of a new property
|
|
|
- chado_pub_node_form_add_new_empty_props($form, $properties_select);
|
|
|
-
|
|
|
-
|
|
|
- $form['removed'] = array(
|
|
|
- '#type' => 'hidden',
|
|
|
- '#value' => $d_removed,
|
|
|
- );
|
|
|
-
|
|
|
- $form['num_new'] = array(
|
|
|
- '#type' => 'hidden',
|
|
|
- '#value' => $num_new,
|
|
|
- );
|
|
|
- $form['num_properties'] = array(
|
|
|
- '#type' => 'hidden',
|
|
|
- '#value' => $num_properties,
|
|
|
- );
|
|
|
-
|
|
|
$form['is_obsolete'] = array(
|
|
|
'#type' => 'checkbox',
|
|
|
'#title' => t('Is Obsolete? (Check for Yes)'),
|
|
|
- '#required' => TRUE,
|
|
|
- '#default_value' => $d_is_obsolete,
|
|
|
+ '#default_value' => $is_obsolete,
|
|
|
);
|
|
|
+
|
|
|
+ // get publication properties list
|
|
|
+ $properties_select = array();
|
|
|
+ $properties_select[] = 'Select a Property';
|
|
|
+ $sql = "
|
|
|
+ SELECT
|
|
|
+ DISTINCT CVTS.cvterm_id, CVTS.name, CVTS.definition
|
|
|
+ FROM {cvtermpath} CVTP
|
|
|
+ INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
|
|
|
+ INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
|
|
|
+ INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
|
|
|
+ WHERE CV.name = 'tripal_pub' and
|
|
|
+ (CVTO.name = 'Publication Details' OR CVTS.name = 'Publication Type') AND
|
|
|
+ NOT CVTS.is_obsolete = 1
|
|
|
+ ORDER BY CVTS.name ASC
|
|
|
+ ";
|
|
|
+ $prop_types = chado_query($sql);
|
|
|
+ while ($prop = $prop_types->fetchObject()) {
|
|
|
+ // add all properties except the Citation. That property is set via the uniquename field
|
|
|
+ if ($prop->name != 'Citation') {
|
|
|
+ $properties[$prop->cvterm_id] = $prop->name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // add in the properties fields. The 'Citation' term is special because it serves
|
|
|
+ // both as a property and as the uniquename for the publiation table so we exclude it
|
|
|
+ // as it shouldn't be selected as a property
|
|
|
+ $exclude = array("Citation");
|
|
|
+ $instructions = '';
|
|
|
+ tripal_core_properties_form($form, $form_state, 'pubprop', 'pub_id', 'tripal_pub',
|
|
|
+ $properties, $pub_id, $exclude, $instructions);
|
|
|
+
|
|
|
return $form;
|
|
|
|
|
|
}
|
|
|
/*
|
|
|
*
|
|
|
*/
|
|
|
-function chado_pub_validate($node, &$form) {
|
|
|
+function chado_pub_validate($node, $form, &$form_state) {
|
|
|
|
|
|
// get the submitted values
|
|
|
$title = trim($node->pubtitle);
|
|
|
- $uniquename = trim($node->uniquename);
|
|
|
- $type_id = trim($node->type_id);
|
|
|
- $volume = trim($node->volume);
|
|
|
- $volumetitle = trim($node->volumetitle);
|
|
|
- $series_name = trim($node->series_name);
|
|
|
- $issue = trim($node->issue);
|
|
|
$pyear = trim($node->pyear);
|
|
|
- $pages = trim($node->pages);
|
|
|
- $miniref = trim($node->miniref);
|
|
|
- $publisher = trim($node->publisher);
|
|
|
- $pubplace = trim($node->pubplace);
|
|
|
+ $uniquename = trim($node->uniquename);
|
|
|
$is_obsolete = $node->is_obsolete;
|
|
|
- $pub_id = $node->pub_id;
|
|
|
- $num_properties = $node->num_properties;
|
|
|
- $num_new = $node->num_new;
|
|
|
-
|
|
|
- $pub = array();
|
|
|
+ $type_id = $node->type_id;
|
|
|
|
|
|
// if this is a delete then don't validate
|
|
|
if($node->op == 'Delete') {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
|
|
|
+ // we are syncing if we do not have a node ID but we do have a pub_id. We don't
|
|
|
+ // need to validate during syncing so just skip it.
|
|
|
+ if (is_null($node->nid) and property_exists($node, 'pub_id') and $node->pub_id != 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $pub = array();
|
|
|
+
|
|
|
// make sure the year is four digits
|
|
|
if(!preg_match('/^\d{4}$/', $pyear)){
|
|
|
form_set_error('pyear', t('The publication year should be a 4 digit year.'));
|
|
@@ -228,7 +246,8 @@ function chado_pub_validate($node, &$form) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // get the media name looking at the properties
|
|
|
+ // get the media name looking at the properties
|
|
|
+ $series_name = '';
|
|
|
foreach ($node as $element => $value) {
|
|
|
// if this is an existing property (either previously in the database or
|
|
|
// added via AHAH/AJAX callback)
|
|
@@ -244,7 +263,7 @@ function chado_pub_validate($node, &$form) {
|
|
|
$pub[$prop_type->name] = $value;
|
|
|
}
|
|
|
// if this is a new property (added by this submit of the form)
|
|
|
- elseif ($element == 'new_id') {
|
|
|
+ elseif ($element == 'new_id') {
|
|
|
$prop_type = tripal_cv_get_cvterm_by_id($value);
|
|
|
if($prop_type->name == 'Conference Name' or $prop_type->name == 'Journal Name') {
|
|
|
$series_name = $node->new_value;
|
|
@@ -274,12 +293,14 @@ function chado_pub_validate($node, &$form) {
|
|
|
$skip_duplicate_check = 1;
|
|
|
}
|
|
|
|
|
|
- // on an update ($pub_id is set), check to see if there have been changes to fields that
|
|
|
- // are used to check for duplicates. If not, then no need to check for duplicates
|
|
|
- if ($pub_id) {
|
|
|
+ // Validating for an update
|
|
|
+ if (!is_null($node->nid)) {
|
|
|
+
|
|
|
+ $pub_id = $node->pub_id;
|
|
|
+
|
|
|
// first get the original title, type and year before it was changed
|
|
|
$values = array('pub_id' => $pub_id);
|
|
|
- $columns = array('title', 'pyear', 'type_id', 'series_name');
|
|
|
+ $columns = array('title', 'pyear', 'type_id', 'series_name');
|
|
|
$options = array('statement_name' => 'sel_pub_id');
|
|
|
$pub = tripal_core_chado_select('pub', $columns, $values, $options);
|
|
|
|
|
@@ -291,561 +312,86 @@ function chado_pub_validate($node, &$form) {
|
|
|
($pub[0]->year == $pyear)) {
|
|
|
$skip_duplicate_check = 1;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // check to see if a duplicate publication already exists
|
|
|
- if (!$skip_duplicate_check) {
|
|
|
|
|
|
- // make sure the publication is unique using the prefereed import duplication check
|
|
|
- $import_dups_check = variable_get('tripal_pub_import_duplicate_check', 'title_year_media');
|
|
|
- switch ($import_dups_check) {
|
|
|
- case 'title_year':
|
|
|
- $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, NULL, $pyear, NULL);
|
|
|
- // make sure we don't capture our pub_id in the list (remove it)
|
|
|
- foreach ($results as $index => $found_pub_id) {
|
|
|
- if($found_pub_id == $pub_id){
|
|
|
- unset($results[$index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (count($results) > 0) {
|
|
|
- $message = t('A publication with this title and publication year, already exists.');
|
|
|
- form_set_error('pyear', $message);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 'title_year_type':
|
|
|
- $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, $cvterm[0]->name, $pyear, NULL);
|
|
|
-
|
|
|
- // make sure we don't capture our pub_id in the list (remove it)
|
|
|
- foreach ($results as $index => $found_pub_id) {
|
|
|
- if($found_pub_id == $pub_id){
|
|
|
- unset($results[$index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (count($results) > 0) {
|
|
|
- $message = t('A publication with this title, type and publication year, already exists.');
|
|
|
- form_set_error('pyear', $message);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 'title_year_media':
|
|
|
- $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, NULL, $pyear, $series_name);
|
|
|
-
|
|
|
- // make sure we don't capture our pub_id in the list (remove it)
|
|
|
- foreach ($results as $index => $found_pub_id) {
|
|
|
- if($found_pub_id == $pub_id){
|
|
|
- unset($results[$index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (count($results) > 0) {
|
|
|
- $message = t('A publication with this title, media name (e.g. Journal Name) and publication year, already exists.');
|
|
|
- form_set_error('pyear', $message);
|
|
|
- }
|
|
|
- break;
|
|
|
+ // check to see if a duplicate publication already exists
|
|
|
+ if (!$skip_duplicate_check) {
|
|
|
+ chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvterm, $pub_id);
|
|
|
}
|
|
|
+ chado_pub_validate_check_uniquename($uniquename, $pub_id);
|
|
|
}
|
|
|
- // even though we are skipping the duplication checks above we must make sure the uniquename is unique
|
|
|
- // as that is the offical table constraint
|
|
|
+ // Validating for an insert
|
|
|
else {
|
|
|
- $results = tripal_pub_get_pub_by_uniquename($uniquename);
|
|
|
- // make sure we don't capture our pub_id in the list (remove it)
|
|
|
- foreach ($results as $index => $found_pub_id) {
|
|
|
- if($found_pub_id == $pub_id){
|
|
|
- unset($results[$index]);
|
|
|
- }
|
|
|
- }
|
|
|
- if (count($results) > 0) {
|
|
|
- $message = t('A publication with this unique citation already exists.');
|
|
|
- form_set_error('uniquename', $message);
|
|
|
- }
|
|
|
+ chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvterm);
|
|
|
+ chado_pub_validate_check_uniquename($uniquename);
|
|
|
}
|
|
|
}
|
|
|
-/*
|
|
|
- *
|
|
|
- */
|
|
|
-function chado_pub_node_form_add_new_empty_props(&$form, $properties_select) {
|
|
|
-
|
|
|
- // add one more blank set of property fields
|
|
|
- $form['properties']['new']["new_id"] = array(
|
|
|
- '#type' => 'select',
|
|
|
- '#options' => $properties_select,
|
|
|
- '#ahah' => array(
|
|
|
- 'path' => "tripal_pub/properties/description",
|
|
|
- 'wrapper' => 'tripal-pub-new_value-desc',
|
|
|
- 'event' => 'change',
|
|
|
- 'method' => 'replace',
|
|
|
- ),
|
|
|
- );
|
|
|
- $form['properties']['new']["new_value"] = array(
|
|
|
- '#type' => 'textarea',
|
|
|
- '#default_value' => '',
|
|
|
- '#cols' => 5,
|
|
|
- '#rows' => $rows,
|
|
|
- '#description' => '<div id="tripal-pub-new_value-desc"></div>'
|
|
|
- );
|
|
|
- $form['properties']['new']["add"] = array(
|
|
|
- '#type' => 'image_button',
|
|
|
- '#value' => t('Add'),
|
|
|
- '#src' => drupal_get_path('theme', 'tripal') . '/images/add.png',
|
|
|
- '#ahah' => array(
|
|
|
- 'path' => "tripal_pub/properties/add",
|
|
|
- 'wrapper' => 'tripal-pub-edit-properties-table',
|
|
|
- 'event' => 'click',
|
|
|
- 'method' => 'replace',
|
|
|
- ),
|
|
|
- '#attributes' => array('onClick' => 'return false;'),
|
|
|
- );
|
|
|
-}
|
|
|
-/*
|
|
|
- *
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param unknown $uniquename
|
|
|
*/
|
|
|
-function chado_pub_node_form_add_new_props(&$form, $form_state, &$d_properties, &$d_removed) {
|
|
|
-
|
|
|
- // first, add in all of the new properties that were added through a previous AHAH callback
|
|
|
- $j = 0;
|
|
|
- $num_properties++;
|
|
|
-
|
|
|
- // we need to find the
|
|
|
- if ($form_state['values']) {
|
|
|
- foreach ($form_state['values'] as $element_name => $value) {
|
|
|
- if (preg_match('/new_value-(\d+)-(\d+)/', $element_name, $matches)) {
|
|
|
- $new_id = $matches[1];
|
|
|
- $rank = $matches[2];
|
|
|
-
|
|
|
- // skip any properties that the user requested to delete through a previous
|
|
|
- // AHAH callback or through the current AHAH callback
|
|
|
- if($d_removed["$new_id-$rank"]) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if($form_state['post']['remove-' . $new_id . '-' . $rank]) {
|
|
|
- $d_removed["$new_id-$rank"] = 1;
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // get this new_id information
|
|
|
- $cvterm = tripal_core_chado_select('cvterm', array('name', 'definition'), array('cvterm_id' => $new_id));
|
|
|
-
|
|
|
- // add it to the $d_properties array
|
|
|
- $d_properties[$new_id][$rank]['name'] = $cvterm->name;
|
|
|
- $d_properties[$new_id][$rank]['id'] = $new_id;
|
|
|
- $d_properties[$new_id][$rank]['value'] = $value;
|
|
|
- $d_properties[$new_id][$rank]['definition'] = $cvterm->definition;
|
|
|
- $num_properties++;
|
|
|
-
|
|
|
- // determine how many rows we need in the textarea
|
|
|
- $rows = 1;
|
|
|
- if (preg_match('/Abstract/', $cvterm[0]->name)) {
|
|
|
- $rows = 10;
|
|
|
- }
|
|
|
- if ($cvterm[0]->name == 'Authors') {
|
|
|
- $rows = 2;
|
|
|
- }
|
|
|
-
|
|
|
- // add the new fields
|
|
|
- $form['properties']['new'][$new_id][$rank]["new_id-$new_id-$rank"] = array(
|
|
|
- '#type' => 'item',
|
|
|
- '#value' => $cvterm[0]->name
|
|
|
- );
|
|
|
- $form['properties']['new'][$new_id][$rank]["new_value-$new_id-$rank"] = array(
|
|
|
- '#type' => 'textarea',
|
|
|
- '#default_value' => $value,
|
|
|
- '#cols' => 50,
|
|
|
- '#rows' => $rows,
|
|
|
- '#description' => $cvterm->definition,
|
|
|
- );
|
|
|
-
|
|
|
- $form['properties']['new'][$new_id][$rank]["remove-$new_id-$rank"] = array(
|
|
|
- '#type' => 'image_button',
|
|
|
- '#value' => t('Remove'),
|
|
|
- '#src' => drupal_get_path('theme', 'tripal') . '/images/minus.png',
|
|
|
- '#ahah' => array(
|
|
|
- 'path' => "tripal_pub/properties/minus/$new_id/$rank",
|
|
|
- 'wrapper' => 'tripal-pub-edit-properties-table',
|
|
|
- 'event' => 'click',
|
|
|
- 'method' => 'replace',
|
|
|
- ),
|
|
|
- '#attributes' => array('onClick' => 'return false;'),
|
|
|
- );
|
|
|
- }
|
|
|
+function chado_pub_validate_check_uniquename($uniquename, $pub_id = NULL) {
|
|
|
+
|
|
|
+ $results = tripal_pub_get_pub_by_uniquename($uniquename);
|
|
|
+ // make sure we don't capture our pub_id in the list (remove it)
|
|
|
+ foreach ($results as $index => $found_pub_id) {
|
|
|
+ if($found_pub_id == $pub_id){
|
|
|
+ unset($results[$index]);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- // second add in any new properties added during this callback
|
|
|
- if($form_state['post']['add']) {
|
|
|
- $new_id = $form_state['values']['new_id'];
|
|
|
- $new_value = $form_state['values']['new_value'];
|
|
|
-
|
|
|
- // get the rank by counting the number of entries
|
|
|
- $rank = count($d_properties[$new_id]);
|
|
|
-
|
|
|
- // get this new_id information
|
|
|
- $cvterm = tripal_core_chado_select('cvterm', array('name', 'definition'), array('cvterm_id' => $new_id));
|
|
|
-
|
|
|
- // add it to the $d_properties array
|
|
|
- $d_properties[$new_id][$rank]['name'] = $cvterm->name;
|
|
|
- $d_properties[$new_id][$rank]['id'] = $new_id;
|
|
|
- $d_properties[$new_id][$rank]['value'] = $value;
|
|
|
- $d_properties[$new_id][$rank]['definition'] = $cvterm->definition;
|
|
|
- $num_properties++;
|
|
|
-
|
|
|
- // determine how many rows we need in the textarea
|
|
|
- $rows = 1;
|
|
|
- if (preg_match('/Abstract/', $cvterm[0]->name)) {
|
|
|
- $rows = 10;
|
|
|
- }
|
|
|
- if ($cvterm[0]->name == 'Authors') {
|
|
|
- $rows = 2;
|
|
|
- }
|
|
|
-
|
|
|
- // add the new fields
|
|
|
- $form['properties']['new'][$new_id][$rank]["new_id-$new_id-$rank"] = array(
|
|
|
- '#type' => 'item',
|
|
|
- '#value' => $cvterm[0]->name
|
|
|
- );
|
|
|
- $form['properties']['new'][$new_id][$rank]["new_value-$new_id-$rank"] = array(
|
|
|
- '#type' => 'textarea',
|
|
|
- '#default_value' => $new_value,
|
|
|
- '#cols' => 50,
|
|
|
- '#rows' => $rows,
|
|
|
- '#description' => $cvterm->definition,
|
|
|
- );
|
|
|
-
|
|
|
- $form['properties']['new'][$new_id][$rank]["remove-$new_id-$rank"] = array(
|
|
|
- '#type' => 'image_button',
|
|
|
- '#value' => t('Remove'),
|
|
|
- '#src' => drupal_get_path('theme', 'tripal') . '/images/minus.png',
|
|
|
- '#ahah' => array(
|
|
|
- 'path' => "tripal_pub/properties/minus/$new_id/$rank",
|
|
|
- 'wrapper' => 'tripal-pub-edit-properties-table',
|
|
|
- 'event' => 'click',
|
|
|
- 'method' => 'replace',
|
|
|
- ),
|
|
|
- '#attributes' => array('onClick' => 'return false;'),
|
|
|
- );
|
|
|
-
|
|
|
+ if (count($results) > 0) {
|
|
|
+ $message = t('A publication with this unique citation already exists.');
|
|
|
+ form_set_error('uniquename', $message);
|
|
|
}
|
|
|
-
|
|
|
- return $num_properties;
|
|
|
}
|
|
|
-/*
|
|
|
- *
|
|
|
- */
|
|
|
-function chado_pub_node_form_add_pubprop_table_props(&$form, $form_state, $pub_id, &$d_properties, &$d_removed) {
|
|
|
-
|
|
|
- // get the properties for this publication
|
|
|
- $num_properties = 0;
|
|
|
-
|
|
|
- if(!$pub_id) {
|
|
|
- return $num_properties;
|
|
|
- }
|
|
|
-
|
|
|
- $sql = "
|
|
|
- SELECT CVT.cvterm_id, CVT.name, CVT.definition, PP.value, PP.rank
|
|
|
- FROM {pubprop} PP
|
|
|
- INNER JOIN {cvterm} CVT on CVT.cvterm_id = PP.type_id
|
|
|
- WHERE PP.pub_id = :pub_id
|
|
|
- ORDER BY CVT.name, PP.rank
|
|
|
- ";
|
|
|
- $pub_props = chado_query($sql, array(':pub_id' => $pub_id));
|
|
|
- while ($prop = $pub_props->fetchObject()) {
|
|
|
-
|
|
|
- $type_id = $prop->cvterm_id;
|
|
|
- $rank = count($d_properties[$type_id]);
|
|
|
-
|
|
|
- // skip properties that are found in the pub table
|
|
|
- if($prop->name == "Volume" or $prop->name == "Volume Title" or
|
|
|
- $prop->name == "Issue" or $prop->name == "Pages" or
|
|
|
- $prop->name == "Citation" or $prop->name == "Journal Name") {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // skip any properties that the user requested to delete through a previous
|
|
|
- // AHAH callback or through the current AHAH callback
|
|
|
- if($d_removed["$type_id-$rank"]) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if($form_state['post']['remove-' . $type_id . '-' . $rank]) {
|
|
|
- $d_removed["$type_id-$rank"] = 1;
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- $d_properties[$type_id][$rank]['name'] = $prop->name;
|
|
|
- $d_properties[$type_id][$rank]['id'] = $type_id;
|
|
|
- $d_properties[$type_id][$rank]['value'] = $prop->value;
|
|
|
- $d_properties[$type_id][$rank]['definition'] = $prop->definition;
|
|
|
- $num_properties++;
|
|
|
-
|
|
|
- // determine how many rows we need in the textarea
|
|
|
- $rows = 1;
|
|
|
- if (preg_match('/Abstract/', $prop->name)) {
|
|
|
- $rows = 10;
|
|
|
- }
|
|
|
- if ($prop->name == 'Authors') {
|
|
|
- $rows = 2;
|
|
|
- }
|
|
|
-
|
|
|
- $form['properties'][$type_id][$rank]["prop_id-$type_id-$rank"] = array(
|
|
|
- '#type' => 'item',
|
|
|
- '#value' => $prop->name,
|
|
|
- );
|
|
|
- $form['properties'][$type_id][$rank]["prop_value-$type_id-$rank"] = array(
|
|
|
- '#type' => 'textarea',
|
|
|
- '#default_value' => $prop->value,
|
|
|
- '#cols' => 50,
|
|
|
- '#rows' => $rows,
|
|
|
- '#description' => $prop->definition,
|
|
|
- );
|
|
|
-
|
|
|
- $form['properties'][$type_id][$rank]["remove-$type_id-$rank"] = array(
|
|
|
- '#type' => 'image_button',
|
|
|
- '#value' => t('Remove'),
|
|
|
- '#src' => drupal_get_path('theme', 'tripal') . '/images/minus.png',
|
|
|
- '#ahah' => array(
|
|
|
- 'path' => "tripal_pub/properties/minus/$type_id/$rank",
|
|
|
- 'wrapper' => 'tripal-pub-edit-properties-table',
|
|
|
- 'event' => 'click',
|
|
|
- 'method' => 'replace',
|
|
|
- ),
|
|
|
- '#attributes' => array('onClick' => 'return false;'),
|
|
|
- );
|
|
|
- }
|
|
|
- return $num_properties;
|
|
|
-}
|
|
|
-/*
|
|
|
- *
|
|
|
+/**
|
|
|
+ *
|
|
|
*/
|
|
|
-function 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) {
|
|
|
-
|
|
|
- $num_properties = 0;
|
|
|
- $rank = 0;
|
|
|
-
|
|
|
- // add properties that are actually part of the pub table
|
|
|
- foreach($properties_list as $type_id => $prop) {
|
|
|
-
|
|
|
- // skip any properties that the user requested to delete through a previous
|
|
|
- // AHAH callback or through the current AHAH callback
|
|
|
- if($d_removed["$type_id-$rank"]) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if($form_state['post']["remove-$type_id-$rank"]) {
|
|
|
- $d_removed["$type_id-$rank"] = 1;
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // if any of the properties match the fields in the pub table then we
|
|
|
- // want to include those automatically
|
|
|
- if (($prop->name == 'Volume' and $d_volume) or
|
|
|
- ($prop->name == 'Issue' and $d_issue) or
|
|
|
- ($prop->name == 'Pages' and $d_pages) or
|
|
|
- ($prop->name == 'Volume Title' and $d_volumetitle) or
|
|
|
- ($prop->name == 'Journal Name' and $d_series_name)) {
|
|
|
-
|
|
|
- $d_properties[$type_id][$rank]['name'] = $prop->name;
|
|
|
- $d_properties[$type_id][$rank]['id'] = $type_id;
|
|
|
- $d_properties[$type_id][$rank]['definition'] = $prop->definition;
|
|
|
- $num_properties++;
|
|
|
-
|
|
|
- if ($prop->name == 'Volume') {
|
|
|
- $d_properties[$type_id][$rank]['value'] = $d_volume;
|
|
|
- }
|
|
|
- if ($prop->name == 'Issue') {
|
|
|
- $d_properties[$type_id][$rank]['value'] = $d_issue;
|
|
|
- }
|
|
|
- if ($prop->name == 'Pages') {
|
|
|
- $d_properties[$type_id][$rank]['value'] = $d_pages;
|
|
|
- }
|
|
|
- if ($prop->name == 'Volume Title') {
|
|
|
- $d_properties[$type_id][$rank]['value'] = $d_volumetitle;
|
|
|
+function chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvterm, $pub_id = NULL) {
|
|
|
+
|
|
|
+ // make sure the publication is unique using the prefereed import duplication check
|
|
|
+ $import_dups_check = variable_get('tripal_pub_import_duplicate_check', 'title_year_media');
|
|
|
+ switch ($import_dups_check) {
|
|
|
+ case 'title_year':
|
|
|
+ $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, NULL, $pyear, NULL);
|
|
|
+ // make sure we don't capture our pub_id in the list (remove it)
|
|
|
+ foreach ($results as $index => $found_pub_id) {
|
|
|
+ if($found_pub_id == $pub_id){
|
|
|
+ unset($results[$index]);
|
|
|
+ }
|
|
|
}
|
|
|
- if ($prop->name == 'Journal Name') {
|
|
|
- $d_properties[$type_id][$rank]['value'] = $d_series_name;
|
|
|
+ if (count($results) > 0) {
|
|
|
+ $message = t('A publication with this title and publication year, already exists.');
|
|
|
+ form_set_error('pyear', $message);
|
|
|
}
|
|
|
-
|
|
|
- // determine how many rows we need in the textarea
|
|
|
- $rows = 1;
|
|
|
- if (preg_match('/Abstract/', $prop->name)) {
|
|
|
- $rows = 10;
|
|
|
+ break;
|
|
|
+ case 'title_year_type':
|
|
|
+ $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, $cvterm[0]->name, $pyear, NULL);
|
|
|
+
|
|
|
+ // make sure we don't capture our pub_id in the list (remove it)
|
|
|
+ foreach ($results as $index => $found_pub_id) {
|
|
|
+ if($found_pub_id == $pub_id){
|
|
|
+ unset($results[$index]);
|
|
|
+ }
|
|
|
}
|
|
|
- if ($prop->name == 'Authors') {
|
|
|
- $rows = 2;
|
|
|
+ if (count($results) > 0) {
|
|
|
+ $message = t('A publication with this title, type and publication year, already exists.');
|
|
|
+ form_set_error('pyear', $message);
|
|
|
}
|
|
|
-
|
|
|
- // add in the fields
|
|
|
- $form['properties'][$type_id][$rank]["prop_id-$type_id-$rank"] = array(
|
|
|
- '#type' => 'item',
|
|
|
- '#value' => $prop->name
|
|
|
- );
|
|
|
- $form['properties'][$type_id][$rank]["prop_value-$type_id-$rank"] = array(
|
|
|
- '#type' => 'textarea',
|
|
|
- '#default_value' => $d_properties[$type_id][$rank]['value'],
|
|
|
- '#cols' => 50,
|
|
|
- '#rows' => $rows,
|
|
|
- '#description' => $description,
|
|
|
- );
|
|
|
-
|
|
|
- $form['properties'][$type_id][$rank]["remove-$type_id-$rank"] = array(
|
|
|
- '#type' => 'image_button',
|
|
|
- '#value' => t('Remove'),
|
|
|
- '#src' => drupal_get_path('theme', 'tripal') . '/images/minus.png',
|
|
|
- '#ahah' => array(
|
|
|
- 'path' => "tripal_pub/properties/minus/$type_id/$rank",
|
|
|
- 'wrapper' => 'tripal-pub-edit-properties-table',
|
|
|
- 'event' => 'click',
|
|
|
- 'method' => 'replace',
|
|
|
- ),
|
|
|
- '#attributes' => array('onClick' => 'return false;'),
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- return $num_properties;
|
|
|
-}
|
|
|
-/*
|
|
|
- *
|
|
|
- */
|
|
|
-function theme_chado_pub_node_form($form) {
|
|
|
-
|
|
|
- $properties_table = tripal_pub_theme_node_form_properties($form);
|
|
|
-
|
|
|
- $markup = drupal_render($form['pub_id']);
|
|
|
- $markup .= drupal_render($form['pubtitle']);
|
|
|
- $markup .= drupal_render($form['type_id']);
|
|
|
- $markup .= drupal_render($form['series_name']);
|
|
|
- $markup .= drupal_render($form['pyear']);
|
|
|
- $markup .= drupal_render($form['uniquename']);
|
|
|
- $markup .= "<b>Include Additional Details</b><br>You may add additional properties to this publication by scrolling to the bottom of this table, selecting a property type from the dropdown and adding text. You may add as many properties as desired by clicking the plus button on the right. To remove a property, click the minus button";
|
|
|
- $markup .= $properties_table;
|
|
|
- $markup .= drupal_render($form['is_obsolete']);
|
|
|
-
|
|
|
- $form['properties'] = array(
|
|
|
- '#type' => 'markup',
|
|
|
- '#value' => $markup,
|
|
|
- );
|
|
|
- return drupal_render($form);
|
|
|
-}
|
|
|
-
|
|
|
-/*
|
|
|
- *
|
|
|
- */
|
|
|
-function tripal_pub_theme_node_form_properties($form) {
|
|
|
- $rows = array();
|
|
|
-
|
|
|
- if ($form['properties']) {
|
|
|
-
|
|
|
- // first add in the properties derived from the pub and pubprop tables
|
|
|
- // the array tree for these properties looks like this:
|
|
|
- // $form['properties'][$type_id][$rank]["prop_id-$type_id-$rank"]
|
|
|
- foreach ($form['properties'] as $type_id => $elements) {
|
|
|
- // there are other fields in the properties array so we only
|
|
|
- // want the numeric ones those are our type_id
|
|
|
- if (is_numeric($type_id)) {
|
|
|
- foreach ($elements as $rank => $element) {
|
|
|
- if (is_numeric($rank)) {
|
|
|
- $rows[] = array(
|
|
|
- drupal_render($element["prop_id-$type_id-$rank"]),
|
|
|
- drupal_render($element["prop_value-$type_id-$rank"]),
|
|
|
- drupal_render($element["remove-$type_id-$rank"]),
|
|
|
- );
|
|
|
- }
|
|
|
+ break;
|
|
|
+ case 'title_year_media':
|
|
|
+ $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, NULL, $pyear, $series_name);
|
|
|
+
|
|
|
+ // make sure we don't capture our pub_id in the list (remove it)
|
|
|
+ foreach ($results as $index => $found_pub_id) {
|
|
|
+ if($found_pub_id == $pub_id){
|
|
|
+ unset($results[$index]);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // second, add in any new properties added by the user through AHAH callbacks
|
|
|
- // the array tree for these properties looks like this:
|
|
|
- // $form['properties']['new'][$type_id][$rank]["new_id-$new_id-$rank"]
|
|
|
- foreach ($form['properties']['new'] as $type_id => $elements) {
|
|
|
- if (is_numeric($type_id)) {
|
|
|
- foreach ($elements as $rank => $element) {
|
|
|
- if (is_numeric($rank)) {
|
|
|
- $rows[] = array(
|
|
|
- drupal_render($element["new_id-$type_id-$rank"]),
|
|
|
- drupal_render($element["new_value-$type_id-$rank"]),
|
|
|
- drupal_render($element["remove-$type_id-$rank"]),
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
+ if (count($results) > 0) {
|
|
|
+ $message = t('A publication with this title, media name (e.g. Journal Name) and publication year, already exists.');
|
|
|
+ form_set_error('pyear', $message);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // finally add in a set of blank field for adding a new property
|
|
|
- $rows[] = array(
|
|
|
- drupal_render($form['properties']['new']['new_id']),
|
|
|
- drupal_render($form['properties']['new']['new_value']),
|
|
|
- drupal_render($form['properties']['new']['add']),
|
|
|
- );
|
|
|
+ break;
|
|
|
}
|
|
|
-
|
|
|
- $headers = array('Property Type','Value', '');
|
|
|
- return theme('table', $headers, $rows, array('id'=> "tripal-pub-edit-properties-table"));
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
- *
|
|
|
- */
|
|
|
-function tripal_pub_property_add() {
|
|
|
- $status = TRUE;
|
|
|
-
|
|
|
- // prepare and render the form
|
|
|
- $form = tripal_core_ahah_prepare_form();
|
|
|
-
|
|
|
- // we only want to return the properties as that's all we'll replace with this AHAh callback
|
|
|
- $data = tripal_pub_theme_node_form_properties($form);
|
|
|
-
|
|
|
- // bind javascript events to the new objects that will be returned
|
|
|
- // so that AHAH enabled elements will work.
|
|
|
- $settings = tripal_core_ahah_bind_events();
|
|
|
-
|
|
|
- // return the updated JSON
|
|
|
- drupal_json(
|
|
|
- array(
|
|
|
- 'status' => $status,
|
|
|
- 'data' => $data,
|
|
|
- 'settings' => $settings,
|
|
|
- )
|
|
|
- );
|
|
|
-}
|
|
|
-/*
|
|
|
- *
|
|
|
- */
|
|
|
-function tripal_pub_property_delete() {
|
|
|
- $status = TRUE;
|
|
|
-
|
|
|
- // prepare and render the form
|
|
|
- $form = tripal_core_ahah_prepare_form();
|
|
|
-
|
|
|
- // we only want to return the properties as that's all we'll replace with this AHAh callback
|
|
|
- $data = tripal_pub_theme_node_form_properties($form);
|
|
|
-
|
|
|
- // bind javascript events to the new objects that will be returned
|
|
|
- // so that AHAH enabled elements will work.
|
|
|
- $settings = tripal_core_ahah_bind_events();
|
|
|
-
|
|
|
- // return the updated JSON
|
|
|
- drupal_json(
|
|
|
- array(
|
|
|
- 'status' => $status,
|
|
|
- 'data' => $data,
|
|
|
- 'settings' => $settings,
|
|
|
- )
|
|
|
- );
|
|
|
-}
|
|
|
-/*
|
|
|
- *
|
|
|
- */
|
|
|
-function tripal_pub_property_get_description() {
|
|
|
- $new_id = $_POST['new_id'];
|
|
|
-
|
|
|
- $values = array('cvterm_id' => $new_id);
|
|
|
- $cvterm = tripal_core_chado_select('cvterm', array('definition'), $values);
|
|
|
-
|
|
|
- $description = ' ';
|
|
|
- if ($cvterm[0]->definition) {
|
|
|
- $description = $cvterm[0]->definition;
|
|
|
- }
|
|
|
- drupal_json(
|
|
|
- array(
|
|
|
- 'status' => TRUE,
|
|
|
- 'data' => '<div id="tripal-pub-new_value-desc">' . $description . '</div>',
|
|
|
- )
|
|
|
- );
|
|
|
-}
|