소스 검색

Merge branch 'collections' of github.com:tripal/tripal into collections

Shawna Spoor 7 년 전
부모
커밋
b9da1d7c8a

+ 16 - 14
tripal/api/tripal.fields.api.inc

@@ -220,32 +220,34 @@ function tripal_get_field_widgets() {
  *
  * @param $field
  *   A field array as returned by the field_info_field() function.
+ * @param $instance
+ *   An field instance array.
  * @return
  *   A list of file formatter class names.
  */
-function tripal_get_field_field_formatters($field) {
+function tripal_get_field_field_formatters($field, $instance) {
   $field_name = $field['field_name'];
   $field_type = $field['type'];
 
   $downloaders = array();
 
-  // All fields should support the Tab and CSV downloaders.
-  tripal_load_include_downloader_class('TripalTabDownloader');
-  $downloaders['TripalTabDownloader'] = TripalTabDownloader::$label;
-  tripal_load_include_downloader_class('TripalCSVDownloader');
-  $downloaders['TripalCSVDownloader'] = TripalCSVDownloader::$label;
-
+  // If the field type is a TripalField then get information about the formatter.
   if (tripal_load_include_field_class($field_type)) {
-    $settings = $field_type::$default_instance_settings;
-    if (array_key_exists('download_formatters', $settings)) {
-      foreach ($settings['download_formatters'] as $class_name) {
-        if (!array_key_exists($class_name, $downloaders)) {
-          tripal_load_include_downloader_class($class_name);
-          $downloaders[$class_name] = $class_name::$label;
-        }
+    $formatters = $field_type::$download_formatters;
+    foreach ($formatters as $class_name) {
+      if (!array_key_exists($class_name, $downloaders)) {
+        tripal_load_include_downloader_class($class_name);
+        $downloaders[$class_name] = $class_name::$label;
       }
     }
   }
+  else {
+    // For non TripalFields we'll assume TAB and CSV.
+    tripal_load_include_downloader_class('TripalTabDownloader');
+    tripal_load_include_downloader_class('TripalCSVDownloader');
+    $downloaders['TripalTabDownloader'] = TripalTabDownloader::$label;
+    $downloaders['TripalCSVDownloader'] = TripalCSVDownloader::$label;
+  }
   return $downloaders;
 }
 

+ 13 - 12
tripal/includes/TripalEntityCollection.inc

@@ -75,7 +75,7 @@ class TripalEntityCollection {
         tripal_load_include_downloader_class($class_name);
         $outfile = $this->getOutfile($class_name);
         $downloader = new $class_name($this->bundles, $this->ids, $this->fields,
-            $outfile, $this->getUserID());
+            $outfile, $this->getUserID(), $this->collection_id);
         $downloader->delete();
       }
 
@@ -311,14 +311,14 @@ class TripalEntityCollection {
               $site_id = $this->getSiteId($bundle_name);
               // Use the webservices call to pull the available downloaders list.
               // Need to pull the vocab doc of the web services to know the download formats.
-              // Use the api call to get the vocab for the site which will need to be parsed 
+              // Use the api call to get the vocab for the site which will need to be parsed
               // to find the accession and the download types available.
               $site_vocab = tripal_web_services_vocab_request($site_id);
               if (!empty($site_vocab)) {
                 // Because there are multiple sites available we need to differentiate the
-                // different cached vocab structures. 
+                // different cached vocab structures.
                 $cache_name = 'tripal_web_services_vocab_' . $site_id['site_id'];
-                // Put it in the cache so we don't need to make repeated calls to it.                
+                // Put it in the cache so we don't need to make repeated calls to it.
                 cache_set($cache_name, $site_vocab);
 
                 // Now find the tripal formatters in the json data returned.
@@ -337,7 +337,7 @@ class TripalEntityCollection {
               // API function
               // All fields should support the Tab and CSV downloaders.
               $downloaders = array();
-              $this->downloaders += tripal_get_field_field_formatters($field);
+              $this->downloaders += tripal_get_field_field_formatters($field, $instance);
             }
           }
         }
@@ -350,7 +350,7 @@ class TripalEntityCollection {
           $instance = field_info_instance('TripalEntity', $field_name, $bundle_name);
           // API function
           $downloaders = array();
-          $this->downloaders += tripal_get_field_field_formatters($field);
+          $this->downloaders += tripal_get_field_field_formatters($field, $instance);
         }
       }
     }
@@ -390,7 +390,7 @@ class TripalEntityCollection {
           "required": false,
           "readable": false,
           "writeable": true.
-          "tripal_formatter": "                 
+          "tripal_formatter": "
           (
           [0] => TripalTabDownloader
           [1] => TripalCSVDownloader
@@ -461,7 +461,7 @@ class TripalEntityCollection {
     $unserialized_result = [];
     foreach ($result as $id_list) {
       $unserialized_id_list = unserialize($id_list->ids);
-  
+
       foreach ($id_list as $item) {
         $unserialized_result[] = $unserialized_id_list;
       }
@@ -478,7 +478,8 @@ class TripalEntityCollection {
    */
   public function getFields($bundle_name) {
     $collection_id = $this->collection_id;
-    // Return the bundles from the collection_bundle table.
+
+    // Get the fields from the collection_bundle table.
     $result = db_select('tripal_collection_bundle')
       ->fields('tripal_collection_bundle', array('fields'))
       ->condition('collection_id', $collection_id, '=')
@@ -486,8 +487,8 @@ class TripalEntityCollection {
       ->execute()
       ->fetchAll();
 
-     // Unserialize the array of standard class objects.
-    $unserialized_result = [];
+    // Unserialize the array of standard class objects.
+    $unserialized_result = array();
     foreach ($result as $field_list) {
       $unserialized_field_list = unserialize($field_list->fields);
       foreach ($field_list as $item) {
@@ -713,7 +714,7 @@ class TripalEntityCollection {
               }
               // Use the webservices call to pull the available downloaders list.
               // Need to pull the vocab doc of the web services to know the download formats.
-              // Use the api call to get the vocab for the site which will need to be parsed 
+              // Use the api call to get the vocab for the site which will need to be parsed
               // to find the accession and the download types available.
               if (!empty($site_id)) {
                 $cache_name = 'tripal_web_services_vocab_' . $site_id;

+ 10 - 3
tripal/includes/TripalFieldDownloaders/TripalCSVDownloader.inc

@@ -2,9 +2,16 @@
 
 class TripalCSVDownloader extends TripalFieldDownloader {
   /**
-   * Sets the label shown to the user describing this formatter.
+   * Sets the label shown to the user describing this formatter.  It
+   * should be a short identifier. Use the $full_label for a more
+   * descriptive label.
    */
-  static public $label = 'CSV (comma separated)';
+  static public $label = 'CSV';
+
+  /**
+   * A more verbose label that better describes the formatter.
+   */
+  static public $full_label = 'Comma separated';
 
   /**
    * Indicates the default extension for the outputfile.
@@ -68,7 +75,7 @@ class TripalCSVDownloader extends TripalFieldDownloader {
       else {
         $field_info = field_info_field_by_id($field);
         $field_name = $field_info['field_name'];
-        
+
         if (count($entity->{$field_name}['und']) == 1) {
           $value = $entity->{$field_name}['und'][0]['value'];
           // Add the tabs so it's in the right place.

+ 23 - 16
tripal/includes/TripalFieldDownloaders/TripalFieldDownloader.inc

@@ -4,10 +4,17 @@
 abstract class TripalFieldDownloader {
 
   /**
-   * Sets the label shown to the user describing this formatter.
+   * Sets the label shown to the user describing this formatter.  It
+   * should be a short identifier. Use the $full_label for a more
+   * descriptive label.
    */
   static public $label = 'Generic';
 
+  /**
+   * A more verbose label that better describes the formatter.
+   */
+  static public $full_label = 'Generic File format';
+
   /**
    * Indicates the default extension for the outputfile.
    */
@@ -21,20 +28,20 @@ abstract class TripalFieldDownloader {
   /**
    * The collection ID
    */
-  protected $collection_id = NULL;  
+  protected $collection_id = NULL;
 
   /**
    * The collection bundle IDs
    */
-  protected $collection_bundles = '';  
+  protected $collection_bundles = '';
 
     /**
    * The collection bundle IDs
    */
-  protected $collection_bundle_ids = array();  
+  protected $collection_bundle_ids = array();
 
   /**
-   * A set of entity IDs. 
+   * A set of entity IDs.
    */
   protected $entity_ids = array();
 
@@ -165,7 +172,7 @@ abstract class TripalFieldDownloader {
       $fields = unserialize($bundle_collection->fields);
       $entity_ids = unserialize($bundle_collection->ids);
       $site_id = $bundle_collection->site_id;
-  
+
       // Determine if the entity is remote or local.
       if (strpos($bundle_name, 'bio_data_') !== 0) {
         $external = TRUE;
@@ -176,7 +183,7 @@ abstract class TripalFieldDownloader {
 
       // Now handle the external bundles.
       if ($external) {
-        // Now we have the remote site info we need to check against the 
+        // Now we have the remote site info we need to check against the
         // passed field and entity ids.
         foreach ($entity_ids as $remote_id) {
           $fake_tripal_entity = $this->getRemoteEntity($remote_id, $site_id, $fields, $bundle_name);
@@ -224,14 +231,14 @@ abstract class TripalFieldDownloader {
 
   /**
    * Recursive function to walk down the array looking for the passed value.
-   * 
-   * @param $haystack 
+   *
+   * @param $haystack
    *   The array of vocab returned from the remote site.
    * @param $needle
    *   The field which is trying to be matched to.
    * @param $current_array
    *   Holder for the last array identified.
-   * 
+   *
    * @return
    *   The array of the field with title included.
    */
@@ -259,10 +266,10 @@ abstract class TripalFieldDownloader {
 
   /**
    * Find the header info for the remote field
-   * 
-   * @param $field 
+   *
+   * @param $field
    *   The accession which is stored as the field id.
-   * 
+   *
    * @return
    *   .
    */
@@ -326,16 +333,16 @@ abstract class TripalFieldDownloader {
        *  [sequence_coordinates] => http://demo.tripal.info/3.x/web-services/content/v0.1/Gene/296/Sequence+coordinates
        *  [relationship] => http://demo.tripal.info/3.x/web-services/content/v0.1/Gene/296/relationship
        */
-      
+
       // Build the fields for the fake entity.
       /**
        * $site_vocab will look like this:
        * [3] => Array(
        *  [property] => data:0842
        *  [hydra:title] => Identifier
-       *  [hydra:description] => 
+       *  [hydra:description] =>
        *  [required] => 1
-       *  [readable] => 
+       *  [readable] =>
        *  [writeable] => 1
        *  [tripal_formatters] => Array
        *    (

+ 9 - 2
tripal/includes/TripalFieldDownloaders/TripalNucFASTADownloader.inc

@@ -3,9 +3,16 @@
 class TripalNucFASTADownloader extends TripalFieldDownloader {
 
   /**
-   * Sets the label shown to the user describing this formatter.
+   * Sets the label shown to the user describing this formatter.  It
+   * should be a short identifier. Use the $full_label for a more
+   * descriptive label.
    */
-  static public $label = 'Nucleotide FASTA';
+  static public $label = 'FASTA';
+
+  /**
+   * A more verbose label that better describes the formatter.
+   */
+  static public $full_label = 'Nucleotide FASTA';
 
   /**
    * Indicates the default extension for the outputfile.

+ 8 - 2
tripal/includes/TripalFieldDownloaders/TripalProteinFASTADownloader.inc

@@ -2,10 +2,16 @@
 class TripalProteinFASTADownloader extends TripalFieldDownloader {
 
   /**
-   * Sets the label shown to the user describing this formatter.
+   * Sets the label shown to the user describing this formatter.  It
+   * should be a short identifier. Use the $full_label for a more
+   * descriptive label.
    */
-  static public $label = 'Protein FASTA';
+  static public $label = 'FASTA';
 
+  /**
+   * A more verbose label that better describes the formatter.
+   */
+  static public $full_label = 'Protein FASTA';
   /**
    * Indicates the default extension for the outputfile.
    */

+ 10 - 3
tripal/includes/TripalFieldDownloaders/TripalTabDownloader.inc

@@ -2,9 +2,16 @@
 
 class TripalTabDownloader extends TripalFieldDownloader {
   /**
-   * Sets the label shown to the user describing this formatter.
+   * Sets the label shown to the user describing this formatter.  It
+   * should be a short identifier. Use the $full_label for a more
+   * descriptive label.
    */
-  static public $label = 'Tab delimeted';
+  static public $label = 'TAB';
+
+  /**
+   * A more verbose label that better describes the formatter.
+   */
+  static public $full_label = 'Tab delimeted';
 
   /**
    * Indicates the default extension for the outputfile.
@@ -68,7 +75,7 @@ class TripalTabDownloader extends TripalFieldDownloader {
       else {
         $field_info = field_info_field_by_id($field);
         $field_name = $field_info['field_name'];
-        
+
         if (count($entity->{$field_name}['und']) == 1) {
           $value = $entity->{$field_name}['und'][0]['value'];
           // Add the tabs so it's in the right place.

+ 7 - 6
tripal/includes/TripalFields/TripalField.inc

@@ -50,12 +50,13 @@ class TripalField {
     // Set to TRUE if the site admin is not allowed to change the term
     // type, otherwise the admin can change the term mapped to a field.
     'term_fixed' => FALSE,
-    // Indicates the download formats for this field.  The list must be the
-    // name of a child class of the TripalFieldDownloader.
-    'download_formatters' => array(
-      'TripalTabDownloader',
-      'TripalCSVDownloader',
-    ),
+  );
+
+  // Indicates the download formats for this field.  The list must be the
+  // name of a child class of the TripalFieldDownloader.
+  public static $download_formatters = array(
+    'TripalTabDownloader',
+    'TripalCSVDownloader',
   );
 
   // The default widget for this field.

+ 94 - 2
tripal/includes/tripal.collections.inc

@@ -7,7 +7,8 @@
 function tripal_user_collections_page() {
   global $user;
 
-  $headers = array('Name', 'Description', 'Create Date', 'Downloads Formats', 'Generate File', 'Delete');
+  $headers = array('Name', 'Description', 'Create Date', 'Downloads Formats',
+    'Generate File', 'Actions');
   $rows = array();
 
   $collections = db_select('tripal_collection', 'tc')
@@ -24,7 +25,7 @@ function tripal_user_collections_page() {
     $formatters = $collection->getDownloadFormatters();
 
     foreach ($formatters as $class_name => $label) {
-     
+
       $outfile = $collection->getOutfilePath($class_name);
 
       if (file_exists($outfile)) {
@@ -49,6 +50,7 @@ function tripal_user_collections_page() {
         $collection->getCreateDate(),
         $download_list,
         l('Generate File for Download', 'user/' . $user->uid . '/data-collections/generate/' . $collection_id),
+        l('View', 'user/' . $user->uid . '/data-collections/' . $collection_id . '/view') . ' ' .
         l('Delete', 'user/' . $user->uid . '/data-collections/' . $collection_id . '/delete'),
       ),
     );
@@ -79,6 +81,96 @@ function tripal_user_collections_page() {
   return $content;
 }
 
+/**
+ * Renders a view of a data collection
+ */
+function tripal_user_collections_view_page($uid, $collection_id) {
+
+  $user = user_load($uid);
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l($user->name, 'user/' . $uid);
+  $breadcrumb[] = l('Data Collections', 'user/' . $uid . '/data-collections');
+  drupal_set_breadcrumb($breadcrumb);
+
+  $collection = new TripalEntityCollection();
+  $collection->load($collection_id);
+
+  drupal_set_title('Data Collection: ' . $collection->getName());
+
+  // Get the content types for this data collection.
+  $bundles = $collection->getBundles();
+  $content_types = array();
+  $field_list = array();
+  $formatters_list = array();
+  $entities_list = array();
+  foreach ($bundles as $bundle) {
+    $bundle = tripal_load_bundle_entity(array('name' => $bundle->bundle_name));
+    $content_types[] = $bundle->label;
+
+    $fields = $collection->getFields($bundle->name);
+    foreach ($fields as $index => $flist) {
+      foreach ($flist as $field_id) {
+        $field = field_info_field_by_id($field_id);
+        $instance = field_info_instance('TripalEntity', $field['field_name'], $bundle->name);
+        $field_list[] = $instance['label'];
+
+        $field_formatters = tripal_get_field_field_formatters($field, $instance);
+        foreach ($field_formatters as $class_name => $label) {
+          tripal_load_include_downloader_class($class_name);
+          $formatters_list[] = $label . ' (' . $class_name::$full_label . ')';
+        }
+      }
+    }
+
+    $eids = $collection->getEntityIDs($bundle->name);
+    foreach ($eids as $index => $elist) {
+      foreach ($elist as $eid) {
+        $entities_list[] = $eid;
+      }
+    }
+  }
+
+
+  $contents['content_types'] = array(
+    '#type' => 'item',
+    '#title' => 'Content types',
+    '#description' => t('The content types in this data collection'),
+    '#markup' => join(', ', $content_types),
+  );
+
+  $contents['field_list'] = array(
+    '#type' => 'item',
+    '#title' => 'Fields',
+    '#description' => t('The fields listed in this data collection'),
+    '#markup' => join(', ', array_unique($field_list)),
+  );
+  $contents['formatters'] = array(
+    '#type' => 'item',
+    '#title' => 'Supported File Types',
+    '#description' => t('The fields in your data collection appear to support the above file formats.  Please note that not all fields are compatible with all formats and only those that are compatible will appear in the format. Some file formats require certain fields and if all fields are not present in the collection they will not be complete.'),
+    '#markup' => join(', ', array_unique($formatters_list)),
+  );
+  $contents['ecount'] = array(
+    '#type' => 'item',
+    '#title' => 'Records',
+    '#description' => t('The number of records contained in this data collection.'),
+    '#markup' => count($entities_list),
+  );
+
+  $contents['peek'] = array(
+    '#type' => 'item',
+    '#title' => 'Data View',
+    '#markup' => 'Coming soon...',
+  );
+
+
+  return $contents;
+}
+/**
+ * Provides the confirm form for deleting a data collection.
+ */
 function tripal_user_collections_delete_form($form, &$form_state,  $uid, $collection_id) {
   $form_state['collection_id'] = $collection_id;
   $form['#submit'][] = 'tripal_user_collections_delete_form_submit';

+ 0 - 9
tripal/includes/tripal.fields.inc

@@ -61,15 +61,6 @@ function tripal_field_info_alter(&$info) {
       $info[$field_name]['instance_settings']['term_fixed'] = FALSE;
       $info[$field_name]['instance_settings']['auto_attach'] = TRUE;
     }
-
-    // Make sure all fields have some sort of downloader support. The Tab
-    // delimited and CSV downloaders should support all types of fields.
-    if (!array_key_exists('download_formatters', $details)) {
-      $info[$field_name]['instance_settings']['download_formatters'] = array(
-        'TripalTabDownloader',
-        'TripalCSVDownloader',
-      );
-    }
   }
 }
 

+ 16 - 0
tripal/tripal.module

@@ -390,6 +390,17 @@ function tripal_menu() {
     'file' => 'includes/tripal.collections.inc',
     'file path' => drupal_get_path('module', 'tripal'),
   );
+  $items['user/%/data-collections/%/view'] = array (
+    'title' => 'View a Collections',
+    'description' => 'Views a data collection.',
+    'page callback' => 'tripal_user_collections_view_page',
+    'page arguments' => array(1, 3),
+    'access callback' => 'tripal_accesss_user_collections',
+    'access arguments' => array(1),
+    'type' => MENU_CALLBACK,
+    'file' => 'includes/tripal.collections.inc',
+    'file path' => drupal_get_path('module', 'tripal'),
+  );
   $items['user/%/data-collections/generate/%'] = array (
     'title' => 'Generate a file for download of a Collections',
     'description' => 'Generates a data collection file for download.',
@@ -543,6 +554,11 @@ function tripal_theme($existing, $type, $theme, $path) {
       'render element' => 'element',
       'file' => 'includes/tripal.fields.inc',
     ),
+    // Themed forms
+    'tripal_views_handler_area_collections_fields_fset' => array(
+      'render element' => 'form',
+      'file' => 'views_handlers/tripal_views_handler_area_collections.inc',
+    ),
   );
 
   return $themes;

+ 98 - 39
tripal/views_handlers/tripal_views_handler_area_collections.inc

@@ -78,10 +78,16 @@ function tripal_views_handler_area_collections_form($form, $form_state, $view, $
     '#default_value' => $collection_name,
     '#required' => TRUE,
   );
-  $form['save_collection']['collection_desc'] = array(
+  $form['save_collection']['description_fset'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Add a Description'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  $form['save_collection']['description_fset']['collection_desc'] = array(
     '#type' => 'textarea',
     '#title' => t('Description'),
-    '#description' => t('Please provide a description about this data collection.'),
+    '#description' => t('Please provide a description about this data collection. This is meant to help you remember what is in the collection.'),
     '#default_value' => $collection_name,
   );
 
@@ -93,6 +99,24 @@ function tripal_views_handler_area_collections_form($form, $form_state, $view, $
   else {
     $view_fields = $view->display['default']->display_options['fields'];
   }
+
+  $form['save_collection']['fields'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Add or Update Fields'),
+    '#description' => t('You may select any of the additional fields below to
+      add to this data collection. Please note that different fields may be able
+      to create different output file types.'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+
+  // We want to theme all of the fields, so we add this next level in the
+  // form array to theme.
+  $form['save_collection']['fields']['items'] = array(
+    '#theme' => 'tripal_views_handler_area_collections_fields_fset'
+  );
+
+
   // Get the list of fields in this view.
   $field_ids = array();
   $defaults = array();
@@ -111,52 +135,40 @@ function tripal_views_handler_area_collections_form($form, $form_state, $view, $
 
     // Add in in any non CSV or Tab formatters to the label.
     $formatters = array();
-    if (tripal_load_include_field_class($field_type)) {
-      $instance_settings = $field_type::$default_instance_settings;
-      if (array_key_exists('download_formatters', $instance_settings)) {
-        foreach ($instance_settings['download_formatters'] as $class_name) {
-          if ($class_name != 'TripalTabDownloader' and $class_name != 'TripalCSVDownloader') {
-            tripal_load_include_downloader_class($class_name);
-            $formatters[] = $class_name::$label;
-          }
-        }
-      }
-    }
-    if (count($formatters) > 0) {
-      $field_label .= ' (' . implode(',' , $formatters) . ')';
+    $field_formatters = tripal_get_field_field_formatters($field, $instance);
+    foreach ($field_formatters as $class_name => $label) {
+      tripal_load_include_downloader_class($class_name);
+      $formatters[] = $label;
     }
 
     // Add the field to those supported.
-    $field_ids[$instance['field_id']] = $field_label;
+    $field_ids[$instance['field_id']]= $field_label;
+
 
     // Automatically check fields that are in the view and not excluded.
+    $checked = FALSE;
     if (array_key_exists($field_name, $view_fields)) {
       if (array_key_exists('exclude', $view_fields[$field_name]) and
           $view_fields[$field_name]['exclude'] == TRUE) {
         continue;
       }
-      $defaults[] = $instance['field_id'];
+      $checked = TRUE;
     }
+
+    $form['save_collection']['fields']['items'] ['select-' . $instance['field_id']] = array(
+      '#type' => 'checkbox',
+      '#title' => $field_label,
+      '#default_value' => $checked,
+    );
+    $form['save_collection']['fields']['items'] ['description-' . $instance['field_id']] = array(
+      '#type' => 'markup',
+      '#markup' => $instance['description']
+    );
+    $form['save_collection']['fields']['items'] ['formatters-' . $instance['field_id']] = array(
+      '#type' => 'markup',
+      '#markup' => join(', ', $formatters)
+    );
   }
-  $form['save_collection']['fields'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Advanced field selection'),
-    '#description' => t('Please select the fields to include in this data
-      collection. Not all of these fields appear in the search results
-      above but they are available for this content type. By default,
-      tab-delimeted and comma-separated files are genearted for the
-      collection using only the fields selected. However, some fields when
-      selected will generate other downloadable file formats.  Fields that
-      generate other file formats are indicated. '),
-    '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
-  );
-  $form['save_collection']['fields']['field_ids'] = array(
-    '#type' => 'checkboxes',
-    '#title' => t('Field Selection'),
-    '#options' => $field_ids,
-    '#default_value' => $defaults,
-  );
 
   $form['save_collection']['button'] = array(
     '#type' => 'submit',
@@ -174,6 +186,48 @@ function tripal_views_handler_area_collections_form($form, $form_state, $view, $
   $form['#suffix'] = '</div>';
   return $form;
 }
+/**
+ * Theme the fields section of the tripal_views_handler_area_collections form.
+ *
+ * @ingroup tripal_pub
+ */
+function theme_tripal_views_handler_area_collections_fields_fset($variables) {
+  $form = $variables['form'];
+
+  // Organize the elements by the same field id
+  $fields = array();
+  $order = array();
+  $children =  element_children($form);
+  foreach ($children as $key) {
+    list($item, $field_id) = preg_split('/-/', $key);
+    $fields[$field_id][$item] = $form[$key];
+    if (!in_array($field_id, $order)) {
+      $order[] = $field_id;
+    }
+  }
+
+  // Next create a table with each field in a different row.
+  $headers = array('Field', 'Description', 'Supported Files Types');
+  $rows = array();
+  foreach ($order as $field_id) {
+    $rows[] = array(
+      drupal_render($fields[$field_id]['select']),
+      drupal_render($fields[$field_id]['description']),
+      drupal_render($fields[$field_id]['formatters'])
+    );
+  }
+  $table = array(
+    'header' => $headers,
+    'rows' => $rows,
+    'attributes' => array(),
+    'sticky' => TRUE,
+    'caption' => '',
+    'colgroups' => array(),
+    'empty' => '',
+  );
+
+  return theme_table($table);
+}
 
 /**
  *
@@ -196,13 +250,18 @@ function tripal_views_handler_area_collections_form_submit($form, $form_state) {
   $uid = $user->uid;
   $bundle_name = $bundle->name;
 
+  // Get the fields that have been selected
   $selected_fids = array();
-  foreach ($field_ids as $field_id => $is_selected) {
-    if ($is_selected) {
-      $selected_fids[] = $field_id;
+  foreach ($form_state['values'] as $key => $value) {
+    $matches = array();
+    if (preg_match('/select-(\d+)/', $key, $matches)) {
+      if ($value == 1) {
+        $selected_fids[] = $matches[1];
+      }
     }
   }
 
+
   // Get the entity Ids that match results
   $query->range['length'] = $view->total_rows;
   $results = $query->execute();

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

@@ -41,12 +41,13 @@ class ChadoField extends TripalField {
     'chado_column' => '',
     // The base table.
     'base_table' => '',
-    // Indicates the download formats for this field.  The list must be the
-    // name of a child class of the TripalFieldDownloader.
-    'download_formatters' => array(
-      'TripalTabDownloader',
-      'TripalCSVDownloader',
-    ),
+  );
+
+  // Indicates the download formats for this field.  The list must be the
+  // name of a child class of the TripalFieldDownloader.
+  public static $download_formatters = array(
+    'TripalTabDownloader',
+    'TripalCSVDownloader',
   );
 
   // The module that manages this field.

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

@@ -38,7 +38,6 @@ class chado_linker__contact extends ChadoField {
     'term_fixed' => FALSE,
   );
 
-
   // The default widget for this field.
   public static $default_widget = 'chado_linker__contact_widget';
 

+ 8 - 7
tripal_chado/includes/TripalFields/data__protein_sequence/data__protein_sequence.inc

@@ -35,13 +35,14 @@ class data__protein_sequence extends ChadoField {
     // type. This will create form elements when editing the field instance
     // to allow the site admin to change the term settings above.
     'term_fixed' => FALSE,
-    // Indicates the download formats for this field.  The list must be the
-    // name of a child class of the TripalFieldDownloader.
-    'download_formatters' => array(
-      'TripalTabDownloader',
-      'TripalCSVDownloader',
-      'TripalProteinFASTADownloader',
-    ),
+  );
+
+  // Indicates the download formats for this field.  The list must be the
+  // name of a child class of the TripalFieldDownloader.
+  public static $download_formatters = array(
+    'TripalTabDownloader',
+    'TripalCSVDownloader',
+    'TripalProteinFASTADownloader',
   );
 
   // The default widget for this field.

+ 8 - 7
tripal_chado/includes/TripalFields/data__sequence/data__sequence.inc

@@ -35,13 +35,14 @@ class data__sequence extends ChadoField {
     // type. This will create form elements when editing the field instance
     // to allow the site admin to change the term settings above.
     'term_fixed' => FALSE,
-    // Indicates the download formats for this field.  The list must be the
-    // name of a child class of the TripalFieldDownloader.
-    'download_formatters' => array(
-      'TripalTabDownloader',
-      'TripalCSVDownloader',
-      'TripalNucFASTADownloader',
-    ),
+  );
+
+  // Indicates the download formats for this field.  The list must be the
+  // name of a child class of the TripalFieldDownloader.
+  public static $download_formatters = array(
+    'TripalTabDownloader',
+    'TripalCSVDownloader',
+    'TripalNucFASTADownloader',
   );
 
   // The default widget for this field.

+ 1 - 1
tripal_chado/includes/tripal_chado.migrate.inc

@@ -927,7 +927,7 @@ function tripal_chado_migrate_organism_image_add_file ($fid, $entity_id, $bundle
     file_usage_add($file, 'file', 'TripalEntity', $entity_id);
     $image_file = (array) $file;
     // Attached it to the entity
-    /* 
+    /*
     $entities = entity_load('TripalEntity', array($entity_id));
     $entity = $entities[$entity_id];
     $image = array(

+ 1 - 1
tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc

@@ -1168,7 +1168,7 @@ class TripalContentService_v0_1 extends TripalWebService {
         $proptype = $link;
       }
 
-      $formatters = tripal_get_field_field_formatters($field);
+      $formatters = tripal_get_field_field_formatters($field, $instance);
 
       $property = array(
         'type' => $proptype,