tripal_natural_diversity.module 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. require_once('api/tripal_natural_diversity.api.inc');
  3. require_once('includes/tripal_natural_diversity.schema.inc');
  4. /**
  5. * @file
  6. * This file contains the basic functions needed for this drupal module.
  7. * The drupal tripal_natural_diversity module maps directly to the chado X module.
  8. *
  9. * For documentation regarding the Chado X module:
  10. * @see http://gmod.org/wiki/Chado_General_Module
  11. *
  12. * @defgroup tripal_natural_diversity Natural Diversity Module
  13. * @ingroup tripal_modules
  14. */
  15. /*************************************************************************
  16. * Implements hook_views_api()
  17. * Purpose: Essentially this hook tells drupal that there is views support for
  18. * for this module which then includes tripal_natural_diversity.views.inc where all the
  19. * views integration code is
  20. *
  21. * @ingroup tripal_natural_diversity
  22. */
  23. function tripal_natural_diversity_views_api() {
  24. return array(
  25. 'api' => 2.0,
  26. );
  27. }
  28. /**
  29. * Implements hook_theme
  30. *
  31. * @ingroup tripal_natural_diversity
  32. */
  33. function tripal_natural_diversity_theme() {
  34. $theme_path = drupal_get_path('module', 'tripal_natural_diversity') . '/theme';
  35. $items = array(
  36. // tripal_feature templates
  37. 'tripal_feature_nd_genotypes' => array(
  38. 'arguments' => array('node' => NULL),
  39. 'template' => 'tripal_feature_nd_genotypes',
  40. 'path' => "$theme_path/tripal_feature",
  41. ),
  42. // tripal_stock templates
  43. 'tripal_stock_nd_genotypes' => array(
  44. 'arguments' => array('node' => NULL),
  45. 'template' => 'tripal_stock_nd_genotypes',
  46. 'path' => "$theme_path/tripal_stock",
  47. ),
  48. 'tripal_stock_nd_phenotypes' => array(
  49. 'arguments' => array('node' => NULL),
  50. 'template' => 'tripal_stock_nd_phenotypes',
  51. 'path' => "$theme_path/tripal_stock",
  52. ),
  53. );
  54. return $items;
  55. }
  56. /**
  57. * @ingroup tripal_library
  58. */
  59. function tripal_natural_diversity_block_info() {
  60. $blocks['ndfgenotype']['info'] = t('Tripal Natural Diversity Feature Genotypes');
  61. $blocks['ndfgenotype']['cache'] = BLOCK_NO_CACHE;
  62. $blocks['ndsgenotype']['info'] = t('Tripal Natural Diversity Library Genotypes');
  63. $blocks['ndsgenotype']['cache'] = BLOCK_NO_CACHE;
  64. $blocks['ndsphenotype']['info'] = t('Tripal Natural Diversity Stock Phenotypes');
  65. $blocks['ndsphenotype']['cache'] = BLOCK_NO_CACHE;
  66. return $blocks;
  67. }
  68. /**
  69. * @ingroup tripal_library
  70. */
  71. function tripal_natural_diversity_block_view($delta = '') {
  72. if (user_access('access chado_library content') and arg(0) == 'node' and is_numeric(arg(1))) {
  73. $nid = arg(1);
  74. $node = node_load($nid);
  75. $block = array();
  76. switch ($delta) {
  77. case 'ndfgenotype':
  78. $block['subject'] = t('Genotypes');
  79. $block['content'] = theme('tripal_feature_nd_genotypes', $node);
  80. break;
  81. case 'ndsgenotype':
  82. $block['subject'] = t('Stock Genotypes');
  83. $block['content'] = theme('tripal_stock_nd_genotypes', $node);
  84. break;
  85. case 'ndsphenotype':
  86. $block['subject'] = t('Phenotypes');
  87. $block['content'] = theme('tripal_stock_nd_phenotypes', $node);
  88. break;
  89. default :
  90. }
  91. return $block;
  92. }
  93. }
  94. /**
  95. *
  96. * @ingroup tripal_natural_diversity
  97. */
  98. function tripal_natural_diversity_node_view(&$node, $view_mode, $langcode) {
  99. if ($node->type == 'chado_feature') {
  100. // the tripal_genetic module provides a tripal_feature_genotype
  101. // template. The only difference between them is the addition of
  102. // project information by this module's template. Therefore,
  103. // if the tripal_genetic content is present get rid of as this
  104. // module superceeds it.
  105. if ($view_mode == 'full') {
  106. if (array_key_exists('tripal_feature_genotypes', $node->content)) {
  107. unset($node->content['tripal_feature_genotypes']);
  108. }
  109. $node->content['tripal_feature_nd_genotypes'] = array(
  110. '#value' => theme('tripal_feature_nd_genotypes', $node),
  111. );
  112. }
  113. }
  114. if ($node->type == 'chado_stock') {
  115. if ($view_mode == 'full') {
  116. $node->content['tripal_stock_nd_genotypes'] = array(
  117. '#value' => theme('tripal_stock_nd_genotypes', $node),
  118. );
  119. $node->content['tripal_stock_nd_phenotypes'] = array(
  120. '#value' => theme('tripal_stock_nd_phenotypes', $node),
  121. );
  122. }
  123. }
  124. break;
  125. }