sep__protocol.inc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * @class
  4. * Purpose:
  5. *
  6. * Data:
  7. * Assumptions:
  8. */
  9. class sep__protocol extends ChadoField {
  10. // --------------------------------------------------------------------------
  11. // EDITABLE STATIC CONSTANTS
  12. //
  13. // The following constants SHOULD be set for each descendant class. They are
  14. // used by the static functions to provide information to Drupal about
  15. // the field and it's default widget and formatter.
  16. // --------------------------------------------------------------------------
  17. // The default label for this field.
  18. public static $default_label = 'Protocol';
  19. // The default description for this field.
  20. public static $default_description = 'The protocol followed to generate this resource.';
  21. // The default widget for this field.
  22. public static $default_widget = 'sep__protocol_widget';
  23. // The default formatter for this field.
  24. public static $default_formatter = 'sep__protocol_formatter';
  25. // The module that manages this field.
  26. public static $module = 'tripal_chado';
  27. // A list of global settings. These can be accessed within the
  28. // globalSettingsForm. When the globalSettingsForm is submitted then
  29. // Drupal will automatically change these settings for all fields.
  30. // Once instances exist for a field type then these settings cannot be
  31. // changed.
  32. public static $default_settings = array(
  33. 'storage' => 'field_chado_storage',
  34. // It is expected that all fields set a 'value' in the load() function.
  35. // In many cases, the value may be an associative array of key/value pairs.
  36. // In order for Tripal to provide context for all data, the keys should
  37. // be a controlled vocabulary term (e.g. rdfs:type). Keys in the load()
  38. // function that are supported by the query() function should be
  39. // listed here.
  40. 'searchable_keys' => array(),
  41. );
  42. // Provide a list of instance specific settings. These can be access within
  43. // the instanceSettingsForm. When the instanceSettingsForm is submitted
  44. // then Drupal with automatically change these settings for the instance.
  45. // It is recommended to put settings at the instance level whenever possible.
  46. // If you override this variable in a child class be sure to replicate the
  47. // term_name, term_vocab, term_accession and term_fixed keys as these are
  48. // required for all TripalFields.
  49. public static $default_instance_settings = array(
  50. // The DATABASE name, as it appears in chado.db. This also builds the link-out url. In most cases this will simply be the CV name. In some cases (EDAM) this will be the SUBONTOLOGY.
  51. 'term_vocabulary' => 'sep',
  52. // The name of the term.
  53. 'term_name' => 'protocol',
  54. // The unique ID (i.e. accession) of the term.
  55. 'term_accession' => '00101',
  56. // Set to TRUE if the site admin is not allowed to change the term
  57. // type, otherwise the admin can change the term mapped to a field.
  58. 'term_fixed' => FALSE,
  59. // Indicates if this field should be automatically attached to display
  60. // or web services or if this field should be loaded separately. This
  61. // is convenient for speed. Fields that are slow should for loading
  62. // should have auto_attach set to FALSE so tha their values can be
  63. // attached asynchronously.
  64. 'auto_attach' => FALSE,
  65. );
  66. // A boolean specifying that users should not be allowed to create
  67. // fields and instances of this field type through the UI. Such
  68. // fields can only be created programmatically with field_create_field()
  69. // and field_create_instance().
  70. public static $no_ui = FALSE;
  71. // A boolean specifying that the field will not contain any data. This
  72. // should exclude the field from web services or downloads. An example
  73. // could be a quick search field that appears on the page that redirects
  74. // the user but otherwise provides no data.
  75. public static $no_data = FALSE;
  76. /**
  77. * Loads the field values from the underlying data store.
  78. *
  79. * @param $entity
  80. *
  81. * @return
  82. * An array of the following format:
  83. * $entity->{$field_name}['und'][0]['value'] = $value;
  84. * where:
  85. * - $entity is the entity object to which this field is attached.
  86. * - $field_name is the name of this field
  87. * - 'und' is the language code (in this case 'und' == undefined)
  88. * - 0 is the cardinality. Increment by 1 when more than one item is
  89. * available.
  90. * - 'value' is the key indicating the value of this field. It should
  91. * always be set. The value of the 'value' key will be the contents
  92. * used for web services and for downloadable content. The value
  93. * should be of the follow format types: 1) A single value (text,
  94. * numeric, etc.) 2) An array of key value pair. 3) If multiple entries
  95. * then cardinality should incremented and format types 1 and 2 should
  96. * be used for each item.
  97. * The array may contain as many other keys at the same level as 'value'
  98. * but those keys are for internal field use and are not considered the
  99. * value of the field.
  100. *
  101. *
  102. */
  103. public function load($entity) {
  104. // ChadoFields automatically load the chado column specified in the
  105. // default settings above. If that is all you need then you don't even
  106. // need to implement this function. However, if you need to add any
  107. // additional data to be used in the display, you should add it here.
  108. parent::load($entity);
  109. }
  110. }