tripal_core_files.api.inc

The Tripal Files API

This file provides the API to help Tripal modules to storing files in a consistent directory strcuture.

tripal_files_api Files API

Provides an application programming interface (API) for managing files within the Tripal data directory structure.

File

tripal_core/api/tripal_core_files.api.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * The Tripal Files API
  5. *
  6. * This file provides the API to help Tripal modules to storing files
  7. * in a consistent directory strcuture.
  8. *
  9. * @defgroup tripal_files_api Files API
  10. * @ingroup tripal_core_api
  11. * @{
  12. * Provides an application programming interface (API) for managing files within
  13. * the Tripal data directory structure.
  14. *
  15. * @}
  16. *
  17. */
  18. /**
  19. * This function is typically used in the '.install' file for a Tripal module
  20. * Each module should call this function during installation to create
  21. * the module data directory which is sites/default/files/tripal/[module_name]
  22. * for default Drupal settings. This directory can then be used by the module
  23. * for storing files.
  24. *
  25. * @param $module_name
  26. * the name of the module being installed.
  27. *
  28. * @returns
  29. * nothing
  30. *
  31. * @ingroup tripal_files_api
  32. */
  33. function tripal_create_moddir($module_name) {
  34. // make the data directory for this module
  35. $data_dir = file_directory_path() . "/tripal/$module_name";
  36. if (!file_check_directory($data_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
  37. $message = "Cannot create directory $data_dir. This module may not ".
  38. "behave correctly without this directory. Please create ".
  39. "the directory manually or fix the problem and reinstall.";
  40. drupal_set_message(check_plain(t($message)), 'error');
  41. watchdog('tripal_core', $message, array(), WATCHDOG_ERROR);
  42. }
  43. }
  44. /**
  45. * Each Tripal module has a unique data directory which was creatd using the
  46. * tripal_create_moddir function during installation. This function
  47. * retrieves the directory path.
  48. *
  49. * @param $module_name
  50. * The name of the module
  51. *
  52. * @returns
  53. * The path within the Drupal installation where the data directory resides
  54. *
  55. * @ingroup tripal_files_api
  56. */
  57. function tripal_get_moddir($module_name) {
  58. $data_dir = file_directory_path() . "/tripal/$module_name";
  59. return $data_dir;
  60. }

Related topics