tripal_genetic.module 4.1 KB

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