tripal_cv.module 21 KB

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