Browse Source

renamed fieldInfo function of the TripalField class to fieldDefaults(). Fixed instanceSettingsForm on the relationship field

Stephen Ficklin 10 years ago
parent
commit
4a10270bfc
24 changed files with 54 additions and 51 deletions
  1. 5 4
      tripal/includes/TripalField.inc
  2. 2 2
      tripal/includes/fields/content_type.inc
  3. 1 1
      tripal/includes/tripal.fields.inc
  4. 2 2
      tripal_chado/includes/fields/chado_base__dbxref_id.inc
  5. 1 1
      tripal_chado/includes/fields/chado_base__organism_id.inc
  6. 2 2
      tripal_chado/includes/fields/chado_feature__md5checksum.inc
  7. 2 2
      tripal_chado/includes/fields/chado_feature__residues.inc
  8. 2 2
      tripal_chado/includes/fields/chado_feature__seqlen.inc
  9. 2 2
      tripal_chado/includes/fields/chado_gene__transcripts.inc
  10. 2 2
      tripal_chado/includes/fields/chado_linker__contact.inc
  11. 2 2
      tripal_chado/includes/fields/chado_linker__cvterm.inc
  12. 2 2
      tripal_chado/includes/fields/chado_linker__cvterm_adder.inc
  13. 1 1
      tripal_chado/includes/fields/chado_linker__dbxref.inc
  14. 2 2
      tripal_chado/includes/fields/chado_linker__expression.inc
  15. 2 2
      tripal_chado/includes/fields/chado_linker__featureloc.inc
  16. 2 2
      tripal_chado/includes/fields/chado_linker__genotype.inc
  17. 2 2
      tripal_chado/includes/fields/chado_linker__phenotype.inc
  18. 2 2
      tripal_chado/includes/fields/chado_linker__prop.inc
  19. 2 2
      tripal_chado/includes/fields/chado_linker__prop_adder.inc
  20. 2 2
      tripal_chado/includes/fields/chado_linker__pub.inc
  21. 7 5
      tripal_chado/includes/fields/chado_linker__relationship.inc
  22. 2 2
      tripal_chado/includes/fields/chado_linker__synonym.inc
  23. 2 2
      tripal_chado/includes/fields/chado_organism__type_id.inc
  24. 3 3
      tripal_chado/includes/tripal_chado.fields.inc

+ 5 - 4
tripal/includes/TripalField.inc

@@ -147,7 +147,8 @@ class TripalField {
    * Provides default settings for the field.
    * Provides default settings for the field.
    *
    *
    * This is a static function and defines defaults for all fields of this
    * This is a static function and defines defaults for all fields of this
-   * type.
+   * type.  This function corresponds to the hook_field_info() of the Drupal
+   * Field API.
    *
    *
    * @return
    * @return
    *   An array whose keys are field type names and whose values are arrays
    *   An array whose keys are field type names and whose values are arrays
@@ -185,7 +186,7 @@ class TripalField {
    *     field_create_field() and field_create_instance(). Defaults to
    *     field_create_field() and field_create_instance(). Defaults to
    *     FALSE.
    *     FALSE.
    */
    */
-  public static function fieldInfo() {
+  public static function fieldDefaults() {
     return array(
     return array(
     );
     );
   }
   }
@@ -196,7 +197,7 @@ class TripalField {
    *
    *
    * These settings are global for every instance of the field.
    * These settings are global for every instance of the field.
    *
    *
-   * he TripalField class allows a field to decide which bundles it would
+   * The TripalField class allows a field to decide which bundles it would
    * like to attach itself to. Therefore, the entity type, and bundle are
    * like to attach itself to. Therefore, the entity type, and bundle are
    * passed as arguments to allow the field to decide if it wants to be
    * passed as arguments to allow the field to decide if it wants to be
    * attached.
    * attached.
@@ -622,7 +623,7 @@ class TripalField {
     $module = $field['module'];
     $module = $field['module'];
     $element['#field'] = $field;
     $element['#field'] = $field;
     $element['#instance'] = $instance;
     $element['#instance'] = $instance;
-    $element['#element_validate'][] = $module . '_instance_settings_form_validate';
+    $element['#element_validate'][] = $module . '_field_instance_settings_form_validate';
 
 
     return $element;
     return $element;
   }
   }

+ 2 - 2
tripal/includes/fields/content_type.inc

@@ -19,9 +19,9 @@ class content_type extends TripalField {
     }
     }
   }
   }
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Record Type'),
       'label' => t('Record Type'),
       'description' => t('The content type.'),
       'description' => t('The content type.'),

+ 1 - 1
tripal/includes/tripal.fields.inc

@@ -9,7 +9,7 @@ function tripal_field_info() {
 
 
   $field_types = tripal_get_field_types('tripal');
   $field_types = tripal_get_field_types('tripal');
   foreach ($field_types as $field_type) {
   foreach ($field_types as $field_type) {
-    $info[$field_type] = $field_type::fieldInfo();
+    $info[$field_type] = $field_type::fieldDefaults();
   }
   }
   return $info;
   return $info;
 }
 }

+ 2 - 2
tripal_chado/includes/fields/chado_base__dbxref_id.inc

@@ -2,9 +2,9 @@
 
 
 class chado_base__dbxref_id extends TripalField {
 class chado_base__dbxref_id extends TripalField {
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Accession'),
       'label' => t('Accession'),
       'description' => t('This field specifies the unique stable accession (ID) for
       'description' => t('This field specifies the unique stable accession (ID) for

+ 1 - 1
tripal_chado/includes/fields/chado_base__organism_id.inc

@@ -5,7 +5,7 @@ class chado_base__organism_id extends TripalField {
   /**
   /**
    * @see TripalField::info()
    * @see TripalField::info()
    */
    */
-  public static function fieldInfo() {
+  public static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Organism'),
       'label' => t('Organism'),
       'description' => t('A field for specifying an organism.'),
       'description' => t('A field for specifying an organism.'),

+ 2 - 2
tripal_chado/includes/fields/chado_feature__md5checksum.inc

@@ -3,9 +3,9 @@
 class chado_feature__md5checksum  extends TripalField {
 class chado_feature__md5checksum  extends TripalField {
 
 
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Sequence MD5 checksum'),
       'label' => t('Sequence MD5 checksum'),
       'description' => t('A field for generating MD5 checksum for a sequence.'),
       'description' => t('A field for generating MD5 checksum for a sequence.'),

+ 2 - 2
tripal_chado/includes/fields/chado_feature__residues.inc

@@ -3,9 +3,9 @@
 class chado_feature__residues extends TripalField {
 class chado_feature__residues extends TripalField {
 
 
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Sequences'),
       'label' => t('Sequences'),
       'description' => t('A field for managing nucleotide and protein residues.'),
       'description' => t('A field for managing nucleotide and protein residues.'),

+ 2 - 2
tripal_chado/includes/fields/chado_feature__seqlen.inc

@@ -2,9 +2,9 @@
 
 
 class chado_feature__seqlen extends TripalField {
 class chado_feature__seqlen extends TripalField {
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Sequence length'),
       'label' => t('Sequence length'),
       'description' => t('A field for calculating the length of a sequence.'),
       'description' => t('A field for calculating the length of a sequence.'),

+ 2 - 2
tripal_chado/includes/fields/chado_gene__transcripts.inc

@@ -3,9 +3,9 @@
 class chado_gene__transcripts extends TripalField {
 class chado_gene__transcripts extends TripalField {
 
 
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  public static function fieldInfo() {
+  public static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Transcripts'),
       'label' => t('Transcripts'),
       'description' => t('Transcripts of genes.'),
       'description' => t('Transcripts of genes.'),

+ 2 - 2
tripal_chado/includes/fields/chado_linker__contact.inc

@@ -3,9 +3,9 @@
 class chado_linker__contact extends TripalField {
 class chado_linker__contact extends TripalField {
 
 
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  public static function fieldInfo() {
+  public static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Contacts'),
       'label' => t('Contacts'),
       'description' => t('Associates an indviddual or organization with
       'description' => t('Associates an indviddual or organization with

+ 2 - 2
tripal_chado/includes/fields/chado_linker__cvterm.inc

@@ -2,9 +2,9 @@
 
 
 class chado_linker__cvterm extends TripalField {
 class chado_linker__cvterm extends TripalField {
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Annotations'),
       'label' => t('Annotations'),
       'description' => t('This record can be annotated with terms
       'description' => t('This record can be annotated with terms

+ 2 - 2
tripal_chado/includes/fields/chado_linker__cvterm_adder.inc

@@ -1,9 +1,9 @@
 <?php
 <?php
 class chado_linker__cvterm_addr extends TripalField {
 class chado_linker__cvterm_addr extends TripalField {
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Add an Annotation Type'),
       'label' => t('Add an Annotation Type'),
       'description' => t('This record may have any number of types of
       'description' => t('This record may have any number of types of

+ 1 - 1
tripal_chado/includes/fields/chado_linker__dbxref.inc

@@ -16,7 +16,7 @@ class chado_linker__dbxref extends TripalField {
    * This is a hook provided by the tripal_chado module for offloading the
    * This is a hook provided by the tripal_chado module for offloading the
    * hook_fieldInfo() hook for each field to specify.
    * hook_fieldInfo() hook for each field to specify.
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Cross references'),
       'label' => t('Cross references'),
       'description' => t('This record can be cross referenced with a record in
       'description' => t('This record can be cross referenced with a record in

+ 2 - 2
tripal_chado/includes/fields/chado_linker__expression.inc

@@ -3,9 +3,9 @@
 class chado_linker__expression extends TripalField {
 class chado_linker__expression extends TripalField {
 
 
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  public static function fieldInfo() {
+  public static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Expression'),
       'label' => t('Expression'),
       'description' => t('Associates an expression with
       'description' => t('Associates an expression with

+ 2 - 2
tripal_chado/includes/fields/chado_linker__featureloc.inc

@@ -3,9 +3,9 @@
 class chado_linker__featureloc extends TripalField {
 class chado_linker__featureloc extends TripalField {
 
 
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  public static function fieldInfo() {
+  public static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Aligned Locations'),
       'label' => t('Aligned Locations'),
       'description' => t('Locations on landmark sequences where the feature is aligned.'),
       'description' => t('Locations on landmark sequences where the feature is aligned.'),

+ 2 - 2
tripal_chado/includes/fields/chado_linker__genotype.inc

@@ -3,9 +3,9 @@
 class chado_linker__genotype extends TripalField {
 class chado_linker__genotype extends TripalField {
 
 
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  public static function fieldInfo() {
+  public static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Genotypes'),
       'label' => t('Genotypes'),
       'description' => t('Associates an indviddual or organization with
       'description' => t('Associates an indviddual or organization with

+ 2 - 2
tripal_chado/includes/fields/chado_linker__phenotype.inc

@@ -3,9 +3,9 @@
 class chado_linker__phenotype extends TripalField {
 class chado_linker__phenotype extends TripalField {
 
 
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  public static function fieldInfo() {
+  public static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Phenotypes'),
       'label' => t('Phenotypes'),
       'description' => t('Associates an indviddual or organization with
       'description' => t('Associates an indviddual or organization with

+ 2 - 2
tripal_chado/includes/fields/chado_linker__prop.inc

@@ -2,9 +2,9 @@
 
 
 class chado_linker__prop extends TripalField {
 class chado_linker__prop extends TripalField {
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Add a Property'),
       'label' => t('Add a Property'),
       'description' => t('Add details about this property.'),
       'description' => t('Add details about this property.'),

+ 2 - 2
tripal_chado/includes/fields/chado_linker__prop_adder.inc

@@ -2,9 +2,9 @@
 
 
 class chado_linker__prop_adder extends TripalField {
 class chado_linker__prop_adder extends TripalField {
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Add a Property Type'),
       'label' => t('Add a Property Type'),
       'description' => t('This record may have any number of properties. Use
       'description' => t('This record may have any number of properties. Use

+ 2 - 2
tripal_chado/includes/fields/chado_linker__pub.inc

@@ -2,9 +2,9 @@
 
 
 class chado_linker_pub extends TripalField {
 class chado_linker_pub extends TripalField {
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Publications'),
       'label' => t('Publications'),
       'description' => t('Associates a publication (e.g. journal article,
       'description' => t('Associates a publication (e.g. journal article,

+ 7 - 5
tripal_chado/includes/fields/chado_linker__relationship.inc

@@ -2,9 +2,9 @@
 
 
 class chado_linker__relationship extends TripalField {
 class chado_linker__relationship extends TripalField {
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Relationships'),
       'label' => t('Relationships'),
       'description' => t('Relationships between records.'),
       'description' => t('Relationships between records.'),
@@ -860,8 +860,9 @@ class chado_linker__relationship extends TripalField {
    * @param unknown $instance
    * @param unknown $instance
    * @param unknown $has_data
    * @param unknown $has_data
    */
    */
-  public static function fieldSettingsForm($field, $instance, $has_data) {
-    $element = parent::fieldSettingsForm($field, $instance, $has_data);
+  public static function instanceSettingsForm($field, $instance) {
+
+    $element = parent::instanceSettingsForm($field, $instance);
     $element['instructions'] = array(
     $element['instructions'] = array(
       '#type' => 'item',
       '#type' => 'item',
       '#markup' => 'You may provide a list of terms that will be available in a select box
       '#markup' => 'You may provide a list of terms that will be available in a select box
@@ -873,6 +874,7 @@ class chado_linker__relationship extends TripalField {
       '#type' => 'textarea',
       '#type' => 'textarea',
       '#title' => 'Relationship Types',
       '#title' => 'Relationship Types',
       '#description' => 'Provide terms separated by a new line',
       '#description' => 'Provide terms separated by a new line',
+      '#default_value' => $instance['settings']['relationship_types'],
     );
     );
 
 
     return $element;
     return $element;
@@ -884,7 +886,7 @@ class chado_linker__relationship extends TripalField {
    * @param unknown $instance
    * @param unknown $instance
    * @param unknown $has_data
    * @param unknown $has_data
    */
    */
-  public static function fieldSettingsFormValidate($form, &$form_state) {
+  public static function instanceSettingsFormValidate($form, &$form_state) {
     //dpm($form);dpm($form_state);
     //dpm($form);dpm($form_state);
   }
   }
 }
 }

+ 2 - 2
tripal_chado/includes/fields/chado_linker__synonym.inc

@@ -3,9 +3,9 @@
 class chado_linker__synonym extends TripalField {
 class chado_linker__synonym extends TripalField {
 
 
   /**
   /**
-   * @see TripalField::fieldInfo()
+   * @see TripalField::fieldDefaults()
    */
    */
-  static function fieldInfo() {
+  static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Synonyms'),
       'label' => t('Synonyms'),
       'description' => t('Adds an alternative name (synonym or alias) to this record.'),
       'description' => t('Adds an alternative name (synonym or alias) to this record.'),

+ 2 - 2
tripal_chado/includes/fields/chado_organism__type_id.inc

@@ -3,9 +3,9 @@
 class chado_organism__type_id extends TripalField {
 class chado_organism__type_id extends TripalField {
 
 
   /**
   /**
-   * @see TripalField::info()
+   * @see TripalField::fieldDefaults()
    */
    */
-  public static function fieldInfo() {
+  public static function fieldDefaults() {
     return array(
     return array(
       'label' => t('Infraspecific Type'),
       'label' => t('Infraspecific Type'),
       'description' => t('A field for specifying an infraspecific type.'),
       'description' => t('A field for specifying an infraspecific type.'),

+ 3 - 3
tripal_chado/includes/tripal_chado.fields.inc

@@ -19,7 +19,7 @@ function tripal_chado_field_info() {
 
 
   $field_types = tripal_get_field_types('tripal_chado');
   $field_types = tripal_get_field_types('tripal_chado');
   foreach ($field_types as $field_type) {
   foreach ($field_types as $field_type) {
-    $info[$field_type] = $field_type::fieldInfo();
+    $info[$field_type] = $field_type::fieldDefaults();
   }
   }
   return $info;
   return $info;
 
 
@@ -533,7 +533,7 @@ function tripal_chado_field_settings_form($field, $instance, $has_data) {
 /**
 /**
  * Implements hook_instance_settings_form()
  * Implements hook_instance_settings_form()
  */
  */
-function tripal_chado_instance_settings_form($field, $instance) {
+function tripal_chado_field_instance_settings_form($field, $instance) {
   $form = array();
   $form = array();
   $field_type = $field['type'];
   $field_type = $field['type'];
   module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
   module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
@@ -566,7 +566,7 @@ function tripal_chado_field_settings_form_validate($form, &$form_state) {
  * to alow the TripalField objects to have a instanceSettingsFormValidate()
  * to alow the TripalField objects to have a instanceSettingsFormValidate()
  * member function.
  * member function.
  */
  */
-function tripal_chado_instance_settings_form_validate($form, &$form_state) {
+function tripal_chado_field_instance_settings_form_validate($form, &$form_state) {
   $field = $form['#field'];
   $field = $form['#field'];
   $instance = $form['#instance'];
   $instance = $form['#instance'];
   $field_type = $field['type'];
   $field_type = $field['type'];