tripal_analysis.module 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <?php
  2. /**
  3. * @file
  4. * Contains all the main hook implementations for the tripal_analysis module
  5. *
  6. * @defgroup tripal_analysis Analysis Module
  7. * @ingroup tripal_modules
  8. * @{
  9. * Provides functions for managing chado analysis' including creating details pages for each one
  10. *
  11. * @}
  12. *
  13. *
  14. */
  15. require_once 'api/tripal_analysis.api.inc';
  16. require_once 'includes/tripal_analysis_privacy.inc';
  17. require_once 'includes/tripal_analysis.admin.inc';
  18. require_once 'includes/tripal_analysis.chado_node.inc';
  19. require_once "api/tripal_analysis.schema.api.inc";
  20. /**
  21. * Add tripal javascript to page headers
  22. *
  23. * @ingroup tripal_analysis
  24. */
  25. function tripal_analysis_init() {
  26. drupal_add_js(drupal_get_path('module', 'tripal_analysis') . '/theme/js/tripal_analysis.js');
  27. drupal_add_css(drupal_get_path('module', 'tripal_analysis') . '/theme/css/tripal_analysis.css');
  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 analyses'),
  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 analyses'),
  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 analyses'),
  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. function tripal_analysis_help ($path, $arg) {
  78. if ($path == 'admin/help#tripal_analysis') {
  79. return theme('tripal_analysis_help', array());
  80. }
  81. }
  82. /**
  83. * Set the permission types that the chado module uses. Essentially we
  84. * want permissionis that protect creation, editing and deleting of chado
  85. * data objects
  86. *
  87. * @ingroup tripal_analysis
  88. */
  89. function tripal_analysis_permission() {
  90. return array(
  91. 'access chado_analysis content' => array(
  92. 'title' => t('View Analyses'),
  93. 'description' => t('Allow users to view analysis pages.'),
  94. ),
  95. 'create chado_analysis content' => array(
  96. 'title' => t('Create Analyses'),
  97. 'description' => t('Allow users to create new analysis pages.'),
  98. ),
  99. 'delete chado_analysis content' => array(
  100. 'title' => t('Delete Analyses'),
  101. 'description' => t('Allow users to delete analysis pages.'),
  102. ),
  103. 'edit chado_analysis content' => array(
  104. 'title' => t('Edit Analyses'),
  105. 'description' => t('Allow users to edit analysis pages.'),
  106. ),
  107. 'adminster tripal analysis' => array(
  108. 'title' => t('Administer Analyses'),
  109. 'description' => t('Allow users to administer all analyses.'),
  110. ),
  111. );
  112. }
  113. /**
  114. * We need to let drupal know about our theme functions and their arguments.
  115. * We create theme functions to allow users of the module to customize the
  116. * look and feel of the output generated in this module
  117. *
  118. * @ingroup tripal_analysis
  119. */
  120. function tripal_analysis_theme($existing, $type, $theme, $path) {
  121. $core_path = drupal_get_path('module', 'tripal_core');
  122. $items = array(
  123. 'node__chado_analysis' => array(
  124. 'template' => 'node--chado-generic',
  125. 'render element' => 'node',
  126. 'base hook' => 'node',
  127. 'path' => "$core_path/theme",
  128. ),
  129. 'tripal_analysis_base' => array(
  130. 'variables' => array('node' => NULL),
  131. 'template' => 'tripal_analysis_base',
  132. 'path' => "$path/theme/tripal_analysis",
  133. ),
  134. 'tripal_analysis_properties' => array(
  135. 'variables' => array('node' => NULL),
  136. 'template' => 'tripal_analysis_properties',
  137. 'path' => "$path/theme/tripal_analysis",
  138. ),
  139. 'tripal_analysis_teaser' => array(
  140. 'variables' => array('node' => NULL),
  141. 'template' => 'tripal_analysis_teaser',
  142. 'path' => "$path/theme/tripal_analysis",
  143. ),
  144. 'tripal_analysis_help' => array(
  145. 'template' => 'tripal_analysis_help',
  146. 'variables' => array(NULL),
  147. 'path' => "$path/theme",
  148. ),
  149. // tripal_feature theme
  150. 'tripal_feature_analyses' => array(
  151. 'template' => 'tripal_feature_analyses',
  152. 'variables' => array('node' => NULL),
  153. 'path' => "$path/theme/tripal_analysis",
  154. ),
  155. );
  156. return $items;
  157. }
  158. /**
  159. *
  160. *
  161. * @ingroup tripal_analysis
  162. */
  163. function tripal_analysis_block_info() {
  164. $blocks['base']['info'] = t('Tripal Analysis Details');
  165. $blocks['base']['cache'] = DRUPAL_NO_CACHE;
  166. $blocks['featureblast']['info'] = t('Tripal Feature Analyses');
  167. $blocks['featureblast']['cache'] = DRUPAL_NO_CACHE;
  168. return $blocks;
  169. }
  170. /**
  171. *
  172. *
  173. * @ingroup tripal_analysis
  174. */
  175. function tripal_analysis_block_view($delta = '') {
  176. if (user_access('access chado_analysis content') and arg(0) == 'node' and is_numeric(arg(1))) {
  177. $nid = arg(1);
  178. $node = node_load($nid);
  179. $block = array();
  180. switch ($delta) {
  181. case 'base':
  182. $block['subject'] = t('Analysis Details');
  183. $block['content'] = theme('tripal_analysis_base', $node);
  184. break;
  185. case 'tripal_feature_analyses':
  186. $block['subject'] = t('Feature Analyses');
  187. $block['content'] = theme('tripal_feature_analyses', $node);
  188. break;
  189. default :
  190. }
  191. return $block;
  192. }
  193. }
  194. /**
  195. * Implements hook_views_api()
  196. * Purpose: Essentially this hook tells drupal that there is views support for
  197. * for this module which then includes tripal_analysis.views.inc where all the
  198. * views integration code is
  199. *
  200. * @ingroup tripal_analysis
  201. */
  202. function tripal_analysis_views_api() {
  203. return array(
  204. 'api' => 2.0,
  205. );
  206. }
  207. /**
  208. * Implementation of hook_form_alter()
  209. *
  210. * @param $form
  211. * @param $form_state
  212. * @param $form_id
  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. }