data__sequence.inc 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. class data__sequence extends ChadoField {
  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 default label for this field.
  11. public static $default_label = 'Sequence';
  12. // The default description for this field.
  13. public static $description = 'A field for managing the primary sequence for a feature.';
  14. // Provide a list of instance specific settings. These can be accessed within
  15. // the instanceSettingsForm. When the instanceSettingsForm is submitted
  16. // then Drupal will automatically change these settings for the instance.
  17. // It is recommended to put settings at the instance level whenever possible.
  18. // If you override this variable in a child class be sure to replicate the
  19. // term_name, term_vocab, term_accession and term_fixed keys as these are
  20. // required for all TripalFields.
  21. public static $default_instance_settings = [
  22. // The short name for the vocabulary (e.g. schema, SO, GO, PATO, etc.).
  23. 'term_vocabulary' => 'data',
  24. // The name of the term.
  25. 'term_name' => 'sequence',
  26. // The unique ID (i.e. accession) of the term.
  27. 'term_accession' => '2044',
  28. // Set to TRUE if the site admin is allowed to change the term
  29. // type. This will create form elements when editing the field instance
  30. // to allow the site admin to change the term settings above.
  31. 'term_fixed' => FALSE,
  32. ];
  33. // Indicates the download formats for this field. The list must be the
  34. // name of a child class of the TripalFieldDownloader.
  35. public static $download_formatters = [
  36. 'TripalTabDownloader',
  37. 'TripalCSVDownloader',
  38. 'TripalNucFASTADownloader',
  39. ];
  40. // The default widget for this field.
  41. public static $default_widget = 'data__sequence_widget';
  42. // The default formatter for this field.
  43. public static $default_formatter = 'data__sequence_formatter';
  44. /**
  45. * @see TripalField::elementInfo()
  46. */
  47. public function elementInfo() {
  48. $field_term = $this->getFieldTermID();
  49. return [
  50. $field_term => [
  51. 'operations' => [],
  52. 'sortable' => FALSE,
  53. 'searchable' => FALSE,
  54. 'type' => 'xs:string',
  55. 'readonly' => FALSE,
  56. ],
  57. ];
  58. }
  59. /**
  60. * @see TripalField::load()
  61. */
  62. public function load($entity) {
  63. $field_name = $this->field['field_name'];
  64. $feature = $entity->chado_record;
  65. $feature = chado_expand_var($feature, 'field', 'feature.residues');
  66. $entity->{$field_name}['und'][0]['value'] = $feature->residues;
  67. }
  68. }