Browse Source

cleaning up documentation, fixing some function names, and fixing the hide functionality for tables

Shawna 7 years ago
parent
commit
a8eb0581f1

+ 55 - 57
tripal_chado/api/modules/tripal_chado.cv.api.inc

@@ -381,8 +381,11 @@ function tripal_update_cvtermpath_bak($cv_id, $job_id = NULL){
     array(':cvid' => $cv_id)
     array(':cvid' => $cv_id)
   );
   );
 
 
-  $record = $result->fetchObject();
-  tripal_update_cvtermpath_root_loop($record->cvterm_id, $record->cv_id);
+  $record = $result->fetchAll();
+  foreach ($record as $item){
+    tripal_update_cvtermpath_root_loop($item->cvterm_id, $item->cv_id);
+
+  }
 }
 }
 
 
 /**
 /**
@@ -400,7 +403,6 @@ function tripal_update_cvtermpath_root_loop($rootid, $cvid){
   $ttype->condition($db_or);
   $ttype->condition($db_or);
   $result = $ttype->execute()->fetchObject();
   $result = $ttype->execute()->fetchObject();
 
 
-  // If the variables are the loop components run passed it.
   tripal_update_cvtermpath_loop($rootid, $rootid, $cvid, $result->cvterm_id, 0, 0, array());
   tripal_update_cvtermpath_loop($rootid, $rootid, $cvid, $result->cvterm_id, 0, 0, array());
 
 
   $cterm = db_query(
   $cterm = db_query(
@@ -443,77 +445,75 @@ function tripal_update_cvtermpath_loop($origin, $child_id, $cv_id, $type_id, $de
 
 
   try{
   try{
     if($count_total == 0) {
     if($count_total == 0) {
-      // Build the ID.
-      $children_id = $origin . '|' . $child_id . '|' . $cv_id . '|' . $type_id;
       // Now check if the most recent entry already exists in the array.
       // Now check if the most recent entry already exists in the array.
-      if ($increment_of_depth != 0) {
+      if ($increment_of_depth != 0 && empty($loop_data)) {
+        // Build the ID.
+        $children_id = $origin . '|' . $child_id . '|' . $cv_id . '|' . $type_id;
         // Search the $array_of_children for the new $child_id in the build_id column.
         // Search the $array_of_children for the new $child_id in the build_id column.
         foreach ($array_of_children as $key => $val) {
         foreach ($array_of_children as $key => $val) {
-         // watchdog('debug', '<pre> $val: ' . print_r($val, TRUE) . '</pre>');
-          //watchdog('debug', '<pre> $children_id: ' . print_r($children_id, TRUE) . '</pre>');
-
           if ($val['build_id'] == $children_id) {
           if ($val['build_id'] == $children_id) {
             // If the search returns something check for a possible loop.
             // If the search returns something check for a possible loop.
             $result_of_loop_checker = tripal_update_cvtermpath_loop_checker($origin, $child_id, $cv_id, $type_id, $depth, $increment_of_depth, 0, $val, [], $depth);
             $result_of_loop_checker = tripal_update_cvtermpath_loop_checker($origin, $child_id, $cv_id, $type_id, $depth, $increment_of_depth, 0, $val, [], $depth);
             if (!empty($result_of_loop_checker)) {
             if (!empty($result_of_loop_checker)) {
               $loop_data = $result_of_loop_checker;
               $loop_data = $result_of_loop_checker;
-              watchdog('loop', '<pre>$loop_data: ' . print_r($loop_data, TRUE) . '</pre>');
               //Find the depth of the loop start by finding it in the array_of_children
               //Find the depth of the loop start by finding it in the array_of_children
-              $loop_location = array_search($loop_data, $array_of_children);
-              $loop_data->depth = $array_of_children[$loop_location]['depth'];
+              foreach($array_of_children as $children => $child){
+                if($child['build_id'] == $loop_data['build_id']){
+                  $loop_location = $child['depth'];
+                }
+              }
+              $array_loop_data = (array)$loop_data;
+              $array_loop_data['depth'] = $loop_location;
+              $loop_data = $array_loop_data;
               break;
               break;
             }
             }
           }
           }
-          if (!empty($result_of_loop_checker)) {
-            watchdog('debug', 'Loop 2 found exit the loop function');
-            return $result_of_loop_checker;
+          if (!empty($loop_data)) {
+            return $loop_data;
           }
           }
         }
         }
       }
       }
+     chado_set_active('chado');
+
+      $query = db_insert('cvtermpath')
+        ->fields([
+          'object_id' => $origin,
+          'subject_id' => $child_id,
+          'cv_id' => $cv_id,
+          'type_id' => $type_id,
+          'pathdistance' => $depth,
+        ]);
+      $rows = $query->execute();
+
+      // Then add that new entry to the $array_of_children.
+      $array_of_children[$increment_of_depth] = [
+        'build_id' => $children_id,
+        'depth' => $depth
+      ];
+
+      $query = db_select('cvterm_relationship', 'cvtr')
+        ->fields('cvtr')
+        ->condition('cvtr.object_id', $child_id, '=')
+        ->execute();
+      $cterm = $query->fetchAll();
+      foreach ($cterm as $item) {
 
 
-      if(empty($result_of_loop_checker)) {
-        // If row with values does not already exist write to table.
-        chado_set_active('chado');
-
-        $query = db_insert('cvtermpath')
-          ->fields([
-            'object_id' => $origin,
-            'subject_id' => $child_id,
-            'cv_id' => $cv_id,
-            'type_id' => $type_id,
-            'pathdistance' => $depth,
-          ]);
-        $rows = $query->execute();
-
-        // Then add that new entry to the $array_of_children.
-        $array_of_children[$increment_of_depth] = [
-          'build_id' => $children_id,
-          'depth' => $depth
-        ];
-
-        $query = db_select('cvterm_relationship', 'cvtr')
-          ->fields('cvtr')
-          ->condition('cvtr.object_id', $child_id, '=')
-          ->execute();
-        $cterm = $query->fetchAll();
-
-        foreach ($cterm as $item) {
-          //watchdog('debug', 'tripal_update_cvtermpath_loop ');
-          if ($loop_data->depth < $depth) {
-           watchdog('loop', '<pre>$loop_data: 2' . print_r($loop_data, TRUE) . '</pre>');
+        if (!empty($loop_data)) {
+          if ($loop_data['depth'] < $depth) {
             break;
             break;
           }
           }
-          elseif ($loop_data == $item){
-            continue;
-          }
-          elseif ($loop_data->depth == $depth){
+          elseif ($loop_data['depth'] > $depth) {
             $loop_data = NULL;
             $loop_data = NULL;
+            break;
+
           }
           }
+        }
+        else {
           $increment_of_depth++;
           $increment_of_depth++;
           tripal_update_cvtermpath_loop($origin, $item->subject_id, $cv_id, $item->type_id, $depth + 1, $increment_of_depth, $array_of_children);
           tripal_update_cvtermpath_loop($origin, $item->subject_id, $cv_id, $item->type_id, $depth + 1, $increment_of_depth, $array_of_children);
-
         }
         }
       }
       }
+
     }
     }
   }
   }
   catch(Exception $e){
   catch(Exception $e){
@@ -552,7 +552,6 @@ function tripal_update_cvtermpath_loop_checker($origin, $child_id, $cv_id, $type
           // If the search returns something check for a possible loop.
           // If the search returns something check for a possible loop.
           if (!empty($val)) {
           if (!empty($val)) {
             $result = tripal_update_cvtermpath_loop_checker_traverse($origin, $child_id, $cv_id, $type_id, $depth, $increment_of_depth, $possible_start_of_loop, $array_of_possible_loop, array(), 0);
             $result = tripal_update_cvtermpath_loop_checker_traverse($origin, $child_id, $cv_id, $type_id, $depth, $increment_of_depth, $possible_start_of_loop, $array_of_possible_loop, array(), 0);
-            watchdog('debug', '<pre>tripal_update_cvtermpath_loop_checker  $result: '. print_r($result, TRUE) .'</pre>');
             if(!empty($result)){
             if(!empty($result)){
               break 2;
               break 2;
             }
             }
@@ -579,9 +578,10 @@ function tripal_update_cvtermpath_loop_checker($origin, $child_id, $cv_id, $type
 }
 }
 
 
 function tripal_update_cvtermpath_loop_checker_traverse($origin, $child_id, $cv_id, $type_id, $depth, $increment_of_depth, $possible_start_of_loop, $array_of_possible_loop, $traverse_of_loop, $increment) {
 function tripal_update_cvtermpath_loop_checker_traverse($origin, $child_id, $cv_id, $type_id, $depth, $increment_of_depth, $possible_start_of_loop, $array_of_possible_loop, $traverse_of_loop, $increment) {
-  if ($increment > 10) {
+  //watchdog('debug', '<pre>$increment: '. print_r($increment, TRUE) .'</pre>');
+  /*if ($increment > 10) {
     die();
     die();
-  }
+  }*/
   chado_set_active('chado');
   chado_set_active('chado');
   $query = db_select('cvterm_relationship', 'cvtr')
   $query = db_select('cvterm_relationship', 'cvtr')
     ->fields('cvtr')
     ->fields('cvtr')
@@ -591,11 +591,9 @@ function tripal_update_cvtermpath_loop_checker_traverse($origin, $child_id, $cv_
 
 
   foreach ($cterm as $item) {
   foreach ($cterm as $item) {
     if ($array_of_possible_loop === $traverse_of_loop) {
     if ($array_of_possible_loop === $traverse_of_loop) {
-      watchdog('debug', '<pre>$array_of_possible_loop: ' . print_r($array_of_possible_loop, TRUE) . '</pre>');
-      watchdog('debug', '<pre>$traverse_of_loop: ' . print_r($traverse_of_loop, TRUE) . '</pre>');
       watchdog('debug', 'LOOP');
       watchdog('debug', 'LOOP');
       //Report the loop.
       //Report the loop.
-      $loop_found = $item;
+      $loop_found = end($array_of_possible_loop);
       break;
       break;
     }
     }
     elseif ($array_of_possible_loop != $traverse_of_loop) {
     elseif ($array_of_possible_loop != $traverse_of_loop) {
@@ -621,7 +619,7 @@ function tripal_update_cvtermpath_loop_checker_traverse($origin, $child_id, $cv_
  *
  *
  * @param $origin
  * @param $origin
  * @param $subject_id
  * @param $subject_id
- * @param $cv_id
+ * @param $cv_idxkcd
  * @param $type_id
  * @param $type_id
  * @param $depth
  * @param $depth
  * @return multitype:
  * @return multitype:

+ 10 - 8
tripal_ds/api/tripal_ds.pane.api.inc

@@ -27,13 +27,15 @@
  * Example usage:
  * Example usage:
  *
  *
  * @code
  * @code
- *
+ *  field_create_field($field);
+ *  field_create_instance($instance);
+ *  tripal_ds_field_create_field($field_label, $field, $bundle);
  */
  */
 function tripal_ds_field_create_field($field_label, $field, $bundle_name) {
 function tripal_ds_field_create_field($field_label, $field, $bundle_name) {
-//Build the rest of the passes parameters.
-$group_field_name = 'gp_'.$field['field_name'];
-//Create the field groups.
-_additional_fields_field_group_info($bundle_name, $field_label, $group_field_name, $field);
-//Place the field groups in the layout.
-tripal_ds_update_ds_layout($bundle_name, $field, $group_field_name);
-}
+  //Build the rest of the passes parameters.
+  $group_field_name = 'gp_'.$field['field_name'];
+  //Create the field groups.
+  _additional_fields_field_group_info($bundle_name, $field_label, $group_field_name, $field);
+  //Place the field groups in the layout.
+  tripal_ds_update_ds_layout($bundle_name, $field, $group_field_name);
+}

+ 32 - 10
tripal_ds/includes/tripal_ds.ds.inc

@@ -8,7 +8,7 @@
  *
  *
  * @return \Closure
  * @return \Closure
  */
  */
-function sort_array($key) {
+function tripal_ds_sort_array($key) {
   return function ($a, $b) use ($key) {
   return function ($a, $b) use ($key) {
     return strnatcmp($a[$key], $b[$key]);
     return strnatcmp($a[$key], $b[$key]);
   };
   };
@@ -21,13 +21,20 @@ function sort_array($key) {
  *
  *
  * @return \Closure
  * @return \Closure
  */
  */
-function sort_object($key) {
+function tripal_ds_sort_object($key) {
   return function ($a, $b) use ($key) {
   return function ($a, $b) use ($key) {
     return strnatcmp($a->$key, $b->$key);
     return strnatcmp($a->$key, $b->$key);
   };
   };
 }
 }
+
 /**
 /**
- * Implements hook_ds_layout_settings_info().
+ * Builds the tripal_ds layout for all content types other than Publications.
+ *
+ * @param $bundle_name
+ *  Machine name of bundle, example bio_data_1
+ * @param $instances
+ *
+ * @return bool
  */
  */
 function _ds_layout_settings_info($bundle_name, $instances) {
 function _ds_layout_settings_info($bundle_name, $instances) {
   $region_right = array();
   $region_right = array();
@@ -39,7 +46,6 @@ function _ds_layout_settings_info($bundle_name, $instances) {
   $fields_with_regions = array();
   $fields_with_regions = array();
   $i = 0;
   $i = 0;
   $all_fields = array();
   $all_fields = array();
-  watchdog('debug', '<pre>$instances: '. print_r($instances, TRUE) .'</pre>');
 
 
   try {
   try {
     // Get the bundle and term objects.
     // Get the bundle and term objects.
@@ -52,7 +58,7 @@ function _ds_layout_settings_info($bundle_name, $instances) {
       $all_fields[$i] = $instance;
       $all_fields[$i] = $instance;
       $i++;
       $i++;
     }
     }
-    usort($all_fields, sort_array('label'));
+    usort($all_fields, tripal_ds_sort_array('label'));
 
 
     // Iterate through the fields of this bundle.
     // Iterate through the fields of this bundle.
     foreach ($all_fields as $key => $instance){
     foreach ($all_fields as $key => $instance){
@@ -143,7 +149,7 @@ function _ds_layout_settings_info($bundle_name, $instances) {
       foreach ($all_field_groups['default'] as $key => $field_name) {
       foreach ($all_field_groups['default'] as $key => $field_name) {
         $right_fields[$key] = $field_name;
         $right_fields[$key] = $field_name;
       }
       }
-      usort($right_fields, sort_object('label'));
+      usort($right_fields, tripal_ds_sort_object('label'));
     }
     }
     elseif(empty($all_field_groups)) {
     elseif(empty($all_field_groups)) {
       //Add the original instances that were passed and the field_groups that
       //Add the original instances that were passed and the field_groups that
@@ -168,7 +174,7 @@ function _ds_layout_settings_info($bundle_name, $instances) {
 
 
       }
       }
       $all_field_groups = array_merge($instance_names, $field_group_names);
       $all_field_groups = array_merge($instance_names, $field_group_names);
-      usort($all_field_groups, sort_array('label'));
+      usort($all_field_groups, tripal_ds_sort_array('label'));
     }
     }
 
 
     // Now build the $region_right array and the fields array.
     // Now build the $region_right array and the fields array.
@@ -245,7 +251,7 @@ function _ds_layout_settings_info($bundle_name, $instances) {
     );
     );
     $record->settings = $settings;
     $record->settings = $settings;
     drupal_write_record('ds_layout_settings', $record);
     drupal_write_record('ds_layout_settings', $record);
-    // Clear the Drpual chace
+    // Clear the Drupal cache.
     cache_clear_all();
     cache_clear_all();
   }
   }
   catch (Exception $e) {
   catch (Exception $e) {
@@ -257,7 +263,13 @@ function _ds_layout_settings_info($bundle_name, $instances) {
 
 
 
 
 /**
 /**
- *  Implements hook_ds_layout_settings_info().
+ * Builds the tripal_ds layout for Publications.
+ *
+ * @param $bundle_name
+ *  Machine name of bundle, example bio_data_1
+ * @param $instances
+ *
+ * @return bool
  */
  */
 function _ds_layout_pub_settings_info($bundle_name, $instances) {
 function _ds_layout_pub_settings_info($bundle_name, $instances) {
   $region_right = array();
   $region_right = array();
@@ -370,6 +382,9 @@ function _ds_layout_pub_settings_info($bundle_name, $instances) {
 
 
 /**
 /**
  * Implements hook_ds_fields_info().
  * Implements hook_ds_fields_info().
+ * Creates the Table of Contents field.
+ *
+ * $param $entity_type
  */
  */
 function tripal_ds_ds_fields_info($entity_type) {
 function tripal_ds_ds_fields_info($entity_type) {
   $fields = array();
   $fields = array();
@@ -383,9 +398,10 @@ function tripal_ds_ds_fields_info($entity_type) {
 }
 }
 
 
 /**
 /**
+ * Adds the content the to Table of Contents block.
  *
  *
  * @param $entity_type
  * @param $entity_type
- * @return
+ * @return Object
  */
  */
 function tripal_ds_toc_block($entity_type) {
 function tripal_ds_toc_block($entity_type) {
   $bundle_name = $entity_type['bundle'];
   $bundle_name = $entity_type['bundle'];
@@ -393,6 +409,12 @@ function tripal_ds_toc_block($entity_type) {
   return $toc;
   return $toc;
 }
 }
 
 
+/**
+ * Creates the field_group for the Table of Contents.
+ *
+ * @param $bundle_name
+ *  Machine name of bundle, example bio_data_1
+ */
 function _ds_fields_info_write($bundle_name) {
 function _ds_fields_info_write($bundle_name) {
   $fields = new stdClass;
   $fields = new stdClass;
   $fields->id ='TripalEntity|' . $bundle_name . '|default';
   $fields->id ='TripalEntity|' . $bundle_name . '|default';

+ 2 - 0
tripal_ds/includes/tripal_ds.field_formatter.inc

@@ -88,7 +88,9 @@ function tripal_ds_field_group_pre_render(&$element, $group, &$form) {
  * Updated the weight of field groups to reflect their order in the layout array.
  * Updated the weight of field groups to reflect their order in the layout array.
  *
  *
  * @param $field_name
  * @param $field_name
+ *  Machine readable name of the field.
  * @param $bundle
  * @param $bundle
+ *  Machine name of bundle, example bio_data_1
  * @param $weight
  * @param $weight
  */
  */
 function tripal_ds_field_group_update_weight($field_name, $bundle, $weight) {
 function tripal_ds_field_group_update_weight($field_name, $bundle, $weight) {

+ 29 - 2
tripal_ds/includes/tripal_ds.field_group.inc

@@ -1,7 +1,11 @@
 <?php
 <?php
 /**
 /**
+ * Creates the Summary tripal pane and the table within that pane.
+ *
  * @param $bundle_name
  * @param $bundle_name
+ *  Machine name of bundle, example bio_data_1
  * @param $fields
  * @param $fields
+ *  Array of the machine names of the children of the field group being created.
  */
  */
 function _summary_field_group_info($bundle_name, $fields){
 function _summary_field_group_info($bundle_name, $fields){
   //Tripal pane to nest the summary fieldset within.
   //Tripal pane to nest the summary fieldset within.
@@ -69,8 +73,12 @@ function _summary_field_group_info($bundle_name, $fields){
 }
 }
 
 
 /**
 /**
+ * Creates the Properties Table tripal pane and the table within that pane.
+ *
  * @param $bundle_name
  * @param $bundle_name
+ *  Machine name of bundle, example bio_data_1
  * @param $fields
  * @param $fields
+ *  Array of the machine names of the children of the field group being created.
  */
  */
 function _prop_field_group_info($bundle_name, $fields){
 function _prop_field_group_info($bundle_name, $fields){
   //Tripal pane  to nest the fieldset within.
   //Tripal pane  to nest the fieldset within.
@@ -137,8 +145,12 @@ function _prop_field_group_info($bundle_name, $fields){
 }
 }
 
 
 /**
 /**
+ * Creates the Data Sequence tripal pane and the table within that pane.
+ *
  * @param $bundle_name
  * @param $bundle_name
+ *  Machine name of bundle, example bio_data_1
  * @param $fields
  * @param $fields
+ *  Array of the machine names of the children of the field group being created.
  */
  */
 function _data_sequence_field_group_info($bundle_name, $fields){
 function _data_sequence_field_group_info($bundle_name, $fields){
   //Tripal pane  to nest the fieldset within.
   //Tripal pane  to nest the fieldset within.
@@ -204,9 +216,19 @@ function _data_sequence_field_group_info($bundle_name, $fields){
   drupal_write_record('field_group', $field_group);
   drupal_write_record('field_group', $field_group);
 }
 }
 
 
+
 /**
 /**
+ * Processes all fields other than those that belong in the summary table,
+ * property table, or data sequence table.
+ *
  * @param $bundle_name
  * @param $bundle_name
- * @param $fields
+ *  Machine name of bundle, example bio_data_1
+ * @param $field_label
+ *  Human readable name of the field.
+ * @param $group_field_name
+ *  Machine name of the field.
+ * @param $field_name
+ *  Machine name of the child element.
  */
  */
 function _additional_fields_field_group_info($bundle_name, $field_label, $group_field_name, $field_name){
 function _additional_fields_field_group_info($bundle_name, $field_label, $group_field_name, $field_name){
   //Write to the tripal_ds table to record the new tripal pane.
   //Write to the tripal_ds table to record the new tripal pane.
@@ -243,7 +265,12 @@ function _additional_fields_field_group_info($bundle_name, $field_label, $group_
 }
 }
 
 
 /**
 /**
- * Implements hook_field_group_info().
+ * Creates the tripal panes for Publications..
+ *
+ * @param $bundle_name
+ *  Machine name of bundle, example bio_data_1
+ * @param $fields
+ *  Array of the machine names of the children of the field group being created.
  */
  */
 function _publication_prop_field_group_info($bundle_name, $fields){
 function _publication_prop_field_group_info($bundle_name, $fields){
   //Tripal pane  to nest the fieldset within.
   //Tripal pane  to nest the fieldset within.

+ 48 - 6
tripal_ds/tripal_ds.module

@@ -5,6 +5,11 @@ require_once "includes/tripal_ds.ds.inc";
 require_once "includes/tripal_ds.field_group.inc";
 require_once "includes/tripal_ds.field_group.inc";
 require_once "includes/tripal_ds.field_formatter.inc";
 require_once "includes/tripal_ds.field_formatter.inc";
 
 
+/**
+ * Implements hook_init().
+ *
+ * Injects required javascript and css.
+ */
 function tripal_ds_init() {
 function tripal_ds_init() {
   drupal_add_css(drupal_get_path('module', 'tripal_ds') . '/theme/css/tripal_ds.css');
   drupal_add_css(drupal_get_path('module', 'tripal_ds') . '/theme/css/tripal_ds.css');
   drupal_add_js(drupal_get_path('module', 'tripal_ds') . '/theme/js/tripal_ds.js');
   drupal_add_js(drupal_get_path('module', 'tripal_ds') . '/theme/js/tripal_ds.js');
@@ -53,11 +58,14 @@ function tripal_ds_menu() {
   );
   );
   return $items;
   return $items;
 }
 }
+
 /**
 /**
  * Implements hook_bundle_postcreate().
  * Implements hook_bundle_postcreate().
  *
  *
  * This is a Triapl defined hook and is called in the TripalBundle::create()
  * This is a Triapl defined hook and is called in the TripalBundle::create()
  * function to allow modules to perform tasks when a bundle is created.
  * function to allow modules to perform tasks when a bundle is created.
+ *
+ * @param $bundle
  */
  */
 function tripal_ds_bundle_postcreate($bundle) {
 function tripal_ds_bundle_postcreate($bundle) {
   $bundle_name = $bundle->name;
   $bundle_name = $bundle->name;
@@ -73,7 +81,10 @@ function tripal_ds_bundle_postcreate($bundle) {
 }
 }
 
 
 /**
 /**
- * Update the tripal_ds table when a tripal pane is deleted.
+ * Update the tripal_ds table when a tripal pane is deleted. This will remove
+ * the link from the table of contents block.
+ *
+ * @param $bundle
  */
  */
 function tripal_ds_table_column_delete($bundle){
 function tripal_ds_table_column_delete($bundle){
     $bundle_name = $bundle->name;
     $bundle_name = $bundle->name;
@@ -83,13 +94,23 @@ function tripal_ds_table_column_delete($bundle){
 }
 }
 /**
 /**
  * Trigger the update to the tripal_ds table when a tripal pane is deleted.
  * Trigger the update to the tripal_ds table when a tripal pane is deleted.
+ *
+ * @param $bundle
  */
  */
 function tripal_ds_bundle_delete($bundle){
 function tripal_ds_bundle_delete($bundle){
   tripal_ds_table_column_delete($bundle);
   tripal_ds_table_column_delete($bundle);
 }
 }
 
 
+
 /**
 /**
  * Implements hook_ds_field_settings_alter()
  * Implements hook_ds_field_settings_alter()
+ *
+ * Upon save field groups are reviewed so that the tripal_ds table is update and
+ * thus the table of contents block is be updated.
+ *
+ * @param $field_settings
+ * @param $form
+ * @param $form_state
  */
  */
 function tripal_ds_ds_field_settings_alter(&$field_settings, $form, $form_state){
 function tripal_ds_ds_field_settings_alter(&$field_settings, $form, $form_state){
   // Get the form info from the bundle about to be saved.
   // Get the form info from the bundle about to be saved.
@@ -169,7 +190,10 @@ function tripal_ds_bundle_menu_item($bundle_name, $field_label, $field_name, $en
 
 
 /**
 /**
  * Implements hook_ds_layout_info() to define layouts from code in a module for
  * Implements hook_ds_layout_info() to define layouts from code in a module for
- * display suite
+ * display suite.
+ *
+ * Defines the Tripal Feature Layout option.
+ *
  */
  */
 function tripal_ds_ds_layout_info() {
 function tripal_ds_ds_layout_info() {
   $path = drupal_get_path('module', 'tripal_ds');
   $path = drupal_get_path('module', 'tripal_ds');
@@ -193,7 +217,7 @@ function tripal_ds_ds_layout_info() {
  * Implements hook_form()
  * Implements hook_form()
  *
  *
  * Adds a confirmation message to applying default layout option in 'Manage
  * Adds a confirmation message to applying default layout option in 'Manage
- * Display'
+ * Display'.
  *
  *
  * @param $form
  * @param $form
  * @param $form_state
  * @param $form_state
@@ -223,6 +247,9 @@ function tripal_ds_update_layout_form($form, &$form_state, $bundle_name) {
 /**
 /**
  * Implements hook_form_submit()
  * Implements hook_form_submit()
  *
  *
+ * Deletes all existing settings associated with a bundle's display settings
+ * so that the default layout is applied cleanly.
+ *
  * @param $form_state
  * @param $form_state
  * @param $form
  * @param $form
  */
  */
@@ -358,8 +385,17 @@ function tripal_ds_pane_addition_button_form_submit($form, &$form_state) {
   drupal_goto("admin/structure/bio_data/manage/$bundle_name/display");
   drupal_goto("admin/structure/bio_data/manage/$bundle_name/display");
 }
 }
 
 
+
 /**
 /**
+ * When called the function will add field_groups to the existing tripal_ds
+ * layout in the correct regions.
+ *
  * @param $bundle_name
  * @param $bundle_name
+ *  The name of the bundle the pane is being added to.
+ * @param $field_name
+ *  The machine name for the field.
+ * @param $tripal_pane_name
+ *  The machine name for the tripal pane.
  */
  */
 function tripal_ds_update_ds_layout($bundle_name, $field_name, $tripal_pane_name) {
 function tripal_ds_update_ds_layout($bundle_name, $field_name, $tripal_pane_name) {
   //Build the identifier to check against ds_layout_settings.
   //Build the identifier to check against ds_layout_settings.
@@ -415,7 +451,13 @@ function tripal_ds_update_ds_layout($bundle_name, $field_name, $tripal_pane_name
 */
 */
 
 
 /**
 /**
- *  Implements hook_field_display_alter().
+ * Implements hook_field_display_alter().
+ * Alters the display settings of a field before it gets displayed.
+ *
+ * Hides the empty tripal panes if the content type has been set to hide empty
+ * fields. This option is found in the edit tab of the tripal content type with
+ * a title 'Field Display'.
+ *
  * @param $display
  * @param $display
  * @param $context
  * @param $context
  */
  */
@@ -473,10 +515,10 @@ function tripal_ds_find_field_group_parent($field_name, $entity_type, $bundle, $
   foreach ($fg_for_bundle as $field_groups => $field_group) {
   foreach ($fg_for_bundle as $field_groups => $field_group) {
    $field_group_data = unserialize($field_group->data);
    $field_group_data = unserialize($field_group->data);
    // There is a separate function to deal with tables, so disregard.
    // There is a separate function to deal with tables, so disregard.
-    if ($field_group_data['format_type'] == 'table'){
+    /*if ($field_group_data['format_type'] == 'table'){
       // Do nothing
       // Do nothing
     }
     }
-    elseif (!empty($field_group_data['children'][0])) {
+    else*/if (!empty($field_group_data['children'][0])) {
       $children = $field_group_data['children'];
       $children = $field_group_data['children'];
       //If there is more than one child all need to be checked.
       //If there is more than one child all need to be checked.
       if (count($children) > 1) {
       if (count($children) > 1) {