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

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