tripal_cv.module 7.9 KB

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