file_entity.api.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the File Entity module.
  5. */
  6. /**
  7. * Define file types.
  8. *
  9. * @return
  10. * An array whose keys are file type names and whose values are arrays
  11. * describing the file type, with the following key/value pairs:
  12. * - label: The human-readable name of the file type.
  13. * - claim callback: The name of the function that returns if a given file is
  14. * of this type. See hook_file_type_TYPE_claim() for details.
  15. * - default view callback: (optional) The name of the function that returns a
  16. * drupal_render() array for displaying the file. Used when there are no
  17. * administrator configured file formatters, or none of the configured ones
  18. * return a display. See hook_file_type_TYPE_default_view() for details.
  19. * - description: (optional) A short description of the file type.
  20. * - weight: (optional) A number defining the order in which the 'claim
  21. * callback' function for this type is called relative to the claim
  22. * callbacks of other defined types, when the type of a file needs to be
  23. * determined. The type with the lowest weighted claim callback to return
  24. * TRUE is assigned to the file. Also, on administrative pages listing file
  25. * types, the types are ordered by weight.
  26. * - admin: (optional) An array of information, to be added to the
  27. * ['bundles'][TYPE]['admin'] entry for the 'file' entity type, thereby
  28. * controlling the path at which Field UI pages are attached for this file
  29. * type, and which users may access them. Defaults to attaching the Field UI
  30. * pages to the admin/config/media/file-types/manage/TYPE path and requiring
  31. * 'administer site configuration' permission. See hook_entity_info() for
  32. * details about this array. This value can also be set to NULL to suppress
  33. * Field UI pages from attaching at all for this file type.
  34. *
  35. * @see hook_file_type_info_alter()
  36. */
  37. function hook_file_type_info() {
  38. return array(
  39. 'image' => array(
  40. 'label' => t('Image'),
  41. ),
  42. );
  43. }
  44. /**
  45. * Perform alterations on file types.
  46. *
  47. * @param $info
  48. * Array of information on file types exposed by hook_file_type_info()
  49. * implementations.
  50. */
  51. function hook_file_type_info_alter(&$info) {
  52. // @todo Add example.
  53. }
  54. /**
  55. * @todo Add documentation.
  56. *
  57. * Note: This is not really a hook. The function name is manually specified via
  58. * 'claim callback' in hook_file_type_info(), with this recommended
  59. * callback name pattern.
  60. */
  61. function hook_file_type_TYPE_claim($file, $type) {
  62. }
  63. /**
  64. * @todo Add documentation.
  65. *
  66. * Note: This is not really a hook. The function name is manually specified via
  67. * 'default view callback' in hook_file_type_info(), with this recommended
  68. * callback name pattern.
  69. */
  70. function hook_file_type_TYPE_default_view($file, $view_mode, $langcode) {
  71. }
  72. /**
  73. * Define file formatters.
  74. *
  75. * @return
  76. * An array whose keys are file formatter names and whose values are arrays
  77. * describing the formatter.
  78. *
  79. * @todo Document key/value pairs that comprise a formatter.
  80. *
  81. * @see hook_file_formatter_info_alter()
  82. */
  83. function hook_file_formatter_info() {
  84. // @todo Add example.
  85. }
  86. /**
  87. * Perform alterations on file formatters.
  88. *
  89. * @param $info
  90. * Array of information on file formatters exposed by
  91. * hook_file_formatter_info() implementations.
  92. */
  93. function hook_file_formatter_info_alter(&$info) {
  94. // @todo Add example.
  95. }
  96. /**
  97. * @todo Add documentation.
  98. *
  99. * Note: This is not really a hook. The function name is manually specified via
  100. * 'view callback' in hook_file_formatter_info(), with this recommended callback
  101. * name pattern.
  102. */
  103. function hook_file_formatter_FORMATTER_view($file, $display, $langcode) {
  104. }
  105. /**
  106. * @todo Add documentation.
  107. *
  108. * Note: This is not really a hook. The function name is manually specified via
  109. * 'settings callback' in hook_file_formatter_info(), with this recommended
  110. * callback name pattern.
  111. */
  112. function hook_file_formatter_FORMATTER_settings($form, &$form_state, $settings) {
  113. }
  114. /**
  115. * @todo Add documentation.
  116. */
  117. function hook_file_displays_alter($displays, $file, $view_mode) {
  118. }
  119. /**
  120. * @todo Add documentation.
  121. */
  122. function hook_file_view($file, $view_mode, $langcode) {
  123. }
  124. /**
  125. * @todo Add documentation.
  126. */
  127. function hook_file_view_alter($build, $type) {
  128. }