tripal_phenotype.module 4.6 KB

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