tripal_analysis.form.inc 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <?php
  2. /**
  3. * When editing or creating a new node of type 'chado_analysis' we need
  4. * a form. This function creates the form that will be used for this.
  5. *
  6. * @ingroup tripal_analysis
  7. */
  8. function chado_analysis_form(&$node, $form_state) {
  9. tripal_core_ahah_init_form();
  10. $form = array();
  11. $analysis = $node->analysis;
  12. // add in the description column. It is a text field and may not be included
  13. // if the text is too big.
  14. $analysis = tripal_core_expand_chado_vars($analysis, 'field', 'analysis.description');
  15. // get form defaults
  16. $analysis_id = $node->analysis_id;
  17. if (!$analysis_id) {
  18. $analysis_id = $analysis->analysis_id;
  19. }
  20. $analysisname = $node->analysisname;
  21. if (!$analysisname) {
  22. $analysisname = $analysis->name;
  23. }
  24. $program = $node->program;
  25. if (!$program) {
  26. $program = $analysis->program;
  27. }
  28. $programversion = $node->programversion;
  29. if (!$programversion) {
  30. $programversion = $analysis->programversion;
  31. }
  32. $algorithm = $node->algorithm;
  33. if (!$algorithm) {
  34. $algorithm = $analysis->algorithm;
  35. }
  36. $sourcename = $node->sourcename;
  37. if (!$sourcename) {
  38. $sourcename = $analysis->sourcename;
  39. }
  40. $sourceversion = $node->sourceversion;
  41. if (!$sourceversion) {
  42. $sourceversion = $analysis->sourceversion;
  43. }
  44. $sourceuri = $node->sourceuri;
  45. if (!$sourceuri) {
  46. $sourceuri = $analysis->sourceuri;
  47. }
  48. $timeexecuted = $node->timeexecuted;
  49. if (!$timeexecuted) {
  50. $timeexecuted = $analysis->timeexecuted;
  51. }
  52. $description = $node->description;
  53. if (!$description) {
  54. $description = $analysis->description;
  55. }
  56. // on AHAH callbacks we want to keep a list of all the properties that have been removed
  57. // we'll store this info in a hidden field and retrieve it here
  58. $d_removed = $form_state['values']['removed'];
  59. // get the number of new fields that have been aded via AHAH callbacks
  60. $num_new = $form_state['values']['num_new'] ? $form_state['values']['num_new'] : 0;
  61. // initialze default properties array. This is where we store the property defaults
  62. $d_properties = array();
  63. $form['title']= array(
  64. '#type' => 'hidden',
  65. '#default_value' => $node->title,
  66. );
  67. $form['analysis_id']= array(
  68. '#type' => 'hidden',
  69. '#default_value' => $analysis_id,
  70. );
  71. $form['analysisname']= array(
  72. '#type' => 'textfield',
  73. '#title' => t('Analysis Name'),
  74. '#required' => TRUE,
  75. '#default_value' => $analysisname,
  76. '#description' => t("This should be a brief name that
  77. describes the analysis succintly. This name will helps the user find analyses."),
  78. );
  79. $form['program']= array(
  80. '#type' => 'textfield',
  81. '#title' => t('Program'),
  82. '#required' => TRUE,
  83. '#default_value' => $program,
  84. '#description' => t("Program name, e.g. blastx, blastp, sim4, genscan."),
  85. );
  86. $form['programversion']= array(
  87. '#type' => 'textfield',
  88. '#title' => t('Program Version'),
  89. '#required' => TRUE,
  90. '#default_value' => $programversion,
  91. '#description' => t("Version description, e.g. TBLASTX 2.0MP-WashU [09-Nov-2000]. Enter 'n/a' if no version is available."),
  92. );
  93. $form['algorithm']= array(
  94. '#type' => 'textfield',
  95. '#title' => t('Algorithm'),
  96. '#required' => FALSE,
  97. '#default_value' => $algorithm,
  98. '#description' => t("Algorithm name, e.g. blast."),
  99. );
  100. $form['sourcename']= array(
  101. '#type' => 'textfield',
  102. '#title' => t('Source Name'),
  103. '#required' => TRUE,
  104. '#default_value' => $sourcename,
  105. '#description' => t('The name of the source data. This could be a file name, data set name or a
  106. small description for how the data was collected. For long descriptions use the description field below'),
  107. );
  108. $form['sourceversion']= array(
  109. '#type' => 'textfield',
  110. '#title' => t('Source Version'),
  111. '#required' => FALSE,
  112. '#default_value' => $sourceversion,
  113. '#description' => t('If the source dataset has a version, include it here'),
  114. );
  115. $form['sourceuri']= array(
  116. '#type' => 'textfield',
  117. '#title' => t('Source URI'),
  118. '#required' => FALSE,
  119. '#default_value' => $sourceuri,
  120. '#description' => t("This is a permanent URL or URI for the source of the analysis.
  121. Someone could recreate the analysis directly by going to this URI and
  122. fetching the source data (e.g. the blast database, or the training model)."),
  123. );
  124. // Get time saved in chado
  125. $default_time = $timeexecuted;
  126. $year = preg_replace("/^(\d+)-\d+-\d+ .*/", "$1", $default_time);
  127. $month = preg_replace("/^\d+-0?(\d+)-\d+ .*/", "$1", $default_time);
  128. $day = preg_replace("/^\d+-\d+-0?(\d+) .*/", "$1", $default_time);
  129. // If the time is not set, use current time
  130. if (!$default_time) {
  131. $default_time = time();
  132. $year = format_date($default_time, 'custom', 'Y');
  133. $month = format_date($default_time, 'custom', 'n');
  134. $day = format_date($default_time, 'custom', 'j');
  135. }
  136. $form['timeexecuted']= array(
  137. '#type' => 'date',
  138. '#title' => t('Time Executed'),
  139. '#required' => TRUE,
  140. '#default_value' => array(
  141. 'year' => $year,
  142. 'month' => $month,
  143. 'day' => $day,
  144. ),
  145. );
  146. $form['description']= array(
  147. '#type' => 'textarea',
  148. '#rows' => 15,
  149. '#title' => t('Materials & Methods (Description and/or Program Settings)'),
  150. '#required' => FALSE,
  151. '#default_value' => $description,
  152. '#description' => t('Please provide all necessary information to allow
  153. someone to recreate the analysis, including materials and methods
  154. for collection of the source data and performing the analysis'),
  155. );
  156. // get the analysis properties
  157. $properties_select = array();
  158. $properties_select[] = 'Select a Property';
  159. $properties_list = array();
  160. $sql = "
  161. SELECT DISTINCT CVT.cvterm_id, CVT.name, CVT.definition
  162. FROM {cvterm} CVT
  163. INNER JOIN {cv} ON CVT.cv_id = CV.cv_id
  164. WHERE
  165. CV.name = 'analysis_property' AND
  166. NOT CVT.is_obsolete = 1
  167. ORDER BY CVT.name ASC
  168. ";
  169. $prop_types = chado_query($sql);
  170. while ($prop = db_fetch_object($prop_types)) {
  171. $properties_select[$prop->cvterm_id] = $prop->name;
  172. $properties_list[$prop->cvterm_id] = $prop;
  173. }
  174. // add in the properties from the analysisprop table
  175. $num_properties += chado_analysis_node_form_add_analysisprop_table_props($form, $form_state, $analysis_id, $d_properties, $d_removed);
  176. // add in any new properties that have been added by the user through an AHAH callback
  177. $num_new = chado_analysis_node_form_add_new_props($form, $form_state, $d_properties, $d_removed);
  178. // add an empty row of field to allow for addition of a new property
  179. chado_analysis_node_form_add_new_empty_props($form, $properties_select);
  180. return $form;
  181. }
  182. /**
  183. * Validates the user input before creating an analysis node
  184. *
  185. * @ingroup tripal_analysis
  186. */
  187. function chado_analysis_validate($node, &$form) {
  188. // use the analysis parent to validate the node
  189. tripal_analysis_validate($node, $form);
  190. }
  191. /**
  192. * This validation is being used for three activities:
  193. * CASE A: Update a node that exists in both drupal and chado
  194. * CASE B: Synchronizing a node from chado to drupal
  195. * CASE C: Inserting a new node that exists in niether drupal nor chado
  196. *
  197. * @ingroup tripal_analysis
  198. */
  199. function tripal_analysis_validate($node, &$form) {
  200. // Only nodes being updated will have an nid already
  201. if (!is_null($node->nid)) {
  202. // CASE A: We are validating a form for updating an existing node
  203. // get the existing node
  204. $values = array('analysis_id' => $node->analysis_id);
  205. $result = tripal_core_chado_select('analysis', array('*'), $values);
  206. $analysis = $result[0];
  207. // if the name has changed make sure it doesn't conflict with an existing name
  208. if($analysis->name != $node->analysisname) {
  209. $values = array('name' => $node->analysisname);
  210. $result = tripal_core_chado_select('analysis', array('analysis_id'), $values);
  211. if($result and count($result) > 0) {
  212. form_set_error('analysisname', 'Cannot update the analysis with this analysis name. An analysis with this name already exists.');
  213. return;
  214. }
  215. }
  216. // if the unique constraint has changed check to make sure it doesn't conflict with an
  217. // existing record
  218. if($analysis->program != $node->program or $analysis->programversion != $node->programversion or
  219. $analysis->sourcename != $node->sourcename) {
  220. $values = array(
  221. 'program' => $node->program,
  222. 'programversion' => $node->programversion,
  223. 'sourcename' => $node->sourcename,
  224. );
  225. $result = tripal_core_chado_select('analysis', array('analysis_id'), $values);
  226. if ($result and count($result) > 0) {
  227. if ($analysis->program != $node->program) {
  228. $field = 'program';
  229. }
  230. if ($analysis->programversion != $node->programversion) {
  231. $field = 'programversion';
  232. }
  233. if ($analysis->sourcename != $node->sourcename) {
  234. $field = 'sourcename';
  235. }
  236. form_set_error($field, 'Cannot update the analysis with this program,
  237. program version and source name. An analysis with these values already exists.');
  238. return;
  239. }
  240. }
  241. }
  242. else{
  243. // To differentiate if we are syncing or creating a new analysis altogther, see if an
  244. // analysis_id already exists
  245. if ($node->analysis_id and $node->analysis_id != 0) {
  246. // CASE B: Synchronizing a node from chado to drupal
  247. // we don't need to do anything.
  248. }
  249. else {
  250. // CASE C: We are validating a form for inserting a new node
  251. // The unique constraint for the chado analysis table is: program, programversion, sourcename
  252. $values = array(
  253. 'program' => $node->program,
  254. 'programversion' => $node->programversion,
  255. 'sourcename' => $node->sourcename,
  256. );
  257. $analysis = tripal_core_chado_select('analysis', array('analysis_id'), $values);
  258. if ($analysis and count($analysis) > 0) {
  259. form_set_error('program', 'Cannot add the analysis with this program,
  260. program version and source name. An analysis with these values already exists.');
  261. return;
  262. }
  263. // make sure we have a unique analysis name. This is not a requirement
  264. // for the analysis table but we use the analysis name for the Drupal node
  265. // title, so it should be unique
  266. $values = array('name' => $node->analysisname);
  267. $result = tripal_core_chado_select('analysis', array('analysis_id'), $values);
  268. if($result and count($result) > 0) {
  269. form_set_error('analysisname', 'Cannot add the analysis with this analysis name. An analysis with this name already exists.');
  270. return;
  271. }
  272. }
  273. }
  274. }
  275. /*
  276. *
  277. */
  278. function chado_analysis_node_form_add_new_empty_props(&$form, $properties_select) {
  279. // add one more blank set of property fields
  280. $form['properties']['new']["new_id"] = array(
  281. '#type' => 'select',
  282. '#options' => $properties_select,
  283. '#ahah' => array(
  284. 'path' => "tripal_analysis/properties/description",
  285. 'wrapper' => 'tripal-analysis-new_value-desc',
  286. 'event' => 'change',
  287. 'method' => 'replace',
  288. ),
  289. );
  290. $form['properties']['new']["new_value"] = array(
  291. '#type' => 'textarea',
  292. '#default_value' => '',
  293. '#cols' => 5,
  294. '#rows' => $rows,
  295. '#description' => '<div id="tripal-analysis-new_value-desc"></div>'
  296. );
  297. $form['properties']['new']["add"] = array(
  298. '#type' => 'image_button',
  299. '#value' => t('Add'),
  300. '#src' => drupal_get_path('theme', 'tripal') . '/images/add.png',
  301. '#ahah' => array(
  302. 'path' => "tripal_analysis/properties/add",
  303. 'wrapper' => 'tripal-analysis-edit-properties-table',
  304. 'event' => 'click',
  305. 'method' => 'replace',
  306. ),
  307. '#attributes' => array('onClick' => 'return false;'),
  308. );
  309. }
  310. /*
  311. *
  312. */
  313. function chado_analysis_node_form_add_new_props(&$form, $form_state, &$d_properties, &$d_removed) {
  314. // first, add in all of the new properties that were added through a previous AHAH callback
  315. $j = 0;
  316. $num_properties++;
  317. // we need to find the
  318. if ($form_state['values']) {
  319. foreach ($form_state['values'] as $element_name => $value) {
  320. if (preg_match('/new_value-(\d+)-(\d+)/', $element_name, $matches)) {
  321. $new_id = $matches[1];
  322. $rank = $matches[2];
  323. // skip any properties that the user requested to delete through a previous
  324. // AHAH callback or through the current AHAH callback
  325. if($d_removed["$new_id-$rank"]) {
  326. continue;
  327. }
  328. if($form_state['post']['remove-' . $new_id . '-' . $rank]) {
  329. $d_removed["$new_id-$rank"] = 1;
  330. continue;
  331. }
  332. // get this new_id information
  333. $cvterm = tripal_core_chado_select('cvterm', array('name', 'definition'), array('cvterm_id' => $new_id));
  334. // add it to the $d_properties array
  335. $d_properties[$new_id][$rank]['name'] = $cvterm->name;
  336. $d_properties[$new_id][$rank]['id'] = $new_id;
  337. $d_properties[$new_id][$rank]['value'] = $value;
  338. $d_properties[$new_id][$rank]['definition'] = $cvterm->definition;
  339. $num_properties++;
  340. // determine how many rows we need in the textarea
  341. $rows = 1;
  342. // add the new fields
  343. $form['properties']['new'][$new_id][$rank]["new_id-$new_id-$rank"] = array(
  344. '#type' => 'item',
  345. '#value' => $cvterm[0]->name
  346. );
  347. $form['properties']['new'][$new_id][$rank]["new_value-$new_id-$rank"] = array(
  348. '#type' => 'textarea',
  349. '#default_value' => $value,
  350. '#cols' => 50,
  351. '#rows' => $rows,
  352. '#description' => $cvterm->definition,
  353. );
  354. $form['properties']['new'][$new_id][$rank]["remove-$new_id-$rank"] = array(
  355. '#type' => 'image_button',
  356. '#value' => t('Remove'),
  357. '#src' => drupal_get_path('theme', 'tripal') . '/images/minus.png',
  358. '#ahah' => array(
  359. 'path' => "tripal_analysis/properties/minus/$new_id/$rank",
  360. 'wrapper' => 'tripal-analysis-edit-properties-table',
  361. 'event' => 'click',
  362. 'method' => 'replace',
  363. ),
  364. '#attributes' => array('onClick' => 'return false;'),
  365. );
  366. }
  367. }
  368. }
  369. // second add in any new properties added during this callback
  370. if($form_state['post']['add']) {
  371. $new_id = $form_state['values']['new_id'];
  372. $new_value = $form_state['values']['new_value'];
  373. // get the rank by counting the number of entries
  374. $rank = count($d_properties[$new_id]);
  375. // get this new_id information
  376. $cvterm = tripal_core_chado_select('cvterm', array('name', 'definition'), array('cvterm_id' => $new_id));
  377. // add it to the $d_properties array
  378. $d_properties[$new_id][$rank]['name'] = $cvterm->name;
  379. $d_properties[$new_id][$rank]['id'] = $new_id;
  380. $d_properties[$new_id][$rank]['value'] = $value;
  381. $d_properties[$new_id][$rank]['definition'] = $cvterm->definition;
  382. $num_properties++;
  383. // determine how many rows we need in the textarea
  384. $rows = 1;
  385. // add the new fields
  386. $form['properties']['new'][$new_id][$rank]["new_id-$new_id-$rank"] = array(
  387. '#type' => 'item',
  388. '#value' => $cvterm[0]->name
  389. );
  390. $form['properties']['new'][$new_id][$rank]["new_value-$new_id-$rank"] = array(
  391. '#type' => 'textarea',
  392. '#default_value' => $new_value,
  393. '#cols' => 50,
  394. '#rows' => $rows,
  395. '#description' => $cvterm->definition,
  396. );
  397. $form['properties']['new'][$new_id][$rank]["remove-$new_id-$rank"] = array(
  398. '#type' => 'image_button',
  399. '#value' => t('Remove'),
  400. '#src' => drupal_get_path('theme', 'tripal') . '/images/minus.png',
  401. '#ahah' => array(
  402. 'path' => "tripal_analysis/properties/minus/$new_id/$rank",
  403. 'wrapper' => 'tripal-analysis-edit-properties-table',
  404. 'event' => 'click',
  405. 'method' => 'replace',
  406. ),
  407. '#attributes' => array('onClick' => 'return false;'),
  408. );
  409. }
  410. return $num_properties;
  411. }
  412. /*
  413. *
  414. */
  415. function chado_analysis_node_form_add_analysisprop_table_props(&$form, $form_state, $analysis_id, &$d_properties, &$d_removed) {
  416. // get the properties for this analysis
  417. $num_properties = 0;
  418. if(!$analysis_id) {
  419. return $num_properties;
  420. }
  421. $sql = "
  422. SELECT CVT.cvterm_id, CVT.name, CVT.definition, PP.value, PP.rank
  423. FROM {analysisprop} PP
  424. INNER JOIN {cvterm} CVT on CVT.cvterm_id = PP.type_id
  425. WHERE PP.analysis_id = %d
  426. ORDER BY CVT.name, PP.rank
  427. ";
  428. $analysis_props = chado_query($sql, $analysis_id);
  429. while ($prop = db_fetch_object($analysis_props)) {
  430. $type_id = $prop->cvterm_id;
  431. $rank = count($d_properties[$type_id]);
  432. // skip any properties that the user requested to delete through a previous
  433. // AHAH callback or through the current AHAH callback
  434. if($d_removed["$type_id-$rank"]) {
  435. continue;
  436. }
  437. if($form_state['post']['remove-' . $type_id . '-' . $rank]) {
  438. $d_removed["$type_id-$rank"] = 1;
  439. continue;
  440. }
  441. $d_properties[$type_id][$rank]['name'] = $prop->name;
  442. $d_properties[$type_id][$rank]['id'] = $type_id;
  443. $d_properties[$type_id][$rank]['value'] = $prop->value;
  444. $d_properties[$type_id][$rank]['definition'] = $prop->definition;
  445. $num_properties++;
  446. $form['properties'][$type_id][$rank]["prop_id-$type_id-$rank"] = array(
  447. '#type' => 'item',
  448. '#value' => $prop->name,
  449. );
  450. $form['properties'][$type_id][$rank]["prop_value-$type_id-$rank"] = array(
  451. '#type' => 'textarea',
  452. '#default_value' => $prop->value,
  453. '#cols' => 50,
  454. '#rows' => $rows,
  455. '#description' => $prop->definition,
  456. );
  457. $form['properties'][$type_id][$rank]["remove-$type_id-$rank"] = array(
  458. '#type' => 'image_button',
  459. '#value' => t('Remove'),
  460. '#src' => drupal_get_path('theme', 'tripal') . '/images/minus.png',
  461. '#ahah' => array(
  462. 'path' => "tripal_analysis/properties/minus/$type_id/$rank",
  463. 'wrapper' => 'tripal-analysis-edit-properties-table',
  464. 'event' => 'click',
  465. 'method' => 'replace',
  466. ),
  467. '#attributes' => array('onClick' => 'return false;'),
  468. );
  469. }
  470. return $num_properties;
  471. }
  472. /*
  473. *
  474. */
  475. function tripal_analysis_theme_node_form_properties($form) {
  476. $rows = array();
  477. if ($form['properties']) {
  478. // first add in the properties derived from the analysisprop table
  479. // the array tree for these properties looks like this:
  480. // $form['properties'][$type_id][$rank]["prop_id-$type_id-$rank"]
  481. foreach ($form['properties'] as $type_id => $elements) {
  482. // there are other fields in the properties array so we only
  483. // want the numeric ones those are our type_id
  484. if (is_numeric($type_id)) {
  485. foreach ($elements as $rank => $element) {
  486. if (is_numeric($rank)) {
  487. $rows[] = array(
  488. drupal_render($element["prop_id-$type_id-$rank"]),
  489. drupal_render($element["prop_value-$type_id-$rank"]),
  490. drupal_render($element["remove-$type_id-$rank"]),
  491. );
  492. }
  493. }
  494. }
  495. }
  496. // second, add in any new properties added by the user through AHAH callbacks
  497. // the array tree for these properties looks like this:
  498. // $form['properties']['new'][$type_id][$rank]["new_id-$new_id-$rank"]
  499. foreach ($form['properties']['new'] as $type_id => $elements) {
  500. if (is_numeric($type_id)) {
  501. foreach ($elements as $rank => $element) {
  502. if (is_numeric($rank)) {
  503. $rows[] = array(
  504. drupal_render($element["new_id-$type_id-$rank"]),
  505. drupal_render($element["new_value-$type_id-$rank"]),
  506. drupal_render($element["remove-$type_id-$rank"]),
  507. );
  508. }
  509. }
  510. }
  511. }
  512. // finally add in a set of blank field for adding a new property
  513. $rows[] = array(
  514. drupal_render($form['properties']['new']['new_id']),
  515. drupal_render($form['properties']['new']['new_value']),
  516. drupal_render($form['properties']['new']['add']),
  517. );
  518. }
  519. $headers = array('Property Type','Value', '');
  520. return theme('table', $headers, $rows, array('id'=> "tripal-analysis-edit-properties-table"));
  521. }
  522. /*
  523. *
  524. */
  525. function tripal_analysis_property_add() {
  526. $status = TRUE;
  527. // prepare and render the form
  528. $form = tripal_core_ahah_prepare_form();
  529. // we only want to return the properties as that's all we'll replace with this AHAh callback
  530. $data = tripal_analysis_theme_node_form_properties($form);
  531. // bind javascript events to the new objects that will be returned
  532. // so that AHAH enabled elements will work.
  533. $settings = tripal_core_ahah_bind_events();
  534. // return the updated JSON
  535. drupal_json(
  536. array(
  537. 'status' => $status,
  538. 'data' => $data,
  539. 'settings' => $settings,
  540. )
  541. );
  542. }
  543. /*
  544. *
  545. */
  546. function tripal_analysis_property_delete() {
  547. $status = TRUE;
  548. // prepare and render the form
  549. $form = tripal_core_ahah_prepare_form();
  550. // we only want to return the properties as that's all we'll replace with this AHAh callback
  551. $data = tripal_analysis_theme_node_form_properties($form);
  552. // bind javascript events to the new objects that will be returned
  553. // so that AHAH enabled elements will work.
  554. $settings = tripal_core_ahah_bind_events();
  555. // return the updated JSON
  556. drupal_json(
  557. array(
  558. 'status' => $status,
  559. 'data' => $data,
  560. 'settings' => $settings,
  561. )
  562. );
  563. }
  564. /*
  565. *
  566. */
  567. function tripal_analysis_property_get_description() {
  568. $new_id = $_POST['new_id'];
  569. $values = array('cvterm_id' => $new_id);
  570. $cvterm = tripal_core_chado_select('cvterm', array('definition'), $values);
  571. $description = '&nbsp;';
  572. if ($cvterm[0]->definition) {
  573. $description = $cvterm[0]->definition;
  574. }
  575. drupal_json(
  576. array(
  577. 'status' => TRUE,
  578. 'data' => '<div id="tripal-analysis-new_value-desc">' . $description . '</div>',
  579. )
  580. );
  581. }
  582. /*
  583. *
  584. */
  585. function theme_chado_analysis_node_form($form) {
  586. $properties_table = tripal_analysis_theme_node_form_properties($form);
  587. $markup = drupal_render($form['analysis_id']);
  588. $markup .= drupal_render($form['title']);
  589. $markup .= drupal_render($form['type_id']);
  590. $markup .= drupal_render($form['description']);
  591. $markup .= "<b>Include Additional Details</b><br>You may add additional properties to this analysis by scrolling to the bottom of this table, selecting a property type from the dropdown and adding text. You may add as many properties as desired by clicking the plus button on the right. To remove a property, click the minus button";
  592. $markup .= $properties_table;
  593. $form['properties'] = array(
  594. '#type' => 'markup',
  595. '#value' => $markup,
  596. );
  597. $form['buttons']['#weight'] = 50;
  598. return drupal_render($form);
  599. }