WebServicesField.inc

File

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