tripal_genetic.module 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. /**
  3. * @file
  4. * Basic functionality for the genetic
  5. */
  6. /**
  7. * @defgroup tripal_genetic Genetic Module
  8. * @ingroup tripal_modules
  9. * @{
  10. * Provides functions for managing chado genetic data
  11. * @}
  12. */
  13. require_once 'theme/tripal_genetic.theme.inc';
  14. require_once 'includes/tripal_genetic.admin.inc';
  15. /**
  16. * Implements hook_permission().
  17. *
  18. * Set the permission types that the chado module uses. Essentially we
  19. * want permissionis
  20. *
  21. * @ingroup tripal_genetic
  22. */
  23. function tripal_genetic_permission() {
  24. return array(
  25. /*
  26. 'administer tripal genetic' => array(
  27. 'title' => t('Administer Genetic Module'),
  28. 'description' => t('Allow users to administer the genetic module.'),
  29. ),
  30. */
  31. );
  32. }
  33. /**
  34. * Implements hook_menu().
  35. *
  36. * Menu items are automatically added for the new node types created
  37. * by this module to the 'Create Content' Navigation menu item. This function
  38. * adds more menu items needed for this module.
  39. *
  40. * @ingroup tripal_genetic
  41. */
  42. function tripal_genetic_menu() {
  43. $items = array();
  44. // the administative settings menu
  45. /*
  46. $items['admin/tripal/chado/tripal_genetic'] = array(
  47. 'title' => 'Genetics',
  48. 'description' => 'Genetic data including Genotypes.',
  49. 'page callback' => 'tripal_genetic_admin_genetics_listing',
  50. 'access arguments' => array('administer tripal genetic'),
  51. 'type' => MENU_NORMAL_ITEM,
  52. );
  53. $items['admin/tripal/chado/tripal_genetic/help'] = array(
  54. 'title' => 'Help',
  55. 'description' => "A description of the Tripal genetic module including a short description of it's usage.",
  56. 'page callback' => 'theme',
  57. 'page arguments' => array('tripal_genetic_help'),
  58. 'access arguments' => array('administer tripal genetic'),
  59. 'type' => MENU_LOCAL_TASK,
  60. );
  61. $items['admin/tripal/chado/tripal_genetic/views/genetics/enable'] = array(
  62. 'title' => 'Enable genetic Administrative View',
  63. 'page callback' => 'tripal_enable_view',
  64. 'page arguments' => array('tripal_genetic_admin_genetics', 'admin/tripal/chado/tripal_genetic'),
  65. 'access arguments' => array('administer tripal genetic'),
  66. 'type' => MENU_CALLBACK,
  67. );
  68. */
  69. return $items;
  70. }
  71. /**
  72. * Implements hook_search_biological_data_views().
  73. *
  74. * Adds the described views to the "Search Data" Page created by Tripal Views
  75. */
  76. function tripal_genetic_search_biological_data_views() {
  77. return array(
  78. 'tripal_genetic_user_genotypes' => array(
  79. 'machine_name' => 'tripal_genetic_user_genotypes',
  80. 'human_name' => 'Genotypes',
  81. 'description' => 'Genetic variations such as SNPs, MNPs and indels.',
  82. 'link' => 'chado/genotype'
  83. ),
  84. );
  85. }
  86. /**
  87. * Implements hook_views_api().
  88. *
  89. * Essentially this hook tells drupal that there is views support for
  90. * for this module which then includes tripal_genetic.views.inc where all the
  91. * views integration code is
  92. *
  93. * @ingroup tripal_genetic
  94. */
  95. function tripal_genetic_views_api() {
  96. return array(
  97. 'api' => 3.0,
  98. );
  99. }
  100. /**
  101. * Implements hook_theme().
  102. *
  103. * @ingroup tripal_genetic
  104. */
  105. function tripal_genetic_theme($existing, $type, $theme, $path) {
  106. $core_path = drupal_get_path('module', 'tripal_core');
  107. $items = array(
  108. 'tripal_feature_genotypes' => array(
  109. 'variables' => array('node' => NULL),
  110. 'template' => 'tripal_feature_genotypes',
  111. 'path' => "$path/theme/templates",
  112. ),
  113. 'tripal_stock_genotypes' => array(
  114. 'variables' => array('node' => NULL),
  115. 'template' => 'tripal_stock_genotypes',
  116. 'path' => "$path/theme/templates",
  117. ),
  118. 'tripal_genetic_help' => array(
  119. 'template' => 'tripal_genetic_help',
  120. 'variables' => array(NULL),
  121. 'path' => "$path/theme/templates",
  122. ),
  123. );
  124. return $items;
  125. }
  126. /**
  127. * Implements hook_node_view(). Acts on all content types
  128. *
  129. * @ingroup tripal_genetic
  130. */
  131. function tripal_genetic_node_view($node, $view_mode, $langcode) {
  132. if ($node->type == 'chado_feature') {
  133. if ($view_mode == 'full') {
  134. // the tripal_natural_diversity module provides a tripal_feature_nd_genotype
  135. // template. The ND template superceeds this one. Therefore,
  136. // if the tripal_natural_diversity content is present then don't add the
  137. // template from this module as the ND module would superceed this.
  138. if (!array_key_exists('tripal_feature_nd_genotypes', $node->content)) {
  139. $node->content['tripal_feature_genotypes'] = array(
  140. '#theme' => 'tripal_feature_genotypes',
  141. '#node' => $node,
  142. '#tripal_toc_id' => 'genotypes',
  143. '#tripal_toc_title' => 'Genotypes',
  144. );
  145. }
  146. }
  147. }
  148. if ($node->type == 'chado_stock') {
  149. if ($view_mode == 'full') {
  150. // the tripal_natural_diversity module provides a tripal_stock_nd_genotype
  151. // template. The ND template superceeds this one. Therefore,
  152. // if the tripal_natural_diversity content is present then don't add the
  153. // template from this module as the ND module would superceed this.
  154. if (!array_key_exists('tripal_stock_nd_genotypes', $node->content)) {
  155. $node->content['tripal_stock_genotypes'] = array(
  156. '#theme' => 'tripal_stock_genotypes',
  157. '#node' => $node,
  158. '#tripal_toc_id' => 'genotypes',
  159. '#tripal_toc_title' => 'Genotypes',
  160. );
  161. }
  162. }
  163. }
  164. }