tripal_genetic.module

  1. 2.x tripal_genetic/tripal_genetic.module
  2. 3.x legacy/tripal_genetic/tripal_genetic.module
  3. 1.x tripal_genetic/tripal_genetic.module

Basic functionality for the genetic

File

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