tripal_cv.module 8.8 KB

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