Ver Fonte

Fixed bug in updating pub through drush. Altered them to not encode charaters in the abstract

Stephen Ficklin há 8 anos atrás
pai
commit
fc7fdd576f

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

@@ -91,6 +91,7 @@ function tripal_get_publication($identifiers, $options = array()) {
           'name' => $dbname
         ),
       );
+
       $dbxref = chado_select_record('dbxref', array('dbxref_id'), $values);
       if (count($dbxref) == 0) {
         return FALSE;
@@ -127,7 +128,6 @@ function tripal_get_publication($identifiers, $options = array()) {
     // Try to get the pub
     $pub = chado_generate_var('pub', $identifiers, $options);
   }
-
   // Ensure the pub is singular. If it's an array then it is not singular
   if (is_array($pub)) {
     tripal_report_error('tripal_pub_api', TRIPAL_ERROR,
@@ -135,7 +135,6 @@ function tripal_get_publication($identifiers, $options = array()) {
       array('%identifier'=> print_r($identifiers, TRUE))
     );
   }
-
   // Report an error if $pub is FALSE since then chado_generate_var has failed
   elseif ($pub === FALSE) {
     tripal_report_error('tripal_pub_api', TRIPAL_ERROR,
@@ -144,7 +143,6 @@ function tripal_get_publication($identifiers, $options = array()) {
       array('%identifier'=> print_r($identifiers, TRUE))
     );
   }
-
   // Else, as far we know, everything is fine so give them their pub :)
   else {
     return $pub;
@@ -181,8 +179,8 @@ function tripal_get_publication($identifiers, $options = array()) {
  * @ingroup tripal_pub_api
  */
 function tripal_publication_exists($pub_details) {
-
-  // first try to find the publication using the accession number if that key exists in the details array
+  // First try to find the publication using the accession number if that key
+  // exists in the details array
   if (array_key_exists('Publication Dbxref', $pub_details)) {
     $pub = tripal_get_publication(array('dbxref' => $pub_details['Publication Dbxref']));
     if($pub) {
@@ -190,7 +188,7 @@ function tripal_publication_exists($pub_details) {
     }
   }
 
-  // make sure the citation is unique
+  // Make sure the citation is unique
   if (array_key_exists('Citation', $pub_details)) {
     $pub = tripal_get_publication(array('uniquename' => $pub_details['Citation']));
     if($pub) {
@@ -198,7 +196,7 @@ function tripal_publication_exists($pub_details) {
     }
   }
 
-  // get the publication type (use the first publication type)
+  // Gget the publication type (use the first publication type)
   if (array_key_exists('Publication Type', $pub_details)) {
     $type_name = '';
     if(is_array($pub_details['Publication Type'])) {

+ 4 - 3
tripal_pub/includes/importers/tripal_pub.AGL.inc

@@ -925,15 +925,16 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
     $pub['Authors'] = $pub['Author List'];
   }
 
-  // for Title, Abstract, Authors, convert the html entity and remove special unicode chars that are not meant for display
+  // for Title, Abstract, Authors, convert the html entity and remove special
+  // unicode chars that are not meant for display
   $pub['Title'] = preg_replace( '/[\p{So}]/u', '', mb_convert_encoding($pub['Title'], 'UTF-8', 'HTML-ENTITIES'));
   if (key_exists('Abstract', $pub)) {
-    $pub['Abstract'] =preg_replace( '/[\p{So}]/u', '',mb_convert_encoding($pub['Abstract'], 'UTF-8', 'HTML-ENTITIES'));
+    $pub['Abstract'] = preg_replace( '/[\p{So}]/u', '', mb_convert_encoding($pub['Abstract'], 'UTF-8', 'HTML-ENTITIES'));
   }
   $newauths = array();
   foreach ($pub['Author List'] AS $auth) {
     foreach($auth AS $k => $v) {
-      $auth[$k] = preg_replace( '/[\p{So}]/u', '',mb_convert_encoding($v, 'UTF-8', 'HTML-ENTITIES'));
+      $auth[$k] = preg_replace( '/[\p{So}]/u', '', mb_convert_encoding($v, 'UTF-8', 'HTML-ENTITIES'));
     }
     array_push($newauths, $auth);
   }

+ 1 - 1
tripal_pub/includes/importers/tripal_pub.PMID.inc

@@ -683,7 +683,7 @@ function tripal_pub_PMID_parse_abstract($xml, &$pub) {
             $pub['Structured Abstract Part'][] = $part;
           }
           else {
-            $abstract .= '<p>' . $xml->value . '</p>';
+            $abstract .= "<p>" . $xml->value . "</p>";
           }
           break;
         case 'CopyrightInformation':

+ 5 - 2
tripal_pub/includes/tripal_pub.pub_importers.inc

@@ -956,7 +956,6 @@ function tripal_pub_add_publication($pub_details, &$action, $do_contact = FALSE,
   // before proceeding check to see if the publication already exists. If there is only one match
   // and the $update_if_exists is NOT set then return FALSE
   $pub_ids = tripal_publication_exists($pub_details);
-
   if(count($pub_ids) == 1 and !$update_if_exists) {
     tripal_report_error('tripal_pub', TRIPAL_NOTICE,
      "There is a publication that is a duplicate of this publication. Cannot continue. It either ".
@@ -988,6 +987,9 @@ function tripal_pub_add_publication($pub_details, &$action, $do_contact = FALSE,
     $action = 'skipped';
     return FALSE;
   }
+  if(count($pub_ids) == 1 and $update_if_exists) {
+    $pub_id = $pub_ids[0];
+  }
 
   // get the publication type (use the first publication type)
   if (array_key_exists('Publication Type', $pub_details)) {
@@ -1500,7 +1502,8 @@ function tripal_execute_active_pub_importers($report_email = FALSE, $do_update =
     print "Syncing publications with Drupal...\n";
     chado_node_sync_records('pub');
 
-    // iterate through each of the reports and generate a final report with HTML links
+    // Iterate through each of the reports and generate a final report with
+    // HTML links.
     $HTML_report = '';
     if ($report_email) {
       $HTML_report .= "<html>";

+ 6 - 6
tripal_pub/theme/templates/pub_types/journal_article.inc

@@ -1,6 +1,6 @@
-<?php 
-// the $headers array is an array of fields to use as the colum headers. 
-// additional documentation can be found here 
+<?php
+// the $headers array is an array of fields to use as the colum headers.
+// additional documentation can be found here
 // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
 // This table for the analysis has a vertical header (down the first column)
 // so we do not provide headers here, but specify them in the $rows array below.
@@ -9,7 +9,7 @@ $headers = array();
 // the $rows array contains an array of rows where each row is an array
 // of values for each column of the table in that row.  Additional documentation
 // can be found here:
-// https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7 
+// https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
 $rows = array();
 
 // Title row
@@ -142,5 +142,5 @@ $table = array(
 print theme_table($table);
 if ($abstract_text) { ?>
   <p><b>Abstract</b></p>
-  <div style="text-align: justify"><?php print $abstract_text; ?></div> <?php 
-} 
+  <div style="text-align: justify"><?php print $abstract_text; ?></div> <?php
+}

+ 1 - 1
tripal_pub/theme/templates/tripal_pub_base.tpl.php

@@ -34,7 +34,7 @@ $abstract = chado_generate_var('pubprop', $values);
 $abstract = chado_expand_var($abstract, 'field', 'pubprop.value');
 $abstract_text = '';
 if ($abstract) {
-  $abstract_text = htmlspecialchars($abstract->value);
+  $abstract_text = $abstract->value;
 }
 
 // get the author list