This function returns a flattened and filtered form state.
This is useful for any functions that display all of the detailed contents of a TPPS Submission.
21 $data = isset($state[
'saved_values']) ? $state[
'saved_values'] : NULL;
26 unset($data[
'frontpage']);
27 unset($data[
'form_build_id']);
30 $pub = &$page_1[
'publication'];
31 $org = &$page_1[
'organism'];
33 if (isset($page_1[
'#cleared']) and $page_1[
'#cleared']) {
34 $data[
'#page_1_cleared'] = TRUE;
37 $data[
'#page_1_cleared'] = FALSE;
39 $data[
'#study_photo'] = $page_1[
'photo'] ?? NULL;
40 $data[
'Publication DOI'] = isset($page_1[
'doi']) ? $page_1[
'doi'] : NULL;
41 $data[
'Publication Title'] = isset($pub[
'title']) ? $pub[
'title'] : NULL;
42 $data[
'Primary Author'] = isset($page_1[
'primaryAuthor']) ? $page_1[
'primaryAuthor'] : NULL;
43 $data[
'Organization'] = isset($page_1[
'organization']) ? $page_1[
'organization'] : NULL;
44 $data[
'Publication Status'] = isset($pub[
'status']) ? $pub[
'status'] : NULL;
45 $data[
'Publication Year'] = isset($pub[
'year']) ? $pub[
'year'] : NULL;
46 $data[
'Publication Abstract'] = isset($pub[
'abstract']) ? $pub[
'abstract'] : NULL;
47 $data[
'Publication Journal'] = isset($pub[
'journal']) ? $pub[
'journal'] : NULL;
49 if (isset($pub[
'secondaryAuthors'][
'number'])) {
50 $data[
'#number_secondary_authors'] = $pub[
'secondaryAuthors'][
'number'];
51 for ($i = 1; $i <= $data[
'#number_secondary_authors']; $i++) {
52 if (isset($pub[
'secondaryAuthors'][
"$i"]) and $pub[
'secondaryAuthors'][
"$i"] !=
'') {
53 $data[
"Secondary Author $i"] = $pub[
'secondaryAuthors'][
"$i"];
58 if (isset($org[
'number'])) {
59 $data[
'#number_organisms'] = $org[
'number'];
60 for ($i = 1; $i <= $data[
'#number_organisms']; $i++) {
61 if (isset($org[
"$i"][
'name']) and $org[
"$i"][
'name'] !=
'') {
62 $data[
"Species $i"] = $org[
"$i"][
'name'];
70 if (isset($page_2[
'#cleared']) and $page_2[
'#cleared']) {
71 $data[
'#page_2_cleared'] = TRUE;
74 $data[
'#page_2_cleared'] = FALSE;
76 $data[
'Experiment Starting Month'] = !empty($page_2[
'StartingDate'][
'month']) ? $page_2[
'StartingDate'][
'month'] : NULL;
77 $data[
'Experiment Starting Year'] = !empty($page_2[
'StartingDate'][
'year']) ? $page_2[
'StartingDate'][
'year'] : NULL;
78 $data[
'Experiment Ending Month'] = !empty($page_2[
'EndingDate'][
'month']) ? $page_2[
'EndingDate'][
'month'] : NULL;
79 $data[
'Experiment Ending Year'] = !empty($page_2[
'EndingDate'][
'year']) ? $page_2[
'EndingDate'][
'year'] : NULL;
80 if (!empty($page_2[
'study_location'])) {
82 $legacy_loc = &$page_2[
'study_location'];
83 $data[
'#location_type'] = (isset($legacy_loc[
'type']) and $legacy_loc[
'type']) ? $legacy_loc[
'type'] : NULL;
85 if ($data[
'#location_type'] ==
'2' and isset($legacy_loc[
'custom'])) {
86 $data[
'Study Location'] = $legacy_loc[
'custom'];
88 elseif ($data[
'#location_type'] and isset($legacy_loc[
'coordinates'])) {
89 $data[
'Study Location'] = $legacy_loc[
'coordinates'];
93 if (isset($page_2[
'data_type']) and $page_2[
'data_type']) {
94 $data[
'Data Type'] = $page_2[
'data_type'];
97 if (isset($page_2[
'study_type']) and $page_2[
'study_type']) {
98 $study_type_options = array(
99 1 =>
'Natural Population (Landscape)',
100 2 =>
'Growth Chamber',
102 4 =>
'Experimental/Common Garden',
105 if (isset($study_type_options[$page_2[
'study_type']])) {
106 $data[
'Study Type'] = $study_type_options[$page_2[
'study_type']];
109 if (!empty($page_2[
'study_info'][
'season'])) {
110 $data[
'Seasons Assessed'] = implode($page_2[
'study_info'][
'season']);
113 if (!empty($page_2[
'study_info'][
'assessions'])) {
114 $data[
'Average number of assessions'] = $page_2[
'study_info'][
'assessions'];
117 $data[
'Average High Temperature'] = isset($page_2[
'study_info'][
'temp'][
'high']) ? $page_2[
'study_info'][
'temp'][
'high'] : NULL;
118 $data[
'Average Low Temperature'] = isset($page_2[
'study_info'][
'temp'][
'low']) ? $page_2[
'study_info'][
'temp'][
'low'] : NULL;
122 'humidity' =>
'Air Humidity',
123 'light' =>
'Light Intensity',
124 'salinity' =>
'Salinity',
127 foreach ($types as $type => $label) {
128 if (!empty($page_2[
'study_info'][$type])) {
129 $set = $page_2[
'study_info'][$type];
130 if (!empty($set[
'option'])) {
131 $data[
"$label Control"] = ($set[
'option'] ==
'1') ?
'Controlled' :
'Uncontrolled';
132 if ($set[
'option'] ==
'1' and !empty($set[
'controlled'])) {
133 $data[
"$label Value"] = $set[
'controlled'];
135 elseif (!empty($set[
'uncontrolled'])) {
136 $data[
"$label Value"] = $set[
'uncontrolled'];
142 if (!empty($page_2[
'study_info'][
'rooting'][
'option'])) {
143 $data[
'Rooting Type'] = $page_2[
'study_info'][
'rooting'][
'option'];
145 if ($data[
'Rooting Type'] ==
'Soil' and !empty($page_2[
'study_info'][
'rooting'][
'soil'][
'type'])) {
146 $soil = &$page_2[
'study_info'][
'rooting'][
'soil'];
147 $data[
'Soil Type'] = $soil[
'type'];
149 if ($data[
'Soil Type'] ==
'Other') {
150 $data[
'Custom Soil Type'] = $soil[
'other'];
153 $data[
'Soil Container Type'] = isset($soil[
'container']) ? $soil[
'container'] : NULL;
157 if (!empty($page_2[
'study_info'][
'rooting'][
'ph'][
'option'])) {
158 $set = $page_2[
'study_info'][
'rooting'][
'ph'];
159 $data[
'pH Control'] = ($set[
'option'] ==
'1') ?
'Controlled' :
'Uncontrolled';
161 if ($set[
'option'] ==
'1' and !empty($set[
'controlled'])) {
162 $data[
"pH Value"] = $set[
'controlled'];
164 elseif (!empty($set[
'uncontrolled'])) {
165 $data[
"pH Value"] = $set[
'uncontrolled'];
169 if (!empty($page_2[
'study_info'][
'rooting'][
'treatment'])) {
170 $treatment = $page_2[
'study_info'][
'rooting'][
'treatment'];
172 $description = FALSE;
174 foreach ($treatment as $field => $value) {
177 $selected = ($value) ? $field : FALSE;
180 elseif ($selected and !empty($value)) {
181 $data[
"Treatment: $selected description"] = $value;
183 $description = FALSE;
187 if (!empty($page_2[
'study_info'][
'irrigation']) and !empty($page_2[
'study_info'][
'irrigation'][
'option'])) {
188 $data[
'Irrigation Type'] = $page_2[
'study_info'][
'irrigation'][
'option'];
189 if ($data[
'Irrigation Type'] ==
'Other' and !empty($page_2[
'study_info'][
'irrigation'][
'other'])) {
190 $data[
'Custom Irrigation Type'] = $page_2[
'study_info'][
'irrigation'][
'other'];
194 if (!empty($page_2[
'study_info'][
'biotic_env'][
'option'])) {
195 $biotic_envs = array();
196 foreach ($page_2[
'study_info'][
'biotic_env'][
'option'] as $key => $val) {
198 $biotic_envs[] = $key;
202 if (!empty($biotic_envs)) {
203 $data[
'Biotic Environment'] = implode(
', ', $biotic_envs);
204 if (in_array(
'Other', $biotic_envs) and !empty($page_2[
'study_info'][
'biotic_env'][
'other'])) {
205 $data[
'Custom Biotic Environment'] = $page_2[
'study_info'][
'biotic_env'][
'other'];
210 if (!empty($page_2[
'study_info'][
'treatment'][
'check'])) {
211 $treatment = &$page_2[
'study_info'][
'treatment'];
213 $description = FALSE;
215 foreach ($treatment as $field => $value) {
216 if ($field !=
'check') {
219 $selected = ($value) ? $field : FALSE;
222 elseif ($selected and !empty($value)) {
223 $data[
"Treatment: $selected description"] = $value;
225 $description = FALSE;
234 if (isset($page_3[
'#cleared']) and $page_3[
'#cleared']) {
235 $data[
'#page_3_cleared'] = TRUE;
238 $data[
'#page_3_cleared'] = FALSE;
241 $data[
'#skip_loc'] = !empty($page_3[
'skip_validation']);
242 $loc = &$page_3[
'study_location'];
243 $data[
'#location_type'] = (isset($loc[
'type']) and $loc[
'type']) ? $loc[
'type'] : NULL;
245 if ($data[
'#location_type'] ==
'2' and isset($loc[
'custom'])) {
246 $data[
'Study Location'] = $loc[
'custom'];
248 elseif ($data[
'#location_type'] and isset($loc[
'coordinates'])) {
249 $data[
'Study Location'] = $loc[
'coordinates'];
253 if (!empty($data[
'#number_organisms'])) {
254 for ($i = 1; $i <= $data[
'#number_organisms']; $i++) {
255 if (!empty($page_3[
"species-$i"][
'file'])) {
256 $organism_name = $data[
"Species $i"] .
' Accession File';
257 if ($data[
'#number_organisms'] > 1 and empty($page_3[
'check'])) {
258 $organism_name =
'Plant Accession File';
261 $data[$organism_name] = $page_3[
"species-$i"][
'file'];
262 $loc_type = $page_3[
"species-$i"][
'file-groups'][
'Location (latitude/longitude or country/state or population group)'][
'#type'] ?? NULL;
263 if (!empty($loc_type) and ($loc_type ==
"gps" or (array_search(
'gps', $loc_type) !== FALSE))) {
264 $fid = $page_3[
"species-$i"][
'file'];
267 'accession_files' => array(
269 'no_header' => $page_3[
"species-$i"][
'file-no-header'] ??
'0',
270 'id_col' => $page_3[
"species-$i"][
'file-groups'][
'Tree Id'][1],
271 'lat_col' => $page_3[
"species-$i"][
'file-groups'][
'Location (latitude/longitude or country/state or population group)'][4],
272 'long_col' => $page_3[
"species-$i"][
'file-groups'][
'Location (latitude/longitude or country/state or population group)'][5],
280 if (empty($page_3[
'check'])) {
286 $data[
"Total number of plants"] = $state[
'stats'][
'tree_count'] ?? NULL;
291 if (isset($page_4[
'#cleared']) and $page_4[
'#cleared']) {
292 $data[
'#page_4_cleared'] = TRUE;
295 $data[
'#page_4_cleared'] = FALSE;
297 if (!empty($data[
'#number_organisms'])) {
298 for ($i = 1; $i <= $data[
'#number_organisms']; $i++) {
299 if (isset($page_4[
"organism-$i"])) {
300 $org = &$page_4[
"organism-$i"];
301 $org_name = isset($data[
"Species $i"]) ? $data[
"Species $i"] : NULL;
303 if (isset($org[
'phenotype'])) {
304 $pheno = &$org[
'phenotype'];
306 if (!empty($pheno[
'iso-check'])) {
307 $data[
"$org_name Phenotype Isotope/Mass Spectrometry File"] = $pheno[
'iso'];
310 if (isset($pheno[
'phenotypes-meta'][
'number'])) {
311 $data[
'#number_phenotypes'] = $pheno[
'phenotypes-meta'][
'number'];
312 $pheno_meta = &$pheno[
'phenotypes-meta'];
313 for ($j = 1; $j <= $data[
'#number_phenotypes']; $j++) {
316 'attribute' =>
'Attribute',
317 'description' =>
'Description',
320 if (isset($pheno_meta[
"$j"][
'struct-check']) and $pheno_meta[
"$j"][
'struct-check']) {
321 $fields[
'structure'] =
'Structure';
323 if (isset($pheno_meta[
"$j"][
'val-check']) and $pheno_meta[
"$j"][
'val-check']) {
324 $fields[
'min'] =
'Minimum Value';
325 $fields[
'max'] =
'Maximum Value';
328 foreach ($fields as $field => $field_string) {
329 if (isset($pheno_meta[
"$j"][$field]) and $pheno_meta[
"$j"][$field] !=
'') {
330 $data[
"$org_name Phenotype $j $field_string"] = $pheno_meta[$j][$field];
336 if (isset($pheno[
'check']) and $pheno[
'check'] and isset($pheno[
'metadata']) and $pheno[
'metadata']) {
337 $data[
"$org_name Phenotype Metadata File"] = $pheno[
'metadata'];
340 if (isset($pheno[
'file']) and $pheno[
'file']) {
341 $data[
"$org_name Phenotype File"] = $pheno[
'file'];
343 $data[
"$org_name Phenotypes Assessed"] = isset($pheno[
'phenotype_count']) ? $pheno[
'phenotype_count'] : NULL;
347 if (isset($org[
'genotype'])) {
348 $geno = &$org[
'genotype'];
350 $marker_types = array();
351 foreach ($geno[
'marker-type'] as $key => $val) {
353 $marker_types[] = $key;
356 $data[
"$org_name Genotype Marker Types"] = isset($marker_types) ? implode(
', ', $marker_types) : NULL;
358 if (isset($geno[
'marker-type'][
'SNPs']) and $geno[
'marker-type'][
'SNPs']) {
359 $snp = $geno[
'SNPs'];
360 if (isset($snp[
'genotyping-design']) and $snp[
'genotyping-design']) {
361 $geno_design_options = array(
363 2 =>
'Targeted Capture',
364 3 =>
'Whole Genome Resequencing',
366 5 =>
'Genotyping Array',
368 if (isset($geno_design_options[$snp[
'genotyping-design']])) {
369 $data[
"$org_name Genotyping Design"] = $geno_design_options[$snp[
'genotyping-design']];
372 if (isset($data[
"$org_name Genotyping Design"]) and $data[
"$org_name Genotyping Design"] ==
'GBS' and isset($snp[
'GBS']) and $snp[
'GBS']) {
373 $gbs_options = array(
380 if (isset($gbs_options[$snp[
'GBS']])) {
381 $data[
"$org_name GBS Type"] = $gbs_options[$snp[
'GBS']];
384 if (isset($data[
"$org_name GBS Type"]) and $data[
"$org_name GBS Type"] ==
'Other' and isset($snp[
'GBS-other']) and $snp[
'GBS-other'] !=
'') {
385 $data[
"$org_name Custom GBS Type"] = $snp[
'GBS-other'];
389 if (isset($data[
"$org_name Genotyping Design"]) and $data[
"$org_name Genotyping Design"] ==
'Targeted Capture' and isset($snp[
'targeted-capture']) and $snp[
'targeted-capture']) {
390 $targeted_capture_options = array(
391 1 =>
'Exome Capture',
394 if (isset($targeted_capture_options[$snp[
'targeted-capture']])) {
395 $data[
"$org_name Targeted Capture Type"] = $targeted_capture_options[$snp[
'targeted-capture']];
398 if (isset($data[
"$org_name Targeted Capture Type"]) and $data[
"$org_name Targeted Capture Type"] ==
'Other' and isset($snp[
'targeted-capture-other']) and $snp[
'targeted-capture-other'] !=
'') {
399 $data[
"$org_name Custom Targeted Capture Type"] = $snp[
'targeted-capture-other'];
404 if (isset($geno[
'marker-type'][
'SSRs/cpSSRs']) and $geno[
'marker-type'][
'SSRs/cpSSRs'] and isset($geno[
'SSRs/cpSSRs']) and $geno[
'SSRs/cpSSRs'] !=
'') {
405 $data[
"$org_name SSRs/cpSSRs Type"] = $geno[
'SSRs/cpSSRs'];
407 if (isset($geno[
'marker-type'][
'Other']) and $geno[
'marker-type'][
'Other'] and isset($geno[
'other-marker']) and $geno[
'other-marker'] !=
'') {
408 $data[
"$org_name Other Marker Type"] = $geno[
'other-marker'];
411 if (isset($geno[
'ref-genome']) and $geno[
'ref-genome'] ===
'bio' and isset($geno[
'BioProject-id']) and $geno[
'BioProject-id'] !=
'') {
412 $data[
"$org_name BioProject Id"] = $geno[
'BioProject-id'];
414 if (isset($geno[
'assembly-auto']) and gettype($geno[
'assembly-auto']) ===
'array') {
416 foreach ($geno[
'assembly-auto'] as $id => $check) {
417 if (isset($check) and $check) {
418 $data[
"$org_name Linked Accession $count"] = $id;
424 elseif (isset($geno[
'ref-genome']) and ($geno[
'ref-genome'] ===
'manual' or $geno[
'ref-genome'] ===
'manual2') and isset($geno[
'tripal_fasta'][
'file'][
'file_upload']) and isset($geno[
'tripal_fasta'][
'file'][
'file_upload_existing']) and ($geno[
'tripal_fasta'][
'file'][
'file_upload'] or $geno[
'tripal_fasta'][
'file'][
'file_upload_existing'])) {
425 if ($geno[
'tripal_fasta'][
'file'][
'file_upload']) {
426 $data[
"$org_name Uploaded Reference File"] = $geno[
'tripal_fasta'][
'file'][
'file_upload'];
428 if ($geno[
'tripal_fasta'][
'file'][
'file_upload_existing']) {
429 $data[
"$org_name Reference File"] = $geno[
'tripal_fasta'][
'file'][
'file_upload_existing'];
432 elseif (isset($geno[
'ref-genome']) and $geno[
'ref-genome'] ===
'url' and isset($geno[
'tripal_fasta'][
'file'][
'file_remote']) and $geno[
'tripal_fasta'][
'file'][
'file_remote']) {
433 $data[
"$org_name Website of reference file"] = $geno[
'tripal_fasta'][
'file'][
'file_remote'];
435 elseif (isset($geno[
'ref-genome']) and $geno[
'ref-genome']) {
436 $data[
"$org_name Reference Genome"] = $geno[
'ref-genome'];
439 if (!empty($geno[
'files'][
'snps-assay'])) {
440 $data[
"$org_name SNPs Genotype Assay File"] = $geno[
'files'][
'snps-assay'];
443 if (!empty($geno[
'files'][
'assay-design'])) {
444 $data[
"$org_name Assay Design File"] = $geno[
'files'][
'assay-design'];
447 if (!empty($geno[
'files'][
'ssrs'])) {
448 $data[
"$org_name SSRs/cpSSRs Genotype File"] = $geno[
'files'][
'ssrs'];
451 if (!empty($geno[
'files'][
'ssrs_extra'])) {
452 $data[
"$org_name SSRs/cpSSRs Additional Genotype File"] = $geno[
'files'][
'ssrs_extra'];
455 if (!empty($geno[
'files'][
'indels'])) {
456 $data[
"$org_name Indel Genotype File"] = $geno[
'files'][
'indels'];
459 if (!empty($geno[
'files'][
'other'])) {
460 $data[
"$org_name Other Marker Genotype File"] = $geno[
'files'][
'other'];
463 if (!empty($geno[
'files'][
'vcf'])) {
464 $data[
"$org_name VCF File"] = $geno[
'files'][
'vcf'];
468 if (isset($org[
'environment'])) {
469 $env = &$org[
'environment'];
471 if (variable_get(
'tpps_cartogratree_env', FALSE)) {
472 $data[
"CartograPlant Layers"] = array();
473 foreach ($env[
'env_layers'] as $layer => $layer_id) {
474 if (!empty($layer_id)) {
475 $data[
"CartograPlant Layers"][] = $layer;
477 if (!empty($layer_id) and !empty($env[
'env_params'][$layer])) {
479 foreach ($env[
'env_params'][$layer] as $param => $param_id) {
480 if (!empty($param_id)) {
484 $data[
"CartograPlant Layer: $layer Parameters"] = implode(
', ', $params);
487 if (!empty($data[
"CartograPlant Layers"])) {
488 $data[
"CartograPlant Layers"] = implode(
', ', $data[
"CartograPlant Layers"]);
491 unset($data[
"CartograPlant Layers"]);
500 $sum_page = &$data[
'summarypage'];
501 if (!empty($sum_page[
'comments'])) {
502 $data[
"Additional Comments"] = $sum_page[
'comments'];
504 for ($i = 1; $i <= 10; $i++) {
505 if (!empty($sum_page[
'files'][$i])) {
506 $data[
"Supplemental File $i"] = $sum_page[
'files'][$i];
509 if (!empty($sum_page[
'tree_pictures'])) {
510 foreach ($sum_page[
'tree_pictures'] as $name => $fid) {
511 if (substr($name, -4) ==
'_url' or substr($name, -12) ==
'_attribution' or substr($name, -8) ==
'_license') {
515 $data[
"$name species photo"] = t(
'None provided');
518 $data[
"$name species photo"] = $fid;
522 unset($data[
'summarypage']);
524 $data[
'#dbxref_id'] = isset($state[
'dbxref_id']) ? $state[
'dbxref_id'] : NULL;
525 $data[
'#accession'] = isset($state[
'accession']) ? $state[
'accession'] : NULL;
526 $data[
'#status'] = isset($state[
'status']) ? $state[
'status'] : NULL;
528 foreach ($data as $key => $val) {