Stephen Ficklin пре 4 година
родитељ
комит
f14480ce5d

+ 6 - 7
tripal_chado/includes/TripalFields/sbo__relationship/sbo__relationship.inc

@@ -440,16 +440,15 @@ class sbo__relationship extends ChadoField {
     // and as such both subject and object names need to be shown.
     // Keep the clause as an array for now so we can apply formatting
     // and links in the formatter
-    $clause = [ 'The ', $subject_type, ', ', $subject_name, ', ',
-                $verb, ' ', $rel_type_clean, ' ', $object_type,
-                ', ', $object_name, '.' ];
-    $entity->{$field_name}['und'][$delta]['clause_parts'] = $clause;
-    $entity->{$field_name}['und'][$delta]['value']['SIO:000493'] = implode('', $clause);
+    $clause = 'The ' . $subject_type . ', ' .
+        $subject_name . ', ' . $verb . ' ' . $rel_type_clean . ' ' .
+        $object_type . ', ' . $object_name . '.';
+    $entity->{$field_name}['und'][$delta]['value']['SIO:000493'] = $clause;
 
     // Adding a label allows us to provide a single text value for the
     // entire field. It is this text value that can be used in tab/csv
     // downloaders.
-    $entity->{$field_name}['und'][$delta]['value']['rdfs:label'] = implode('', $clause);
+    $entity->{$field_name}['und'][$delta]['value']['rdfs:label'] = $clause;
 
     $entity->{$field_name}['und'][$delta]['chado-' . $field_table . '__' . $pkey] = $relationship->$pkey;
     $entity->{$field_name}['und'][$delta]['chado-' . $field_table . '__' . $subject_id_key] = $relationship->$subject_id_key->$subject_pkey;
@@ -648,7 +647,7 @@ class sbo__relationship extends ChadoField {
    * @return
    *   The verb to use when creating a sentence of the relationship.
    */
-  private function get_rel_verb($rel_type) {
+  public static function get_rel_verb($rel_type) {
     $rel_type_clean = lcfirst(preg_replace('/_/', ' ', $rel_type));
     $verb = '';
     switch ($rel_type_clean) {

+ 9 - 1
tripal_chado/includes/TripalFields/sbo__relationship/sbo__relationship_formatter.inc

@@ -72,7 +72,15 @@ class sbo__relationship_formatter extends ChadoFieldFormatter {
       $subject_type = $item['value']['local:relationship_subject']['rdfs:type'];
       $object_name = $item['value']['local:relationship_object']['schema:name'];
       $object_type = $item['value']['local:relationship_object']['rdfs:type'];
-      $clause_parts = $item['clause_parts'];
+      $rel_type = $item['value']['local:relationship_type'];
+
+      // Get some better human-readable formats for the type and verb.
+      $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.