Browse Source

Merge branch '6.x-1.x' into 7.x-2.x

spficklin 11 years ago
parent
commit
ccdc2fefc3

+ 1 - 1
tripal_core/api/tripal_core_chado.api.inc

@@ -2873,4 +2873,4 @@ function tripal_db_set_active($dbname  = 'default') {
   elseif (array_key_exists($dbname, $databases)) {
     return db_set_active($dbname);
   }
-}
+}

+ 53 - 5
tripal_pub/api/tripal_pub.api.inc

@@ -840,7 +840,7 @@ function tripal_pub_add_authors($pub_id, $authors, $do_contact) {
     $values = array(
       'pub_id' => $pub_id,
       'rank' => $rank,
-      'surname' => $author['Surname'] ? $author['Surname'] : $author['Collective'],
+      'surname' => $author['Surname'] ? substr($author['Surname'], 0, 100) : substr($author['Collective'], 0, 100),
       'givennames' => $author['Given Name'],
       'suffix' => $author['Suffix'],
     );
@@ -1169,13 +1169,20 @@ function tripal_pub_create_citation($pub) {
       if ($ptype == 'Journal Article' ) {
         $pub_type = $ptype;
         break;
-      } else if ($ptype == 'Conference Proceedings'){ 
+      } 
+      else if ($ptype == 'Conference Proceedings'){ 
         $pub_type = $ptype;
         break;
-      } else if ($ptype == 'Book') {
+      } 
+      else if ($ptype == 'Book') {
         $pub_type = $ptype;
         break;
-      } else if ($ptype == 'Book Chapter') {
+      } 
+      else if ($ptype == 'Letter') {
+        $pub_type = $ptype;
+        break;
+      } 
+      else if ($ptype == 'Book Chapter') {
         $pub_type = $ptype;
         break;
       }
@@ -1231,6 +1238,47 @@ function tripal_pub_create_citation($pub) {
     $citation .= '.';
   }
   //----------------------
+  // Letter
+  //----------------------
+  elseif ($pub_type == 'Letter') {
+    $citation = $pub['Authors'] . '. ' . $pub['Title'] .  '. ';
+  
+    if ($pub['Journal Name']) {
+      $citation .= $pub['Journal Name'] . '. ';
+    }
+    elseif ($pub['Journal Abbreviation']) {
+      $citation .= $pub['Journal Abbreviation'] . '. ';
+    }
+    elseif ($pub['Series Name']) {
+      $citation .= $pub['Series Name'] . '. ';  
+    }
+    elseif ($pub['Series Abbreviation']) {
+      $citation .= $pub['Series Abbreviation'] . '. ';
+    }
+    if ($pub['Publication Date']) {
+      $citation .= $pub['Publication Date'];
+    }
+    elseif ($pub['Year']) {
+      $citation .= $pub['Year'];
+    }
+    if ($pub['Volume'] or $pub['Issue'] or $pub['Pages']) {
+      $citation .= '; ';
+    }
+    if ($pub['Volume']) {
+      $citation .= $pub['Volume'];
+    }
+    if ($pub['Issue']) {
+      $citation .= '(' . $pub['Issue'] . ')';
+    }
+    if ($pub['Pages']) {
+      if($pub['Volume']) {
+        $citation .= ':';
+      }
+      $citation .= $pub['Pages'];
+    }
+    $citation .= '.';
+  }
+  //----------------------
   // Book
   //----------------------
   elseif ($pub_type == 'Book') {
@@ -1282,4 +1330,4 @@ function tripal_pub_create_citation($pub) {
   }
 
   return $citation;
-}
+}

+ 1 - 2
tripal_pub/includes/pub_form.inc

@@ -200,7 +200,6 @@ function chado_pub_validate($node, &$form) {
   $pub_id       = $node->pub_id;
   $num_properties = $node->num_properties;
   $num_new = $node->num_new;
-  dpm($node);
   
   $pub = array();
 
@@ -260,7 +259,7 @@ function chado_pub_validate($node, &$form) {
     $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.');
+      form_set_error('uniquename', "Cannot automatically generate a citation for this publication type. Please add one manually.");
     }
   }
 

+ 5 - 3
tripal_pub/includes/pub_sync.inc

@@ -66,7 +66,8 @@ function tripal_pub_sync_pub($pub) {
   global $user;
 
   if(!$pub->pyear) {
-    watchdog('tpub_sync', "Skipping pub without published year: %title.", array('%title' => $pub->title), WATCHDOG_WARNING);
+    watchdog('tpub_sync', "Skipping pub without published year: %title.", 
+      array('%title' => $pub->title), WATCHDOG_WARNING);
     return FALSE;
   }
 
@@ -90,7 +91,8 @@ function tripal_pub_sync_pub($pub) {
       print "Added " . $pub->pub_id . "\n";
     }
     else {
-      watchdog('tpub_sync', "Unable to create publication node: %title.", array('%title' => $pub->title), WATCHDOG_ERROR);
+      watchdog('tpub_sync', "Unable to create publication node: %title.", 
+        array('%title' => $pub->title), WATCHDOG_ERROR);
       return FALSE;
     }
   }
@@ -98,7 +100,7 @@ function tripal_pub_sync_pub($pub) {
   else {
     form_set_error(NULL,'',TRUE);
     watchdog('tpub_sync', "Unable to create publication node: %title\n%errs",
-    array('%title' => $pub->title, '%errs' => print_r($errors, TRUE)), WATCHDOG_ERROR);
+      array('%title' => $pub->title, '%errs' => print_r($errors, TRUE)), WATCHDOG_ERROR);
     return FALSE;
   }
   return $node;

+ 1 - 1
tripal_pub/tripal_pub.module

@@ -502,7 +502,7 @@ function chado_pub_insert($node) {
   else {
     drupal_set_message(t('Unable to add publication.', 'warning'));
     watchdog('tripal_pub', 'Insert publication: Unable to create pub where values: %values',
-    array('%values' => print_r($values, TRUE)), WATCHDOG_WARNING);
+      array('%values' => print_r($values, TRUE)), WATCHDOG_WARNING);
   }
 }