tripal_natural_diversity.module

  1. 2.x tripal_natural_diversity/tripal_natural_diversity.module
  2. 3.x legacy/tripal_natural_diversity/tripal_natural_diversity.module
  3. 1.x tripal_natural_diversity/tripal_natural_diversity.module

Basic function for the natural diversity module

File

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