tripal_analysis.module 6.8 KB

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