tripal_natural_diversity.module 5.4 KB

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