tripal_natural_diversity.module 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. /**
  3. * @file
  4. * Basic function for the natural diversity module
  5. */
  6. /**
  7. * @defgroup tripal_legacy_natural_diversity Legacy Natural Diversity Module
  8. * @ingroup tripal_legacy_modules
  9. * @{
  10. * Provides functions for managing chado natural diversity data
  11. * @}
  12. */
  13. require_once 'theme/tripal_natural_diversity.theme.inc';
  14. require_once 'includes/tripal_natural_diversity.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_natural_diversity
  22. */
  23. function tripal_natural_diversity_permission() {
  24. return array(
  25. /*
  26. 'administer tripal nd' => array(
  27. 'title' => t('Administer Natural Diversity Module'),
  28. 'description' => t('Allow users to administer the natural diversity 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_natural_diversity
  41. */
  42. function tripal_natural_diversity_menu() {
  43. $items = array();
  44. // the administative settings menu
  45. $items['admin/tripal/legacy/tripal_natdiv'] = array(
  46. 'title' => 'Natural Diversity Experiments',
  47. 'description' => 'Experiments relating to natural diversity such as genotype and phenotype experiments.',
  48. 'page callback' => 'tripal_natural_diversity_admin_natdiv_view',
  49. 'access arguments' => array('administer tripal nd'),
  50. 'type' => MENU_NORMAL_ITEM,
  51. );
  52. $items['admin/tripal/legacy/tripal_natdiv/help'] = array(
  53. 'title' => 'Help',
  54. 'description' => ('Help for the Tripal natural diversity module.'),
  55. 'page callback' => 'theme',
  56. 'page arguments' => array('tripal_natural_diversity_help'),
  57. 'access arguments' => array('administer tripal nd'),
  58. 'type' => MENU_LOCAL_TASK,
  59. 'weight' => 10
  60. );
  61. $items['admin/tripal/legacy/tripal_natdiv/views/natdiv_exp/enable'] = array(
  62. 'title' => 'Enable Natural Diversity Administrative View',
  63. 'page callback' => 'tripal_enable_view',
  64. 'page arguments' => array('tripal_natural_diversity_admin_natdiv_exp', 'admin/tripal/legacy/tripal_natdiv'),
  65. 'access arguments' => array('administer tripal nd'),
  66. 'type' => MENU_CALLBACK,
  67. );
  68. return $items;
  69. }
  70. /**
  71. * Implements hook_views_api().
  72. *
  73. * Essentially this hook tells drupal that there is views support for
  74. * for this module which then includes tripal_natural_diversity.views.inc where all the
  75. * views integration code is
  76. *
  77. * @ingroup tripal_legacy_natural_diversity
  78. */
  79. function tripal_natural_diversity_views_api() {
  80. return array(
  81. 'api' => 3.0,
  82. );
  83. }
  84. /**
  85. * Implements hook_theme().
  86. *
  87. * @ingroup tripal_legacy_natural_diversity
  88. */
  89. function tripal_natural_diversity_theme($existing, $type, $theme, $path) {
  90. $core_path = drupal_get_path('module', 'tripal_core');
  91. $items = array(
  92. // tripal_feature templates
  93. 'tripal_feature_nd_genotypes' => array(
  94. 'variables' => array('node' => NULL),
  95. 'template' => 'tripal_feature_nd_genotypes',
  96. 'path' => "$path/theme/templates",
  97. ),
  98. // tripal_stock templates
  99. 'tripal_stock_nd_genotypes' => array(
  100. 'variables' => array('node' => NULL),
  101. 'template' => 'tripal_stock_nd_genotypes',
  102. 'path' => "$path/theme/templates",
  103. ),
  104. 'tripal_stock_nd_phenotypes' => array(
  105. 'variables' => array('node' => NULL),
  106. 'template' => 'tripal_stock_nd_phenotypes',
  107. 'path' => "$path/theme/templates",
  108. ),
  109. 'tripal_natural_diversity_help' => array(
  110. 'template' => 'tripal_natural_diversity_help',
  111. 'variables' => array(NULL),
  112. 'path' => "$path/theme/templates",
  113. ),
  114. );
  115. return $items;
  116. }
  117. /**
  118. * Implements hook_node_view(). Acts on all content types.
  119. *
  120. * @ingroup tripal_legacy_natural_diversity
  121. */
  122. function tripal_natural_diversity_node_view($node, $view_mode, $langcode) {
  123. switch ($node->type) {
  124. case 'chado_feature':
  125. if ($view_mode == 'full') {
  126. // the tripal_genetic module provides a tripal_feature_genotype
  127. // template. if the tripal_genetic content is present get rid of it as this
  128. // module superceeds it.
  129. if (array_key_exists('tripal_feature_genotypes', $node->content)) {
  130. unset($node->content['tripal_feature_genotypes']);
  131. }
  132. $node->content['tripal_feature_nd_genotypes'] = array(
  133. '#theme' => 'tripal_feature_nd_genotypes',
  134. '#node' => $node,
  135. '#tripal_toc_id' => 'genotypes',
  136. '#tripal_toc_title' => 'Genotypes',
  137. );
  138. }
  139. break;
  140. case 'chado_stock':
  141. if ($view_mode == 'full') {
  142. // the tripal_genetic module provides a tripal_stock_genotype
  143. // template. if the tripal_genetic content is present get rid of it as this
  144. // module superceeds it.
  145. if (array_key_exists('tripal_stock_genotypes', $node->content)) {
  146. unset($node->content['tripal_stock_genotypes']);
  147. }
  148. $node->content['tripal_stock_nd_genotypes'] = array(
  149. '#theme' => 'tripal_stock_nd_genotypes',
  150. '#node' => $node,
  151. '#tripal_toc_id' => 'genotypes',
  152. '#tripal_toc_title' => 'Genotypes',
  153. );
  154. $node->content['tripal_stock_nd_phenotypes'] = array(
  155. '#theme' => 'tripal_stock_nd_phenotypes',
  156. '#node' => $node,
  157. '#tripal_toc_id' => 'phenotypes',
  158. '#tripal_toc_title' => 'Phenotypes',
  159. );
  160. }
  161. break;
  162. }
  163. }