Browse Source

Switching static functions to non-static

Stephen Ficklin 8 years ago
parent
commit
f5ec68063a
31 changed files with 372 additions and 497 deletions
  1. 6 5
      tripal/api/tripal.entities.api.inc
  2. 2 47
      tripal/api/tripal.fields.api.inc
  3. 10 10
      tripal/includes/TripalEntityController.inc
  4. 4 0
      tripal/includes/TripalEntityUIController.inc
  5. 93 133
      tripal/includes/TripalField.inc
  6. 5 7
      tripal/includes/TripalFields/content_type.inc
  7. 3 2
      tripal/includes/tripal.field_storage.inc
  8. 15 17
      tripal/includes/tripal.fields.inc
  9. 11 13
      tripal_chado/includes/TripalFields/chado_base__dbxref_id.inc
  10. 14 16
      tripal_chado/includes/TripalFields/chado_base__organism_id.inc
  11. 7 10
      tripal_chado/includes/TripalFields/chado_feature__md5checksum.inc
  12. 9 11
      tripal_chado/includes/TripalFields/chado_feature__residues.inc
  13. 8 10
      tripal_chado/includes/TripalFields/chado_feature__seqlen.inc
  14. 4 6
      tripal_chado/includes/TripalFields/chado_gene__transcripts.inc
  15. 7 9
      tripal_chado/includes/TripalFields/chado_linker__contact.inc
  16. 11 13
      tripal_chado/includes/TripalFields/chado_linker__cvterm.inc
  17. 6 6
      tripal_chado/includes/TripalFields/chado_linker__cvterm_adder.inc
  18. 14 16
      tripal_chado/includes/TripalFields/chado_linker__dbxref.inc
  19. 6 7
      tripal_chado/includes/TripalFields/chado_linker__expression.inc
  20. 6 8
      tripal_chado/includes/TripalFields/chado_linker__featureloc.inc
  21. 7 9
      tripal_chado/includes/TripalFields/chado_linker__genotype.inc
  22. 7 9
      tripal_chado/includes/TripalFields/chado_linker__phenotype.inc
  23. 6 8
      tripal_chado/includes/TripalFields/chado_linker__prop.inc
  24. 2 3
      tripal_chado/includes/TripalFields/chado_linker__prop_adder.inc
  25. 15 17
      tripal_chado/includes/TripalFields/chado_linker__pub.inc
  26. 40 42
      tripal_chado/includes/TripalFields/chado_linker__relationship.inc
  27. 12 14
      tripal_chado/includes/TripalFields/chado_linker__synonym.inc
  28. 12 13
      tripal_chado/includes/TripalFields/chado_organism__type_id.inc
  29. 6 5
      tripal_chado/includes/tripal_chado.field_storage.inc
  30. 22 29
      tripal_chado/includes/tripal_chado.fields.inc
  31. 2 2
      tripal_chado/tripal_chado.views.inc

+ 6 - 5
tripal/api/tripal.entities.api.inc

@@ -252,13 +252,15 @@ function tripal_create_bundle($vocabulary, $accession, $term_name, &$error = '')
         if (!$fields){
           continue;
         }
-        foreach ($fields as $info) {
+        foreach ($fields as $field_name => $info) {
+          $field_type = $info['type'];
+
           // If the field already exists then skip it.
           $field = field_info_field($info['field_name']);
           if ($field) {
             continue;
           }
-          dpm($info);
+          // Create the field.
           $field = field_create_field($info);
           if (!$field) {
             tripal_set_message(t("Could not create new field: %field.",
@@ -276,7 +278,7 @@ function tripal_create_bundle($vocabulary, $accession, $term_name, &$error = '')
         if (!$fields){
           continue;
         }
-        foreach ($fields as $info) {
+        foreach ($fields as $field_name => $info) {
           // If the field is already attached to this bundle then skip it.
           $field = field_info_field($info['field_name']);
           if ($field and array_key_exists('bundles', $field) and
@@ -284,7 +286,7 @@ function tripal_create_bundle($vocabulary, $accession, $term_name, &$error = '')
               in_array($bundle_name, $field['bundles']['TripalEntity'])) {
             continue;
           }
-          dpm($info);
+          // Create the field instance.
           $instance = field_create_instance($info);
         }
       }
@@ -293,7 +295,6 @@ function tripal_create_bundle($vocabulary, $accession, $term_name, &$error = '')
   catch (Exception $e) {
     $transaction->rollback();
     $error = _drupal_decode_exception($e);
-    dpm($info);
     drupal_set_message(t("Failed to create content type': %message",
         array('%message' => $error['!message'])), 'error');
     return FALSE;

+ 2 - 47
tripal/api/tripal.fields.api.inc

@@ -29,51 +29,6 @@
 function hook_field_storage_tquery($conditions, $orderBy) {
   // See the tripal_chado_field_storage_tquery() function for an example.
 }
-/**
- * Retrieves a list of TripalField class instances for a given module.
- *
- * The TripalField classes can be added by a site developer and should be
- * placed in the [module]/includes/fields directory.  Tripal will support
- * any field as long as it is in this directory and extends the TripalField
- * class.  To support dynamic inclusion of new fields this function
- * will look for TripalField class files and return a list of instantiated
- * objects for all of them.
- *
- * @param $module
- *   The module that provides fields.
- * @param $entity_type
- *   The type of entity (e.g. TripalEntity).
- * @param $bundle
- *   The bundle object.  This is the bundle that is being offered
- *   to the field for attachement. The function will determine if this
- *   field should be attached to this bundle.
- * @param $details
- *   An array of additional "details" that are required by the modue that
- *   implements this field. For example, an associative array of values
- *   needed for the field to work properly.
- * @return
- *   A list of TripalField objects.  If no field can be found in the
- *   module then an empty array is returned.
- */
-function tripal_get_fields($module, $entity_type, $bundle, $details = array()) {
-
-  $objects = array();
-
-  // Find all of the files in the tripal_chado/includes/fields directory.
-  $fields_path = drupal_get_path('module', $module) . '/includes/fields';
-  $field_files = file_scan_directory($fields_path, '/.*\.inc$/');
-
-  // Iterate through the fields, include the file and run the info function.
-  foreach ($field_files as $file) {
-    $field_type = $file->name;
-    module_load_include('inc', $module, 'includes/fields/' . $field_type);
-    if (class_exists($field_type)) {
-      $objects[] = new $field_type($entity_type, $bundle, $details);
-    }
-  }
-
-  return $objects;
-}
 /**
  * Retrieves a list of TripalField types.
  *
@@ -121,9 +76,9 @@ function tripal_load_include_field_type($field_type) {
 
   $modules = module_list(TRUE);
   foreach ($modules as $module) {
-    $file_path = drupal_get_path('module', $module) . '/includes/TripalFields/' . $field_type;
+    $file_path = realpath(".") . '/' . drupal_get_path('module', $module) . '/includes/TripalFields/' . $field_type . '.inc';
     if (file_exists($file_path)) {
-      module_load_include('inc', $module, 'includes/fields/' . $field_type);
+      module_load_include('inc', $module, 'includes/TripalFields/' . $field_type);
       if (class_exists($field_type)) {
         return TRUE;
       }

+ 10 - 10
tripal/includes/TripalEntityController.inc

@@ -530,19 +530,19 @@ class TripalEntityController extends EntityAPIController {
                   $entity_ids[] = $field['id'];
                 }
                 // If the field is not auto attached then we want to add an
-                // empty default valuea nd add an 'unattached' key to
+                // empty default valuea and add an 'unattached' key to
                 // clue in other things that there may be data, it's just
                 // not attached.
                 else {
-                  $value = array(
-                    'und' => array(
-                      0 => array(
-                        'value' => '',
-                        '#unattached' => TRUE,
-                      ),
-                    ),
-                  );
-                  $entity->$field_name = $value;
+//                   $value = array(
+//                     'und' => array(
+//                       0 => array(
+//                         'value' => '',
+//                         '#unattached' => TRUE,
+//                       ),
+//                     ),
+//                   );
+//                   $entity->$field_name = $value;
                 }
               }
             }

+ 4 - 0
tripal/includes/TripalEntityUIController.inc

@@ -39,6 +39,10 @@ class TripalEntityUIController extends EntityDefaultUIController {
       $matches = array();
       if (preg_match('/^bio_data_(.*?)$/', $bundle_name, $matches)) {
         $bundle = tripal_load_bundle_entity(array('name' => $bundle_name));
+        if (!$bundle) {
+          throw new Exception(t("Cannot find bundle that matches: %bundle_name",
+              array('%bundle_name' => $bundle_name)));
+        }
         // Get the term for this bundle
         $term = entity_load('TripalTerm', array('id' => $matches[1]));
         $term = reset($term);

+ 93 - 133
tripal/includes/TripalField.inc

@@ -2,50 +2,46 @@
 
 
 /**
- * A base class for fields attached to Tripal Entities.
+ * A base for fields attached Tripal Entities.
  *
- * The Field API of Drupal defines three "levels" for fields:  field types,
- * fields, and instances of fields. This class attempts to consolidate use
- * of all three "levels".  All fields must be of a specific type, and
- * the field types are typically defined using the hook_field_info() hook.
- * Normally, using Drupal's Field API, fields can be created by using the
- * field_create_field() function which defines the parameters and settings
- * for the field.  The field_create_instance() function is then used to attach
- * a field to a bundle and to set local parameters and settings for the field
- * when attached to the bundle.  There are also a variety of hooks for creating
- * widgets, formatters, customizaing settings forms, loading values, validating
- * widget forms, etc. Rather than use all of these hooks, the TripalField class
- * is used to consolidate and simplify creation and management of Fields.
+ * This class is intended to simplify development of fields for Tripal Entities.
+ * The Drupal Field API can still be used if desired, but the hope for this
+ * class it to put the necessary functions in one place so that other Tripal
+ * developers do not need to suffer the pain of navigating and learning the
+ * Drupal Field API.
  *
- * A module can extend this class to create new fields, and attach them to
- * bundles.  The class is structured to allow fields to specify which bundles
- * they want to "automatically" attach. This is a bit different from how fields
- * would normally be attached. But allows a field to be self-aware.
- *
- * All of  the functionality for a field is self-contained in the Class
- * implementation.  To change functionality a developer need only edit the
- * class file for a field rathaer than look for all of the Field API hook that
- * would typically be spread around the module.
- *
- * This class also supports use of controlled vocabulaaries for providing
- * "types" to these fields. This is important for use with the semantic web
- * support for Tripal v3.
- *
- * AJAX callbacks, and theme functions unfortunately cannot be part of the
- * implementation of this class.  To keep all functionality for a field
- * in the same file, it is recommended that those functions, if needed, should
- * be added to the bottom of the file where the child class is housed, and each
- * TripalField child class should each be written in a separate file.
+ * To create a new field that can be attached to a Tripal Entity follow these
+ * steps:
+ * # Create a new class that inherits from TripalField
+ * # Copy the editable constant variables (default_desription, default_label,
+ *   default_settings and default_storage) to your class and edit as needed.
+ *   Be sure not to rename these variables and be sure to keep the 'static'
+ *   qualifier on them.
+ * # Copy the functions you want to override. You will not need to copy the
+ *   constructor, the static info() functions, or the getters and setters. In
+ *   short you'll typically only need to override the Settingsform funtions,
+ *   their validators and submitters, the load() function, and the widgetForm
+ *   with it's validator and submitter.
+ * # In your custom module implement the function hook_create_tripalfields()
+ *   This function will be called anytime a new TripalEntity is created. It
+ *   allows your module to create the new fields.  See the documentation for
+ *   this function for creating the fields.  A field is usually only ever
+ *   created once and can be reused on multiple entities.  So, even though
+ *   this function is called everytime a new TripalEntity is created the fields
+ *   will only be created once.
+ * # In your custom module implement the function
+ *   hook_create_tripalfield_instance().  This function is called anytime a
+ *   new TripalEntity is created. It allows you to specify which fields are
+ *   attached to an entity.  See the documentation for this hook function for
+ *   more information.
  *
  */
 class TripalField {
 
-  // An object containing configuration data for this field. The contents
-  // of this object come directly from the field_config table of Drupal.
-  protected $field;
+
 
   // --------------------------------------------------------------------------
-  //                          STATIC CONSTANTS
+  //                     EDITABLE STATIC CONSTANTS
   //
   // The following constants SHOULD be set for each descendent class.  They are
   // used by the static functions to provide information to Drupal about
@@ -69,43 +65,41 @@ class TripalField {
   // this field.
   public static $default_storage = 'tripal_no_storage';
 
+  // --------------------------------------------------------------------------
+  //              PROTECTED CLASS MEMBERS -- DO NOT OVERRIDE
+  // --------------------------------------------------------------------------
+  // An array containing details about the field. The format of this array
+  // is the same as that returned by field_info_fields()
+  protected $field;
+  // An array containing details about an instance of the field. A field does
+  // not have to have an instance.  But if dealing with an instance (such as
+  // when using the widgetForm, formatterSettingsForm, etc.) it should be set.
+  protected $instance;
 
 
   // --------------------------------------------------------------------------
-  //           CONSTRUCTORS & STATIC CONSTRUCTOR HELPERS
-  //
-  // Child classes SHOULD NOT need to override these functions.
+  //                     CONSTRUCTORS -- DO NOT OVERRIDE
   // --------------------------------------------------------------------------
 
   /**
    * Instantiates a new TripalField object.
    *
    * @param $field
-   *   If the field already exists in Drupal, then pass in the $field array
-   *   for this argument.  If nothing is passed in then an "empty" field
-   *   is created.  This is only useful
-   *
-   * The field must have already been previously created.
+   *   An array containing the field data as returned by field_info_field()
+   * @param $instance
+   *   (Optional). Set the instance of this field when one is available. This
+   *   is necessary when working with instance specific functions such as the
+   *   formatterSettingsForm, widgetForm, etc.
    */
-  public function __construct($info = array()) {
-    // If the field array has been passed in then just link it.
-    if (array_key_exists('field', $info)) {
-      $this->field = $field;
-    }
-    // If the field name has been passed in then retreive the form info.
-    if (array_key_exists('field_name', $info)) {
-      $this->field = field_info_field($field_name);
-    }
-    // If the field info has been passed in then create the field.
-    if (array_key_exists('info', $info)) {
-      $this->field = field_create_field($info['info']);
-    }
+  public function __construct($field, $instance = NULL) {
+    $this->field = $field;
+    $this->instance = $instance;
 
     // Include any instances that have been created for this field.
-    if (is_array($field) and array_key_exists('id', $this->field)) {
+    if (is_array($this->field) and array_key_exists('id', $this->field)) {
       $instances = db_select('field_config_instance', 'fci')
         ->fields('fci')
-        ->condition('field_id', $field['id'])
+        ->condition('field_id', $this->field['id'])
         ->execute();
 
       while ($instance = $instances->fetchObject()) {
@@ -115,9 +109,7 @@ class TripalField {
   }
 
   // --------------------------------------------------------------------------
-  //                      STATIC INFO FUNCTIONS
-  //
-  // Child classes SHOULD NOT need to override these functions.
+  //           STATIC INFO FUNCTIONS -- DO NOT OVERRIDE
   // --------------------------------------------------------------------------
 
   /**
@@ -191,9 +183,7 @@ class TripalField {
   }
 
   // --------------------------------------------------------------------------
-  //                         GETTERS AND SETTERS
-  //
-  // Child classes SHOULD NOT need to override these functions.
+  //                 GETTERS AND SETTERS -- DO NOT OVERRIDE
   // --------------------------------------------------------------------------
 
   /**
@@ -206,66 +196,18 @@ class TripalField {
     return $this->field['field_name'];
   }
 
-  // --------------------------------------------------------------------------
-  //                     FIELD SPECIFIC FUNCTIONS
-  //
-  // Child classes SHOULD NOT override these functions as needed.
-  // --------------------------------------------------------------------------
+  public function getField() {
+    return $this->field;
+  }
+  public function getInstance() {
+    return $this->instance;
+  }
 
 
   // --------------------------------------------------------------------------
-  //                  OVERRIDEABLE FIELD SPECIFIC FUNCTIONS
-  //
-  // Child classes SHOULD override these functions as needed.
+  //                 OVERRIDEABLE FUNCTIONS
   // --------------------------------------------------------------------------
 
-  /**
-   * Performs a check to see disallow attaching of a field instance to a bundle.
-   *
-   * By default Tripal will try to automatically attach all TripalFields to
-   * every bundle.  But this is certainly not appropriate.
-   * This function should be overridden by a child to ensure it is attached
-   * to only desired bundles.
-   *
-   * This function returns FALSE if this field should NOT be attached to the
-   * bundle. This should always be honored by a child class. If the parent class
-   * returns FALSE then so should the child.  Alternatively, this function
-   * returns NULL if there is no good reason to deny attachment and leaves it up
-   * to the child class to decide.  If the child class does not impolment
-   * this function then the NULL is recognized as FALSE by Tripal and the
-   * field will not be attached to the bundle.  Therefore, it is necessary
-   * for the child class to implement this function and return TRUE for
-   * bundles to which this field should be attached.  Because bundles names
-   * use controlled vocabulary terms the child class should be able to
-   * determine if it should attach.
-   *
-   * @param $entity_type
-   *   The entity type
-   * @param $bundle_name
-   *   The name of the bundle
-   *
-   * @return
-   *   FALSE if the child class should return FALSE, NULL if the child class
-   *   should decide.  The child class should always return FAlSE or TRUE. If
-   *   TRUE is returned then an instance of the field can be attached to the
-   *   bundle.
-   */
-//   protected function canAttach($entity_type, $bundle_name) {
-//     // Don't attach if it's already attached.
-//     if (array_key_exists('bundles', $this->field) and
-//         array_key_exists('TripalEntity', $this->field['bundles']) and
-//         in_array($bundle_name, $this->field['bundles']['TripalEntity'])) {
-//       return FALSE;
-//     }
-
-//     // Child classes should check to see if this field can be attached
-//     // to the bundle.
-//     return NULL;
-//   }
-
-
-
-
   /**
    * Provides a summary of the formatter settings.
    *
@@ -345,8 +287,7 @@ class TripalField {
    *    An element array compatible with that returned by the
    *    hook_field_formatter_view() function.
    */
-  public static function formatterView(&$element, $entity_type, $entity,
-      $field, $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
     foreach($items as $delta => $item) {
       $element[$delta] = array(
@@ -369,26 +310,46 @@ class TripalField {
    * or via web services, or some other mechanism.  However, the 'value' is
    * sometimes not enough for a field.  For example, the Tripal Chado module
    * maps fields to table columns and sometimes those columns are foreign keys
-   * therefore, the Tripal Chado modules does not use the 'value' but adds
+   * therefore, the Tripal Chado modules does not just use the 'value' but adds
    * additional elements to help link records via FKs.  But even in this case
-   * the 'value' element must always be present in the returne form and in such
+   * the 'value' element must always be present in the return form and in such
    * cases it's value should be set equal to that added in the 'load' function.
    *
    * @param $widget
    * @param $form
+   *   The form structure where widgets are being attached to. This might be a
+   *   full form structure, or a sub-element of a larger form.
    * @param $form_state
-   * @param $field
-   * @param $instance
+   *   An associative array containing the current state of the form.
    * @param $langcode
+   *   The language associated with $items.
    * @param $items
+   *   Array of default values for this field.
    * @param $delta
+   *   The order of this item in the array of subelements (0, 1, 2, etc).
    * @param $element
-   *
-   * @return
-   *   A Drupal form. See the hook_field_widget_form() function for more information.
+   * A form element array containing basic properties for the widget:
+   *  - #entity_type: The name of the entity the field is attached to.
+   *  - #bundle: The name of the field bundle the field is contained in.
+   *  - #field_name: The name of the field.
+   *  - #language: The language the field is being edited in.
+   *  - #field_parents: The 'parents' space for the field in the form. Most
+   *    widgets can simply overlook this property. This identifies the location
+   *    where the field values are placed within $form_state['values'], and is
+   *    used to access processing information for the field through the
+   *    field_form_get_state() and field_form_set_state() functions.
+   *  - #columns: A list of field storage columns of the field.
+   *  - #title: The sanitized element label for the field instance, ready for
+   *    output.
+   *  - #description: The sanitized element description for the field instance,
+   *    ready for output.
+   *  - #required: A Boolean indicating whether the element value is required;
+   *    for required multiple value fields, only the first widget's values are
+   *    required.
+   *  - #delta: The order of this item in the array of subelements; see
+   *    $delta above
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
     $widget['value'] = array(
       '#type' => 'value',
@@ -463,7 +424,6 @@ class TripalField {
   /**
    * Loads the field values from the underlying data store.
    *
-   * @param $field
    * @param $entity
    * @param $details
    *
@@ -489,7 +449,7 @@ class TripalField {
    *
    *
    */
-  public static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
   }
 

+ 5 - 7
tripal/includes/TripalFields/content_type.inc

@@ -22,16 +22,15 @@ class content_type extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
     $bundle = tripal_load_bundle_entity(array('name' => $entity->bundle));
-    $entity->{$field['field_name']}['und'][0]['value'] = $bundle->label;
+    $entity->{$this->field['field_name']}['und'][0]['value'] = $bundle->label;
   }
 
   /**
    * @see TripalField::formatterView()
    */
-  static function formatterView(&$element, $entity_type, $entity,
-      $field, $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
     foreach ($items as $delta => $item) {
       $element[$delta] = array(
@@ -44,11 +43,10 @@ class content_type extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
     $widget = $element;
-    switch ($instance['widget']['type']) {
+    switch ($this->instance['widget']['type']) {
       case 'tripal_content_type_widget':
         // There is no widget for this type.
         break;

+ 3 - 2
tripal/includes/tripal.field_storage.inc

@@ -51,9 +51,10 @@ function tripal_field_storage_load($entity_type, $entities, $age,
       // Allow the creating module to alter the value if desired.  The
       // module should do this if the field has any other form elements
       // that need populationg besides the value which was set above.
-      module_load_include('inc', $field_module, 'includes/fields/' . $field_type);
+      tripal_load_include_field_type($field_type);
       if (class_exists($field_type)) {
-        $field_type::load($field, $entity);
+        $tfield = new $field_type($field);
+        $tfield->load($entity);
       }
 
     } // end: foreach ($fields as $field_id => $ids) {

+ 15 - 17
tripal/includes/tripal.fields.inc

@@ -51,7 +51,7 @@ function tripal_field_formatter_info() {
 function tripal_create_tripalfields($entity_type, $bundle) {
   $field_name = 'content_type';
   $info = array();
-  $info[] = array(
+  $info[$field_name] = array(
     'field_name' => $field_name,
     'type' => 'content_type',
     'cardinality' => 1,
@@ -74,10 +74,10 @@ function tripal_create_tripalfields($entity_type, $bundle) {
 function tripal_create_tripalfield_instance($entity_type, $bundle) {
   $field_name = 'content_type';
   $info = array();
-  $info[] = array(
+  $info[$field_name] = array(
     'field_name' => $field_name,
     'entity_type' => 'TripalEntity',
-    'bundle' => $this->bundle->name,
+    'bundle' => $bundle->name,
     'label' => 'Resource Type',
     'description' => '',
     'required' => FALSE,
@@ -110,9 +110,8 @@ function tripal_field_formatter_view($entity_type, $entity, $field,
   $field_type = $field['type'];
   $is_loaded = tripal_load_include_field_type($field_type);
   if ($is_loaded) {
-    $tfield = new $field_type(array('field' => $field));
-    $tfield->formatterView($element, $entity_type, $entity, $field,
-        $instance, $langcode, $items, $display);
+    $tfield = new $field_type($field, $instance);
+    $tfield->formatterView($element, $entity_type, $entity, $langcode, $items, $display);
   }
   return $element;
 }
@@ -218,7 +217,7 @@ function tripal_field_settings_form($field, $instance, $has_data) {
   $field_type = $field['type'];
   $is_loaded = tripal_load_include_field_type($field_type);
   if ($is_loaded) {
-    $tfield = new $field_type(array('field' => $field));
+    $tfield = new $field_type($field, $instance);
     $form = $tfield->fieldSettingsForm($field, $instance, $has_data);
   }
   return $form;
@@ -231,7 +230,7 @@ function tripal_field_instance_settings_form($field, $instance) {
   $field_type = $field['type'];
   $is_loaded = tripal_load_include_field_type($field_type);
   if ($is_loaded) {
-    $tfield = new $field_type(array('field' => $field));
+    $tfield = new $field_type($field, $instance);
     $form = $tfield->instanceSettingsForm($field, $instance);
   }
   return $form;
@@ -250,7 +249,7 @@ function tripal_field_settings_form_validate($form, &$form_state) {
   $field_type = $field['type'];
   $is_loaded = tripal_load_include_field_type($field_type);
   if ($is_loaded) {
-    $tfield = new $field_type(array('field' => $field));
+    $tfield = new $field_type($field, $instance);
     $form = $tfield->fieldSettingsFormValidate($field, $instance, $form, $form_state);
   }
 }
@@ -267,7 +266,7 @@ function tripal_instance_settings_form_validate($form, &$form_state) {
   $field_type = $field['type'];
   $is_loaded = tripal_load_include_field_type($field_type);
   if ($is_loaded) {
-    $tfield = new $field_type(array('field' => $field));
+    $tfield = new $field_type($field, $instance);
     $form = $tfield->instanceSettingsFormValidate($field, $instance, $form, $form_state);
   }
 }
@@ -281,7 +280,7 @@ function tripal_field_formatter_settings_summary($field, $instance, $view_mode)
   $field_type = $field['type'];
   $is_loaded = tripal_load_include_field_type($field_type);
   if ($is_loaded) {
-    $tfield = new $field_type(array('field' => $field));
+    $tfield = new $field_type($field, $instance);
     $form = $tfield->formatterSettingsSummary($field, $instance, $view_mode);
   }
   return $summary;
@@ -297,7 +296,7 @@ function tripal_formatter_settings_form($field, $instance,
   $field_type = $field['type'];
   $is_loaded = tripal_load_include_field_type($field_type);
   if ($is_loaded) {
-    $tfield = new $field_type(array('field' => $field));
+    $tfield = new $field_type($field, $instance);
     $form = $tfield->formatterSettingsForm(field, $instance, $view_mode, $form, $form_state);
   }
   return $form;
@@ -314,9 +313,8 @@ function tripal_field_widget_form(&$form, &$form_state, $field,
   $field_type = $field['type'];
   $is_loaded = tripal_load_include_field_type($field_type);
   if ($is_loaded) {
-    $tfield = new $field_type(array('field' => $field));
-    $tfield->widgetForm($widget, $form, $form_state, $field, $instance,
-      $langcode, $items, $delta, $element);
+    $tfield = new $field_type($field, $instance);
+    $tfield->widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
   }
   return $widget;
 
@@ -368,7 +366,7 @@ function tripal_field_validate($entity_type, $entity, $field, $instance,
   $field_type = $field['type'];
   $is_loaded = tripal_load_include_field_type($field_type);
   if ($is_loaded) {
-    $tfield = new $field_type(array('field' => $field));
+    $tfield = new $field_type($field, $instance);
     $bundle = isset($entity->bundle) ? $entity->bundle : NULL;
     $form = $field_type::widgetFormValidate($entity_type, $entity, $field, $instance,
         $langcode, $items, $errors);
@@ -386,7 +384,7 @@ function tripal_field_submit($entity_type, $entity, $field, $instance,
   $field_type = $field['type'];
   $is_loaded = tripal_load_include_field_type($field_type);
   if ($is_loaded) {
-    $tfield = new $field_type(array('field' => $field));
+    $tfield = new $field_type($field, $instance);
     $form = $field_type::widgetFormSubmit($entity_type, $entity, $field, $instance,
         $langcode, $items, $form, $form_state);
   }

+ 11 - 13
tripal_chado/includes/TripalFields/chado_base__dbxref_id.inc

@@ -121,8 +121,7 @@ class chado_base__dbxref_id extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  static function formatterView(&$element, $entity_type, $entity, $field,
-      $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
     foreach ($items as $delta => $item) {
       if ($item['value']) {
@@ -137,13 +136,12 @@ class chado_base__dbxref_id extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Get the field defaults.
     $fk_val = '';
@@ -272,14 +270,14 @@ class chado_base__dbxref_id extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
     $record = $details['record'];
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
 
     // Set some defauls for the empty record

+ 14 - 16
tripal_chado/includes/TripalFields/chado_base__organism_id.inc

@@ -130,8 +130,7 @@ class chado_base__organism_id extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  public static function formatterView(&$element, $entity_type, $entity,
-      $field, $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
     if (count($items) > 0) {
       $content = $items[0]['value']['label'];
@@ -152,14 +151,13 @@ class chado_base__organism_id extends TripalField {
   /**
    * @see TripalField::widget()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
-    $settings = $field['settings'];
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $settings = $this->field['settings'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     $organism_id = 0;
     if (count($items) > 0 and array_key_exists($field_table . '__organism_id', $items[0])) {
@@ -187,15 +185,15 @@ class chado_base__organism_id extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
     $record = $details['record'];
-    $settings = $field['settings'];
+    $settings = $this->field['settings'];
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Set some defaults for the empty record.
     $entity->{$field_name}['und'][0] = array(
@@ -252,7 +250,7 @@ class chado_base__organism_id extends TripalField {
   public static function fieldSettingsForm($field, $instance, $has_data) {
     $element = parent::fieldSettingsForm($field, $instance, $has_data);
 
-    $settings = $field['settings'];
+    $settings = $this->field['settings'];
 
     $element['instructions'] = array(
       '#type' => 'item',

+ 7 - 10
tripal_chado/includes/TripalFields/chado_feature__md5checksum.inc

@@ -126,8 +126,7 @@ class chado_feature__md5checksum  extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  static function formatterView(&$element, $entity_type, $entity, $field,
-      $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
     foreach ($items as $delta => $item) {
       $content = key_exists('value', $item) ? $item['value'] : '';
       $element[$delta] = array(
@@ -141,14 +140,12 @@ class chado_feature__md5checksum  extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
-
-    $settings = $field['settings'];
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
+    $settings = $this->field['settings'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Get the field defaults.
     $md5checksum = '';

+ 9 - 11
tripal_chado/includes/TripalFields/chado_feature__residues.inc

@@ -130,8 +130,7 @@ class chado_feature__residues extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  static function formatterView(&$element, $entity_type, $entity, $field,
-    $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
 
     $element[0] = array(
@@ -168,13 +167,12 @@ class chado_feature__residues extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
-    $settings = $field['settings'];
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
+    $settings = $this->field['settings'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Get the field defaults.
     $residues = '';
@@ -204,9 +202,9 @@ class chado_feature__residues extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
-    $field_name = $field['field_name'];
+    $field_name = $this->field['field_name'];
     $feature = $details['record'];
     $num_seqs = 0;
 

+ 8 - 10
tripal_chado/includes/TripalFields/chado_feature__seqlen.inc

@@ -120,8 +120,7 @@ class chado_feature__seqlen extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  static function formatterView(&$element, $entity_type, $entity, $field,
-      $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
     foreach ($items as $delta => $item) {
       $element[$delta] = array(
@@ -134,14 +133,13 @@ class chado_feature__seqlen extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
-
-    $settings = $field['settings'];
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
+
+    $settings = $this->field['settings'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     $widget['value'] = array(
       '#type' => 'value',

+ 4 - 6
tripal_chado/includes/TripalFields/chado_gene__transcripts.inc

@@ -141,8 +141,7 @@ class chado_gene__transcripts extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  public static function formatterView(&$element, $entity_type, $entity,
-      $field, $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
     // Get the settings
     $settings = $display['settings'];
@@ -196,11 +195,11 @@ class chado_gene__transcripts extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
     $record = $details['record'];
 
-    $field_name = $field['field_name'];
+    $field_name = $this->field['field_name'];
 
     // Set some defaults for the empty record.
     $entity->{$field_name}['und'][0] = array(
@@ -265,8 +264,7 @@ class chado_gene__transcripts extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
   }
 }

+ 7 - 9
tripal_chado/includes/TripalFields/chado_linker__contact.inc

@@ -132,8 +132,7 @@ class chado_linker__contact extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  public static function formatterView(&$element, $entity_type, $entity,
-      $field, $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
     // Get the settings
     $settings = $display['settings'];
 
@@ -186,21 +185,20 @@ class chado_linker__contact extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
   }
 
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
     $record = $details['record'];
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Get the FK that links to the base record.
     $schema = chado_get_schema($field_table);

+ 11 - 13
tripal_chado/includes/TripalFields/chado_linker__cvterm.inc

@@ -72,13 +72,12 @@ class chado_linker__cvterm extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  static function formatterView(&$element, $entity_type, $entity, $field,
-      $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
     $headers = array('Term', 'Definition', 'Is Not', 'Reference');
     $rows = array();
 
-    $chado_table = $field['settings']['chado_table'];
+    $chado_table = $this->field['settings']['chado_table'];
     foreach ($items as $delta => $item) {
       if ($item[$chado_table . '__cvterm_id']) {
         $cvterm = chado_generate_var('cvterm', array('cvterm_id' => $item[$chado_table . '__cvterm_id']));
@@ -133,11 +132,10 @@ class chado_linker__cvterm extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
     $entity = $form['#entity'];
-    $field_name = $field['field_name'];
+    $field_name = $this->field['field_name'];
 
     $matches = array();
     preg_match('/(.*?)__(\d+)/', $field_name, $matches);
@@ -150,8 +148,8 @@ class chado_linker__cvterm extends TripalField {
     $cv_id = $matches[2];
 
     // Get the FK column that links to the base table.
-    $chado_table = $field['settings']['chado_table'];
-    $base_table = $field['settings']['base_table'];
+    $chado_table = $this->field['settings']['chado_table'];
+    $base_table = $this->field['settings']['base_table'];
     $schema = chado_get_schema($chado_table);
     $pkey = $schema['primary key'][0];
     $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
@@ -251,14 +249,14 @@ class chado_linker__cvterm extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
     $record = $details['record'];
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     $matches = array();
     preg_match('/(.*?)__(\d+)/', $field_name, $matches);

+ 6 - 6
tripal_chado/includes/TripalFields/chado_linker__cvterm_adder.inc

@@ -1,5 +1,5 @@
 <?php
-class chado_linker__cvterm_addr extends TripalField {
+class chado_linker__cvterm_adder extends TripalField {
 
   // The default lable for this field.
   public static $default_label = 'Add an Annotation Type';
@@ -103,12 +103,10 @@ class chado_linker__cvterm_addr extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
     // This field has no value field.  Just a fieldset for adding new annotation types.
 
-    $widget['#element_validate'] = array('chado_linker__cvterm_adder_widget_validate');
 
     $widget['#type'] = 'fieldset';
     $widget['#title'] = $element['#title'];
@@ -134,6 +132,8 @@ class chado_linker__cvterm_addr extends TripalField {
           you want to allow users to use for annotations."),
     );
 
+    //    $widget['#element_validate'] = array('chado_linker__cvterm_adder_widget_validate');
+
     // When this button is clicked, the form will be validated and submitted.
     // Therefore, we set custom submit and validate functions to override the
     // default form submit.  In the validate function we set the form_state
@@ -145,8 +145,8 @@ class chado_linker__cvterm_addr extends TripalField {
       '#value' => t('Add Annotation Type'),
       '#type' => 'submit',
       '#name' => 'cvterm_class_adder_button',
-      '#submit' => array('chado_linker__cvterm_adder_widget_submit'),
-      '#limit_validation_errors' => array(array($field['field_name'])),
+//      '#submit' => array('chado_linker__cvterm_adder_widget_submit'),
+      '#limit_validation_errors' => array(array($this->field['field_name'])),
     );
   }
 

+ 14 - 16
tripal_chado/includes/TripalFields/chado_linker__dbxref.inc

@@ -140,10 +140,9 @@ class chado_linker__dbxref extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  static function formatterView(&$element, $entity_type, $entity, $field,
-      $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
-    $chado_table = $field['settings']['chado_table'];
+    $chado_table = $this->field['settings']['chado_table'];
     foreach ($items as $delta => $item) {
       if (!$item['value']) {
         continue;
@@ -168,17 +167,16 @@ class chado_linker__dbxref extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Get the FK column that links to the base table.
-    $chado_table = $field['settings']['chado_table'];
-    $base_table = $field['settings']['base_table'];
+    $chado_table = $this->field['settings']['chado_table'];
+    $base_table = $this->field['settings']['base_table'];
     $schema = chado_get_schema($chado_table);
     $pkey = $schema['primary key'][0];
     $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
@@ -303,14 +301,14 @@ class chado_linker__dbxref extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
     $record = $details['record'];
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
     $base_table = $record->tablename;
 
     $schema = chado_get_schema($field_table);

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

@@ -125,8 +125,7 @@ class chado_linker__expression extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  public static function formatterView(&$element, $entity_type, $entity,
-      $field, $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
     // Get the settings
     $settings = $display['settings'];
@@ -199,13 +198,13 @@ class chado_linker__expression extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
     $record = $details['record'];
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Get the FK that links to the base record.
     $schema = chado_get_schema($field_table);

+ 6 - 8
tripal_chado/includes/TripalFields/chado_linker__featureloc.inc

@@ -144,8 +144,7 @@ class chado_linker__featureloc extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  static function formatterView(&$element, $entity_type, $entity,
-      $field, $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
     // Get the settings
     $settings = $display['settings'];
@@ -222,12 +221,12 @@ class chado_linker__featureloc extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
     $record = $details['record'];
-    $settings = $field['settings'];
+    $settings = $this->field['settings'];
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
 
     // Set some defaults for the empty record.
     $entity->{$field_name}['und'][0] = array(
@@ -400,8 +399,7 @@ class chado_linker__featureloc extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-   public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+   public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
   }
 

+ 7 - 9
tripal_chado/includes/TripalFields/chado_linker__genotype.inc

@@ -99,8 +99,7 @@ class chado_linker__genotype extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  public static function formatterView(&$element, $entity_type, $entity,
-      $field, $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
     // Get the settings
     $settings = $display['settings'];
@@ -154,20 +153,19 @@ class chado_linker__genotype extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
   }
 
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
     $record = $details['record'];
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Get the FK that links to the base record.
     $schema = chado_get_schema($field_table);

+ 7 - 9
tripal_chado/includes/TripalFields/chado_linker__phenotype.inc

@@ -100,8 +100,7 @@ class chado_linker__phenotype extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  public static function formatterView(&$element, $entity_type, $entity,
-      $field, $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
     // Get the settings
     $settings = $display['settings'];
 
@@ -154,21 +153,20 @@ class chado_linker__phenotype extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
   }
 
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
     $record = $details['record'];
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Get the FK that links to the base record.
     $schema = chado_get_schema($field_table);

+ 6 - 8
tripal_chado/includes/TripalFields/chado_linker__prop.inc

@@ -25,11 +25,10 @@ class chado_linker__prop extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  static function formatterView(&$element, $entity_type, $entity, $field,
-    $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
-    $field_name = $field['field_name'];
-    $chado_table = $field['settings']['chado_table'];
+    $field_name = $this->field['field_name'];
+    $chado_table = $this->field['settings']['chado_table'];
 
     $properties = array();
     foreach ($items as $delta => $item) {
@@ -47,11 +46,10 @@ class chado_linker__prop extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
     $entity = $form['#entity'];
-    $field_name = $field['field_name'];
+    $field_name = $this->field['field_name'];
 
     // Get the record and table mapping info.
     $chado_table = $entity->chado_table;
@@ -180,7 +178,7 @@ class chado_linker__prop extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
     $field_name = $details['field_name'];
     $field_type = $details['type'];

+ 2 - 3
tripal_chado/includes/TripalFields/chado_linker__prop_adder.inc

@@ -104,8 +104,7 @@ class chado_linker__prop_adder extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  static function widgetForm(&$widget, &$form, &$form_state,
-      $field, $instance, $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
     $widget['#type'] = 'fieldset';
     $widget['#title'] = $element['#title'];
@@ -143,7 +142,7 @@ class chado_linker__prop_adder extends TripalField {
       '#value' => t('Add Property'),
       '#type' => 'submit',
       '#name' => 'kvproperty_adder_button',
-      '#limit_validation_errors' => array(array($field['field_name'])),
+      '#limit_validation_errors' => array(array($this->field['field_name'])),
     );
   }
 

+ 15 - 17
tripal_chado/includes/TripalFields/chado_linker__pub.inc

@@ -1,6 +1,6 @@
 <?php
 
-class chado_linker_pub extends TripalField {
+class chado_linker__pub extends TripalField {
 
   // The default lable for this field.
   public static $default_label = 'Publications';
@@ -125,11 +125,10 @@ class chado_linker_pub extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  static function formatterView(&$element, $entity_type, $entity, $field,
-      $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
     $list_items = array();
-    $chado_table = $field['settings']['chado_table'];
+    $chado_table = $this->field['settings']['chado_table'];
     foreach ($items as $delta => $item) {
       if ($item[$chado_table . '__pub_id']) {
         $pub = chado_generate_var('pub', array('pub_id' => $item[$chado_table . '__pub_id']));
@@ -156,15 +155,14 @@ class chado_linker_pub extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
     $entity = $form['#entity'];
-    $field_name = $field['field_name'];
+    $field_name = $this->field['field_name'];
 
     // Get the FK column that links to the base table.
-    $table_name = $field['settings']['chado_table'];
-    $base_table = $field['settings']['base_table'];
+    $table_name = $this->field['settings']['chado_table'];
+    $base_table = $this->field['settings']['base_table'];
     $schema = chado_get_schema($table_name);
     $pkey = $schema['primary key'][0];
     $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
@@ -178,7 +176,7 @@ class chado_linker_pub extends TripalField {
 
     // If the field already has a value then it will come through the $items
     // array.  This happens when editing an existing record.
-    if (array_key_exists($delta, $items)) {
+    if (count($items) > 0 and array_key_exists($delta, $items)) {
       $record_id = $items[$delta][$table_name . '__' . $pkey];
       $fkey_value = $items[$delta][$table_name . '__' . $fkey];
       $pub_id = $items[$delta][$table_name . '__pub_id'];
@@ -197,14 +195,14 @@ class chado_linker_pub extends TripalField {
 
     $widget['#table_name'] = $table_name;
     $widget['#fkey_field'] = $fkey;
-    $widget['#element_validate'] = array('chado_linker__pub_widget_validate');
+//    $widget['#element_validate'] = array('chado_linker__pub_widget_validate');
     $widget['#theme'] = 'chado_linker__pub_widget';
     $widget['#prefix'] =  "<span id='$table_name-$delta'>";
     $widget['#suffix'] =  "</span>";
 
     $widget['value'] = array(
       '#type' => 'value',
-      '#value' => $items[$delta]['value'],
+      '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
     );
 
     $widget[$table_name . '__' . $pkey] = array(
@@ -238,14 +236,14 @@ class chado_linker_pub extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
     $record = $details['record'];
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Get the FK that links to the base record.
     $schema = chado_get_schema($field_table);

+ 40 - 42
tripal_chado/includes/TripalFields/chado_linker__relationship.inc

@@ -155,8 +155,7 @@ class chado_linker__relationship extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  static function formatterView(&$element, $entity_type, $entity,
-      $field, $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
     // Get the settings
     $settings = $display['settings'];
 
@@ -235,17 +234,16 @@ class chado_linker__relationship extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  static function  widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Get the FK column that links to the base table.
-    $chado_table = $field['settings']['chado_table'];
-    $base_table = $field['settings']['base_table'];
+    $chado_table = $this->field['settings']['chado_table'];
+    $base_table = $this->field['settings']['base_table'];
     $schema = chado_get_schema($chado_table);
     $pkey = $schema['primary key'][0];
     $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
@@ -399,11 +397,11 @@ class chado_linker__relationship extends TripalField {
    */
   function validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
-    $base_table = $field['settings']['base_table'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
+    $base_table = $this->field['settings']['base_table'];
 
     $chado_record_id = $entity->chado_record_id;
 
@@ -427,19 +425,19 @@ class chado_linker__relationship extends TripalField {
       // Make sure we have values for all of the fields.
       $form_error = FALSE;
       if (!$type_name) {
-        $errors[$field['field_name']][$langcode][$delta][] = array(
+        $errors[$this->field['field_name']][$langcode][$delta][] = array(
           'error' => 'chado_linker__relationship',
           'message' => t("Please provide the type of relationship."),
         );
       }
       if (!$subject_name) {
-        $errors[$field['field_name']][$langcode][$delta][] = array(
+        $errors[$this->field['field_name']][$langcode][$delta][] = array(
           'error' => 'chado_linker__relationship',
           'message' => t("Please provide the subject of the relationship."),
         );
       }
       if (!$object_name) {
-        $errors[$field['field_name']][$langcode][$delta][] = array(
+        $errors[$this->field['field_name']][$langcode][$delta][] = array(
           'error' => 'chado_linker__relationship',
           'message' => t("Please provide the object of the relationship."),
         );
@@ -460,7 +458,7 @@ class chado_linker__relationship extends TripalField {
         $values = array($fkey_rcolumn => $subject_id);
         $subject = chado_select_record($base_table, array($fkey_rcolumn), $values);
         if (count($subject) == 0) {
-          $errors[$field['field_name']][$langcode][$delta][] = array(
+          $errors[$this->field['field_name']][$langcode][$delta][] = array(
             'error' => 'chado_linker__relationship',
             'message' => t("The subject record cannot be found using the specified id (e.g. [id: xx])."),
           );
@@ -470,13 +468,13 @@ class chado_linker__relationship extends TripalField {
         $values = array('uniquename' => $subject_name);
         $subject = chado_select_record($base_table, array($fkey_rcolumn), $values);
         if (count($subject) == 0) {
-          $errors[$field['field_name']][$langcode][$delta][] = array(
+          $errors[$this->field['field_name']][$langcode][$delta][] = array(
             'error' => 'chado_linker__relationship',
             'message' => t("The subject record cannot be found. Please check spelling."),
           );
         }
         elseif (count($subject) > 1) {
-          $errors[$field['field_name']][$langcode][$delta][] = array(
+          $errors[$this->field['field_name']][$langcode][$delta][] = array(
             'error' => 'chado_linker__relationship',
             'message' => t("The subject is not unique and therefore the relationship cannot be made."),
           );
@@ -492,7 +490,7 @@ class chado_linker__relationship extends TripalField {
         $values = array($fkey_rcolumn => $object_id);
         $object = chado_select_record($base_table, array($fkey_rcolumn), $values);
         if (count($subject) == 0) {
-          $errors[$field['field_name']][$langcode][$delta][] = array(
+          $errors[$this->field['field_name']][$langcode][$delta][] = array(
             'error' => 'chado_linker__relationship',
             'message' => t("The object record cannot be found using the specified id (e.g. [id: xx])."),
           );
@@ -502,13 +500,13 @@ class chado_linker__relationship extends TripalField {
         $values = array('uniquename' => $object_name);
         $object = chado_select_record($base_table, array($fkey_rcolumn), $values);
         if (count($object) == 0) {
-          $errors[$field['field_name']][$langcode][$delta][] = array(
+          $errors[$this->field['field_name']][$langcode][$delta][] = array(
             'error' => 'chado_linker__relationship',
             'message' => t("The object record cannot be found. Please check spelling."),
           );;
         }
         elseif (count($object) > 1) {
-          $errors[$field['field_name']][$langcode][$delta][] = array(
+          $errors[$this->field['field_name']][$langcode][$delta][] = array(
             'error' => 'chado_linker__relationship',
             'message' =>  t("The object is not unique and therefore the relationship cannot be made."),
           );
@@ -517,7 +515,7 @@ class chado_linker__relationship extends TripalField {
 
       // Make sure that either our object or our subject refers to the base record.
       if ($object_id != $chado_record_id  and $subject_id != $chado_record_id) {
-        $errors[$field['field_name']][$langcode][$delta][] = array(
+        $errors[$this->field['field_name']][$langcode][$delta][] = array(
           'error' => 'chado_linker__relationship',
           'message' =>  t("Either the subject or the object in the relationship must refer to this record."),
         );
@@ -525,7 +523,7 @@ class chado_linker__relationship extends TripalField {
 
       // Make sure that the object and subject are not both the same thing.
       if ($object_id == $subject_id) {
-        $errors[$field['field_name']][$langcode][$delta][] = array(
+        $errors[$this->field['field_name']][$langcode][$delta][] = array(
           'error' => 'chado_linker__relationship',
           'message' =>  t("The subject and the object in the relationship cannot both refer to the same record."),
         );
@@ -538,11 +536,11 @@ class chado_linker__relationship extends TripalField {
   public function submit($entity_type, $entity, $field, $instance, $langcode,
       &$items, $form, &$form_state) {
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
-    $base_table = $field['settings']['base_table'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
+    $base_table = $this->field['settings']['base_table'];
 
     $chado_record_id = $entity->chado_record_id;
 
@@ -598,17 +596,17 @@ class chado_linker__relationship extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
-    $settings = $field['settings'];
+    $settings = $this->field['settings'];
 
     $record = $details['record'];
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
-    $base_table = $field['settings']['base_table'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
+    $base_table = $this->field['settings']['base_table'];
 
     // Get the PKey for this table
     $schema = chado_get_schema($field_table);
@@ -907,7 +905,7 @@ class chado_linker__relationship extends TripalField {
       '#multiple' => TRUE,
       '#options' => $vocs,
       '#size' => 6,
-      '#default_value' => $instance['settings']['default_vocabs'],
+      '#default_value' => $this->instance['settings']['default_vocabs'],
       // TODO add ajax here so that the relationship autocomplete below works
     );
 
@@ -925,13 +923,13 @@ class chado_linker__relationship extends TripalField {
       '#description' => 'Specify Default Vocabularies',
       '#multiple' => FALSE,
       '#options' => $vocs,
-      '#default_value' => $instance['settings']['default_vocabs'],
+      '#default_value' => $this->instance['settings']['default_vocabs'],
       // TODO add ajax here so that the relationship autocomplete below works
     );
     $element['relationships']['option2_parent'] = array(
       '#type' => 'textfield',
       '#description' => 'Specify a Heirarchical Parent Term',
-      '#default_value' => $instance['settings']['child_relationship_types'],
+      '#default_value' => $this->instance['settings']['child_relationship_types'],
       '#autocomplete_path' => "admin/tripal/storage/chado/auto_name/cvterm/"
     );
     $element['relationships']['option3'] = array(
@@ -942,7 +940,7 @@ class chado_linker__relationship extends TripalField {
     );
     $element['relationships']['relationship_types'] = array(
       '#type' => 'textarea',
-      '#default_value' => $instance['settings']['relationship_types'],
+      '#default_value' => $this->instance['settings']['relationship_types'],
     );
 
     return $element;

+ 12 - 14
tripal_chado/includes/TripalFields/chado_linker__synonym.inc

@@ -123,10 +123,9 @@ class chado_linker__synonym extends TripalField {
   /**
    * @see TripalField::formatterView()
    */
-  static function formatterView(&$element, $entity_type, $entity, $field,
-      $instance, $langcode, $items, $display) {
+  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
 
-    $chado_table = $field['settings']['chado_table'];
+    $chado_table = $this->field['settings']['chado_table'];
     foreach ($items as $delta => $item) {
       if (array_key_exists($chado_table . '__synonym_id', $item) and
           $item[$chado_table . '__synonym_id']) {
@@ -145,15 +144,14 @@ class chado_linker__synonym extends TripalField {
   /**
    * @see TripalField::widgetForm()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
     $entity = $form['#entity'];
-    $field_name = $field['field_name'];
+    $field_name = $this->field['field_name'];
 
     // Get the FK column that links to the base table.
-    $table_name = $field['settings']['chado_table'];
-    $base_table = $field['settings']['base_table'];
+    $table_name = $this->field['settings']['chado_table'];
+    $base_table = $this->field['settings']['base_table'];
     $schema = chado_get_schema($table_name);
     $pkey = $schema['primary key'][0];
     $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
@@ -258,15 +256,15 @@ class chado_linker__synonym extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
     $record = $details['record'];
-    $base_table = $field['settings']['base_table'];
+    $base_table = $this->field['settings']['base_table'];
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Get the PKey for this table
     $schema = chado_get_schema($field_table);

+ 12 - 13
tripal_chado/includes/TripalFields/chado_organism__type_id.inc

@@ -119,14 +119,13 @@ class chado_organism__type_id extends TripalField {
   /**
    * @see TripalField::widget()
    */
-  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
-      $langcode, $items, $delta, $element) {
+  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
 
-    $settings = $field['settings'];
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $settings = $this->field['settings'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     $type_id = 0;
     if (count($items) > 0 and array_key_exists('organism__type_id', $items[0])) {
@@ -158,15 +157,15 @@ class chado_organism__type_id extends TripalField {
   /**
    * @see TripalField::load()
    */
-  static function load($field, $entity, $details = array()) {
+  public function load($entity, $details = array()) {
 
     $record = $details['record'];
-    $settings = $field['settings'];
+    $settings = $this->field['settings'];
 
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->field['settings']['chado_table'];
+    $field_column = $this->field['settings']['chado_column'];
 
     // Set some defaults for the empty record.
     $entity->{$field_name}['und'][0] = array(

+ 6 - 5
tripal_chado/includes/tripal_chado.field_storage.inc

@@ -287,9 +287,10 @@ function tripal_chado_field_storage_load($entity_type, $entities, $age,
         // Allow the creating module to alter the value if desired.  The
         // module should do this if the field has any other form elements
         // that need populationg besides the value which was set above.
-        module_load_include('inc', $field_module, 'includes/fields/' . $field_type);
+        tripal_load_include_field_type($field_type);
         if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-          $field_type::load($field, $entity, array('record' => $record));
+          $tfield = new $field_type($field);
+          $tfield->load($entity, array('record' => $record));
         }
       }
 
@@ -300,10 +301,10 @@ function tripal_chado_field_storage_load($entity_type, $entities, $age,
 
         // Set an empty value by default, and let the hook function update it.
         $entity->{$field_name}['und'][0]['value'] = '';
-        $load_function = $field_type . '_load';
-        module_load_include('inc', $field_module, 'includes/fields/' . $field_type);
+        tripal_load_include_field_type($field_type);
         if (class_exists($field_type) && method_exists($field_type, 'load')) {
-          $field_type::load($field, $entity, array('record' => $record));
+          $tfield = new $field_type($field);
+          $tfield->load($entity, array('record' => $record));
         }
       }
 

+ 22 - 29
tripal_chado/includes/tripal_chado.fields.inc

@@ -165,7 +165,7 @@ function tripal_chado_create_tripalfields_base(&$info, $details, $entity_type, $
       $base_info['settings']['text_processing'] = 0;
     }
 
-    $info[] = $base_info;
+    $info[$field_name] = $base_info;
   }
 }
 
@@ -199,14 +199,13 @@ function tripal_chado_create_tripalfields_custom(&$info, $details, $entity_type,
         'semantic_web' => tripal_get_chado_semweb_term($table_name, 'dbxref_id'),
       ),
     );
-    $field = new $field_type(array('info' => $info));
   }
 
   // BASE ORGANISM_ID
   if ($table_name != 'organism' and array_key_exists('organism_id', $schema['fields'])) {
     $field_name = $table_name . '__organism_id';
     $field_type = 'chado_base__organism_id';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => 1,
@@ -220,14 +219,13 @@ function tripal_chado_create_tripalfields_custom(&$info, $details, $entity_type,
         'semantic_web' => tripal_get_chado_semweb_term($table_name, 'organism_id'),
       ),
     );
-    $field = new $field_type(array('info' => $info));
   }
 
   // FEATURE MD5CHECKSUM
   if ($table_name == 'feature') {
     $field_name = $table_name . '__md5checksum';
     $field_type = 'chado_feature__md5checksum';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => 1,
@@ -241,14 +239,13 @@ function tripal_chado_create_tripalfields_custom(&$info, $details, $entity_type,
         'semantic_web' => tripal_get_chado_semweb_term($table_name, 'md5checksum'),
       ),
     );
-    $field = new $field_type(array('info' => $info));
   }
 
   // FEATURE RESIDUES
   if ($table_name == 'feature') {
     $field_name = 'feature__residues';
     $field_type = 'chado_feature__residues';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => 1,
@@ -262,14 +259,13 @@ function tripal_chado_create_tripalfields_custom(&$info, $details, $entity_type,
         'semantic_web' => tripal_get_chado_semweb_term($table_name, 'residues'),
       ),
     );
-    $field = new $field_type(array('info' => $info));
   }
 
   // FEATURE SEQLEN
   if ($table_name == 'feature') {
     $field_name = 'feature__seqlen';
     $field_type = 'chado_feature__seqlen';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => 1,
@@ -283,7 +279,6 @@ function tripal_chado_create_tripalfields_custom(&$info, $details, $entity_type,
         'semantic_web' => tripal_get_chado_semweb_term($table_name, 'seqlen'),
       ),
     );
-    $field = new $field_type(array('info' => $info));
   }
 
   // GENE TRANSCRIPTS
@@ -291,7 +286,7 @@ function tripal_chado_create_tripalfields_custom(&$info, $details, $entity_type,
   if (chado_table_exists($rel_table) and $bundle->label == 'gene') {
     $field_name = 'gene_transcripts';
     $field_type = 'chado_gene__transcripts';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => FIELD_CARDINALITY_UNLIMITED,
@@ -306,14 +301,13 @@ function tripal_chado_create_tripalfields_custom(&$info, $details, $entity_type,
         'semantic_web' => 'SO:0000673',
       ),
     );
-    $field = new $field_type(array('info' => $info));
   }
 
   // ORGANISM TYPE_ID
   if ($table_name == 'organism' and array_key_exists('type_id', $schema['fields'])) {
     $field_name = 'organism__type_id';
     $field_type = 'chado_organism__type_id';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => 1,
@@ -327,7 +321,6 @@ function tripal_chado_create_tripalfields_custom(&$info, $details, $entity_type,
         'semantic_web' => tripal_get_chado_semweb_term('organism', 'type_id'),
       ),
     );
-    $field = new $field_type(array('info' => $info));
   }
 }
 
@@ -350,7 +343,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
     $pkey = $schema['primary key'][0];
     $field_name = $table_name . '_contact';
     $field_type = 'chado_linker__contact';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => FIELD_CARDINALITY_UNLIMITED,
@@ -372,7 +365,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
   if (chado_table_exists($cvterm_table)) {
     $field_name = $table_name . '_cvterm';
     $field_type = 'chado_linker__cvterm_adder';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => 1,
@@ -393,7 +386,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
     $pkey = $schema['primary key'][0];
     $field_name = $table_name . '_dbxref';
     $field_type = 'chado_linker__dbxref';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' =>  $field_name,
       'type' => $field_type,
       'cardinality' => FIELD_CARDINALITY_UNLIMITED,
@@ -416,7 +409,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
     $pkey = $schema['primary key'][0];
     $field_name = $table_name . '_expression';
     $field_type = 'chado_linker__expression';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => FIELD_CARDINALITY_UNLIMITED,
@@ -439,7 +432,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
     $pkey = $schema['primary key'][0];
     $field_name = 'featureloc';
     $field_type = 'chado_linker__featureloc';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => FIELD_CARDINALITY_UNLIMITED,
@@ -462,7 +455,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
     $pkey = $schema['primary key'][0];
     $field_name = $table_name . '_genotype';
     $field_type = 'chado_linker__genotype';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => FIELD_CARDINALITY_UNLIMITED,
@@ -486,7 +479,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
     $pkey = $schema['primary key'][0];
     $field_name = $table_name . '_phenotype';
     $field_type = 'chado_linker__phenotype';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => FIELD_CARDINALITY_UNLIMITED,
@@ -508,7 +501,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
   if (chado_table_exists($prop_table)) {
     $field_name = $table_name . 'prop';
     $field_type = 'chado_linker__prop_adder';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => 1,
@@ -528,7 +521,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
     $pkey = $schema['primary key'][0];
     $field_name = $table_name . '_pub';
     $field_type = 'chado_linker__pub';
-    $info[] =  array(
+    $info[$field_name] =  array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => FIELD_CARDINALITY_UNLIMITED,
@@ -553,7 +546,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
     $pkey = $schema['primary key'][0];
     $field_name = $table_name . '_relationship';
     $field_type = 'chado_linker__relationship';
-    $info[] =  array(
+    $info[$field_name] =  array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => FIELD_CARDINALITY_UNLIMITED,
@@ -577,7 +570,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
     $pkey = $schema['primary key'][0];
     $field_name = $table_name . '_synonym';
     $field_type = 'chado_linker__synonym';
-    $info[] =  array(
+    $info[$field_name] =  array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => FIELD_CARDINALITY_UNLIMITED,
@@ -621,7 +614,7 @@ function tripal_chado_create_tripalfield_instance($entity_type, $bundle) {
 
   tripal_chado_create_tripalfield_instance_base($info, $entity_type, $bundle, $details);
   tripal_chado_create_tripalfield_instance_custom($info, $entity_type, $bundle, $details);
-  tripal_chado_create_tripalfeidl_instance_linker($info, $entity_type, $bundle, $details);
+  tripal_chado_create_tripalfield_instance_linker($info, $entity_type, $bundle, $details);
 
   return $info;
 }
@@ -665,7 +658,7 @@ function tripal_chado_create_tripalfield_instance_base(&$info, $entity_type, $bu
     $base_info =  array(
       'field_name' => $field_name,
       'entity_type' => 'TripalEntity',
-      'bundle' => $bundle_name,
+      'bundle' => $bundle->name,
       'label' => ucwords(preg_replace('/_/', ' ', $column_name)),
       'description' => '',
       'required' => FALSE,
@@ -971,7 +964,7 @@ function tripal_chado_create_tripalfield_instance_custom(&$info, $entity_type, $
 
   // GENE TRANSCRIPTS
   $rel_table = $table_name . '_relationship';
-  if (chado_table_exists($rel_table) and $this->bundle->label == 'gene') {
+  if (chado_table_exists($rel_table) and $bundle->label == 'gene') {
     $field_name = 'gene_transcripts';
     $info[] = array(
       'field_name' => $field_name,
@@ -1081,7 +1074,7 @@ function tripal_chado_create_tripalfield_instance_linker(&$info, $entity_type, $
     $field_name = $table_name . '_cvterm';
     $info[] = array(
       'field_name' => $field_name,
-      'entity_type' => entity_type,
+      'entity_type' => $entity_type,
       'bundle' => $bundle->name,
       'label' => 'Add Annotation Types',
       'description' => 'Add additional annotations types to this record.',

+ 2 - 2
tripal_chado/tripal_chado.views.inc

@@ -145,9 +145,9 @@ return;
       }
 
       // Allow the fields to alter the default selections from above.
-      module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
+      tripal_load_include_field_type($field_type);
       if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-        $field_obj = new $field_type();
+        $field_obj = new $field_type($field);
         $field_obj->views_data_alter($data['tripal_entity'][$field_name], $field, $entity_info);
       }
     }