tripal_views.module 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. require_once "tripal_views.views.inc";
  3. require_once "includes/tripal_views_integration.inc";
  4. require_once "includes/tripal_views_form_elements.inc";
  5. require_once "includes/tripal_views_integration_port.inc";
  6. /**
  7. * Implements hook_menu()
  8. *
  9. * Purpose: this hook provides details about new menu items added by this module
  10. *
  11. * @ingroup tripal_views
  12. */
  13. function tripal_views_menu() {
  14. $items = array();
  15. $items['chado'] = array(
  16. 'title' => 'Biological Data',
  17. 'description' => 'Listings of the various biological data available categorized by type.',
  18. 'page callback' => 'tripal_views_biological_data_page',
  19. 'access arguments' => array('access content'),
  20. 'type' => MENU_NORMAL_ITEM,
  21. );
  22. $items['admin/tripal/views'] = array(
  23. 'title' => 'Views Integration',
  24. 'description' => 'Integration with Drupal Views',
  25. 'page callback' => 'tripal_views_description_page',
  26. 'access arguments' => array('administer site configuration'),
  27. 'type' => MENU_NORMAL_ITEM,
  28. );
  29. $items['admin/tripal/views/integration/list'] = array(
  30. 'title' => 'List of Integrated Tables',
  31. 'description' => 'Provide a list of all integrated tables and allows for adding new tables or editing already integrated tables.',
  32. 'page callback' => 'tripal_views_integration_setup_list',
  33. 'access arguments' => array('manage tripal_views_integration'),
  34. 'type' => MENU_NORMAL_ITEM,
  35. 'weight' => 0,
  36. );
  37. $items['admin/tripal/views/integration/new'] = array(
  38. 'title' => 'Integrate A Table',
  39. 'page callback' => 'drupal_get_form',
  40. 'page arguments' => array('tripal_views_integration_form'),
  41. 'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
  42. 'type' => MENU_NORMAL_ITEM,
  43. );
  44. $items['admin/tripal/views/integration/edit/%'] = array(
  45. 'title' => 'Edit Views Integration',
  46. 'page callback' => 'drupal_get_form',
  47. 'page arguments' => array('tripal_views_integration_form', 5),
  48. 'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
  49. 'type' => MENU_CALLBACK,
  50. );
  51. $items['admin/tripal/views/integration/delete/%'] = array(
  52. 'title' => 'Delete Views Integration',
  53. 'page callback' => 'tripal_views_integration_delete',
  54. 'page arguments' => array(5),
  55. 'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
  56. 'type' => MENU_CALLBACK,
  57. );
  58. $items['admin/tripal/views/import'] = array(
  59. 'title' => 'Import Views Integration',
  60. 'page callback' => 'drupal_get_form',
  61. 'page arguments' => array('tripal_views_integration_import_form'),
  62. 'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
  63. 'type' => MENU_NORMAL_ITEM,
  64. );
  65. $items['admin/tripal/views/integration/export/%'] = array(
  66. 'title' => 'Import Views Integration',
  67. 'page callback' => 'drupal_get_form',
  68. 'page arguments' => array('tripal_views_integration_export_form', 5),
  69. 'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
  70. 'type' => MENU_CALLBACK,
  71. );
  72. return $items;
  73. }
  74. /**
  75. * Implements hook_views_api()
  76. *
  77. * Purpose: Set the permission types that the chado module uses.
  78. *
  79. * @ingroup tripal_views
  80. */
  81. function tripal_views_perm() {
  82. return array(
  83. 'manage tripal_views_integration',
  84. );
  85. }
  86. /**
  87. * Implements hook_views_api()
  88. *
  89. * Purpose: Essentially this hook tells drupal that there is views support for
  90. * for this module which then includes tripal_views.views.inc where all the
  91. * views integration code is
  92. *
  93. * @ingroup tripal_views
  94. */
  95. function tripal_views_views_api() {
  96. return array(
  97. 'api' => 2.0,
  98. );
  99. }
  100. /**
  101. * Implements hook_theme()
  102. *
  103. * Purpose: this hook provides details about themable objects added by
  104. * this module
  105. *
  106. * @ingroup tripal_views
  107. */
  108. function tripal_views_theme() {
  109. return array(
  110. 'tripal_views_integration_form' => array(
  111. 'arguments' => array('form' => NULL),
  112. 'template' => 'tripal_views_integration_fields_form',
  113. ),
  114. 'tripal_views_data_export_download_form' => array(
  115. 'arguments' => array('form' => NULL),
  116. 'template' => 'tripal_views_data_export_download_form',
  117. ),
  118. 'file_upload_combo' => array(
  119. 'arguments' => array('element' => NULL)
  120. ),
  121. 'sequence_combo' => array(
  122. 'arguments' => array('element' => NULL)
  123. ),
  124. );
  125. }
  126. /**
  127. * Implements hook_coder_ignore().
  128. * Defines the path to the file (tripal_views.coder_ignores.txt) where ignore rules for coder are stored
  129. */
  130. function tripal_views_coder_ignore() {
  131. return array(
  132. 'path' => drupal_get_path('module', 'tripal_views'),
  133. 'line prefix' => drupal_get_path('module', 'tripal_views'),
  134. );
  135. }
  136. /**
  137. * A landing page for all views of chado content. Simply lists all menu items that
  138. * are children of it.
  139. */
  140. function tripal_views_biological_data_page() {
  141. $output = '';
  142. $item = menu_get_item();
  143. $content = system_admin_menu_block($item);
  144. $output .= '<dl class="admin-list">';
  145. foreach ($content as $item) {
  146. $output .= '<dt>'. l($item['title'], $item['href'], $item['localized_options']) .'</dt>';
  147. $output .= '<dd>'. $item['description'] .'</dd>';
  148. }
  149. $output .= '</dl>';
  150. return $output;
  151. }