tripal_cv.module 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  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. *
  160. */
  161. function tripal_cv_admin_page(){
  162. $add_url = url("admin/tripal/tripal_cv/new");
  163. $obo_url = url("admin/tripal/tripal_cv/obo");
  164. $cvtermpath_url = url("admin/tripal/tripal_cv/cvtermpath");
  165. $browser_url = url("cv_browser");
  166. $output = "<a href=\"$add_url\">Add a new controlled vocabulary</a> | ";
  167. $output .= "<a href=\"$browser_url\">Browse a vocabulary</a> | ";
  168. $output .= "<a href=\"$obo_url\">Add/Update Ontology With OBO File</a> | ";
  169. $output .= "<a href=\"$cvtermpath_url\">Update the cvtermpath table</a> ";
  170. $output .= drupal_get_form('tripal_cv_select_form');
  171. $output .= '<div id="db-edit-div">Please select a vocabulary above to view or edit</div>';
  172. return $output;
  173. }
  174. /*************************************************************************
  175. *
  176. */
  177. function tripal_cv_select_form(){
  178. $previous_db = db_set_active('chado'); // use chado database
  179. // get a list of db from chado for user to choose
  180. $sql = "SELECT * FROM {cv} WHERE NOT name = 'tripal' ORDER BY name ";
  181. $results = db_query ($sql);
  182. db_set_active($previous_db); // use drupal database
  183. $cvs = array();
  184. $cvs[] = '';
  185. while ($cv = db_fetch_object($results)){
  186. $cvs[$cv->cv_id] = $cv->name;
  187. }
  188. $form['cvid'] = array(
  189. '#title' => t('Controlled Vocabulary/Ontology Name'),
  190. '#type' => 'select',
  191. '#options' => $cvs,
  192. '#ahah' => array(
  193. 'path' => 'admin/tripal/tripal_cv/edit/js',
  194. 'wrapper' => 'db-edit-div',
  195. 'effect' => 'fade',
  196. 'event' => 'change',
  197. 'method' => 'replace',
  198. ),
  199. );
  200. return $form;
  201. }
  202. /*************************************************************************
  203. *
  204. */
  205. function tripal_ajax_cv_edit (){
  206. // get the database id, build the form and then return the JSON object
  207. $cvid = $_POST['cvid'];
  208. $form = drupal_get_form('tripal_cv_edit_form',$cvid);
  209. drupal_json(array('status' => TRUE, 'data' => $form));
  210. }
  211. /*************************************************************************
  212. *
  213. */
  214. function tripal_cv_add_form(&$form_state = NULL){
  215. $form['cvid'] = array(
  216. '#type' => 'hidden',
  217. '#value' => $cvid
  218. );
  219. $form['name']= array(
  220. '#type' => 'textfield',
  221. '#title' => t("Controlled Vocabulary name"),
  222. '#description' => t('Please enter the name for this vocabulary. This field will be ignored if an OBO file or URL is provided above'),
  223. '#required' => FALSE,
  224. '#default_value' => $default_cv,
  225. '#weight' => 1
  226. );
  227. $form['definition']= array(
  228. '#type' => 'textarea',
  229. '#title' => t('Description'),
  230. '#description' => t('Please enter a description for this vocabulary'),
  231. '#default_value' => $default_desc,
  232. '#weight' => 2
  233. );
  234. $form['add'] = array (
  235. '#type' => 'submit',
  236. '#value' => t('Add'),
  237. '#weight' => 5,
  238. '#executes_submit_callback' => TRUE,
  239. );
  240. $form['#redirect'] = 'admin/tripal/tripal_cv';
  241. return $form;
  242. }
  243. /*************************************************************************
  244. *
  245. */
  246. function tripal_cv_obo_form(&$form_state = NULL){
  247. // get a list of db from chado for user to choose
  248. $sql = "SELECT * FROM {tripal_cv_obo} ORDER BY obo_id";
  249. $results = db_query ($sql);
  250. $obos = array();
  251. $obos[] = '';
  252. while ($obo = db_fetch_object($results)){
  253. $obos[$obo->obo_id] = "$obo->name | $obo->path";
  254. }
  255. $form['instructions']= array(
  256. '#value' => t('Use this interface to upload a controlled vocabulary in OBO format. A new vocabulary and its
  257. associated terms will be added to the database the first time an OBO is uploaded. Each
  258. subsequent upload will update the terms. The format of the OBO should be in v1.2 format,
  259. however, this loader does support some older styles formats. '),
  260. '#weight' => -2
  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. Note that the name of the
  275. ontology provided here may not match the namespace of the vocabulary. For instance,
  276. the Gene Ontology will add three vocabularies: biological_process, cellular_component, and
  277. molecular_function.'),
  278. '#weight' => -1
  279. );
  280. $form['obo_existing']['obo_id'] = array(
  281. '#title' => t('Ontology OBO File Reference'),
  282. '#type' => 'select',
  283. '#options' => $obos,
  284. '#weight' => 0
  285. );
  286. $form['obo_new']['path_instructions']= array(
  287. '#value' => t('Provide the name and path for the OBO file. If the vocabulary OBO file
  288. is stored local to the server provide a file name. If the vocabulry is stored remotely,
  289. provide a URL. Only provide a URL or a local file, not both.'),
  290. '#weight' => 0
  291. );
  292. $form['obo_new']['obo_name']= array(
  293. '#type' => 'textfield',
  294. '#title' => t('New Vocabulary Name'),
  295. '#description' => t('Please provide a name for this vocabulary. After upload, this name will appear in the drop down
  296. list above for use again later.'),
  297. '#weight' => 1
  298. );
  299. $form['obo_new']['obo_url']= array(
  300. '#type' => 'textfield',
  301. '#title' => t('Remote URL'),
  302. '#description' => t('Please enter a URL for the online OBO file. The file will be downloaded and parsed.
  303. (e.g. http://www.obofoundry.org/ro/ro.obo'),
  304. '#default_value' => $default_desc,
  305. '#weight' => 2
  306. );
  307. $form['obo_new']['obo_file']= array(
  308. '#type' => 'textfield',
  309. '#title' => t('Local File'),
  310. '#description' => t('Please enter the full system path for an OBO definition file, or a path within the Drupal
  311. installation (e.g. /sites/default/files/xyz.obo). The path must be accessible to the
  312. server on which this Drupal instance is running.'),
  313. '#default_value' => $default_desc,
  314. '#weight' => 3
  315. );
  316. $form['submit'] = array (
  317. '#type' => 'submit',
  318. '#value' => t('Submit'),
  319. '#weight' => 5,
  320. '#executes_submit_callback' => TRUE,
  321. );
  322. $form['#redirect'] = 'admin/tripal/tripal_cv/obo';
  323. return $form;
  324. }
  325. /*************************************************************************
  326. *
  327. */
  328. function tripal_cv_edit_form(&$form_state = NULL,$cvid = NULL){
  329. $sql = "SELECT * FROM {cv} WHERE cv_id = %d ";
  330. $previous_db = db_set_active('chado');
  331. $cv = db_fetch_object(db_query($sql,$cvid));
  332. db_set_active($previous_db);
  333. # set the default values. If there is a value set in the
  334. # form_state then let's use that, otherwise, we'll pull
  335. # the values from the database
  336. $default_db = $form_state['values']['name'];
  337. $default_desc = $form_state['values']['description'];
  338. $default_url = $form_state['values']['url'];
  339. $default_urlprefix = $form_state['values']['urlprefix'];
  340. if(!$default_db){
  341. $default_cv = $cv->name;
  342. }
  343. if(!$default_desc){
  344. $default_desc = $cv->definition;
  345. }
  346. $form['cvid'] = array(
  347. '#type' => 'hidden',
  348. '#value' => $cvid
  349. );
  350. $form['name']= array(
  351. '#type' => 'textfield',
  352. '#title' => t("Controlled Vocabulary name"),
  353. '#description' => t('Please enter the name for this vocabulary.'),
  354. '#required' => FALSE,
  355. '#default_value' => $default_cv,
  356. '#weight' => 1
  357. );
  358. $form['definition']= array(
  359. '#type' => 'textarea',
  360. '#title' => t('Description'),
  361. '#description' => t('Please enter a description for this vocabulary'),
  362. '#default_value' => $default_desc,
  363. '#weight' => 2
  364. );
  365. $form['update'] = array (
  366. '#type' => 'submit',
  367. '#value' => t('Update'),
  368. '#weight' => 5,
  369. '#executes_submit_callback' => TRUE,
  370. );
  371. $form['delete'] = array (
  372. '#type' => 'submit',
  373. '#value' => t('Delete'),
  374. '#weight' => 6,
  375. '#executes_submit_callback' => TRUE,
  376. );
  377. $form['#redirect'] = 'admin/tripal/tripal_cv';
  378. return $form;
  379. }
  380. /************************************************************************
  381. *
  382. */
  383. function tripal_cv_edit_form_submit($form, &$form_state){
  384. $name = $form_state['values']['name'];
  385. $desc = $form_state['values']['definition'];
  386. $cvid = $form_state['values']['cvid'];
  387. $op = $form_state['values']['op'];
  388. if(strcmp($op,'Update')==0){
  389. $sql = "
  390. UPDATE {cv} SET
  391. name = '%s',
  392. definition = '%s'
  393. WHERE cv_id = %d
  394. ";
  395. $previous_db = db_set_active('chado');
  396. $db = db_query($sql,$name,$desc,$cvid);
  397. db_set_active($previous_db);
  398. if($db){
  399. drupal_set_message("Controlled vocabulary updated");
  400. } else {
  401. drupal_set_message("Failed to update controlled vocabulary.");
  402. }
  403. }
  404. if(strcmp($op,'Delete')==0){
  405. $sql = "
  406. DELETE FROM {cv}
  407. WHERE cv_id = %d
  408. ";
  409. $previous_db = db_set_active('chado');
  410. $db = db_query($sql,$cvid);
  411. db_set_active($previous_db);
  412. if($db){
  413. drupal_set_message("Controlled vocabulary deleted");
  414. } else {
  415. drupal_set_message("Failed to delete controlled vocabulary.");
  416. }
  417. }
  418. return '';
  419. }
  420. /************************************************************************
  421. *
  422. */
  423. function tripal_cv_add_form_submit($form, &$form_state){
  424. $name = $form_state['values']['name'];
  425. $desc = $form_state['values']['definition'];
  426. $sql = "
  427. INSERT INTO {cv}
  428. (name,definition)
  429. VALUES
  430. ('%s','%s')
  431. ";
  432. $previous_db = db_set_active('chado');
  433. $db = db_query($sql,$name,$desc);
  434. db_set_active($previous_db);
  435. if($db){
  436. drupal_set_message("Controlled vocabulary added");
  437. } else {
  438. drupal_set_message("Failed to add controlled vocabulary.");
  439. }
  440. return '';
  441. }
  442. /************************************************************************
  443. *
  444. */
  445. function tripal_cv_obo_form_submit($form, &$form_state){
  446. global $user;
  447. $obo_id = $form_state['values']['obo_id'];
  448. $obo_name = $form_state['values']['obo_name'];
  449. $obo_url = $form_state['values']['obo_url'];
  450. $obo_file = $form_state['values']['obo_file'];
  451. $sql = "SELECT * FROM {tripal_cv_obo} WHERE obo_id = %d";
  452. $obo = db_fetch_object(db_query($sql,$obo_id));
  453. if($obo_id){
  454. $args = array($obo_id);
  455. tripal_add_job("Load OBO $obo->name",'tripal_cv',
  456. "tripal_cv_load_obo_v1_2_id",$args,$user->uid);
  457. }
  458. else {
  459. if($obo_url){
  460. $args = array($obo_name,$obo_url);
  461. tripal_add_job("Load OBO $obo_name",'tripal_cv',
  462. "tripal_cv_load_obo_v1_2_url",$args,$user->uid);
  463. }
  464. elseif($obo_file){
  465. $args = array($obo_name,$obo_file);
  466. tripal_add_job("Load OBO $obo_name",'tripal_cv',
  467. "tripal_cv_load_obo_v1_2_file",$args,$user->uid);
  468. }
  469. }
  470. return '';
  471. }
  472. /*************************************************************************
  473. *
  474. */
  475. function tripal_cv_cvtermpath_form () {
  476. $previous_db = db_set_active('chado'); // use chado database
  477. // get a list of db from chado for user to choose
  478. $sql = "SELECT * FROM {cv} WHERE NOT name = 'tripal' ORDER BY name ";
  479. $results = db_query ($sql);
  480. db_set_active($previous_db); // use drupal database
  481. $cvs = array();
  482. $cvs[] = '';
  483. while ($cv = db_fetch_object($results)){
  484. $cvs[$cv->cv_id] = $cv->name;
  485. }
  486. $form['cvid'] = array(
  487. '#title' => t('Controlled Vocabulary/Ontology Name'),
  488. '#type' => 'select',
  489. '#options' => $cvs,
  490. '#description' => t('Select a controlled vocabulary for which you would like to upate the cvtermpath.'),
  491. );
  492. $form['description'] = array(
  493. '#type' => 'item',
  494. '#value' => t("Submit a job to update chado cvtermpath table."),
  495. '#weight' => 1,
  496. );
  497. $form['button'] = array(
  498. '#type' => 'submit',
  499. '#value' => t('Update cvtermpath'),
  500. '#weight' => 2,
  501. );
  502. return $form;
  503. }
  504. /*************************************************************************
  505. *
  506. */
  507. function tripal_cv_cvtermpath_form_validate($form, &$form_state) {
  508. global $user;
  509. $cvid = $form_state['values']['cvid'];
  510. // first get the controlled vocabulary name:
  511. $previous_db = db_set_active('chado');
  512. $cv = db_fetch_object(db_query("SELECT * FROM {cv} WHERE cv_id = %d",$cvid));
  513. db_set_active($previous_db);
  514. // Submit a job to update cvtermpath
  515. $job_args = array($cvid);
  516. if ($form_state['values']['op'] == t('Update cvtermpath')) {
  517. tripal_add_job("Update cvtermpath: $cv->name",'tripal_cv',
  518. 'tripal_cv_update_cvtermpath',$job_args,$user->uid);
  519. }
  520. }
  521. /***********************************************************
  522. * Update the cvtermpath table
  523. */
  524. function tripal_cv_update_cvtermpath($cvid = NULL, $job_id = NULL) {
  525. // first get the controlled vocabulary name:
  526. $previous_db = db_set_active('chado');
  527. $cv = db_fetch_object(db_query("SELECT * FROM {cv} WHERE cv_id = %d",$cvid));
  528. print "\nUpdating cvtermpath for $cv->name...\n";
  529. // now fill the cvtermpath table
  530. $sql = "SELECT * FROM fill_cvtermpath('%s')";
  531. db_query($sql,$cv->name);
  532. db_set_active($previous_db);
  533. return;
  534. }
  535. /*******************************************************************************
  536. * We need to let drupal know about our theme functions and their arguments.
  537. * We create theme functions to allow users of the module to customize the
  538. * look and feel of the output generated in this module
  539. */
  540. function tripal_cv_theme () {
  541. return array(
  542. 'tripal_cv_cvterm_edit' => array (
  543. 'arguments' => array('cvterm'),
  544. ),
  545. );
  546. }
  547. /*************************************************************************
  548. */
  549. function tripal_cv_get_cv_id($cv_name){
  550. $sql = "
  551. SELECT cv_id FROM {cv} WHERE name = '%s'
  552. ";
  553. $previous_db = db_set_active('chado');
  554. $cv = db_fetch_object(db_query($sql,$cv_name));
  555. db_set_active($previous_db);
  556. return $cv->cv_id;
  557. }
  558. /*************************************************************************
  559. *
  560. */
  561. function tripal_cv_cvterm_edit($cvterm_id){
  562. $sql = "
  563. SELECT CVT.name as cvtermname, CVT.definition, CV.name as cvname
  564. FROM {CVTerm} CVT
  565. INNER JOIN CV on CVT.cv_id = CV.cv_id
  566. WHERE CVT.cvterm_id = %d
  567. ";
  568. $previous_db = db_set_active('chado');
  569. $cvterm = db_fetch_object(db_query($sql,$cvterm_id));
  570. db_set_active($previous_db);
  571. return theme('tripal_cv_cvterm_edit',$cvterm);
  572. }
  573. /*************************************************************************
  574. *
  575. */
  576. function theme_tripal_cv_cvterm_edit(&$cvterm){
  577. $output = "
  578. <div id=\"cvterm\">
  579. <table>
  580. <tr><th>Term</th><td>$cvterm->cvtermname</td></tr>
  581. <tr><th>Vocabulary</th><td>$cvterm->cvname</td></tr>
  582. <tr><th>Definition</th><td>$cvterm->definition</td></tr>
  583. </table>
  584. </div>
  585. ";
  586. return $output;
  587. }