tripal_natural_diversity.module 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. require_once('api/tripal_natural_diversity.api.inc');
  3. require_once('theme/tripal_natural_diversity.theme.inc');
  4. require_once('includes/tripal_natural_diversity.schema.inc');
  5. require_once('includes/tripal_natural_diversity.admin.inc');
  6. /**
  7. * @defgroup tripal_natural_diversity Natural Diversity Module
  8. * @ingroup tripal_modules
  9. * @{
  10. * Provides functions for managing chado natural diversity data
  11. * @}
  12. */
  13. /**
  14. * Menu items are automatically added for the new node types created
  15. * by this module to the 'Create Content' Navigation menu item. This function
  16. * adds more menu items needed for this module.
  17. *
  18. * @ingroup tripal_natural_diversity
  19. */
  20. function tripal_natural_diversity_menu() {
  21. $items = array();
  22. // the administative settings menu
  23. $items['admin/tripal/chado/tripal_natdiv'] = array(
  24. 'title' => 'Natural Diversity Experiments',
  25. 'description' => 'Experiments relating to natural diversity such as genotype and phenotype experiments.',
  26. 'page callback' => 'tripal_natural_diversity_admin_natdiv_view',
  27. 'access arguments' => array('adminster tripal natural_diversity'),
  28. 'type' => MENU_NORMAL_ITEM,
  29. );
  30. $items['admin/tripal/chado/tripal_natdiv/help'] = array(
  31. 'title' => 'Help',
  32. 'description' => ('Help for the Tripal natural diversity module.'),
  33. 'page callback' => 'theme',
  34. 'page arguments' => array('tripal_natural_diversity_help'),
  35. 'access arguments' => array('administer tripal natual_diversity'),
  36. 'type' => MENU_LOCAL_TASK,
  37. 'weight' => 10
  38. );
  39. $items['admin/tripal/chado/tripal_natdiv/views/natdiv_exp/enable'] = array(
  40. 'title' => 'Enable Natural Diversity Administrative View',
  41. 'page callback' => 'tripal_views_admin_enable_view',
  42. 'page arguments' => array('tripal_natural_diversity_admin_natdiv_exp', 'admin/tripal/chado/tripal_natdiv'),
  43. 'access arguments' => array('administer tripal natural_diversity'),
  44. 'type' => MENU_CALLBACK,
  45. );
  46. return $items;
  47. }
  48. /**
  49. * Implements hook_views_api()
  50. * Purpose: Essentially this hook tells drupal that there is views support for
  51. * for this module which then includes tripal_natural_diversity.views.inc where all the
  52. * views integration code is
  53. *
  54. * @ingroup tripal_natural_diversity
  55. */
  56. function tripal_natural_diversity_views_api() {
  57. return array(
  58. 'api' => 3.0,
  59. );
  60. }
  61. /**
  62. * Implements hook_theme
  63. *
  64. * @ingroup tripal_natural_diversity
  65. */
  66. function tripal_natural_diversity_theme($existing, $type, $theme, $path) {
  67. $core_path = drupal_get_path('module', 'tripal_core');
  68. $items = array(
  69. // tripal_feature templates
  70. 'tripal_feature_nd_genotypes' => array(
  71. 'variables' => array('node' => NULL),
  72. 'template' => 'tripal_feature.nd_genotypes',
  73. 'path' => "$path/theme/tripal_feature",
  74. ),
  75. // tripal_stock templates
  76. 'tripal_stock_nd_genotypes' => array(
  77. 'variables' => array('node' => NULL),
  78. 'template' => 'tripal_stock.nd_genotypes',
  79. 'path' => "$path/theme/tripal_stock",
  80. ),
  81. 'tripal_stock_nd_phenotypes' => array(
  82. 'variables' => array('node' => NULL),
  83. 'template' => 'tripal_stock.nd_phenotypes',
  84. 'path' => "$path/theme/tripal_stock",
  85. ),
  86. 'tripal_natural_diversity_help' => array(
  87. 'template' => 'tripal_natural_diversity.help',
  88. 'variables' => array(NULL),
  89. 'path' => "$path/theme",
  90. ),
  91. );
  92. return $items;
  93. }
  94. /**
  95. * @ingroup tripal_library
  96. */
  97. function tripal_natural_diversity_block_info() {
  98. $blocks['ndfgenotype']['info'] = t('Tripal Natural Diversity Feature Genotypes');
  99. $blocks['ndfgenotype']['cache'] = 'BLOCK_NO_CACHE';
  100. $blocks['ndsgenotype']['info'] = t('Tripal Natural Diversity Library Genotypes');
  101. $blocks['ndsgenotype']['cache'] = 'BLOCK_NO_CACHE';
  102. $blocks['ndsphenotype']['info'] = t('Tripal Natural Diversity Stock Phenotypes');
  103. $blocks['ndsphenotype']['cache'] = 'BLOCK_NO_CACHE';
  104. return $blocks;
  105. }
  106. /**
  107. * @ingroup tripal_library
  108. */
  109. function tripal_natural_diversity_block_view($delta = '') {
  110. if (user_access('access chado_library content') and arg(0) == 'node' and is_numeric(arg(1))) {
  111. $nid = arg(1);
  112. $node = node_load($nid);
  113. $block = array();
  114. switch ($delta) {
  115. case 'ndfgenotype':
  116. $block['subject'] = t('Genotypes');
  117. $block['content'] = theme('tripal_feature_nd_genotypes', $node);
  118. break;
  119. case 'ndsgenotype':
  120. $block['subject'] = t('Stock Genotypes');
  121. $block['content'] = theme('tripal_stock_nd_genotypes', $node);
  122. break;
  123. case 'ndsphenotype':
  124. $block['subject'] = t('Phenotypes');
  125. $block['content'] = theme('tripal_stock_nd_phenotypes', $node);
  126. break;
  127. default :
  128. }
  129. return $block;
  130. }
  131. }
  132. /**
  133. *
  134. * @ingroup tripal_natural_diversity
  135. */
  136. function tripal_natural_diversity_node_view($node, $view_mode, $langcode) {
  137. switch ($node->type) {
  138. case 'chado_feature':
  139. if ($view_mode == 'full') {
  140. // the tripal_genetic module provides a tripal_feature_genotype
  141. // template. if the tripal_genetic content is present get rid of it as this
  142. // module superceeds it.
  143. if (array_key_exists('tripal_feature_genotypes', $node->content)) {
  144. unset($node->content['tripal_feature_genotypes']);
  145. }
  146. $node->content['tripal_feature_nd_genotypes'] = array(
  147. '#value' => theme('tripal_feature_nd_genotypes', array('node' => $node)),
  148. );
  149. }
  150. break;
  151. case 'chado_stock':
  152. if ($view_mode == 'full') {
  153. // the tripal_genetic module provides a tripal_stock_genotype
  154. // template. if the tripal_genetic content is present get rid of it as this
  155. // module superceeds it.
  156. if (array_key_exists('tripal_stock_genotypes', $node->content)) {
  157. unset($node->content['tripal_stock_genotypes']);
  158. }
  159. $node->content['tripal_stock_nd_genotypes'] = array(
  160. '#value' => theme('tripal_stock_nd_genotypes', array('node' => $node)),
  161. );
  162. $node->content['tripal_stock_nd_phenotypes'] = array(
  163. '#value' => theme('tripal_stock_nd_phenotypes', array('node' => $node)),
  164. );
  165. }
  166. break;
  167. }
  168. }