tripal_natural_diversity.module 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. return array(
  35. 'tripal_feature_nd_genotypes' => array(
  36. 'arguments' => array('node' => NULL),
  37. 'template' => 'tripal_feature_nd_genotypes',
  38. ),
  39. 'tripal_stock_nd_genotypes' => array(
  40. 'arguments' => array('node' => NULL),
  41. 'template' => 'tripal_stock_nd_genotypes',
  42. ),
  43. 'tripal_stock_nd_phenotypes' => array(
  44. 'arguments' => array('node' => NULL),
  45. 'template' => 'tripal_stock_nd_phenotypes',
  46. ),
  47. );
  48. }
  49. /**
  50. * @ingroup tripal_library
  51. */
  52. function tripal_natural_diversity_block_info() {
  53. $blocks['ndfgenotype']['info'] = t('Tripal Natural Diversity Feature Genotypes');
  54. $blocks['ndfgenotype']['cache'] = BLOCK_NO_CACHE;
  55. $blocks['ndsgenotype']['info'] = t('Tripal Natural Diversity Library Genotypes');
  56. $blocks['ndsgenotype']['cache'] = BLOCK_NO_CACHE;
  57. $blocks['ndsphenotype']['info'] = t('Tripal Natural Diversity Stock Phenotypes');
  58. $blocks['ndsphenotype']['cache'] = BLOCK_NO_CACHE;
  59. return $blocks;
  60. }
  61. /**
  62. * @ingroup tripal_library
  63. */
  64. function tripal_natural_diversity_block_view($delta = '') {
  65. if (user_access('access chado_library content') and arg(0) == 'node' and is_numeric(arg(1))) {
  66. $nid = arg(1);
  67. $node = node_load($nid);
  68. $block = array();
  69. switch ($delta) {
  70. case 'ndfgenotype':
  71. $block['subject'] = t('Genotypes');
  72. $block['content'] = theme('tripal_feature_nd_genotypes', $node);
  73. break;
  74. case 'ndsgenotype':
  75. $block['subject'] = t('Stock Genotypes');
  76. $block['content'] = theme('tripal_stock_nd_genotypes', $node);
  77. break;
  78. case 'ndsphenotype':
  79. $block['subject'] = t('Phenotypes');
  80. $block['content'] = theme('tripal_stock_nd_phenotypes', $node);
  81. break;
  82. default :
  83. }
  84. return $block;
  85. }
  86. }
  87. /**
  88. *
  89. * @ingroup tripal_natural_diversity
  90. */
  91. function tripal_natural_diversity_node_view(&$node, $view_mode, $langcode) {
  92. if ($node->type == 'chado_feature') {
  93. // the tripal_genetic module provides a tripal_feature_genotype
  94. // template. The only difference between them is the addition of
  95. // project information by this module's template. Therefore,
  96. // if the tripal_genetic content is present get rid of as this
  97. // module superceeds it.
  98. if ($view_mode == 'full') {
  99. if (array_key_exists('tripal_feature_genotypes', $node->content)) {
  100. unset($node->content['tripal_feature_genotypes']);
  101. }
  102. $node->content['tripal_feature_nd_genotypes'] = array(
  103. '#value' => theme('tripal_feature_nd_genotypes', $node),
  104. );
  105. }
  106. }
  107. if ($node->type == 'chado_stock') {
  108. if ($view_mode == 'full') {
  109. $node->content['tripal_stock_nd_genotypes'] = array(
  110. '#value' => theme('tripal_stock_nd_genotypes', $node),
  111. );
  112. $node->content['tripal_stock_nd_phenotypes'] = array(
  113. '#value' => theme('tripal_stock_nd_phenotypes', $node),
  114. );
  115. }
  116. }
  117. break;
  118. }