Przeglądaj źródła

Merge branch '7.x-3.x' into 523-relationship_formatters

Lacey Sanderson 6 lat temu
rodzic
commit
b3ab6c331c

+ 6 - 0
tripal_chado/includes/TripalFields/ogi__location_on_map/ogi__location_on_map.inc

@@ -321,6 +321,12 @@ class ogi__location_on_map extends ChadoField {
         $i++;
       }
     }
+
+    // If there are no map positions expanded above then remove the stub.
+    // This is needed to ensure this field isn't displayed when there are no locations.
+    if (!isset($feature->featurepos->feature_id) OR (sizeof($feature->featurepos->feature_id) == 0)) {
+      unset($entity->{$field_name});
+    }
   }
 
 }

+ 17 - 10
tripal_chado/includes/TripalFields/schema__publication/schema__publication.inc

@@ -83,13 +83,18 @@ class schema__publication extends ChadoField {
     $field_table = $this->instance['settings']['chado_table'];
     $field_column = $this->instance['settings']['chado_column'];
     $base_table = $this->instance['settings']['base_table'];
-    
+
     // These fields are used when the publications come through a linker table.
     $pkey = '';
     $fkey_lcolumn = '';
     $fkey_rcolumn = '';
-    $linker_table = '';   
-    
+    $linker_table = '';
+
+    // If we don't have a chado record return before creating a stub for this field!
+    if (!$record) {
+      return;
+    }
+
     // If the field table and the base table are not the same thing then
     // we are going through a linker table.
     if ($field_table != $base_table) {
@@ -116,10 +121,6 @@ class schema__publication extends ChadoField {
         'chado-' . $field_table . '__' . $field_column => '',
       );
     }
-    
-    if (!$record) {
-      return;
-    }
 
     // Get the list of publications
     $pubs = array();
@@ -132,7 +133,7 @@ class schema__publication extends ChadoField {
         $i = 0;
         foreach ($record->$linker_table as $index => $linker) {
           $pub = $linker->pub_id;
-          $pubs[$pub->pub_id] = $pub;          
+          $pubs[$pub->pub_id] = $pub;
         }
       }
     }
@@ -142,7 +143,13 @@ class schema__publication extends ChadoField {
         $pubs[$pub->pub_id] = $pub;
       }
     }
-    
+
+    // Ensure we don't have a value if there are no publications.
+    // This is needed due to stubbing out the field above.
+    if (sizeof($pubs) == 0) {
+      unset($entity->{$field_name});
+    }
+
     $i = 0;
     foreach ($pubs as $pub_id => $pub) {
       $pub_details = chado_get_minimal_pub_info($pub);
@@ -163,4 +170,4 @@ class schema__publication extends ChadoField {
       $i++;
     }
   }
-}
+}

+ 5 - 0
tripal_chado/includes/TripalFields/schema__publication/schema__publication_formatter.inc

@@ -15,6 +15,11 @@ class schema__publication_formatter extends ChadoFieldFormatter {
     $list_items = array();
     $chado_table = $this->instance['settings']['chado_table'];
 
+    // If there are no items, we don't want to return any markup.
+    if (empty($items)) {
+      return;
+    }
+
     foreach ($items as $delta => $item) {
 
       $title = isset($item['value']['TPUB:0000039']) ? $item['value']['TPUB:0000039'] : '';

+ 6 - 0
tripal_chado/includes/TripalFields/sio__annotation/sio__annotation.inc

@@ -328,6 +328,12 @@ class sio__annotation extends ChadoField {
         $entity->{$field_name}['und'][$i]['chado-' . $field_table . '__pub_id'] = $linker->pub_id;
       }
     }
+
+    // If there are no cvterms selected above then remove the stub.
+    // This is needed to ensure this field isn't displayed when there are no annotations.
+    if (sizeof($fcvterms) == 0) {
+      unset($entity->{$field_name});
+    }
   }
 }