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

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