file_entity.api.php 3.8 KB

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