tripal_db.module 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. require_once "api/tripal_db.api.inc";
  3. require_once "includes/tripal_db.admin.inc";
  4. /**
  5. * @defgroup tripal_db Database Reference Module
  6. * @ingroup tripal_modules
  7. * @{
  8. * Provides functions for managing chado database references which link chado content, such
  9. * as features and stocks, to records/pages in external databases/websites. For example,
  10. * you might have a feature record in your site which is also in the NCBI website and by
  11. * adding a database refrence to your feature, an automatic link to the content at NCBI
  12. * is created.
  13. * @}
  14. */
  15. /**
  16. *
  17. * @ingroup tripal_db
  18. */
  19. function tripal_db_init() {
  20. // add the tripal_db JS and CSS
  21. drupal_add_css(drupal_get_path('module', 'tripal_db') . '/theme/css/tripal_db.css');
  22. drupal_add_js(drupal_get_path('module', 'tripal_db') . '/theme/js/tripal_db.js');
  23. }
  24. /**
  25. *
  26. * @ingroup tripal_db
  27. */
  28. function tripal_db_menu() {
  29. $items = array();
  30. $items['admin/tripal/chado/tripal_db'] = array(
  31. 'title' => 'Databases',
  32. 'description' => 'References to External Database sites such as NCBI',
  33. 'page callback' => 'tripal_db_admin_db_listing',
  34. 'access arguments' => array('administer db cross-references'),
  35. 'type' => MENU_NORMAL_ITEM,
  36. );
  37. $items['admin/tripal/chado/tripal_db/help'] = array(
  38. 'title' => 'Help',
  39. 'description' => "A description of the Tripal Database module including a short description of it's usage.",
  40. 'page callback' => 'theme',
  41. 'page arguments' => array('tripal_db_admin'),
  42. 'access arguments' => array('administer db cross-references'),
  43. 'type' => MENU_LOCAL_TASK,
  44. 'weight' => 10
  45. );
  46. $items['admin/tripal/chado/tripal_db/edit/%'] = array(
  47. 'title' => 'Edit a Database Reference',
  48. 'description' => 'Edit existing Database References.',
  49. 'page callback' => 'drupal_get_form',
  50. 'page arguments' => array('tripal_db_db_edit_form',5),
  51. 'access callback' => 'user_access',
  52. 'access arguments' => array('administer db cross-references'),
  53. 'type' => MENU_CALLBACK,
  54. );
  55. $items['admin/tripal/chado/tripal_db/add'] = array(
  56. 'title' => 'Create a Database Reference',
  57. 'description' => 'Create a new reference to an External Database.',
  58. 'page callback' => 'drupal_get_form',
  59. 'page arguments' => array('tripal_db_db_add_form'),
  60. 'access callback' => 'user_access',
  61. 'access arguments' => array('administer db cross-references'),
  62. 'type' => MENU_CALLBACK,
  63. );
  64. $items['admin/tripal/chado/tripal_db/views/dbs/enable'] = array(
  65. 'title' => 'Enable Database Administrative View',
  66. 'page callback' => 'tripal_views_admin_enable_view',
  67. 'page arguments' => array('tripal_db_admin_dbs', 'admin/tripal/chado/tripal_db'),
  68. 'access arguments' => array('administer controlled vocabularies'),
  69. 'type' => MENU_CALLBACK,
  70. );
  71. $items['admin/tripal/chado/tripal_db/views/dbxrefs/enable'] = array(
  72. 'title' => 'Enable Reference Administrative View',
  73. 'page callback' => 'tripal_views_admin_enable_view',
  74. 'page arguments' => array('tripal_db_admin_dbxrefs', 'admin/tripal/chado/tripal_db'),
  75. 'access arguments' => array('administer controlled vocabularies'),
  76. 'type' => MENU_CALLBACK,
  77. );
  78. return $items;
  79. }
  80. /**
  81. * Implements hook_help()
  82. * Purpose: Adds a help page to the module list
  83. */
  84. function tripal_db_help ($path, $arg) {
  85. if ($path == 'admin/help#tripal_db') {
  86. return theme('tripal_db_help', array());
  87. }
  88. }
  89. /**
  90. * Set the permission types that the chado module uses. Essentially we
  91. * want permissionis that protect creation, editing and deleting of chado
  92. * data objects
  93. *
  94. * @ingroup tripal_db
  95. */
  96. function tripal_db_permission() {
  97. return array(
  98. 'administer db cross-references' => array(
  99. 'title' => t('Administer the list of external databases used for data cross-references.'),
  100. 'description' => t('Allows the user to add, edit or delete databases stored in the Chado database.'),
  101. ),
  102. );
  103. }
  104. /**
  105. * Implements hook_views_api()
  106. * Purpose: Essentially this hook tells drupal that there is views support for
  107. * for this module which then includes tripal_db.views.inc where all the
  108. * views integration code is
  109. *
  110. * @ingroup tripal_db
  111. */
  112. function tripal_db_views_api() {
  113. return array('api' => 2.0);
  114. }
  115. /**
  116. * We need to let drupal know about our theme functions and their arguments.
  117. * We create theme functions to allow users of the module to customize the
  118. * look and feel of the output generated in this module
  119. *
  120. * @ingroup tripal_db
  121. */
  122. function tripal_db_theme() {
  123. $theme_path = drupal_get_path('module', 'tripal_db') . '/theme';
  124. $items = array(
  125. 'tripal_db_admin' => array(
  126. 'template' => 'tripal_db_admin',
  127. 'arguments' => array(NULL),
  128. 'path' => $theme_path,
  129. ),
  130. );
  131. return $items;
  132. }