tripal_genetic.module 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. 'adminster 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('adminster 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('adminster 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_views_admin_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_views_api().
  70. *
  71. * Essentially this hook tells drupal that there is views support for
  72. * for this module which then includes tripal_genetic.views.inc where all the
  73. * views integration code is
  74. *
  75. * @ingroup tripal_genetic
  76. */
  77. function tripal_genetic_views_api() {
  78. return array(
  79. 'api' => 3.0,
  80. );
  81. }
  82. /**
  83. * Implements hook_theme().
  84. *
  85. * @ingroup tripal_genetic
  86. */
  87. function tripal_genetic_theme($existing, $type, $theme, $path) {
  88. $core_path = drupal_get_path('module', 'tripal_core');
  89. $items = array(
  90. 'tripal_feature_genotypes' => array(
  91. 'variables' => array('node' => NULL),
  92. 'template' => 'tripal_feature_genotypes',
  93. 'path' => "$path/theme/tripal_feature",
  94. ),
  95. 'tripal_stock_genotypes' => array(
  96. 'variables' => array('node' => NULL),
  97. 'template' => 'tripal_stock_genotypes',
  98. 'path' => "$path/theme/tripal_stock",
  99. ),
  100. 'tripal_genetic_help' => array(
  101. 'template' => 'tripal_genetic_help',
  102. 'variables' => array(NULL),
  103. 'path' => "$path/theme/",
  104. ),
  105. );
  106. return $items;
  107. }
  108. /**
  109. * Implements hook_node_view(). Acts on all content types
  110. *
  111. * @ingroup tripal_genetic
  112. */
  113. function tripal_genetic_node_view($node, $view_mode, $langcode) {
  114. if ($node->type == 'chado_feature') {
  115. if ($view_mode == 'full') {
  116. // the tripal_natural_diversity module provides a tripal_feature_nd_genotype
  117. // template. The ND template superceeds this one. Therefore,
  118. // if the tripal_natural_diversity content is present then don't add the
  119. // template from this module as the ND module would superceed this.
  120. if (!array_key_exists('tripal_feature_nd_genotypes', $node->content)) {
  121. $node->content['tripal_feature_genotypes'] = array(
  122. '#markup' => theme('tripal_feature_genotypes', array('node' => $node)),
  123. '#tripal_toc_id' => 'genotypes',
  124. '#tripal_toc_title' => 'Genotypes',
  125. );
  126. }
  127. }
  128. }
  129. if ($node->type == 'chado_stock') {
  130. if ($view_mode == 'full') {
  131. // the tripal_natural_diversity module provides a tripal_stock_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_stock_nd_genotypes', $node->content)) {
  136. $node->content['tripal_stock_genotypes'] = array(
  137. '#markup' => theme('tripal_stock_genotypes', array('node' => $node)),
  138. '#tripal_toc_id' => 'genotypes',
  139. '#tripal_toc_title' => 'Genotypes',
  140. );
  141. }
  142. }
  143. }
  144. }