tripal_ws.module 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Implements hook_init()
  4. */
  5. function tripal_ws_init() {
  6. global $base_url;
  7. $version = 'v0.1';
  8. $api_url = $base_url . '/ws/' . $version;
  9. // Following the WC3 Hydra documentation, we want to add LINK to the header
  10. // of the site that indicates where the API documentation can be found.
  11. // This allows a hydra-enabled client to discover the API and use it.
  12. $attributes = array(
  13. 'rel' => 'http://www.w3.org/ns/hydra/core#apiDocumentation',
  14. 'href' => $api_url . '/ws-doc/',
  15. );
  16. drupal_add_html_head_link($attributes, $header = FALSE);
  17. }
  18. /**
  19. * Implements hook_menu().
  20. * Defines all menu items needed by Tripal Core
  21. *
  22. * @ingroup tripal_ws
  23. */
  24. function tripal_ws_menu() {
  25. // Web Services API callbacks.
  26. $items['ws/v0.1'] = array(
  27. 'title' => 'Tripal Entities Web Services API v0.1',
  28. 'page callback' => 'tripal_ws_rest',
  29. 'access arguments' => array('access content'),
  30. 'file' => '/includes/tripal_ws.rest.inc',
  31. 'type' => MENU_CALLBACK,
  32. );
  33. // Tripal Web Services setting groups
  34. $items['admin/tripal/storage/ws'] = array(
  35. 'title' => 'Web Services',
  36. 'description' => t("Import data from other Tripal sites using the web services."),
  37. 'weight' => 20,
  38. 'page callback' => 'system_admin_menu_block_page',
  39. 'access arguments' => array('administer tripal'),
  40. 'file' => 'system.admin.inc',
  41. 'file path' => drupal_get_path('module', 'system'),
  42. );
  43. $items['admin/tripal/storage/ws/tripal_sites'] = array(
  44. 'title' => 'Other Tripal Sites',
  45. 'description' => t('Provides information about other Tripal sites.
  46. This allows data exchange and communication betwen Tripal
  47. enabled sites through the web services.'),
  48. 'page callback' => 'drupal_get_form',
  49. 'page arguments' => array('tripal_ws_tripal_sites_form'),
  50. 'access arguments' => array('administer tripal'),
  51. 'type' => MENU_NORMAL_ITEM,
  52. 'weight' => 0,
  53. 'file' => 'includes/tripal_ws.admin.inc',
  54. 'file path' => drupal_get_path('module', 'tripal_ws'),
  55. );
  56. $items['admin/tripal/storage/ws/tripal_sites/edit'] = array(
  57. 'title' => 'Add Tripal Site',
  58. 'description' => 'Add a Tripal site',
  59. 'page callback' => 'drupal_get_form',
  60. 'page arguments' => array('tripal_ws_tripal_sites_edit_form'),
  61. 'access arguments' => array('administer tripal'),
  62. 'file' => 'includes/tripal_ws.admin.inc',
  63. 'file path' => drupal_get_path('module', 'tripal_ws'),
  64. 'type' => MENU_LOCAL_ACTION,
  65. 'weight' => 2
  66. );
  67. $items['admin/tripal/storage/ws/tripal_sites/remove/%'] = array(
  68. 'title' => 'Remove Tripal Site',
  69. 'description' => 'Remove a Tripal site',
  70. 'page callback' => 'drupal_get_form',
  71. 'page arguments' => array('tripal_ws_tripal_sites_remove_form', 6),
  72. 'access arguments' => array('administer tripal'),
  73. 'file' => 'includes/tripal_ws.admin.inc',
  74. 'file path' => drupal_get_path('module', 'tripal_ws'),
  75. 'type' => MENU_CALLBACK,
  76. 'weight' => 2
  77. );
  78. return $items;
  79. }
  80. function tripal_ws_test() {
  81. print "Blah!!!!\n";
  82. }