tripal_cv.module 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <?php
  2. require_once "includes/charts.inc";
  3. require_once "includes/trees.inc";
  4. require_once "includes/obo_loader.inc";
  5. require_once "includes/tripal_cv_admin.inc";
  6. require_once "api/tripal_cv.api.inc";
  7. /**
  8. * @defgroup tripal_cv CV Module
  9. * @ingroup tripal_modules
  10. */
  11. /**
  12. * Implements hook_init().
  13. * Adds CSS and JS needed for this modules rendered content
  14. *
  15. * @ingroup tripal_cv
  16. */
  17. function tripal_cv_init() {
  18. // add the tripal_cv JS and CSS
  19. drupal_add_css(drupal_get_path('theme', 'tripal') . '/css/tripal_cv.css');
  20. drupal_add_js(drupal_get_path('theme', 'tripal') . '/js/tripal_cv.js');
  21. // add the jgCharts.js
  22. drupal_add_js(drupal_get_path('theme', 'tripal') . '/js/jgcharts/jgcharts.js');
  23. // add the jsTree JS and CSS
  24. drupal_add_css(drupal_get_path('theme', 'tripal') . '/js/jsTree/source/tree_component.css');
  25. drupal_add_js(drupal_get_path('theme', 'tripal') . '/js/jsTree/source/_lib.js');
  26. drupal_add_js(drupal_get_path('theme', 'tripal') . '/js/jsTree/source/tree_component.js');
  27. }
  28. /**
  29. * Implements hook_menu().
  30. * Registers all menu items associated with this module
  31. *
  32. * @ingroup tripal_cv
  33. */
  34. function tripal_cv_menu() {
  35. $items = array();
  36. $items['admin/tripal/tripal_cv'] = array(
  37. 'title' => 'Vocabularies',
  38. 'description' => 'Basic Description of Tripal CV Module Functionality',
  39. 'page callback' => 'theme',
  40. 'page arguments' => array('tripal_cv_admin'),
  41. 'access arguments' => array('administer controlled vocabularies'),
  42. 'type' => MENU_NORMAL_ITEM,
  43. );
  44. $items['admin/tripal/tripal_cv/obo_loader'] = array(
  45. 'title' => 'Load Ontology',
  46. 'page callback' => 'drupal_get_form',
  47. 'page arguments' => array('tripal_cv_obo_form'),
  48. 'access arguments' => array('administer controlled vocabularies'),
  49. 'type' => MENU_NORMAL_ITEM,
  50. );
  51. $items['admin/tripal/tripal_cv/cvtermpath'] = array(
  52. 'title' => 'Update Chado cvtermpath table',
  53. 'description' => 'The Chado cvtermpath table provides lineage for terms and is useful for quickly finding any ancestor parent of a term. However, this table must be populated. This page allows for populating of this table one vocabulary at a time',
  54. 'page callback' => 'drupal_get_form',
  55. 'page arguments' => array('tripal_cv_cvtermpath_form'),
  56. 'access arguments' => array('administer controlled vocabularies'),
  57. 'type' => MENU_NORMAL_ITEM,
  58. );
  59. /*
  60. * Menu items for adding and editing CVs
  61. */
  62. $items['admin/tripal/tripal_cv/cv/add'] = array(
  63. 'title' => 'Add a Vocabulary',
  64. 'page callback' => 'drupal_get_form',
  65. 'page arguments' => array('tripal_cv_add_form'),
  66. 'access arguments' => array('administer controlled vocabularies'),
  67. 'type' => MENU_NORMAL_ITEM,
  68. );
  69. $items['admin/tripal/tripal_cv/cv/edit'] = array(
  70. 'title' => 'Edit a Vocabulary',
  71. 'description' => 'Edit a controlled vocabularies/ontolgoies in Chado ',
  72. 'page callback' => 'tripal_cv_edit_page',
  73. 'access arguments' => array('administer controlled vocabularies'),
  74. 'type' => MENU_NORMAL_ITEM,
  75. );
  76. $items['admin/tripal/tripal_cv/cv/edit/js'] = array(
  77. 'page callback' => 'tripal_ajax_cv_edit',
  78. 'access arguments' => array('administer controlled vocabularies'),
  79. 'type' => MENU_CALLBACK,
  80. );
  81. /*
  82. * Menu items for adding and editing CV terms
  83. */
  84. $items['admin/tripal/tripal_cv/cvterm/add'] = array(
  85. 'title' => 'Add a Term',
  86. 'description' => 'Manage controlled vocabulary/ontology terms in Chado ',
  87. 'page callback' => 'drupal_get_form',
  88. 'page arguments' => array('tripal_cv_cvterm_form', 'add'),
  89. 'access arguments' => array('administer controlled vocabularies'),
  90. 'type' => MENU_NORMAL_ITEM,
  91. );
  92. $items['admin/tripal/tripal_cv/cvterm/ahah'] = array(
  93. 'page callback' => 'tripal_cv_cvterm_callback',
  94. 'access arguments' => array('administer controlled vocabularies'),
  95. 'type' => MENU_CALLBACK,
  96. );
  97. $items['admin/tripal/tripal_cv/cvterm/auto_name/%/%'] = array(
  98. 'page callback' => 'tripal_cv_cvterm_name_autocomplete',
  99. 'page arguments' => array(5, 6),
  100. 'access arguments' => array('administer controlled vocabularies'),
  101. 'type' => MENU_CALLBACK,
  102. );
  103. $items['admin/tripal/tripal_cv/cvterm/edit'] = array(
  104. 'title' => 'Edit a Term',
  105. 'description' => 'Edit an existing controlled vocabulary/ontology terms in Chado ',
  106. 'page callback' => 'drupal_get_form',
  107. 'page arguments' => array('tripal_cv_cvterm_form', 'edit'),
  108. 'access arguments' => array('administer controlled vocabularies'),
  109. 'type' => MENU_NORMAL_ITEM,
  110. );
  111. /*
  112. * Charts
  113. */
  114. $items['tripal_cv_chart'] = array(
  115. 'path' => 'tripal_cv_chart',
  116. 'page callback' => 'tripal_cv_chart',
  117. 'page arguments' => array(1),
  118. 'access arguments' => array('access content'),
  119. 'type' => MENU_CALLBACK
  120. );
  121. /*
  122. * Menu items for working with CV Trees
  123. */
  124. $items['cv_browser'] = array(
  125. 'page callback' => 'tripal_cv_show_browser',
  126. 'access arguments' => array('access content'),
  127. 'type' => MENU_CALLBACK
  128. );
  129. $items['tripal_cv_tree'] = array(
  130. 'path' => 'tripal_cv_tree',
  131. 'page callback' => 'tripal_cv_tree',
  132. 'page arguments' => array(1),
  133. 'access arguments' => array('access content'),
  134. 'type' => MENU_CALLBACK
  135. );
  136. $items['tripal_cv_init_browser'] = array(
  137. 'path' => 'tripal_cv_init_browser',
  138. 'page callback' => 'tripal_cv_init_browser',
  139. 'page arguments' => array(1),
  140. 'access arguments' => array('access content'),
  141. 'type' => MENU_CALLBACK
  142. );
  143. // menu item for interaction with the tree
  144. $items['tripal_cv_update_tree'] = array(
  145. 'path' => 'tripal_cv_update_tree',
  146. 'page callback' => 'tripal_cv_update_tree',
  147. 'page arguments' => array(2, 3),
  148. 'access arguments' => array('access content'),
  149. 'type' => MENU_CALLBACK
  150. );
  151. // menu items for working with terms
  152. $items['tripal_cv_cvterm_info'] = array(
  153. 'path' => 'tripal_cv_cvterm_info',
  154. 'title' => 'CV Term Viewer',
  155. 'page callback' => 'tripal_cv_cvterm_info',
  156. 'page arguments' => array(1),
  157. 'access arguments' => array('access content'),
  158. 'type' => MENU_CALLBACK
  159. );
  160. return $items;
  161. }
  162. /**
  163. * Set the permission types that the chado module uses. Essentially we
  164. * want permissionis that protect creation, editing and deleting of chado
  165. * data objects
  166. *
  167. * @ingroup tripal_cv
  168. */
  169. function tripal_cv_perm() {
  170. return array(
  171. 'administer controlled vocabularies',
  172. );
  173. }
  174. /**
  175. * Implements hook_views_api()
  176. * Purpose: Essentially this hook tells drupal that there is views support for
  177. * for this module which then includes tripal_cv.views.inc where all the
  178. * views integration code is
  179. *
  180. * @ingroup tripal_cv
  181. */
  182. function tripal_cv_views_api() {
  183. return array('api' => 2.0);
  184. }
  185. /**
  186. * Implements hook_coder_ignore().
  187. * Defines the path to the file (tripal_cv.coder_ignores.txt) where ignore rules for coder are stored
  188. */
  189. function tripal_cv_coder_ignore() {
  190. return array(
  191. 'path' => drupal_get_path('module', 'tripal_cv'),
  192. 'line prefix' => drupal_get_path('module', 'tripal_cv'),
  193. );
  194. }
  195. /*
  196. *
  197. */
  198. function tripal_cv_form_alter(&$form, &$form_state, $form_id) {
  199. if ($form_id == "tripal_cv_cvterm_form") {
  200. // updating the form through the ahah callback sets the action of
  201. // the form to the ahah callback URL. We need to set it back
  202. // to the normal form URL
  203. if ($form_state['values']['form_action'] == 'edit') {
  204. $form['#action'] = url("admin/tripal/tripal_cv/cvterm/edit");
  205. }
  206. else {
  207. $form['#action'] = url("admin/tripal/tripal_cv/cvterm/add");
  208. }
  209. }
  210. }
  211. /**
  212. * We need to let drupal know about our theme functions and their arguments.
  213. * We create theme functions to allow users of the module to customize the
  214. * look and feel of the output generated in this module
  215. *
  216. * @ingroup tripal_db
  217. */
  218. function tripal_cv_theme() {
  219. return array(
  220. 'tripal_cv_admin' => array(
  221. 'template' => 'tripal_cv_admin',
  222. 'arguments' => array(NULL),
  223. 'path' => drupal_get_path('module', 'tripal_cv') . '/theme',
  224. ),
  225. );
  226. }