tripal_genetic.module 4.7 KB

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