tripal_phenotype.module 4.3 KB

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