tripal_genetic.module 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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('theme/tripal_genetic.theme.inc');
  15. require('includes/tripal_genetic.schema.inc');
  16. require('includes/tripal_genetic.admin.inc');
  17. /**
  18. * Menu items are automatically added for the new node types created
  19. * by this module to the 'Create Content' Navigation menu item. This function
  20. * adds more menu items needed for this module.
  21. *
  22. * @ingroup tripal_genetic
  23. */
  24. function tripal_genetic_menu() {
  25. $items = array();
  26. // the administative settings menu
  27. $items['admin/tripal/chado/tripal_genetic'] = array(
  28. 'title' => 'Genetics',
  29. 'description' => 'Genetic data including Genotypes.',
  30. 'page callback' => 'tripal_genetic_admin_genetics_listing',
  31. 'access arguments' => array('adminster tripal genetic'),
  32. 'type' => MENU_NORMAL_ITEM,
  33. );
  34. $items['admin/tripal/chado/tripal_genetic/help'] = array(
  35. 'title' => 'Help',
  36. 'description' => "A description of the Tripal genetic module including a short description of it's usage.",
  37. 'page callback' => 'theme',
  38. 'page arguments' => array('tripal_genetic_help'),
  39. 'access arguments' => array('adminster tripal genetic'),
  40. 'type' => MENU_LOCAL_TASK,
  41. );
  42. $items['admin/tripal/chado/tripal_genetic/views/genetics/enable'] = array(
  43. 'title' => 'Enable genetic Administrative View',
  44. 'page callback' => 'tripal_views_admin_enable_view',
  45. 'page arguments' => array('tripal_genetic_admin_genetics', 'admin/tripal/chado/tripal_genetic'),
  46. 'access arguments' => array('administer tripal genetic'),
  47. 'type' => MENU_CALLBACK,
  48. );
  49. return $items;
  50. }
  51. /**
  52. * Implements hook_views_api()
  53. * Purpose: Essentially this hook tells drupal that there is views support for
  54. * for this module which then includes tripal_genetic.views.inc where all the
  55. * views integration code is
  56. *
  57. * @ingroup tripal_genetic
  58. */
  59. function tripal_genetic_views_api() {
  60. return array(
  61. 'api' => 3.0,
  62. );
  63. }
  64. /**
  65. * Implements hook_theme().
  66. *
  67. * @ingroup tripal_genetic
  68. */
  69. function tripal_genetic_theme($existing, $type, $theme, $path) {
  70. $core_path = drupal_get_path('module', 'tripal_core');
  71. $items = array(
  72. 'tripal_feature_genotypes' => array(
  73. 'variables' => array('node' => NULL),
  74. 'template' => 'tripal_feature.genotypes',
  75. 'path' => "$path/theme/tripal_feature",
  76. ),
  77. 'tripal_stock_genotypes' => array(
  78. 'variables' => array('node' => NULL),
  79. 'template' => 'tripal_stock.genotypes',
  80. 'path' => "$path/theme/tripal_stock",
  81. ),
  82. 'tripal_genetic_help' => array(
  83. 'template' => 'tripal_genetic.help',
  84. 'variables' => array(NULL),
  85. 'path' => "$path/theme/",
  86. ),
  87. );
  88. return $items;
  89. }
  90. /**
  91. * Implements hook_nodeapi().
  92. *
  93. * @ingroup tripal_genetic
  94. */
  95. function tripal_genetic_node_view($node, $view_mode, $langcode) {
  96. if ($node->type == 'chado_feature') {
  97. // the tripal_natural_diversity module provides a tripal_feature_nd_genotype
  98. // template. The only difference between them is the addition of
  99. // project information by the ND module's template. Therefore,
  100. // if the tripal_natural_diversity content is present then don't add the
  101. // template from this module as the ND module would superceed this.
  102. if ($view_mode == 'full') {
  103. if (!array_key_exists('tripal_feature_nd_genotypes', $node->content)) {
  104. $node->content['tripal_feature_genotypes'] = array(
  105. '#value' => theme('tripal_feature_genotypes', array('node' => $node)),
  106. );
  107. }
  108. }
  109. }
  110. if ($node->type == 'chado_stock') {
  111. // the tripal_natural_diversity module provides a tripal_stock_nd_genotype
  112. // template. The only difference between them is the addition of
  113. // project information by the ND module's template. Therefore,
  114. // if the tripal_natural_diversity content is present then don't add the
  115. // template from this module as the ND module would superceed this.
  116. if ($view_mode == 'full') {
  117. if (!array_key_exists('tripal_stock_nd_genotypes', $node->content)) {
  118. $node->content['tripal_stock_genotypes'] = array(
  119. '#value' => theme('tripal_stock_genotypes', array('node' => $node)),
  120. );
  121. }
  122. }
  123. }
  124. }