tripal_genetic.module 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 'api/tripal_genetic.api.inc';
  14. require 'theme/tripal_genetic.theme.inc';
  15. require 'includes/tripal_genetic.schema.inc';
  16. require 'includes/tripal_genetic.admin.inc';
  17. /**
  18. * Implements hook_permission().
  19. *
  20. * Set the permission types that the chado module uses. Essentially we
  21. * want permissionis
  22. *
  23. * @ingroup tripal_genetic
  24. */
  25. function tripal_genetic_permission() {
  26. return array(
  27. 'adminster tripal genetic' => array(
  28. 'title' => t('Administer Genetic Module'),
  29. 'description' => t('Allow users to administer the genetic module.'),
  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. $items['admin/tripal/chado/tripal_genetic'] = array(
  46. 'title' => 'Genetics',
  47. 'description' => 'Genetic data including Genotypes.',
  48. 'page callback' => 'tripal_genetic_admin_genetics_listing',
  49. 'access arguments' => array('adminster tripal genetic'),
  50. 'type' => MENU_NORMAL_ITEM,
  51. );
  52. $items['admin/tripal/chado/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('adminster tripal genetic'),
  58. 'type' => MENU_LOCAL_TASK,
  59. );
  60. $items['admin/tripal/chado/tripal_genetic/views/genetics/enable'] = array(
  61. 'title' => 'Enable genetic Administrative View',
  62. 'page callback' => 'tripal_views_admin_enable_view',
  63. 'page arguments' => array('tripal_genetic_admin_genetics', 'admin/tripal/chado/tripal_genetic'),
  64. 'access arguments' => array('administer tripal genetic'),
  65. 'type' => MENU_CALLBACK,
  66. );
  67. return $items;
  68. }
  69. /**
  70. * Implements hook_views_api().
  71. *
  72. * Essentially this hook tells drupal that there is views support for
  73. * for this module which then includes tripal_genetic.views.inc where all the
  74. * views integration code is
  75. *
  76. * @ingroup tripal_genetic
  77. */
  78. function tripal_genetic_views_api() {
  79. return array(
  80. 'api' => 3.0,
  81. );
  82. }
  83. /**
  84. * Implements hook_theme().
  85. *
  86. * @ingroup tripal_genetic
  87. */
  88. function tripal_genetic_theme($existing, $type, $theme, $path) {
  89. $core_path = drupal_get_path('module', 'tripal_core');
  90. $items = array(
  91. 'tripal_feature_genotypes' => array(
  92. 'variables' => array('node' => NULL),
  93. 'template' => 'tripal_feature_genotypes',
  94. 'path' => "$path/theme/tripal_feature",
  95. ),
  96. 'tripal_stock_genotypes' => array(
  97. 'variables' => array('node' => NULL),
  98. 'template' => 'tripal_stock_genotypes',
  99. 'path' => "$path/theme/tripal_stock",
  100. ),
  101. 'tripal_genetic_help' => array(
  102. 'template' => 'tripal_genetic_help',
  103. 'variables' => array(NULL),
  104. 'path' => "$path/theme/",
  105. ),
  106. );
  107. return $items;
  108. }
  109. /**
  110. * Implements hook_node_view(). Acts on all content types
  111. *
  112. * @ingroup tripal_genetic
  113. */
  114. function tripal_genetic_node_view($node, $view_mode, $langcode) {
  115. if ($node->type == 'chado_feature') {
  116. if ($view_mode == 'full') {
  117. // the tripal_natural_diversity module provides a tripal_feature_nd_genotype
  118. // template. The ND template superceeds this one. Therefore,
  119. // if the tripal_natural_diversity content is present then don't add the
  120. // template from this module as the ND module would superceed this.
  121. if (!array_key_exists('tripal_feature_nd_genotypes', $node->content)) {
  122. $node->content['tripal_feature_genotypes'] = array(
  123. '#markup' => theme('tripal_feature_genotypes', array('node' => $node)),
  124. '#tripal_toc_id' => 'genotypes',
  125. '#tripal_toc_title' => 'Genotypes',
  126. );
  127. }
  128. }
  129. }
  130. if ($node->type == 'chado_stock') {
  131. if ($view_mode == 'full') {
  132. // the tripal_natural_diversity module provides a tripal_stock_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_stock_nd_genotypes', $node->content)) {
  137. $node->content['tripal_stock_genotypes'] = array(
  138. '#markup' => theme('tripal_stock_genotypes', array('node' => $node)),
  139. '#tripal_toc_id' => 'genotypes',
  140. '#tripal_toc_title' => 'Genotypes',
  141. );
  142. }
  143. }
  144. }
  145. }