tripal_cv.module 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. <?php
  2. require_once "charts.php";
  3. require_once "trees.php";
  4. require_once "obo_loader.php";
  5. require_once "tripal_cv.api.inc";
  6. /*************************************************************************
  7. *
  8. */
  9. function tripal_cv_init(){
  10. // add the tripal_cv JS and CSS
  11. drupal_add_css(drupal_get_path('theme', 'tripal').
  12. '/css/tripal_cv.css');
  13. drupal_add_js(drupal_get_path('theme', 'tripal').'/js/tripal_cv.js');
  14. // add the jsTree JS and CSS
  15. drupal_add_css(drupal_get_path('theme', 'tripal').'/js/jsTree/source/tree_component.css');
  16. drupal_add_js (drupal_get_path('theme', 'tripal').'/js/jsTree/source/_lib.js');
  17. drupal_add_js (drupal_get_path('theme', 'tripal').'/js/jsTree/source/tree_component.js');
  18. }
  19. /*************************************************************************
  20. *
  21. */
  22. function tripal_cv_menu() {
  23. $items = array();
  24. $items['admin/tripal/tripal_cv/cvtermpath'] = array(
  25. 'title' => 'Update Chado cvtermpath tables',
  26. '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',
  27. 'page callback' => 'drupal_get_form',
  28. 'page arguments' => array('tripal_cv_cvtermpath_form'),
  29. 'access arguments' => array('administer site configuration'),
  30. 'type' => MENU_NORMAL_ITEM,
  31. );
  32. $items['admin/tripal/tripal_cv'] = array(
  33. 'title' => 'Controlled Vocabulary Management',
  34. 'description' => 'Manage controlled vocabularies/ontolgoies in Chado ',
  35. 'page callback' => 'tripal_cv_admin_page',
  36. 'access arguments' => array('administer site configuration'),
  37. 'type' => MENU_NORMAL_ITEM,
  38. );
  39. $items['admin/tripal/tripal_cv/new'] = array(
  40. 'title' => 'Add a Controlled Vocabulary',
  41. 'page callback' => 'drupal_get_form',
  42. 'page arguments' => array('tripal_cv_add_form'),
  43. 'access arguments' => array('access administration pages'),
  44. 'type' => MENU_NORMAL_ITEM,
  45. );
  46. $items['admin/tripal/tripal_cv/obo'] = array(
  47. 'title' =>'Add/Update Ontology With OBO File',
  48. 'page callback' => 'drupal_get_form',
  49. 'page arguments' => array('tripal_cv_obo_form'),
  50. 'access arguments' => array('access administration pages'),
  51. 'type' => MENU_NORMAL_ITEM,
  52. );
  53. $items['admin/tripal/tripal_cv/edit/js'] = array(
  54. 'title' => 'Edit Controlled Vocabularies',
  55. 'page callback' => 'tripal_ajax_cv_edit',
  56. 'access arguments' => array('access administration pages'),
  57. 'type' => MENU_CALLBACK,
  58. );
  59. $items['tripal_cv_chart'] = array(
  60. 'path' => 'tripal_cv_chart',
  61. 'title' => t('CV Chart'),
  62. 'page callback' => 'tripal_cv_chart',
  63. 'page arguments' => array(1),
  64. 'access arguments' => array('access content'),
  65. 'type' => MENU_CALLBACK
  66. );
  67. $items['tripal_cv_tree'] = array(
  68. 'path' => 'tripal_cv_tree',
  69. 'title' => t('CV Term Viewer'),
  70. 'page callback' => 'tripal_cv_tree',
  71. 'page arguments' => array(1),
  72. 'access arguments' => array('access content'),
  73. 'type' => MENU_CALLBACK
  74. );
  75. // menu items for working with the CV module tree browser
  76. $items['cv_browser'] = array(
  77. 'title' => t('CV Relationship Browser'),
  78. 'page callback' => 'tripal_cv_show_browser',
  79. 'access arguments' => array('access chado_cv content'),
  80. 'type' => MENU_CALLBACK
  81. );
  82. $items['tripal_cv_init_browser'] = array(
  83. 'path' => 'tripal_cv_init_browser',
  84. 'title' => t('CV Browser'),
  85. 'page callback' => 'tripal_cv_init_browser',
  86. 'page arguments' => array(1),
  87. 'access arguments' => array('access content'),
  88. 'type' => MENU_CALLBACK
  89. );
  90. // menu item for interaction with the tree
  91. $items['tripal_cv_update_tree'] = array(
  92. 'path' => 'tripal_cv_update_tree',
  93. 'title' => t('CV Tree'),
  94. 'page callback' => 'tripal_cv_update_tree',
  95. 'page arguments' => array(2,3),
  96. 'access arguments' => array('access content'),
  97. 'type' => MENU_CALLBACK
  98. );
  99. // menu items for working with terms
  100. $items['tripal_cv_cvterm_info'] = array(
  101. 'path' => 'tripal_cv_cvterm_info',
  102. 'title' => t('CV Term Viewer'),
  103. 'page callback' => 'tripal_cv_cvterm_info',
  104. 'page arguments' => array(1),
  105. 'access arguments' => array('access content'),
  106. 'type' => MENU_CALLBACK
  107. );
  108. $items['tripal_cv_cvterm_edit'] = array(
  109. 'path' => 'tripal_cv_edit',
  110. 'title' => t('CV Term Editor'),
  111. 'page callback' => 'tripal_cv_cvterm_edit',
  112. 'page arguments' => array(1),
  113. 'access arguments' => array('edit chado_cv content'),
  114. 'type' => MENU_CALLBACK
  115. );
  116. return $items;
  117. }
  118. /*******************************************************************************
  119. * The following function proves access control for users trying to
  120. * perform actions on data managed by this module
  121. */
  122. function chado_cv_access($op, $node, $account){
  123. if ($op == 'create') {
  124. return user_access('create chado_cv content', $account);
  125. }
  126. if ($op == 'update') {
  127. if (user_access('edit chado_cv content', $account)) {
  128. return TRUE;
  129. }
  130. }
  131. if ($op == 'delete') {
  132. if (user_access('delete chado_cv content', $account)) {
  133. return TRUE;
  134. }
  135. }
  136. if ($op == 'view') {
  137. if (user_access('access chado_cv content', $account)) {
  138. return TRUE;
  139. }
  140. }
  141. return FALSE;
  142. }
  143. /*******************************************************************************
  144. * Set the permission types that the chado module uses. Essentially we
  145. * want permissionis that protect creation, editing and deleting of chado
  146. * data objects
  147. */
  148. function tripal_cv_perm(){
  149. return array(
  150. 'access chado_cv content',
  151. 'create chado_cv content',
  152. 'delete chado_cv content',
  153. 'edit chado_cv content',
  154. );
  155. }
  156. /*************************************************************************
  157. * Implements hook_views_api()
  158. * Purpose: Essentially this hook tells drupal that there is views support for
  159. * for this module which then includes tripal_cv.views.inc where all the
  160. * views integration code is
  161. */
  162. function tripal_cv_views_api() {
  163. return array('api' => 2.0);
  164. }
  165. /*************************************************************************
  166. *
  167. */
  168. function tripal_cv_admin_page(){
  169. $add_url = url("admin/tripal/tripal_cv/new");
  170. $obo_url = url("admin/tripal/tripal_cv/obo");
  171. $cvtermpath_url = url("admin/tripal/tripal_cv/cvtermpath");
  172. $browser_url = url("cv_browser");
  173. $output = "<a href=\"$add_url\">Add a new controlled vocabulary</a> | ";
  174. $output .= "<a href=\"$browser_url\">Browse a vocabulary</a> | ";
  175. $output .= "<a href=\"$obo_url\">Add/Update Ontology With OBO File</a> | ";
  176. $output .= "<a href=\"$cvtermpath_url\">Update the cvtermpath table</a> ";
  177. $output .= drupal_get_form('tripal_cv_select_form');
  178. $output .= '<div id="db-edit-div">Please select a vocabulary above to view or edit</div>';
  179. return $output;
  180. }
  181. /*************************************************************************
  182. *
  183. */
  184. function tripal_cv_select_form(){
  185. $previous_db = tripal_db_set_active('chado'); // use chado database
  186. // get a list of db from chado for user to choose
  187. $sql = "SELECT * FROM {cv} WHERE NOT name = 'tripal' ORDER BY name ";
  188. $results = db_query ($sql);
  189. tripal_db_set_active($previous_db); // use drupal database
  190. $cvs = array();
  191. $cvs[] = '';
  192. while ($cv = db_fetch_object($results)){
  193. $cvs[$cv->cv_id] = $cv->name;
  194. }
  195. $form['cvid'] = array(
  196. '#title' => t('Controlled Vocabulary/Ontology Name'),
  197. '#type' => 'select',
  198. '#options' => $cvs,
  199. '#ahah' => array(
  200. 'path' => 'admin/tripal/tripal_cv/edit/js',
  201. 'wrapper' => 'db-edit-div',
  202. 'effect' => 'fade',
  203. 'event' => 'change',
  204. 'method' => 'replace',
  205. ),
  206. );
  207. return $form;
  208. }
  209. /*************************************************************************
  210. *
  211. */
  212. function tripal_ajax_cv_edit (){
  213. // get the database id, build the form and then return the JSON object
  214. $cvid = $_POST['cvid'];
  215. $form = drupal_get_form('tripal_cv_edit_form',$cvid);
  216. drupal_json(array('status' => TRUE, 'data' => $form));
  217. }
  218. /*************************************************************************
  219. *
  220. */
  221. function tripal_cv_add_form(&$form_state = NULL){
  222. $form['cvid'] = array(
  223. '#type' => 'hidden',
  224. '#value' => $cvid
  225. );
  226. $form['name']= array(
  227. '#type' => 'textfield',
  228. '#title' => t("Controlled Vocabulary name"),
  229. '#description' => t('Please enter the name for this vocabulary. This field will be ignored if an OBO file or URL is provided above'),
  230. '#required' => FALSE,
  231. '#default_value' => $default_cv,
  232. '#weight' => 1
  233. );
  234. $form['definition']= array(
  235. '#type' => 'textarea',
  236. '#title' => t('Description'),
  237. '#description' => t('Please enter a description for this vocabulary'),
  238. '#default_value' => $default_desc,
  239. '#weight' => 2
  240. );
  241. $form['add'] = array (
  242. '#type' => 'submit',
  243. '#value' => t('Add'),
  244. '#weight' => 5,
  245. '#executes_submit_callback' => TRUE,
  246. );
  247. $form['#redirect'] = 'admin/tripal/tripal_cv';
  248. return $form;
  249. }
  250. /*************************************************************************
  251. *
  252. */
  253. function tripal_cv_obo_form(&$form_state = NULL){
  254. // get a list of db from chado for user to choose
  255. $sql = "SELECT * FROM {tripal_cv_obo} ORDER BY obo_id";
  256. $results = db_query ($sql);
  257. $obos = array();
  258. $obos[] = '';
  259. while ($obo = db_fetch_object($results)){
  260. $obos[$obo->obo_id] = "$obo->name | $obo->path";
  261. }
  262. $form['obo_existing'] = array(
  263. '#type' =>'fieldset',
  264. '#title' => t('Use a Saved Ontology OBO Reference')
  265. );
  266. $form['obo_new'] = array(
  267. '#type' =>'fieldset',
  268. '#title' => t('Use a New Ontology OBO Reference')
  269. );
  270. $form['obo_existing']['existing_instructions']= array(
  271. '#value' => t('The Ontology OBO files listed in the drop down below have been automatically added upon
  272. installation of the Tripal CV module or were added from a previous upload. Select
  273. an OBO, then click the submit button to load the vocabulary into the database. If the
  274. vocabularies already exist then the ontology will be updated.'),
  275. '#weight' => -1
  276. );
  277. $form['obo_existing']['obo_id'] = array(
  278. '#title' => t('Ontology OBO File Reference'),
  279. '#type' => 'select',
  280. '#options' => $obos,
  281. '#weight' => 0
  282. );
  283. $form['obo_new']['path_instructions']= array(
  284. '#value' => t('Provide the name and path for the OBO file. If the vocabulary OBO file
  285. is stored local to the server provide a file name. If the vocabulry is stored remotely,
  286. provide a URL. Only provide a URL or a local file, not both.'),
  287. '#weight' => 0
  288. );
  289. $form['obo_new']['obo_name']= array(
  290. '#type' => 'textfield',
  291. '#title' => t('New Vocabulary Name'),
  292. '#description' => t('Please provide a name for this vocabulary. After upload, this name will appear in the drop down
  293. list above for use again later.'),
  294. '#weight' => 1
  295. );
  296. $form['obo_new']['obo_url']= array(
  297. '#type' => 'textfield',
  298. '#title' => t('Remote URL'),
  299. '#description' => t('Please enter a URL for the online OBO file. The file will be downloaded and parsed.
  300. (e.g. http://www.obofoundry.org/ro/ro.obo'),
  301. '#default_value' => $default_desc,
  302. '#weight' => 2
  303. );
  304. $form['obo_new']['obo_file']= array(
  305. '#type' => 'textfield',
  306. '#title' => t('Local File'),
  307. '#description' => t('Please enter the full system path for an OBO definition file, or a path within the Drupal
  308. installation (e.g. /sites/default/files/xyz.obo). The path must be accessible to the
  309. server on which this Drupal instance is running.'),
  310. '#default_value' => $default_desc,
  311. '#weight' => 3
  312. );
  313. $form['submit'] = array (
  314. '#type' => 'submit',
  315. '#value' => t('Submit'),
  316. '#weight' => 5,
  317. '#executes_submit_callback' => TRUE,
  318. );
  319. $form['#redirect'] = 'admin/tripal/tripal_cv/obo';
  320. return $form;
  321. }
  322. /*************************************************************************
  323. *
  324. */
  325. function tripal_cv_edit_form(&$form_state = NULL,$cvid = NULL){
  326. $sql = "SELECT * FROM {cv} WHERE cv_id = %d ";
  327. $previous_db = tripal_db_set_active('chado');
  328. $cv = db_fetch_object(db_query($sql,$cvid));
  329. tripal_db_set_active($previous_db);
  330. # set the default values. If there is a value set in the
  331. # form_state then let's use that, otherwise, we'll pull
  332. # the values from the database
  333. $default_db = $form_state['values']['name'];
  334. $default_desc = $form_state['values']['description'];
  335. $default_url = $form_state['values']['url'];
  336. $default_urlprefix = $form_state['values']['urlprefix'];
  337. if(!$default_db){
  338. $default_cv = $cv->name;
  339. }
  340. if(!$default_desc){
  341. $default_desc = $cv->definition;
  342. }
  343. $form['cvid'] = array(
  344. '#type' => 'hidden',
  345. '#value' => $cvid
  346. );
  347. $form['name']= array(
  348. '#type' => 'textfield',
  349. '#title' => t("Controlled Vocabulary name"),
  350. '#description' => t('Please enter the name for this vocabulary.'),
  351. '#required' => FALSE,
  352. '#default_value' => $default_cv,
  353. '#weight' => 1
  354. );
  355. $form['definition']= array(
  356. '#type' => 'textarea',
  357. '#title' => t('Description'),
  358. '#description' => t('Please enter a description for this vocabulary'),
  359. '#default_value' => $default_desc,
  360. '#weight' => 2
  361. );
  362. $form['update'] = array (
  363. '#type' => 'submit',
  364. '#value' => t('Update'),
  365. '#weight' => 5,
  366. '#executes_submit_callback' => TRUE,
  367. );
  368. $form['delete'] = array (
  369. '#type' => 'submit',
  370. '#value' => t('Delete'),
  371. '#weight' => 6,
  372. '#executes_submit_callback' => TRUE,
  373. );
  374. $form['#redirect'] = 'admin/tripal/tripal_cv';
  375. return $form;
  376. }
  377. /************************************************************************
  378. *
  379. */
  380. function tripal_cv_edit_form_submit($form, &$form_state){
  381. $name = $form_state['values']['name'];
  382. $desc = $form_state['values']['definition'];
  383. $cvid = $form_state['values']['cvid'];
  384. $op = $form_state['values']['op'];
  385. if(strcmp($op,'Update')==0){
  386. $sql = "
  387. UPDATE {cv} SET
  388. name = '%s',
  389. definition = '%s'
  390. WHERE cv_id = %d
  391. ";
  392. $previous_db = tripal_db_set_active('chado');
  393. $db = db_query($sql,$name,$desc,$cvid);
  394. tripal_db_set_active($previous_db);
  395. if($db){
  396. drupal_set_message("Controlled vocabulary updated");
  397. } else {
  398. drupal_set_message("Failed to update controlled vocabulary.");
  399. }
  400. }
  401. if(strcmp($op,'Delete')==0){
  402. $sql = "
  403. DELETE FROM {cv}
  404. WHERE cv_id = %d
  405. ";
  406. $previous_db = tripal_db_set_active('chado');
  407. $db = db_query($sql,$cvid);
  408. tripal_db_set_active($previous_db);
  409. if($db){
  410. drupal_set_message("Controlled vocabulary deleted");
  411. } else {
  412. drupal_set_message("Failed to delete controlled vocabulary.");
  413. }
  414. }
  415. return '';
  416. }
  417. /************************************************************************
  418. *
  419. */
  420. function tripal_cv_add_form_submit($form, &$form_state){
  421. $name = $form_state['values']['name'];
  422. $desc = $form_state['values']['definition'];
  423. $sql = "
  424. INSERT INTO {cv}
  425. (name,definition)
  426. VALUES
  427. ('%s','%s')
  428. ";
  429. $previous_db = tripal_db_set_active('chado');
  430. $db = db_query($sql,$name,$desc);
  431. tripal_db_set_active($previous_db);
  432. if($db){
  433. drupal_set_message("Controlled vocabulary added");
  434. } else {
  435. drupal_set_message("Failed to add controlled vocabulary.");
  436. }
  437. return '';
  438. }
  439. /************************************************************************
  440. *
  441. */
  442. function tripal_cv_obo_form_submit($form, &$form_state){
  443. global $user;
  444. $obo_id = $form_state['values']['obo_id'];
  445. $obo_name = $form_state['values']['obo_name'];
  446. $obo_url = $form_state['values']['obo_url'];
  447. $obo_file = $form_state['values']['obo_file'];
  448. $sql = "SELECT * FROM {tripal_cv_obo} WHERE obo_id = %d";
  449. $obo = db_fetch_object(db_query($sql,$obo_id));
  450. if($obo_id){
  451. $args = array($obo_id);
  452. tripal_add_job("Load OBO $obo->name",'tripal_cv',
  453. "tripal_cv_load_obo_v1_2_id",$args,$user->uid);
  454. }
  455. else {
  456. if($obo_url){
  457. $args = array($obo_name,$obo_url);
  458. tripal_add_job("Load OBO $obo_name",'tripal_cv',
  459. "tripal_cv_load_obo_v1_2_url",$args,$user->uid);
  460. }
  461. elseif($obo_file){
  462. $args = array($obo_name,$obo_file);
  463. tripal_add_job("Load OBO $obo_name",'tripal_cv',
  464. "tripal_cv_load_obo_v1_2_file",$args,$user->uid);
  465. }
  466. }
  467. return '';
  468. }
  469. /*************************************************************************
  470. *
  471. */
  472. function tripal_cv_cvtermpath_form () {
  473. $previous_db = tripal_db_set_active('chado'); // use chado database
  474. // get a list of db from chado for user to choose
  475. $sql = "SELECT * FROM {cv} WHERE NOT name = 'tripal' ORDER BY name ";
  476. $results = db_query ($sql);
  477. tripal_db_set_active($previous_db); // use drupal database
  478. $cvs = array();
  479. $cvs[] = '';
  480. while ($cv = db_fetch_object($results)){
  481. $cvs[$cv->cv_id] = $cv->name;
  482. }
  483. $form['cvid'] = array(
  484. '#title' => t('Controlled Vocabulary/Ontology Name'),
  485. '#type' => 'select',
  486. '#options' => $cvs,
  487. '#description' => t('Select a controlled vocabulary for which you would like to upate the cvtermpath.'),
  488. );
  489. $form['description'] = array(
  490. '#type' => 'item',
  491. '#value' => t("Submit a job to update chado cvtermpath table."),
  492. '#weight' => 1,
  493. );
  494. $form['button'] = array(
  495. '#type' => 'submit',
  496. '#value' => t('Update cvtermpath'),
  497. '#weight' => 2,
  498. );
  499. return $form;
  500. }
  501. /*************************************************************************
  502. *
  503. */
  504. function tripal_cv_cvtermpath_form_validate($form, &$form_state) {
  505. global $user;
  506. $cvid = $form_state['values']['cvid'];
  507. // first get the controlled vocabulary name:
  508. $previous_db = tripal_db_set_active('chado');
  509. $cv = db_fetch_object(db_query("SELECT * FROM {cv} WHERE cv_id = %d",$cvid));
  510. tripal_db_set_active($previous_db);
  511. // Submit a job to update cvtermpath
  512. $job_args = array($cvid);
  513. if ($form_state['values']['op'] == t('Update cvtermpath')) {
  514. tripal_add_job("Update cvtermpath: $cv->name",'tripal_cv',
  515. 'tripal_cv_update_cvtermpath',$job_args,$user->uid);
  516. }
  517. }
  518. /***********************************************************
  519. * Update the cvtermpath table
  520. */
  521. function tripal_cv_update_cvtermpath($cvid = NULL, $job_id = NULL) {
  522. // first get the controlled vocabulary name:
  523. $previous_db = tripal_db_set_active('chado');
  524. $cv = db_fetch_object(db_query("SELECT * FROM {cv} WHERE cv_id = %d",$cvid));
  525. print "\nUpdating cvtermpath for $cv->name...\n";
  526. // now fill the cvtermpath table
  527. $sql = "SELECT * FROM fill_cvtermpath('%s')";
  528. db_query($sql,$cv->name);
  529. tripal_db_set_active($previous_db);
  530. return;
  531. }
  532. /*******************************************************************************
  533. * We need to let drupal know about our theme functions and their arguments.
  534. * We create theme functions to allow users of the module to customize the
  535. * look and feel of the output generated in this module
  536. */
  537. function tripal_cv_theme () {
  538. return array(
  539. 'tripal_cv_cvterm_edit' => array (
  540. 'arguments' => array('cvterm'),
  541. ),
  542. );
  543. }
  544. /*************************************************************************
  545. */
  546. function tripal_cv_get_cv_id($cv_name){
  547. $sql = "
  548. SELECT cv_id FROM {cv} WHERE name = '%s'
  549. ";
  550. $previous_db = tripal_db_set_active('chado');
  551. $cv = db_fetch_object(db_query($sql,$cv_name));
  552. tripal_db_set_active($previous_db);
  553. return $cv->cv_id;
  554. }
  555. /*************************************************************************
  556. *
  557. */
  558. function tripal_cv_cvterm_edit($cvterm_id){
  559. $sql = "
  560. SELECT CVT.name as cvtermname, CVT.definition, CV.name as cvname
  561. FROM {CVTerm} CVT
  562. INNER JOIN CV on CVT.cv_id = CV.cv_id
  563. WHERE CVT.cvterm_id = %d
  564. ";
  565. $previous_db = tripal_db_set_active('chado');
  566. $cvterm = db_fetch_object(db_query($sql,$cvterm_id));
  567. tripal_db_set_active($previous_db);
  568. return theme('tripal_cv_cvterm_edit',$cvterm);
  569. }
  570. /*************************************************************************
  571. *
  572. */
  573. function theme_tripal_cv_cvterm_edit(&$cvterm){
  574. $output = "
  575. <div id=\"cvterm\">
  576. <table>
  577. <tr><th>Term</th><td>$cvterm->cvtermname</td></tr>
  578. <tr><th>Vocabulary</th><td>$cvterm->cvname</td></tr>
  579. <tr><th>Definition</th><td>$cvterm->definition</td></tr>
  580. </table>
  581. </div>
  582. ";
  583. return $output;
  584. }