tripal_genetic.module 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * @file
  4. * This file contains the basic functions needed for this drupal module.
  5. * The drupal tripal_genetic module maps directly to the chado X module.
  6. *
  7. * For documentation regarding the Chado X module:
  8. * @see http://gmod.org/wiki/Chado_General_Module
  9. *
  10. * @defgroup tripal_genetic Genetic Module
  11. * @ingroup tripal_modules
  12. */
  13. require('api/tripal_genetic.api.inc');
  14. require('includes/tripal_genetic.schema.inc');
  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_genetic.views.inc where all the
  19. * views integration code is
  20. *
  21. * @ingroup tripal_genetic
  22. */
  23. function tripal_genetic_views_api() {
  24. return array(
  25. 'api' => 2.0,
  26. );
  27. }
  28. /**
  29. * Implements hook_theme().
  30. *
  31. * @ingroup tripal_genetic
  32. */
  33. function tripal_genetic_theme() {
  34. $theme_path = drupal_get_path('module', 'tripal_genetic') . '/theme';
  35. $items = array(
  36. 'tripal_feature_genotypes' => array(
  37. 'arguments' => array('node' => NULL),
  38. 'template' => 'tripal_feature_genotypes',
  39. 'path' => "$theme_path/tripal_feature",
  40. ),
  41. 'tripal_stock_genotypes' => array(
  42. 'arguments' => array('node' => NULL),
  43. 'template' => 'tripal_stock_genotypes',
  44. 'path' => "$theme_path/tripal_stock",
  45. ),
  46. );
  47. return $items;
  48. }
  49. /**
  50. * Implements hook_nodeapi().
  51. *
  52. * @ingroup tripal_genetic
  53. */
  54. function tripal_genetic_node_view(&$node, $view_mode, $langcode) {
  55. if ($node->type == 'chado_feature') {
  56. // the tripal_natural_diversity module provides a tripal_feature_nd_genotype
  57. // template. The only difference between them is the addition of
  58. // project information by this ND module's template. Therefore,
  59. // if the tripal_natural_diversity content is present then don't add the
  60. // template from this module as the ND module would superceed this.
  61. if ($view_mode == 'full') {
  62. if (!array_key_exists('tripal_feature_nd_genotypes', $node->content)) {
  63. $node->content['tripal_feature_genotypes'] = array(
  64. '#value' => theme('tripal_feature_genotypes', $node),
  65. );
  66. }
  67. }
  68. }
  69. if ($node->type == 'chado_stock') {
  70. // the tripal_natural_diversity module provides a tripal_stock_nd_genotype
  71. // template. The only difference between them is the addition of
  72. // project information by this ND module's template. Therefore,
  73. // if the tripal_natural_diversity content is present then don't add the
  74. // template from this module as the ND module would superceed this.
  75. if ($view_mode == 'full') {
  76. if (!array_key_exists('tripal_stock_nd_genotypes', $node->content)) {
  77. $node->content['tripal_stock_genotypes'] = array(
  78. '#value' => theme('tripal_stock_genotypes', $node),
  79. );
  80. }
  81. }
  82. }
  83. }