tripal_cv.module 9.5 KB

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