tripal_phenotype.module

  1. 2.x tripal_phenotype/tripal_phenotype.module
  2. 3.x legacy/tripal_phenotype/tripal_phenotype.module
  3. 1.x tripal_phenotype/tripal_phenotype.module

Basic functionality for the phenotype module

File

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