tripal_genetic.module 4.3 KB

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