tripal_phenotype.module 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. /**
  3. * @file
  4. * Basic functionality for the phenotype module
  5. */
  6. /**
  7. * @defgroup tripal_phenotype Phenotype Module
  8. * @ingroup tripal_modules
  9. * @{
  10. * Provides functions for managing chado phenotype data
  11. * @}
  12. */
  13. /**
  14. * Implements hook_permission().
  15. *
  16. * Set the permission types that the chado module uses. Essentially we
  17. * want permissionis
  18. *
  19. * @ingroup tripal_phenotype
  20. */
  21. function tripal_phenotype_permission() {
  22. return array(
  23. 'adminster tripal phenotype' => array(
  24. 'title' => t('Administer Phenotype Module'),
  25. 'description' => t('Allow users to administer the phenotype module.'),
  26. ),
  27. );
  28. }
  29. /**
  30. * Implements hook_menu().
  31. *
  32. * Menu items are automatically added for the new node types created
  33. * by this module to the 'Create Content' Navigation menu item. This function
  34. * adds more menu items needed for this module.
  35. *
  36. * @ingroup tripal_phenotype
  37. */
  38. function tripal_phenotype_menu() {
  39. $items = array();
  40. // the administative settings menu
  41. $items['admin/tripal/chado/tripal_phenotype'] = array(
  42. 'title' => 'Phenotypes',
  43. 'description' => 'A controlled sentence describing observable effects of non-wild type function.',
  44. 'page callback' => 'tripal_phenotype_admin_phenotypes_listing',
  45. 'access arguments' => array('adminster tripal phenotype'),
  46. 'type' => MENU_NORMAL_ITEM,
  47. );
  48. $items['admin/tripal/chado/tripal_phenotype/help'] = array(
  49. 'title' => 'Help',
  50. 'description' => "A description of the Tripal phenotype module including a short description of it's usage.",
  51. 'page callback' => 'theme',
  52. 'page arguments' => array('tripal_phenotype_help'),
  53. 'access arguments' => array('adminster tripal phenotype'),
  54. 'type' => MENU_LOCAL_TASK,
  55. );
  56. $items['admin/tripal/chado/tripal_phenotype/views/phenotypes/enable'] = array(
  57. 'title' => 'Enable Phenotype Administrative View',
  58. 'page callback' => 'tripal_views_admin_enable_view',
  59. 'page arguments' => array('tripal_phenotype_admin_phenotypes', 'admin/tripal/chado/tripal_phenotype'),
  60. 'access arguments' => array('administer tripal phenotype'),
  61. 'type' => MENU_CALLBACK,
  62. );
  63. return $items;
  64. }
  65. /**
  66. * Implements hook_theme().
  67. *
  68. * We need to let drupal know about our theme functions and their arguments.
  69. * We create theme functions to allow users of the module to customize the
  70. * look and feel of the output generated in this module
  71. *
  72. * @ingroup tripal_phenotype
  73. */
  74. function tripal_phenotype_theme($existing, $type, $theme, $path) {
  75. $core_path = drupal_get_path('module', 'tripal_core');
  76. $items = array(
  77. 'tripal_feature_phenotypes' => array(
  78. 'variables' => array('node' => NULL),
  79. 'template' => 'tripal_feature_phenotypes',
  80. 'path' => "$path/theme/tripal_feature",
  81. ),
  82. 'tripal_phenotype_help' => array(
  83. 'template' => 'tripal_phenotype_help',
  84. 'variables' => array(NULL),
  85. 'path' => "$path/theme",
  86. ),
  87. );
  88. return $items;
  89. }
  90. /**
  91. * Implements hook_views_api().
  92. *
  93. * Essentially this hook tells drupal that there is views support for
  94. * for this module which then includes tripal_phenotype.views.inc where all the
  95. * views integration code is
  96. *
  97. * @ingroup tripal_phenotype
  98. */
  99. function tripal_phenotype_views_api() {
  100. return array(
  101. 'api' => 3.0,
  102. );
  103. }
  104. /**
  105. * Admin Launchpad
  106. *
  107. * @ingroup tripal_phenotype
  108. */
  109. function tripal_phenotype_admin_phenotypes_listing() {
  110. $output = '';
  111. // set the breadcrumb
  112. $breadcrumb = array();
  113. $breadcrumb[] = l('Home', '<front>');
  114. $breadcrumb[] = l('Administration', 'admin');
  115. $breadcrumb[] = l('Tripal', 'admin/tripal');
  116. $breadcrumb[] = l('Chado', 'admin/tripal/chado');
  117. $breadcrumb[] = l('Phenotypes', 'admin/tripal/chado/tripal_phenotype');
  118. drupal_set_breadcrumb($breadcrumb);
  119. // Add the view
  120. $view = views_embed_view('tripal_phenotype_admin_phenotypes','default');
  121. if (isset($view)) {
  122. $output .= $view;
  123. }
  124. else {
  125. $output .= '<p>The Tripal Phenotype Module uses primarily views to provide an '
  126. . 'administrative interface. Currently one or more views needed for this '
  127. . 'administrative interface are disabled. <strong>Click each of the following links to '
  128. . 'enable the pertinent views</strong>:</p>';
  129. $output .= '<ul>';
  130. $output .= '<li>'.l('Phenotype Admin', 'admin/tripal/chado/tripal_phenotype/views/phenotypes/enable').'</li>';
  131. $output .= '</ul>';
  132. }
  133. return $output;
  134. }
  135. /**
  136. * Implements hook_node_view().
  137. *
  138. * @ingroup tripal_phenotype
  139. */
  140. function tripal_phenotype_node_view($node, $view_mode, $langcode) {
  141. switch ($node->type) {
  142. case 'chado_feature':
  143. // Show feature browser and counts
  144. if ($view_mode == 'full') {
  145. $node->content['tripal_feature_phenotypes'] = array(
  146. '#markup' => theme('tripal_feature_phenotypes', array('node' => $node)),
  147. '#tripal_toc_id' => 'phenotypes',
  148. '#tripal_toc_title' => 'Phenotypes',
  149. );
  150. }
  151. break;
  152. }
  153. }