tripal_analysis.module 6.9 KB

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