tripal_phenotype.module 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /**
  3. * @defgroup tripal_phenotype Phenotype Module
  4. * @ingroup tripal_modules
  5. * @{
  6. * Provides functions for managing chado phenotype data
  7. * @}
  8. */
  9. /**
  10. * Menu items are automatically added for the new node types created
  11. * by this module to the 'Create Content' Navigation menu item. This function
  12. * adds more menu items needed for this module.
  13. *
  14. * @ingroup tripal_phenotype
  15. */
  16. function tripal_phenotype_menu() {
  17. $items = array();
  18. // the administative settings menu
  19. $items['admin/tripal/chado/tripal_phenotype'] = array(
  20. 'title' => 'Phenotypes',
  21. 'description' => 'A controlled sentence describing observable effects of non-wild type function.',
  22. 'page callback' => 'tripal_phenotype_admin_phenotypes_listing',
  23. 'access arguments' => array('adminster tripal phenotype'),
  24. 'type' => MENU_NORMAL_ITEM,
  25. );
  26. $items['admin/tripal/chado/tripal_phenotype/help'] = array(
  27. 'title' => 'Help',
  28. 'description' => "A description of the Tripal phenotype module including a short description of it's usage.",
  29. 'page callback' => 'theme',
  30. 'page arguments' => array('tripal_phenotype_help'),
  31. 'access arguments' => array('adminster tripal phenotype'),
  32. 'type' => MENU_LOCAL_TASK,
  33. );
  34. $items['admin/tripal/chado/tripal_phenotype/views/phenotypes/enable'] = array(
  35. 'title' => 'Enable Phenotype Administrative View',
  36. 'page callback' => 'tripal_views_admin_enable_view',
  37. 'page arguments' => array('tripal_phenotype_admin_phenotypes', 'admin/tripal/chado/tripal_phenotype'),
  38. 'access arguments' => array('administer tripal phenotype'),
  39. 'type' => MENU_CALLBACK,
  40. );
  41. return $items;
  42. }
  43. /**
  44. * We need to let drupal know about our theme functions and their arguments.
  45. * We create theme functions to allow users of the module to customize the
  46. * look and feel of the output generated in this module
  47. *
  48. * @ingroup tripal_phenotype
  49. */
  50. function tripal_phenotype_theme($existing, $type, $theme, $path) {
  51. $core_path = drupal_get_path('module', 'tripal_core');
  52. $items = array(
  53. 'tripal_feature_phenotypes' => array(
  54. 'variables' => array('node' => NULL),
  55. 'template' => 'tripal_feature.phenotypes',
  56. 'path' => "$path/theme/tripal_feature",
  57. ),
  58. 'tripal_phenotype_help' => array(
  59. 'template' => 'tripal_phenotype.help',
  60. 'variables' => array(NULL),
  61. 'path' => "$path/theme",
  62. ),
  63. );
  64. return $items;
  65. }
  66. /**
  67. * Implements hook_views_api()
  68. * Purpose: Essentially this hook tells drupal that there is views support for
  69. * for this module which then includes tripal_phenotype.views.inc where all the
  70. * views integration code is
  71. *
  72. * @ingroup tripal_phenotype
  73. */
  74. function tripal_phenotype_views_api() {
  75. return array(
  76. 'api' => 3.0,
  77. );
  78. }
  79. function tripal_phenotype_admin_phenotypes_listing() {
  80. $output = '';
  81. // set the breadcrumb
  82. $breadcrumb = array();
  83. $breadcrumb[] = l('Home', '<front>');
  84. $breadcrumb[] = l('Administration', 'admin');
  85. $breadcrumb[] = l('Tripal', 'admin/tripal');
  86. $breadcrumb[] = l('Chado', 'admin/tripal/chado');
  87. $breadcrumb[] = l('Phenotypes', 'admin/tripal/chado/tripal_phenotype');
  88. drupal_set_breadcrumb($breadcrumb);
  89. // Add the view
  90. $view = views_embed_view('tripal_phenotype_admin_phenotypes','default');
  91. if (isset($view)) {
  92. $output .= $view;
  93. }
  94. else {
  95. $output .= '<p>The Tripal Phenotype Module uses primarily views to provide an '
  96. . 'administrative interface. Currently one or more views needed for this '
  97. . 'administrative interface are disabled. <strong>Click each of the following links to '
  98. . 'enable the pertinent views</strong>:</p>';
  99. $output .= '<ul>';
  100. $output .= '<li>'.l('Phenotype Admin', 'admin/tripal/chado/tripal_phenotype/views/phenotypes/enable').'</li>';
  101. $output .= '</ul>';
  102. }
  103. return $output;
  104. }
  105. /**
  106. *
  107. * @ingroup tripal_phenotype
  108. */
  109. function tripal_phenotype_node_view($node, $view_mode, $langcode) {
  110. switch ($node->type) {
  111. case 'chado_feature':
  112. // Show feature browser and counts
  113. if ($view_mode == 'full') {
  114. $node->content['tripal_feature_phenotypes'] = array(
  115. '#value' => theme('tripal_feature_phenotypes', array('node' => $node)),
  116. );
  117. }
  118. break;
  119. }
  120. }