tripal_views.module 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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' => 'Search 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. 'expanded' => TRUE,
  21. 'type' => MENU_NORMAL_ITEM,
  22. );
  23. $items['admin/tripal/views'] = array(
  24. 'title' => 'Views Integration',
  25. 'description' => 'Integration with Drupal Views',
  26. 'page callback' => 'tripal_views_description_page',
  27. 'access arguments' => array('administer site configuration'),
  28. 'type' => MENU_NORMAL_ITEM,
  29. );
  30. $items['admin/tripal/views/integration/list'] = array(
  31. 'title' => 'List of Integrated Tables',
  32. 'description' => 'Provide a list of all integrated tables and allows for adding new tables or editing already integrated tables.',
  33. 'page callback' => 'tripal_views_integration_setup_list',
  34. 'access arguments' => array('manage tripal_views_integration'),
  35. 'type' => MENU_NORMAL_ITEM,
  36. 'weight' => 0,
  37. );
  38. $items['admin/tripal/views/integration/new'] = array(
  39. 'title' => 'Integrate A Table',
  40. 'page callback' => 'drupal_get_form',
  41. 'page arguments' => array('tripal_views_integration_form'),
  42. 'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
  43. 'type' => MENU_NORMAL_ITEM,
  44. );
  45. $items['admin/tripal/views/integration/edit/%'] = array(
  46. 'title' => 'Edit Views Integration',
  47. 'page callback' => 'drupal_get_form',
  48. 'page arguments' => array('tripal_views_integration_form', 5),
  49. 'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
  50. 'type' => MENU_CALLBACK,
  51. );
  52. $items['admin/tripal/views/integration/delete/%'] = array(
  53. 'title' => 'Delete Views Integration',
  54. 'page callback' => 'tripal_views_integration_delete',
  55. 'page arguments' => array(5),
  56. 'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
  57. 'type' => MENU_CALLBACK,
  58. );
  59. $items['admin/tripal/views/import'] = array(
  60. 'title' => 'Import Views Integration',
  61. 'page callback' => 'drupal_get_form',
  62. 'page arguments' => array('tripal_views_integration_import_form'),
  63. 'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
  64. 'type' => MENU_NORMAL_ITEM,
  65. );
  66. $items['admin/tripal/views/integration/export/%'] = array(
  67. 'title' => 'Import Views Integration',
  68. 'page callback' => 'drupal_get_form',
  69. 'page arguments' => array('tripal_views_integration_export_form', 5),
  70. 'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
  71. 'type' => MENU_CALLBACK,
  72. );
  73. return $items;
  74. }
  75. /**
  76. * Implements hook_init().
  77. */
  78. function tripal_views_init() {
  79. // Need to ensure that all chado tables are integrated w/out making
  80. // the user go to views UI. It would be ideal to do this in a hook called only once
  81. // directly after install/enabling of the module but such a hook doesn't
  82. // exist in Drupal 6
  83. $tripal_views = db_fetch_object(db_query("SELECT true as has_rows FROM {tripal_views}"));
  84. if (!$tripal_views->has_rows) {
  85. tripal_views_integrate_all_chado_tables();
  86. }
  87. }
  88. /**
  89. * Implements hook_views_api()
  90. *
  91. * Purpose: Set the permission types that the chado module uses.
  92. *
  93. * @ingroup tripal_views
  94. */
  95. function tripal_views_perm() {
  96. return array(
  97. 'manage tripal_views_integration',
  98. );
  99. }
  100. /**
  101. * Implements hook_views_api()
  102. *
  103. * Purpose: Essentially this hook tells drupal that there is views support for
  104. * for this module which then includes tripal_views.views.inc where all the
  105. * views integration code is
  106. *
  107. * @ingroup tripal_views
  108. */
  109. function tripal_views_views_api() {
  110. return array(
  111. 'api' => 2.0,
  112. );
  113. }
  114. /**
  115. * Implements hook_theme()
  116. *
  117. * Purpose: this hook provides details about themable objects added by
  118. * this module
  119. *
  120. * @ingroup tripal_views
  121. */
  122. function tripal_views_theme() {
  123. return array(
  124. 'tripal_views_integration_form' => array(
  125. 'arguments' => array('form' => NULL),
  126. 'template' => 'tripal_views_integration_fields_form',
  127. ),
  128. 'tripal_views_data_export_download_form' => array(
  129. 'arguments' => array('form' => NULL),
  130. 'template' => 'tripal_views_data_export_download_form',
  131. ),
  132. 'file_upload_combo' => array(
  133. 'arguments' => array('element' => NULL)
  134. ),
  135. 'sequence_combo' => array(
  136. 'arguments' => array('element' => NULL)
  137. ),
  138. );
  139. }
  140. /**
  141. * Implements hook_coder_ignore().
  142. * Defines the path to the file (tripal_views.coder_ignores.txt) where ignore rules for coder are stored
  143. */
  144. function tripal_views_coder_ignore() {
  145. return array(
  146. 'path' => drupal_get_path('module', 'tripal_views'),
  147. 'line prefix' => drupal_get_path('module', 'tripal_views'),
  148. );
  149. }
  150. /**
  151. * A landing page for all views of chado content. Simply lists all menu items that
  152. * are children of it.
  153. */
  154. function tripal_views_biological_data_page() {
  155. $output = '';
  156. $item = menu_get_item();
  157. $content = system_admin_menu_block($item);
  158. $output .= '<dl class="admin-list">';
  159. foreach ($content as $item) {
  160. $output .= '<dt>'. l($item['title'], $item['href'], $item['localized_options']) .'</dt>';
  161. $output .= '<dd>'. $item['description'] .'</dd>';
  162. }
  163. $output .= '</dl>';
  164. return $output;
  165. }