tripal_views.module 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. '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_views_api()
  77. *
  78. * Purpose: Set the permission types that the chado module uses.
  79. *
  80. * @ingroup tripal_views
  81. */
  82. function tripal_views_perm() {
  83. return array(
  84. 'manage tripal_views_integration',
  85. );
  86. }
  87. /**
  88. * Implements hook_views_api()
  89. *
  90. * Purpose: Essentially this hook tells drupal that there is views support for
  91. * for this module which then includes tripal_views.views.inc where all the
  92. * views integration code is
  93. *
  94. * @ingroup tripal_views
  95. */
  96. function tripal_views_views_api() {
  97. return array(
  98. 'api' => 2.0,
  99. );
  100. }
  101. /**
  102. * Implements hook_theme()
  103. *
  104. * Purpose: this hook provides details about themable objects added by
  105. * this module
  106. *
  107. * @ingroup tripal_views
  108. */
  109. function tripal_views_theme() {
  110. return array(
  111. 'tripal_views_integration_form' => array(
  112. 'arguments' => array('form' => NULL),
  113. 'template' => 'tripal_views_integration_fields_form',
  114. ),
  115. 'tripal_views_data_export_download_form' => array(
  116. 'arguments' => array('form' => NULL),
  117. 'template' => 'tripal_views_data_export_download_form',
  118. ),
  119. 'file_upload_combo' => array(
  120. 'arguments' => array('element' => NULL)
  121. ),
  122. 'sequence_combo' => array(
  123. 'arguments' => array('element' => NULL)
  124. ),
  125. );
  126. }
  127. /**
  128. * Implements hook_coder_ignore().
  129. * Defines the path to the file (tripal_views.coder_ignores.txt) where ignore rules for coder are stored
  130. */
  131. function tripal_views_coder_ignore() {
  132. return array(
  133. 'path' => drupal_get_path('module', 'tripal_views'),
  134. 'line prefix' => drupal_get_path('module', 'tripal_views'),
  135. );
  136. }
  137. /**
  138. * A landing page for all views of chado content. Simply lists all menu items that
  139. * are children of it.
  140. */
  141. function tripal_views_biological_data_page() {
  142. $output = '';
  143. $item = menu_get_item();
  144. $content = system_admin_menu_block($item);
  145. $output .= '<dl class="admin-list">';
  146. foreach ($content as $item) {
  147. $output .= '<dt>'. l($item['title'], $item['href'], $item['localized_options']) .'</dt>';
  148. $output .= '<dd>'. $item['description'] .'</dd>';
  149. }
  150. $output .= '</dl>';
  151. return $output;
  152. }