tripal_analysis.module 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. * Set the permission types that the chado module uses. Essentially we
  86. * want permissionis that protect creation, editing and deleting of chado
  87. * data objects
  88. *
  89. * @ingroup tripal_analysis
  90. */
  91. function tripal_analysis_permission() {
  92. return array(
  93. 'access chado_analysis content' => array(
  94. 'title' => t('View Analyses'),
  95. 'description' => t('Allow users to view analysis pages.'),
  96. ),
  97. 'create chado_analysis content' => array(
  98. 'title' => t('Create Analyses'),
  99. 'description' => t('Allow users to create new analysis pages.'),
  100. ),
  101. 'delete chado_analysis content' => array(
  102. 'title' => t('Delete Analyses'),
  103. 'description' => t('Allow users to delete analysis pages.'),
  104. ),
  105. 'edit chado_analysis content' => array(
  106. 'title' => t('Edit Analyses'),
  107. 'description' => t('Allow users to edit analysis pages.'),
  108. ),
  109. 'adminster tripal analysis' => array(
  110. 'title' => t('Administer Analyses'),
  111. 'description' => t('Allow users to administer all analyses.'),
  112. ),
  113. );
  114. }
  115. /**
  116. * We need to let drupal know about our theme functions and their arguments.
  117. * We create theme functions to allow users of the module to customize the
  118. * look and feel of the output generated in this module
  119. *
  120. * @ingroup tripal_analysis
  121. */
  122. function tripal_analysis_theme($existing, $type, $theme, $path) {
  123. $core_path = drupal_get_path('module', 'tripal_core');
  124. $items = array(
  125. 'node__chado_analysis' => array(
  126. 'template' => 'node--chado-generic',
  127. 'render element' => 'node',
  128. 'base hook' => 'node',
  129. 'path' => "$core_path/theme",
  130. ),
  131. 'tripal_analysis_base' => array(
  132. 'variables' => array('node' => NULL),
  133. 'template' => 'tripal_analysis_base',
  134. 'path' => "$path/theme/tripal_analysis",
  135. ),
  136. 'tripal_analysis_properties' => array(
  137. 'variables' => array('node' => NULL),
  138. 'template' => 'tripal_analysis_properties',
  139. 'path' => "$path/theme/tripal_analysis",
  140. ),
  141. 'tripal_analysis_teaser' => array(
  142. 'variables' => array('node' => NULL),
  143. 'template' => 'tripal_analysis_teaser',
  144. 'path' => "$path/theme/tripal_analysis",
  145. ),
  146. 'tripal_analysis_help' => array(
  147. 'template' => 'tripal_analysis_help',
  148. 'variables' => array(NULL),
  149. 'path' => "$path/theme",
  150. ),
  151. // tripal_feature theme
  152. 'tripal_feature_analyses' => array(
  153. 'template' => 'tripal_feature_analyses',
  154. 'variables' => array('node' => NULL),
  155. 'path' => "$path/theme/tripal_analysis",
  156. ),
  157. );
  158. return $items;
  159. }
  160. /**
  161. * Implements hook_block_info().
  162. *
  163. * @ingroup tripal_analysis
  164. */
  165. function tripal_analysis_block_info() {
  166. $blocks['base']['info'] = t('Tripal Analysis Details');
  167. $blocks['base']['cache'] = DRUPAL_NO_CACHE;
  168. $blocks['featureblast']['info'] = t('Tripal Feature Analyses');
  169. $blocks['featureblast']['cache'] = DRUPAL_NO_CACHE;
  170. return $blocks;
  171. }
  172. /**
  173. * Implements hook_block_view().
  174. *
  175. * @ingroup tripal_analysis
  176. */
  177. function tripal_analysis_block_view($delta = '') {
  178. if (user_access('access chado_analysis content') and arg(0) == 'node' and is_numeric(arg(1))) {
  179. $nid = arg(1);
  180. $node = node_load($nid);
  181. $block = array();
  182. switch ($delta) {
  183. case 'base':
  184. $block['subject'] = t('Analysis Details');
  185. $block['content'] = theme('tripal_analysis_base', $node);
  186. break;
  187. case 'tripal_feature_analyses':
  188. $block['subject'] = t('Feature Analyses');
  189. $block['content'] = theme('tripal_feature_analyses', $node);
  190. break;
  191. default :
  192. }
  193. return $block;
  194. }
  195. }
  196. /**
  197. * Implements hook_views_api().
  198. * Essentially this hook tells drupal that there is views support for
  199. * for this module which then includes tripal_analysis.views.inc where all the
  200. * views integration code is
  201. *
  202. * @ingroup tripal_analysis
  203. */
  204. function tripal_analysis_views_api() {
  205. return array(
  206. 'api' => 3.0,
  207. );
  208. }
  209. /**
  210. * Implementation of hook_form_alter().
  211. *
  212. * @ingroup tripal_analysis
  213. */
  214. function tripal_analysis_form_alter(&$form, &$form_state, $form_id) {
  215. // turn of preview button for insert/updates
  216. if ($form_id == "chado_analysis_node_form") {
  217. $form['actions']['preview']['#access'] = FALSE;
  218. }
  219. }