Tripal Plant PopGen Submit
summary.php File Reference

Go to the source code of this file.

Functions

 tpps_summary_create_form (array &$form, array $form_state)
 

Detailed Description

Creates the Submission Summary form page.

Definition in file summary.php.

Function Documentation

◆ tpps_summary_create_form()

tpps_summary_create_form ( array &  $form,
array  $form_state 
)

Creates the Submission Summary form page.

This function displays the data that the user has already submitted, and also allows fields to add additional files to the submission and provide optional comments.

Parameters
array$formThe form to be populated.
array$form_stateThe state of the form to be populated.
Returns
array The populated form.

Definition at line 23 of file summary.php.

23  {
24 
25  $supplemental_upload_location = 'public://' . variable_get('tpps_supplemental_files_dir', 'tpps_supplemental');
26 
27  $form['comments'] = array(
28  '#type' => 'textarea',
29  '#title' => 'If you have any additional comments about this submission you would like to include, please write them here:',
30  '#prefix' => tpps_table_display($form_state),
31  );
32 
33  $form['files'] = array(
34  '#type' => 'fieldset',
35  '#tree' => TRUE,
36  '#title' => t('<div class="fieldset-title">Additional Files</div>'),
37  '#description' => t('If there are any additional files you would like to include with your submission, please upload up to 10 files here.'),
38  '#collapsible' => TRUE,
39  );
40 
41  $form['files']['add'] = array(
42  '#type' => 'button',
43  '#title' => t('Add File'),
44  '#button_type' => 'button',
45  '#value' => t('Add File'),
46  );
47 
48  $form['files']['remove'] = array(
49  '#type' => 'button',
50  '#title' => t('Remove File'),
51  '#button_type' => 'button',
52  '#value' => t('Remove File'),
53  );
54 
55  $form['files']['number'] = array(
56  '#type' => 'hidden',
57  '#default_value' => isset($form_state['saved_values']['summarypage']['files']['number']) ? $form_state['saved_values']['summarypage']['files']['number'] : '0',
58  );
59 
60  for ($i = 1; $i <= 10; $i++) {
61 
62  $form['files']["$i"] = array(
63  '#type' => 'managed_file',
64  '#title' => t("Supplemental File @i", array('@i' => $i)),
65  '#upload_validators' => array(
66  // These were all the relevant file types I could think of.
67  'file_validate_extensions' => array('csv tsv xlsx txt pdf vcf doc docx xls ppt pptx fa fasta img png jpeg jpg zip gz fsa_nt html flat fsa ai '),
68  ),
69  '#upload_location' => "$supplemental_upload_location",
70  );
71  }
72 
73  $form['release'] = array(
74  '#type' => 'checkbox',
75  '#title' => t('Release this data through the database immediately.'),
76  '#default_value' => isset($form_state['saved_values']['summarypage']['release']) ? $form_state['saved_values']['summarypage']['release'] : TRUE,
77  );
78 
79  $form['release-date'] = array(
80  '#type' => 'date',
81  '#title' => t('Please select the release date for the dataset.'),
82  '#default_value' => isset($form_state['saved_values']['summarypage']['release-date']) ? $form_state['saved_values']['summarypage']['release-date'] : NULL,
83  '#states' => array(
84  'visible' => array(
85  ':input[name="release"]' => array('checked' => FALSE),
86  ),
87  ),
88  );
89 
90  $analysis_options = array(
91  'diversity' => 'Diversity',
92  'population_structure' => 'Population Structure',
93  'association_genetics' => 'Association Genetics',
94  'landscape_genomics' => 'Landscape Genomics',
95  'phenotype_environment' => 'Phenotype-Environment',
96  );
97 
98  $form['analysis'] = array(
99  '#type' => 'fieldset',
100  '#title' => t('Analysis'),
101  '#tree' => TRUE,
102  );
103 
104  foreach ($analysis_options as $option => $label) {
105  $form['analysis']["{$option}_check"] = array(
106  '#type' => 'checkbox',
107  '#title' => $label,
108  );
109 
110  $form['analysis']["{$option}_file"] = array(
111  '#type' => 'managed_file',
112  '#title' => $label . " file:",
113  '#description' => t('Please upload the file associated with this analysis type'),
114  '#upload_location' => 'public://' . variable_get('tpps_analysis_dir', 'tpps_analysis'),
115  '#upload_validators' => array(
116  'file_validate_extensions' => array(),
117  ),
118  '#states' => array(
119  'visible' => array(
120  ":input[name=\"analysis[{$option}_check]\"]" => array('checked' => TRUE),
121  ),
122  ),
123  );
124 
125  $form['analysis']["{$option}_file_description"] = array(
126  '#type' => 'textfield',
127  '#title' => $label . " file description:",
128  '#states' => array(
129  'visible' => array(
130  ":input[name=\"analysis[{$option}_check]\"]" => array('checked' => TRUE),
131  ),
132  ),
133  );
134  }
135 
136  $org_number = $form_state['saved_values'][TPPS_PAGE_1]['organism']['number'];
137  $new_species = array();
138  for ($i = 1; $i <= $org_number; $i++) {
139  $org = $form_state['saved_values'][TPPS_PAGE_1]['organism'][$i]['name'];
140  $parts = explode(" ", $org);
141 
142  $org_record = chado_select_record('organism', array('organism_id'), array(
143  'genus' => $parts[0],
144  'species' => implode(" ", array_slice($parts, 1)),
145  ));
146  if (empty($org_record)) {
147  $new_species[] = $org;
148  }
149  }
150 
151  if (!empty($new_species) and !empty(variable_get('tpps_tree_pics_files_dir', NULL))) {
152  $form['tree_pictures'] = array(
153  '#type' => 'fieldset',
154  '#title' => t('The following plants are new in the database and will need pictures:'),
155  '#tree' => TRUE,
156  );
157 
158  foreach ($new_species as $org) {
159  $form['tree_pictures'][$org] = array(
160  '#type' => 'managed_file',
161  '#title' => t('Picture for @org: (optional)', array('@org' => $org)),
162  '#upload_location' => 'public://' . variable_get('tpps_tree_pics_files_dir'),
163  '#upload_validators' => array(
164  'file_validate_extensions' => array('jpeg jpg'),
165  ),
166  '#description' => t('Please upload a photo of the species in either .jpeg or .jpg format'),
167  );
168 
169  if (db_table_exists('treepictures_metadata')) {
170  $form['tree_pictures']["{$org}_url"] = array(
171  '#type' => 'textfield',
172  '#title' => t('@org Picture source URL:', array('@org' => $org)),
173  '#states' => array(
174  'invisible' => array(
175  ":input[name=\"tree_pictures[{$org}][fid]\"]" => array('value' => 0),
176  ),
177  ),
178  );
179 
180  $form['tree_pictures']["{$org}_attribution"] = array(
181  '#type' => 'textfield',
182  '#title' => t('@org Picture Attribution:', array('@org' => $org)),
183  '#states' => array(
184  'invisible' => array(
185  ":input[name=\"tree_pictures[{$org}][fid]\"]" => array('value' => 0),
186  ),
187  ),
188  );
189 
190  $form['tree_pictures']["{$org}_license"] = array(
191  '#type' => 'textfield',
192  '#title' => t('@org Picture License:', array('@org' => $org)),
193  '#states' => array(
194  'invisible' => array(
195  ":input[name=\"tree_pictures[{$org}][fid]\"]" => array('value' => 0),
196  ),
197  ),
198  );
199  }
200  }
201  }
202 
203  $form['Back'] = array(
204  '#type' => 'submit',
205  '#value' => t('Back'),
206  );
207 
208  $form['Next'] = array(
209  '#type' => 'submit',
210  '#value' => t('Submit'),
211  );
212 
213  return $form;
214 }
const TPPS_PAGE_1
Definition: tpps.module:12
tpps_table_display(array &$state, array $options=array())
Definition: display.inc:546