tripal_ws.module 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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/ws'] = array(
  35. 'title' => 'Web Services',
  36. 'description' => t("Exchange data between 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/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. return $items;
  57. }
  58. function tripal_ws_test() {
  59. print "Blah!!!!\n";
  60. }