taxrank__infraspecific_taxon.inc 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. class taxrank__infraspecific_taxon extends TripalField {
  3. // --------------------------------------------------------------------------
  4. // EDITABLE STATIC CONSTANTS
  5. //
  6. // The following constants SHOULD be set for each descendent class. They are
  7. // used by the static functions to provide information to Drupal about
  8. // the field and it's default widget and formatter.
  9. // --------------------------------------------------------------------------
  10. // The term that this field maps to. The format for the term should be:
  11. // [vocab]:[accession] where [vocab] is the short name of the vocabulary
  12. // and [acession] is the unique accession number for the term. This term
  13. // must already exist in the vocabulary storage backend. This
  14. // value should never be changed once fields exist for this type.
  15. public static $term = 'TAXRANK:0000046';
  16. // The default lable for this field.
  17. public static $label = 'Infraspecific Taxon';
  18. // The default description for this field.
  19. public static $description = 'Specifies the infraspecific taxon of an organism.';
  20. // Provide a list of global settings. These can be accessed witihn the
  21. // globalSettingsForm. When the globalSettingsForm is submitted then
  22. // Drupal will automatically change these settings for all fields.
  23. public static $settings = array(
  24. 'chado_table' => '',
  25. 'chado_column' => '',
  26. 'base_table' => '',
  27. );
  28. // Provide a list of instance specific settings. These can be access within
  29. // the instanceSettingsForm. When the instanceSettingsForm is submitted
  30. // then Drupal with automatically change these settings for the instnace.
  31. // It is recommended to put settings at the instance level whenever possible.
  32. public static $instance_settings = array();
  33. // Set this to the name of the storage backend that by default will support
  34. // this field.
  35. public static $storage = 'tripal_no_storage';
  36. // The default widget for this field.
  37. public static $default_widget = 'HERE_widget';
  38. // The default formatter for this field.
  39. public static $default_formatter = 'HERE_formatter';
  40. // --------------------------------------------------------------------------
  41. // PROTECTED CLASS MEMBERS -- DO NOT OVERRIDE
  42. // --------------------------------------------------------------------------
  43. // An array containing details about the field. The format of this array
  44. // is the same as that returned by field_info_fields()
  45. protected $field;
  46. // An array containing details about an instance of the field. A field does
  47. // not have to have an instance. But if dealing with an instance (such as
  48. // when using the widgetForm, formatterSettingsForm, etc.) it should be set.
  49. protected $instance;
  50. /**
  51. *
  52. * @see TripalField::validate()
  53. */
  54. public function validate($entity_type, $entity, $field, $items, &$errors) {
  55. }
  56. /**
  57. *
  58. * @see TripalField::load()
  59. */
  60. public function load($entity, $details = array()) {
  61. $record = $details['record'];
  62. $settings = $this->field['settings'];
  63. $field_name = $this->field['field_name'];
  64. $field_type = $this->field['type'];
  65. $field_table = $this->field['settings']['chado_table'];
  66. $field_column = $this->field['settings']['chado_column'];
  67. // Set some defaults for the empty record.
  68. $entity->{$field_name}['und'][0] = array(
  69. 'value' => '',
  70. 'organism__type_id' => '',
  71. );
  72. if ($record->type_id) {
  73. $entity->{$field_name}['und'][0]['value'] = $record->type_id->name;
  74. $entity->{$field_name}['und'][0]['organism__type_id'] = $record->type_id->cvterm_id;
  75. }
  76. }
  77. }