tripal_genetic.module 4.5 KB

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