tripal_cv.module 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <?php
  2. /**
  3. * @file
  4. * Provides functions for managing chado controlled vocabularies which are used ubiquitously
  5. * throughout chado.
  6. */
  7. /**
  8. * @defgroup tripal_cv Controlled Vocabulary Module
  9. * @ingroup tripal_modules
  10. * @{
  11. * Provides functions for managing chado controlled vocabularies which are used ubiquitously
  12. * throughout chado.
  13. * @}
  14. */
  15. require_once 'api/tripal_cv.DEPRECATED.inc';
  16. require_once 'includes/tripal_cv.admin.inc';
  17. require_once 'includes/tripal_cv.cv_form.inc';
  18. require_once 'includes/tripal_cv.cvterm_form.inc';
  19. require_once 'includes/tripal_cv.cvtermpath_form.inc';
  20. /**
  21. * Implements hook_init().
  22. * Adds CSS and JS needed for this modules rendered content
  23. *
  24. * @ingroup tripal_cv
  25. */
  26. function tripal_cv_init() {
  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/vocab'] = array(
  37. 'title' => 'Controlled Vocabularies',
  38. 'description' => 'Controlled Vocabularies control the types available for entities and fields.',
  39. 'page callback' => 'tripal_cv_admin_cv_listing',
  40. 'access arguments' => array('administer controlled vocabularies'),
  41. 'type' => MENU_NORMAL_ITEM,
  42. 'weight' => 2,
  43. );
  44. $items['admin/tripal/vocab/defaults'] = array(
  45. 'title' => 'Defaults',
  46. 'description' => 'Set the default vocabularies for properties and relationships.',
  47. 'page callback' => 'drupal_get_form',
  48. 'page arguments' => array('tripal_cv_admin_set_defaults_form'),
  49. 'access arguments' => array('administer controlled vocabularies'),
  50. 'type' => MENU_LOCAL_TASK,
  51. 'weight' => 5
  52. );
  53. $items['admin/tripal/vocab/help'] = array(
  54. 'title' => 'Help',
  55. 'description' => "A description of the Tripal Controlled Vocabulary module including a short description of it's usage.",
  56. 'page callback' => 'theme',
  57. 'page arguments' => array('tripal_cv_admin'),
  58. 'access arguments' => array('administer controlled vocabularies'),
  59. 'type' => MENU_LOCAL_TASK,
  60. 'weight' => 10
  61. );
  62. // The OBO loader will be available in two places
  63. $items['admin/tripal/vocab/obo_loader'] = array(
  64. 'title' => 'OBO File Loader',
  65. 'description' => 'Load an ontology in OBO format chado as a controlled vocabulary.',
  66. 'page callback' => 'drupal_get_form',
  67. 'page arguments' => array('tripal_cv_obo_form'),
  68. 'access arguments' => array('administer controlled vocabularies'),
  69. 'type' => MENU_CALLBACK,
  70. );
  71. $items['admin/tripal/loaders/obo_loader'] = array(
  72. 'title' => 'OBO File Loader',
  73. 'description' => 'Load an ontology in OBO format into chado as a controlled vocabulary.',
  74. 'page callback' => 'drupal_get_form',
  75. 'page arguments' => array('tripal_cv_obo_form'),
  76. 'access arguments' => array('administer controlled vocabularies'),
  77. 'type' => MENU_NORMAL_ITEM,
  78. );
  79. /*
  80. * Menu for updating the cvtermpath
  81. */
  82. $items['admin/tripal/vocab/cvtermpath'] = array(
  83. 'title' => 'Update Chado cvtermpath table',
  84. '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',
  85. 'page callback' => 'drupal_get_form',
  86. 'page arguments' => array('tripal_cv_cvtermpath_form'),
  87. 'access arguments' => array('administer controlled vocabularies'),
  88. 'type' => MENU_CALLBACK,
  89. );
  90. /*
  91. * Menu items for adding and editing CVs
  92. */
  93. $items['admin/tripal/vocab/cv/edit/%'] = array(
  94. 'title' => 'Edit a Controlled Vocabulary',
  95. 'description' => 'Edit the details such as name and description for an existing controlled vocabulary.',
  96. 'page callback' => 'drupal_get_form',
  97. 'page arguments' => array('tripal_cv_cv_edit_form', 6),
  98. 'access callback' => 'user_access',
  99. 'access arguments' => array('administer controlled vocabularies'),
  100. 'type' => MENU_CALLBACK,
  101. );
  102. $items['admin/tripal/vocab/cv/add'] = array(
  103. 'title' => 'Add a Controlled Vocabulary',
  104. 'description' => 'Manually a new controlled vocabulary.',
  105. 'page callback' => 'drupal_get_form',
  106. 'page arguments' => array('tripal_cv_cv_add_form'),
  107. 'access callback' => 'user_access',
  108. 'access arguments' => array('administer controlled vocabularies'),
  109. 'type' => MENU_CALLBACK,
  110. );
  111. /*
  112. * Menu items for adding and editing CVterms
  113. */
  114. $items['admin/tripal/vocab/cv/%/cvterm/add'] = array(
  115. 'title' => 'Add a Controlled Vocabulary Term',
  116. 'description' => 'Add a new controlled vocabulary term.',
  117. 'page callback' => 'drupal_get_form',
  118. 'page arguments' => array('tripal_cv_cvterm_add_form',5),
  119. 'access arguments' => array('administer controlled vocabularies'),
  120. 'type' => MENU_CALLBACK,
  121. );
  122. $items['admin/tripal/vocab/cvterm/add'] = array(
  123. 'title' => 'Add a Controlled Vocabulary Term',
  124. 'description' => 'Add a new controlled vocabulary term.',
  125. 'page callback' => 'drupal_get_form',
  126. 'page arguments' => array('tripal_cv_cvterm_add_form'),
  127. 'access arguments' => array('administer controlled vocabularies'),
  128. 'type' => MENU_CALLBACK,
  129. );
  130. $items['admin/tripal/vocab/cv/%/cvterm/edit/%'] = array(
  131. 'title' => 'Edit a Controlled Vocabulary Term',
  132. 'description' => 'Edit an existing controlled vocabulary term.',
  133. 'page callback' => 'drupal_get_form',
  134. 'page arguments' => array('tripal_cv_cvterm_edit_form',5,8),
  135. 'access arguments' => array('administer controlled vocabularies'),
  136. 'type' => MENU_CALLBACK,
  137. );
  138. $items['admin/tripal/vocab/cvterm/auto_name/%/%'] = array(
  139. 'page callback' => 'tripal_cv_cvterm_name_autocomplete',
  140. 'page arguments' => array(6, 7),
  141. 'access arguments' => array('administer controlled vocabularies'),
  142. 'type' => MENU_CALLBACK,
  143. );
  144. /*
  145. * Menu items for enabling views
  146. */
  147. $items['admin/tripal/vocab/views/cvs/enable'] = array(
  148. 'title' => 'Enable Vocabulary Administrative View',
  149. 'page callback' => 'tripal_enable_view',
  150. 'page arguments' => array('tripal_cv_admin_cvs', 'admin/tripal/vocab'),
  151. 'access arguments' => array('administer controlled vocabularies'),
  152. 'type' => MENU_CALLBACK,
  153. );
  154. $items['admin/tripal/vocab/views/cvterms/enable'] = array(
  155. 'title' => 'Enable Vocabulary Terms Administrative View',
  156. 'page callback' => 'tripal_enable_view',
  157. 'page arguments' => array('tripal_cv_admin_cvterms', 'admin/tripal/vocab'),
  158. 'access arguments' => array('administer controlled vocabularies'),
  159. 'type' => MENU_CALLBACK,
  160. );
  161. /*
  162. * Charts
  163. */
  164. $items['tripal_cv_chart'] = array(
  165. 'path' => 'tripal_cv_chart',
  166. 'page callback' => 'tripal_cv_chart',
  167. 'page arguments' => array(1),
  168. 'access arguments' => array('access content'),
  169. 'type' => MENU_CALLBACK
  170. );
  171. /*
  172. * Menu items for working with CV Trees
  173. */
  174. $items['cv_browser'] = array(
  175. 'page callback' => 'tripal_cv_show_browser',
  176. 'access arguments' => array('access content'),
  177. 'type' => MENU_CALLBACK
  178. );
  179. $items['tripal_cv_tree'] = array(
  180. 'path' => 'tripal_cv_tree',
  181. 'page callback' => 'tripal_cv_tree',
  182. 'page arguments' => array(1),
  183. 'access arguments' => array('access content'),
  184. 'type' => MENU_CALLBACK
  185. );
  186. $items['tripal_cv_init_browser'] = array(
  187. 'path' => 'tripal_cv_init_browser',
  188. 'page callback' => 'tripal_cv_init_browser',
  189. 'page arguments' => array(1),
  190. 'access arguments' => array('access content'),
  191. 'type' => MENU_CALLBACK
  192. );
  193. // menu item for interaction with the tree
  194. $items['tripal_cv_update_tree'] = array(
  195. 'path' => 'tripal_cv_update_tree',
  196. 'page callback' => 'tripal_cv_update_tree',
  197. 'page arguments' => array(2, 3),
  198. 'access arguments' => array('access content'),
  199. 'type' => MENU_CALLBACK
  200. );
  201. // menu items for working with terms
  202. $items['tripal_cv_cvterm_info'] = array(
  203. 'path' => 'tripal_cv_cvterm_info',
  204. 'title' => 'CV Term Viewer',
  205. 'page callback' => 'tripal_cv_cvterm_info',
  206. 'page arguments' => array(1),
  207. 'access arguments' => array('access content'),
  208. 'type' => MENU_CALLBACK
  209. );
  210. return $items;
  211. }
  212. /**
  213. * Implements hook_help().
  214. * Adds a help page to the module list
  215. */
  216. function tripal_cv_help ($path, $arg) {
  217. if ($path == 'admin/help#tripal_cv') {
  218. return theme('tripal_cv_help', array());
  219. }
  220. }
  221. /**
  222. * Implements hook_permission().
  223. *
  224. * Set the permission types that the chado module uses. Essentially we
  225. * want permissionis that protect creation, editing and deleting of chado
  226. * data objects
  227. *
  228. * @ingroup tripal_cv
  229. */
  230. function tripal_cv_permission() {
  231. return array(
  232. );
  233. }
  234. /**
  235. * Implements hook_views_api().
  236. * Essentially this hook tells drupal that there is views support for
  237. * for this module which then includes tripal_cv.views.inc where all the
  238. * views integration code is
  239. *
  240. * @ingroup tripal_cv
  241. */
  242. function tripal_cv_views_api() {
  243. return array('api' => 3.0);
  244. }
  245. /**
  246. * Implements hook_coder_ignore().
  247. * Defines the path to the file (tripal_cv.coder_ignores.txt) where ignore rules for coder are stored
  248. *
  249. * @ingroup tripal_cv
  250. */
  251. function tripal_cv_coder_ignore() {
  252. return array(
  253. 'path' => drupal_get_path('module', 'tripal_cv'),
  254. 'line prefix' => drupal_get_path('module', 'tripal_cv'),
  255. );
  256. }
  257. /**
  258. * Implements hook_form_alter().
  259. * Alter Forms
  260. *
  261. * @ingroup tripal_cv
  262. */
  263. function tripal_cv_form_alter(&$form, &$form_state, $form_id) {
  264. if ($form_id == "tripal_cv_cvterm_form") {
  265. // updating the form through the ahah callback sets the action of
  266. // the form to the ahah callback URL. We need to set it back
  267. // to the normal form URL
  268. if ($form_state['values']['form_action'] == 'edit') {
  269. $form['#action'] = url("admin/tripal/tripal_cv/cvterm/edit");
  270. }
  271. else {
  272. $form['#action'] = url("admin/tripal/tripal_cv/cvterm/add");
  273. }
  274. }
  275. }
  276. /**
  277. * Implements hook_theme().
  278. * We need to let drupal know about our theme functions and their arguments.
  279. * We create theme functions to allow users of the module to customize the
  280. * look and feel of the output generated in this module
  281. *
  282. * @ingroup tripal_cv
  283. */
  284. function tripal_cv_theme($existing, $type, $theme, $path) {
  285. $items = array(
  286. 'tripal_cv_help' => array(
  287. 'template' => 'tripal_cv_help',
  288. 'variables' => array(NULL),
  289. 'path' => "$path/theme/templates"
  290. ),
  291. // Default CV form
  292. 'tripal_cv_admin_set_defaults_form' => array(
  293. 'function' => 'theme_tripal_cv_admin_set_defaults_form',
  294. 'render element' => 'element',
  295. ),
  296. );
  297. return $items;
  298. }