Browse Source

Incorporate S. Ficklin fix and then eliminate array

dsenalik 4 years ago
parent
commit
9d4244df24

+ 0 - 1
tripal_chado/includes/TripalFields/sbo__relationship/sbo__relationship.inc

@@ -433,7 +433,6 @@ class sbo__relationship extends ChadoField {
     $object_type = $entity->{$field_name}['und'][$delta]['value']['local:relationship_object']['rdfs:type'];
     $object_name = $entity->{$field_name}['und'][$delta]['value']['local:relationship_object']['schema:name'];
 
-
     // Remember the current entity could be either the subject or object!
     // Example: The genetic_marker, MARKER1 , derives from the sequence_variant, VARIANT1.
     // The above relationship will be shown both on marker and variant pages

+ 12 - 10
tripal_chado/includes/TripalFields/sbo__relationship/sbo__relationship_formatter.inc

@@ -78,10 +78,6 @@ class sbo__relationship_formatter extends ChadoFieldFormatter {
       $verb = sbo__relationship::get_rel_verb($rel_type);
       $rel_type_clean = lcfirst(preg_replace('/_/', ' ', $rel_type));
 
-      $clause_parts = [ 'The ', $subject_type, ', ', $subject_name, ', ',
-        $verb, ' ', $rel_type_clean, ' ', $object_type,
-        ', ', $object_name, '.' ];
-
       // Handle some special cases.
       // For mRNA objects we don't want to show the CDS, exons, 5' UTR, etc.
       // we want to show the parent gene and the protein.
@@ -100,22 +96,28 @@ class sbo__relationship_formatter extends ChadoFieldFormatter {
         list($entity_type, $object_entity_id) = explode(':', $item['value']['local:relationship_object']['entity']);
 
         if ($object_entity_id != $entity->id) {
-          $clause_parts[11] = l($clause_parts[11], 'bio_data/' . $object_entity_id);
+          $object_name = l($object_name, 'bio_data/' . $object_entity_id);
         }
       }
       if (array_key_exists('entity', $item['value']['local:relationship_subject'])) {
         list($entity_type, $subject_entity_id) = explode(':', $item['value']['local:relationship_subject']['entity']);
         if ($subject_entity_id != $entity->id) {
-          $clause_parts[3] = l($clause_parts[3], 'bio_data/' . $subject_entity_id);
+          $subject_name = l($subject_name, 'bio_data/' . $subject_entity_id);
         }
       }
 
-      // Add bold font to the object and subject names.
-      $clause_parts[3] = '<b>' . $clause_parts[3] . '</b>';
-      $clause_parts[11] = '<b>' . $clause_parts[11] . '</b>';
+      // Add bold font to the subject and object names.
+      $subject_name = '<b>' . $subject_name . '</b>';
+      $object_name = '<b>' . $object_name . '</b>';
+
+      // The $clause text here will match what is already in $item['value']['SIO:000493']
+      // but we rebuild it here to incorporated links and formatting
+      $clause = 'The ' . $subject_type . ', ' .
+        $subject_name . ', ' . $verb . ' ' . $rel_type_clean . ' ' .
+        $object_type . ', ' . $object_name . '.';
 
       $rows[][] = [
-        'data' => implode('', $clause_parts),
+        'data' => $clause,
         //'class' => array('tripal-entity-unattached field-items')
       ];
     }