filefield_paths.api.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the File (Field) Paths module.
  5. */
  6. /**
  7. * Define field(s) to be displayed on the File (Field) Paths settings form and
  8. * used during the processing of uploaded files.
  9. *
  10. * @param $field
  11. * The field definition this File (Field) Paths settings field applies to.
  12. * @param $instance
  13. * The field instance this File (Field) Paths settings field applies to.
  14. *
  15. * @return array
  16. * An array whose keys are field names and whose values are arrays defining
  17. * the field, with the following key/value pairs:
  18. * - title: The title fo the field.
  19. * - form: A keyed array of Form API elements.
  20. *
  21. * @see hook_filefield_paths_process_file().
  22. */
  23. function hook_filefield_paths_field_settings($field, $instance) {
  24. return array(
  25. 'file_path' => array(
  26. 'title' => 'File path',
  27. 'form' => array(
  28. 'value' => array(
  29. '#type' => 'textfield',
  30. '#title' => t('File path'),
  31. '#maxlength' => 512,
  32. '#size' => 128,
  33. '#element_validate' => array('_file_generic_settings_file_directory_validate'),
  34. '#default_value' => $instance['settings']['file_directory'],
  35. ),
  36. ),
  37. ),
  38. );
  39. }
  40. /**
  41. * Declare a compatible field type for use with File (Field) Paths.
  42. *
  43. * @return array
  44. */
  45. function hook_filefield_paths_field_type_info() {
  46. return array('file');
  47. }
  48. /**
  49. * Process the uploaded files.
  50. *
  51. * @param $type
  52. * The entity type containing the files for processing.
  53. * @param $entity
  54. * The entity containing the files for processing.
  55. * @param $field
  56. * The definition of the field containing the files for processing.
  57. * @param $instance
  58. * The instance of the field containing the files for processing.
  59. * @param $langcode
  60. * The language code of the field containing the files for processing.
  61. * @param $items
  62. * A pass-by-reference array of all the files for processing.
  63. *
  64. * @see filefield_paths_filefield_paths_process_file().
  65. */
  66. function hook_filefield_paths_process_file($type, $entity, $field, $instance, $langcode, &$items) {
  67. }