8 require_once
'page_4_ajax.php';
9 require_once
'page_4_helper.php';
24 if (isset($form_state[
'saved_values'][
TPPS_PAGE_4])) {
31 $form[
'#tree'] = TRUE;
33 $organism_number = $form_state[
'saved_values'][
TPPS_PAGE_1][
'organism'][
'number'];
34 $data_type = $form_state[
'saved_values'][
TPPS_PAGE_2][
'data_type'];
35 for ($i = 1; $i <= $organism_number; $i++) {
37 $name = $form_state[
'saved_values'][
TPPS_PAGE_1][
'organism'][
"$i"][
'name'];
39 $form[
"organism-$i"] = array(
40 '#type' =>
'fieldset',
41 '#title' =>
"<div class=\"fieldset-title\">$name:</div>",
43 '#collapsible' => TRUE,
46 if (preg_match(
'/P/', $data_type)) {
48 $form[
"organism-$i"][
'phenotype-repeat-check'] = array(
49 '#type' =>
'checkbox',
50 '#title' =>
"Phenotype information for $name is the same as phenotype information for {$form_state['saved_values'][TPPS_PAGE_1]['organism'][$i - 1]['name']}.",
51 '#default_value' => isset($values[
"organism-$i"][
'phenotype-repeat-check']) ? $values[
"organism-$i"][
'phenotype-repeat-check'] : 1,
55 $form[
"organism-$i"][
'phenotype'] =
tpps_phenotype($form, $form_state, $values,
"organism-$i");
58 $form[
"organism-$i"][
'phenotype'][
'#states'] = array(
60 ":input[name=\"organism-$i\[phenotype-repeat-check]\"]" => array(
'checked' => TRUE),
70 if (!empty($normal_check)) {
71 $image_path = drupal_get_path(
'module',
'tpps') .
'/images/';
72 $form[
"organism-$i"][
'phenotype'][
'format'] = array(
74 '#title' => t(
'Phenotype file format: *'),
80 'callback' =>
'tpps_phenotype_file_format_callback',
81 'wrapper' =>
"edit-organism-$i-phenotype-file-ajax-wrapper",
83 '#default_value' => (isset($form_state[
'saved_values'][TPPS_PAGE_4][
"organism-$i"][
'phenotype'][
'format'])) ? $form_state[
'saved_values'][TPPS_PAGE_4][
"organism-$i"][
'phenotype'][
'format'] : 0,
84 '#description' => t(
'Please select a file format type from the listed options. Below please see examples of each format type.'),
87 ":input[name=\"organism-{$i}[phenotype][phenotypes-meta][number]\"]" => array(
'value' =>
'0'),
88 ":input[name=\"organism-{$i}[phenotype][check]\"]" => array(
'checked' => FALSE),
93 $form[
"organism-$i"][
'phenotype'][
'format'][0][
'#prefix'] =
"<figure><img src=\"/{$image_path}phenotype_format_1.png\"><figcaption>";
94 $form[
"organism-$i"][
'phenotype'][
'format'][0][
'#suffix'] =
"</figcaption></figure>";
95 $form[
"organism-$i"][
'phenotype'][
'format'][1][
'#prefix'] =
"<figure><img src=\"/{$image_path}phenotype_format_2.png\"><figcaption>";
96 $form[
"organism-$i"][
'phenotype'][
'format'][1][
'#suffix'] =
"</figcaption></figure>";
98 $form[
"organism-$i"][
'phenotype'][
'file'] = array(
99 '#type' =>
'managed_file',
100 '#title' => t(
'Phenotype file: Please upload a file containing columns for Plant Identifier, Phenotype Data: *'),
101 '#upload_location' =>
'public://' . variable_get(
'tpps_phenotype_files_dir',
'tpps_phenotype'),
102 '#upload_validators' => array(
103 'file_validate_extensions' => array(
'csv tsv xlsx'),
107 'invisible' => array(
108 ":input[name=\"organism-{$i}[phenotype][phenotypes-meta][number]\"]" => array(
'value' =>
'0'),
109 ":input[name=\"organism-{$i}[phenotype][check]\"]" => array(
'checked' => FALSE),
114 $form[
"organism-$i"][
'phenotype'][
'file'][
'empty'] = array(
115 '#default_value' => isset($values[
"organism-$i"][
'phenotype'][
'file'][
'empty']) ? $values[
"organism-$i"][
'phenotype'][
'file'][
'empty'] :
'NA',
118 $form[
"organism-$i"][
'phenotype'][
'file'][
'columns'] = array(
119 '#description' => t(
'Please define which columns hold the required data: Plant Identifier, Phenotype name, and Value(s)'),
130 $column_options = array(
139 $column_options = array(
142 'Phenotype Name/Identifier',
147 $form[
"organism-$i"][
'phenotype'][
'file'][
'#title'] = t(
'Phenotype file: Please upload a file containing columns for Plant Identifier, Phenotype Name, and value for all of your phenotypic data: *');
150 $form[
"organism-$i"][
'phenotype'][
'file'][
'columns-options'] = array(
152 '#value' => $column_options,
155 $form[
"organism-$i"][
'phenotype'][
'file'][
'no-header'] = array();
159 if (preg_match(
'/G/', $data_type)) {
161 $form[
"organism-$i"][
'genotype-repeat-check'] = array(
162 '#type' =>
'checkbox',
163 '#title' =>
"Genotype information for $name is the same as genotype information for {$form_state['saved_values'][TPPS_PAGE_1]['organism'][$i - 1]['name']}.",
164 '#default_value' => isset($values[
"organism-$i"][
'genotype-repeat-check']) ? $values[
"organism-$i"][
'genotype-repeat-check'] : 1,
168 $form[
"organism-$i"][
'genotype'] =
tpps_genotype($form, $form_state, $values,
"organism-$i");
171 $form[
"organism-$i"][
'genotype'][
'#states'] = array(
172 'invisible' => array(
173 ":input[name=\"organism-$i\[genotype-repeat-check]\"]" => array(
'checked' => TRUE),
180 if (preg_match(
'/E/', $data_type)) {
182 $form[
"organism-$i"][
'environment-repeat-check'] = array(
183 '#type' =>
'checkbox',
184 '#title' =>
"Environmental information for $name is the same as environmental information for {$form_state['saved_values'][TPPS_PAGE_1]['organism'][$i - 1]['name']}.",
185 '#default_value' => isset($values[
"organism-$i"][
'environment-repeat-check']) ? $values[
"organism-$i"][
'environment-repeat-check'] : 1,
189 $form[
"organism-$i"][
'environment'] =
tpps_environment($form, $form_state,
"organism-$i");
192 $form[
"organism-$i"][
'environment'][
'#states'] = array(
193 'invisible' => array(
194 ":input[name=\"organism-$i\[environment-repeat-check]\"]" => array(
'checked' => TRUE),
201 $form[
'Back'] = array(
203 '#value' => t(
'Back'),
204 '#prefix' =>
'<div class="input-description">* : Required Field</div>',
207 $form[
'Save'] = array(
209 '#value' => t(
'Save'),
212 $form[
'submit'] = array(
214 '#value' => t(
'Review Information and Submit'),
217 if (preg_match(
'/G/', $data_type)) {
218 $pre_valid_states = array();
219 for ($i = 1; $i <= $organism_number; $i++) {
220 $pre_valid_states[
"input[name=\"organism-{$i}[genotype][files][file-type][VCF]\"]"] = array(
'checked' => FALSE);
222 $form[
'pre_validate'] = array(
224 '#value' => t(
'Pre-validate my VCF files'),
226 'invisible' => $pre_valid_states,
228 '#suffix' =>
'<div>Sometimes large VCF files can cause problems during the validation step. If your VCF file is very large, you can click the "Pre-validate my VCF files" button to validate your VCF file in the background, before clicking "Review Information and Submit".</div>',
231 $form[
'Back'][
'#prefix'] .=
"<div id=\"pre-validate-message\"></div>";
tpps_genotype(array &$form, array &$form_state, array $values, $id)
tpps_environment(array &$form, array &$form_state, $id)
tpps_phenotype(array &$form, array &$form_state, array $values, $id)
tpps_page_4_create_form(array &$form, array &$form_state)