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