tripal_analysis.module 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?php
  2. /**
  3. * @file
  4. * Contains basic functionality for the analysis module.
  5. *
  6. * @ingroup tripal_analysis
  7. */
  8. require_once 'api/tripal_analysis.api.inc';
  9. require_once 'api/tripal_analysis.schema.api.inc';
  10. require_once 'api/tripal_analysis.DEPRECATED.inc';
  11. require_once 'includes/tripal_analysis_privacy.inc';
  12. require_once 'includes/tripal_analysis.admin.inc';
  13. require_once 'includes/tripal_analysis.chado_node.inc';
  14. /**
  15. * @defgroup tripal_analysis Analysis Module
  16. * @ingroup tripal_modules
  17. * @{
  18. * Integrates the Chado Analysis module with Drupal Nodes & Views
  19. * @}
  20. */
  21. /**
  22. * Implements hook_init().
  23. * Add tripal javascript to page headers
  24. *
  25. * @ingroup tripal_analysis
  26. */
  27. function tripal_analysis_init() {
  28. }
  29. /**
  30. * Implementation of hook_menu().
  31. * Entry points and paths of the module
  32. *
  33. * @ingroup tripal_analysis
  34. */
  35. function tripal_analysis_menu() {
  36. // Tripal Analysis administrative settings
  37. $items['admin/tripal/chado/tripal_analysis'] = array(
  38. 'title' => 'Analyses',
  39. 'description' => 'A bioinformatics analysis producing features.',
  40. 'page callback' => 'tripal_analysis_admin_analysis_view',
  41. 'access arguments' => array('administer tripal analysis'),
  42. 'type' => MENU_NORMAL_ITEM,
  43. );
  44. $items['admin/tripal/chado/tripal_analysis/help'] = array(
  45. 'title' => 'Help',
  46. 'description' => "A description of the Tripal Analysis module including a short description of it's usage.",
  47. 'page callback' => 'theme',
  48. 'page arguments' => array('tripal_analysis_help'),
  49. 'access arguments' => array('administer tripal analysis'),
  50. 'type' => MENU_LOCAL_TASK,
  51. 'weight' => 10,
  52. );
  53. $items['admin/tripal/chado/tripal_analysis/configuration'] = array(
  54. 'title' => 'Settings',
  55. 'description' => 'Settings for the displays of analysis results.',
  56. 'page callback' => 'drupal_get_form',
  57. 'page arguments' => array('tripal_analysis_admin'),
  58. 'access arguments' => array('administer tripal analysis'),
  59. 'type' => MENU_LOCAL_TASK,
  60. 'weight' => 5
  61. );
  62. $items['admin/tripal/chado/tripal_analysis/sync'] = array(
  63. 'title' => ' Sync',
  64. 'description' => 'Create pages on this site for analyses stored in Chado',
  65. 'page callback' => 'drupal_get_form',
  66. 'page arguments' => array('chado_node_sync_form', 'tripal_analysis', 'chado_analysis'),
  67. 'access arguments' => array('administer tripal analysis'),
  68. 'type' => MENU_LOCAL_TASK,
  69. 'weight' => 2
  70. );
  71. return $items;
  72. }
  73. /**
  74. * Implements hook_search_biological_data_views().
  75. *
  76. * Adds the described views to the "Search Data" Page created by Tripal Views
  77. */
  78. function tripal_analysis_search_biological_data_views() {
  79. return array(
  80. 'tripal_analysis_user_analyses' => array(
  81. 'machine_name' => 'tripal_analysis_user_analyses',
  82. 'human_name' => 'Analyses',
  83. 'description' => 'Bioinformatics analyses which often produces features.',
  84. 'link' => 'chado/analysis'
  85. ),
  86. );
  87. }
  88. /**
  89. * Implements hook_help().
  90. * Purpose: Adds a help page to the module list
  91. *
  92. * @ingroup tripal_analysis
  93. */
  94. function tripal_analysis_help ($path, $arg) {
  95. if ($path == 'admin/help#tripal_analysis') {
  96. return theme('tripal_analysis_help', array());
  97. }
  98. }
  99. /**
  100. * Implements hook_permission().
  101. *
  102. * Set the permission types that the chado module uses. Essentially we
  103. * want permissionis that protect creation, editing and deleting of chado
  104. * data objects
  105. *
  106. * @ingroup tripal_analysis
  107. */
  108. function tripal_analysis_permission() {
  109. return array(
  110. 'access chado_analysis content' => array(
  111. 'title' => t('View Analyses'),
  112. 'description' => t('Allow users to view analysis pages.'),
  113. ),
  114. 'create chado_analysis content' => array(
  115. 'title' => t('Create Analyses'),
  116. 'description' => t('Allow users to create new analysis pages.'),
  117. ),
  118. 'delete chado_analysis content' => array(
  119. 'title' => t('Delete Analyses'),
  120. 'description' => t('Allow users to delete analysis pages.'),
  121. ),
  122. 'edit chado_analysis content' => array(
  123. 'title' => t('Edit Analyses'),
  124. 'description' => t('Allow users to edit analysis pages.'),
  125. ),
  126. 'administer tripal analysis' => array(
  127. 'title' => t('Administer Analyses'),
  128. 'description' => t('Allow users to administer all analyses.'),
  129. ),
  130. );
  131. }
  132. /**
  133. * We need to let drupal know about our theme functions and their arguments.
  134. * We create theme functions to allow users of the module to customize the
  135. * look and feel of the output generated in this module
  136. *
  137. * @ingroup tripal_analysis
  138. */
  139. function tripal_analysis_theme($existing, $type, $theme, $path) {
  140. $core_path = drupal_get_path('module', 'tripal_core');
  141. $items = array(
  142. 'node__chado_analysis' => array(
  143. 'template' => 'node--chado-generic',
  144. 'render element' => 'node',
  145. 'base hook' => 'node',
  146. 'path' => "$core_path/theme/templates",
  147. ),
  148. 'tripal_analysis_base' => array(
  149. 'variables' => array('node' => NULL),
  150. 'template' => 'tripal_analysis_base',
  151. 'path' => "$path/theme/templates",
  152. ),
  153. 'tripal_analysis_properties' => array(
  154. 'variables' => array('node' => NULL),
  155. 'template' => 'tripal_analysis_properties',
  156. 'path' => "$path/theme/templates",
  157. ),
  158. 'tripal_analysis_teaser' => array(
  159. 'variables' => array('node' => NULL),
  160. 'template' => 'tripal_analysis_teaser',
  161. 'path' => "$path/theme/templates",
  162. ),
  163. 'tripal_analysis_help' => array(
  164. 'template' => 'tripal_analysis_help',
  165. 'variables' => array(NULL),
  166. 'path' => "$path/theme/templates",
  167. ),
  168. // tripal_feature theme
  169. 'tripal_feature_analyses' => array(
  170. 'template' => 'tripal_feature_analyses',
  171. 'variables' => array('node' => NULL),
  172. 'path' => "$path/theme/templates",
  173. ),
  174. );
  175. return $items;
  176. }
  177. /**
  178. * Implements hook_views_api().
  179. * Essentially this hook tells drupal that there is views support for
  180. * for this module which then includes tripal_analysis.views.inc where all the
  181. * views integration code is
  182. *
  183. * @ingroup tripal_analysis
  184. */
  185. function tripal_analysis_views_api() {
  186. return array(
  187. 'api' => 3.0,
  188. );
  189. }
  190. /**
  191. * Implementation of hook_form_alter().
  192. *
  193. * @ingroup tripal_analysis
  194. */
  195. function tripal_analysis_form_alter(&$form, &$form_state, $form_id) {
  196. // turn of preview button for insert/updates
  197. if ($form_id == "chado_analysis_node_form") {
  198. $form['actions']['preview']['#access'] = FALSE;
  199. //remove the body field
  200. unset($form['body']);
  201. }
  202. }