tripal_phenotype.module 4.5 KB

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