tripal_analysis.module 6.8 KB

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