Tripal Plant PopGen Submit
page_2_helper.php File Reference

Go to the source code of this file.

Functions

 tpps_common_garden (array &$form)
 
 tpps_control (array &$form, $type, $label)
 
 tpps_greenhouse (array &$form)
 
 tpps_growth_chamber (array &$form)
 
 tpps_natural_population (array &$form)
 
 tpps_plantation (array &$form)
 
 tpps_rooting (array &$form)
 
 tpps_study_date ($type, array &$form, array &$form_state)
 

Detailed Description

Define the helper functions for the Study Design page.

Definition in file page_2_helper.php.

Function Documentation

◆ tpps_common_garden()

tpps_common_garden ( array &  $form)

This function creates fields for the common garden study type.

Parameters
array$formThe form to be populated.

Definition at line 234 of file page_2_helper.php.

234  {
235 
236  $form['#title'] = t('<div class="fieldset-title">Common Garden Information:</div>');
237 
238  $form['irrigation'] = array(
239  '#type' => 'fieldset',
240  '#tree' => TRUE,
241  );
242 
243  $form['irrigation']['option'] = array(
244  '#type' => 'select',
245  '#title' => t('Irrigation Type: *'),
246  '#options' => array(
247  0 => t('- Select -'),
248  'Irrigation from top' => t('Irrigation from top'),
249  'Irrigation from bottom' => t('Irrigation from bottom'),
250  'Drip Irrigation' => t('Drip Irrigation'),
251  'Other' => t('Other'),
252  'No Irrigation' => t('No Irrigation'),
253  ),
254  );
255 
256  $form['irrigation']['other'] = array(
257  '#type' => 'textfield',
258  '#states' => array(
259  'visible' => array(
260  ':input[name="study_info[irrigation][option]"]' => array('value' => 'Other'),
261  ),
262  ),
263  );
264 
265  tpps_control($form, 'salinity', 'Salinity');
266 
267  $form['biotic_env'] = array(
268  '#type' => 'fieldset',
269  '#tree' => TRUE,
270  );
271 
272  $form['biotic_env']['option'] = array(
273  '#type' => 'checkboxes',
274  '#title' => t('Biotic Environment: *'),
275  '#options' => drupal_map_assoc(array(
276  t('Herbivores'),
277  t('Mutulists'),
278  t('Pathogens'),
279  t('Endophytes'),
280  t('Other'),
281  t('None'),
282  )),
283  );
284 
285  $form['biotic_env']['other'] = array(
286  '#type' => 'textfield',
287  '#title' => t('Please specify Biotic Environment Type: *'),
288  '#states' => array(
289  'visible' => array(
290  ':input[name="study_info[biotic_env][option][Other]"]' => array('checked' => TRUE),
291  ),
292  ),
293  );
294 
295  $form['season'] = array(
296  '#type' => 'checkboxes',
297  '#title' => t('Seasons: *'),
298  '#options' => drupal_map_assoc(array(
299  t('Spring'),
300  t('Summer'),
301  t('Fall'),
302  t('Winter'),
303  )),
304  '#description' => t('If you do not know which season your samples were collected, please select all.'),
305  );
306 
307  $treatment_options = drupal_map_assoc(array(
308  t('Seasonal environment'),
309  t('Antibiotic regime'),
310  t('Chemical administration'),
311  t('Disease status'),
312  t('Fertilizer regime'),
313  t('Fungicide regime'),
314  t('Gaseous regime'),
315  t('Gravity Growth hormone regime'),
316  t('Herbicide regime'),
317  t('Mechanical treatment'),
318  t('Mineral nutrient regime'),
319  t('Non-mineral nutrient regime'),
320  t('Salt regime'),
321  t('Watering regime'),
322  t('Pesticide regime'),
323  t('pH regime'),
324  t('Other perturbation'),
325  ));
326 
327  $form['treatment'] = array(
328  '#type' => 'fieldset',
329  '#title' => t('<div class="fieldset-title">Treatments:</div>'),
330  );
331 
332  $form['treatment']['check'] = array(
333  '#type' => 'checkbox',
334  '#title' => t('My Common Garden experiment used treatments/regimes/perturbations.'),
335  );
336 
337  foreach ($treatment_options as $option) {
338  $form['treatment']["$option"] = array(
339  '#type' => 'checkbox',
340  '#title' => t("@opt", array('@opt' => $option)),
341  '#states' => array(
342  'visible' => array(
343  ':input[name="study_info[treatment][check]"]' => array('checked' => TRUE),
344  ),
345  ),
346  );
347  $form['treatment']["$option-description"] = array(
348  '#type' => 'textfield',
349  '#description' => t("@opt Description *", array('@opt' => $option)),
350  '#states' => array(
351  'visible' => array(
352  ':input[name="study_info[treatment][' . $option . ']"]' => array('checked' => TRUE),
353  ':input[name="study_info[treatment][check]"]' => array('checked' => TRUE),
354  ),
355  ),
356  );
357  }
358 }
tpps_control(array &$form, $type, $label)

◆ tpps_control()

tpps_control ( array &  $form,
  $type,
  $label 
)

This function creates fields for the items that have control options.

This includes co2, humidity, light intensity, salinity, and pH.

Parameters
array$formThe form to be updated.
string$typeThe machine-readable type of control options.
string$labelThe human-readable label for the control options.

Definition at line 569 of file page_2_helper.php.

569  {
570  $form[$type] = array(
571  '#type' => 'fieldset',
572  '#tree' => TRUE,
573  );
574 
575  $form[$type]['option'] = array(
576  '#type' => 'select',
577  '#title' => t('@label controlled or uncontrolled: *', array('@label' => $label)),
578  '#options' => array(
579  0 => t('- Select -'),
580  1 => t('Controlled'),
581  2 => t('Uncontrolled'),
582  ),
583  );
584 
585  $form[$type]['controlled'] = array(
586  '#type' => 'textfield',
587  '#title' => t('Controlled @label Value: *', array('@label' => $label)),
588  '#states' => array(
589  'visible' => array(
590  ":input[name=\"study_info[$type][option]\"]" => array('value' => '1'),
591  ),
592  ),
593  );
594 
595  $form[$type]['uncontrolled'] = array(
596  '#type' => 'textfield',
597  '#title' => t('Average @label Value: *', array('@label' => $label)),
598  '#states' => array(
599  'visible' => array(
600  ":input[name=\"study_info[$type][option]\"]" => array('value' => '2'),
601  ),
602  ),
603  );
604 
605  if ($type == 'ph') {
606  $form[$type]['controlled']['#states']['visible'] = array(
607  ':input[name="study_info[rooting][ph][option]"]' => array('value' => '1'),
608  );
609  $form[$type]['uncontrolled']['#states']['visible'] = array(
610  ':input[name="study_info[rooting][ph][option]"]' => array('value' => '2'),
611  );
612  }
613 }

◆ tpps_greenhouse()

tpps_greenhouse ( array &  $form)

This function creates fields for the greenhouse study type.

Parameters
array$formThe form to be populated.

Definition at line 201 of file page_2_helper.php.

201  {
202 
203  $form['#title'] = t('<div class="fieldset-title">Greenhouse Information:</div>');
204 
205  tpps_control($form, 'humidity', 'Air humidity');
206  tpps_control($form, 'light', 'Light Intensity');
207 
208  $form['temp'] = array(
209  '#type' => 'fieldset',
210  '#title' => t('<div class="fieldset-title">Temperature Information:</div>'),
211  '#description' => t('Please provide temperatures in Degrees Celsius'),
212  '#tree' => TRUE,
213  );
214 
215  $form['temp']['high'] = array(
216  '#type' => 'textfield',
217  '#title' => t('Average High Temperature: *'),
218  );
219 
220  $form['temp']['low'] = array(
221  '#type' => 'textfield',
222  '#title' => t('Average Low Temperature: *'),
223  );
224 
225  tpps_rooting($form);
226 }
tpps_rooting(array &$form)
tpps_control(array &$form, $type, $label)

◆ tpps_growth_chamber()

tpps_growth_chamber ( array &  $form)

This function creates fields for the growth chamber study type.

Parameters
array$formThe form to be populated.

Definition at line 167 of file page_2_helper.php.

167  {
168 
169  $form['#title'] = t('<div class="fieldset-title">Growth Chamber Information:</div>');
170 
171  tpps_control($form, 'co2', 'CO2');
172  tpps_control($form, 'humidity', 'Air humidity');
173  tpps_control($form, 'light', 'Light Intensity');
174 
175  $form['temp'] = array(
176  '#type' => 'fieldset',
177  '#title' => t('<div class="fieldset-title">Temperature Information:</div>'),
178  '#description' => t('Please provide temperatures in Degrees Celsius'),
179  '#tree' => TRUE,
180  );
181 
182  $form['temp']['high'] = array(
183  '#type' => 'textfield',
184  '#title' => t('Average High Temperature: *'),
185  );
186 
187  $form['temp']['low'] = array(
188  '#type' => 'textfield',
189  '#title' => t('Average Low Temperature: *'),
190  );
191 
192  tpps_rooting($form);
193 }
tpps_rooting(array &$form)
tpps_control(array &$form, $type, $label)

◆ tpps_natural_population()

tpps_natural_population ( array &  $form)

This function creates fields for the natural population study type.

Parameters
array$formThe form to be populated.

Definition at line 132 of file page_2_helper.php.

132  {
133 
134  $form['#title'] = t('<div class="fieldset-title">Natural Population/Landscape Information:</div>');
135 
136  $form['season'] = array(
137  '#type' => 'checkboxes',
138  '#title' => t('Seasons (select all that apply): *'),
139  '#options' => drupal_map_assoc(array(
140  t('Spring'),
141  t('Summer'),
142  t('Fall'),
143  t('Winter'),
144  )),
145  '#description' => t('If you do not know which season your samples were collected, please select all.'),
146  );
147 
148  $num_arr = array();
149  $num_arr[0] = '- Select -';
150  for ($i = 1; $i <= 30; $i++) {
151  $num_arr[$i] = $i;
152  }
153 
154  $form['assessions'] = array(
155  '#type' => 'select',
156  '#title' => t('Number of times the populations were assessed (on average): *'),
157  '#options' => $num_arr,
158  );
159 }

◆ tpps_plantation()

tpps_plantation ( array &  $form)

This function creates fields for the plantation study type.

Parameters
array$formThe form to be populated.

Definition at line 366 of file page_2_helper.php.

366  {
367 
368  $form['#title'] = t('<div class="fieldset-title">Plantation Information:</div>');
369 
370  $form['season'] = array(
371  '#type' => 'checkboxes',
372  '#title' => t('Seasons (select all that apply): *'),
373  '#options' => drupal_map_assoc(array(
374  t('Spring'),
375  t('Summer'),
376  t('Fall'),
377  t('Winter'),
378  )),
379  '#description' => t('If you do not know which season your samples were collected, please select all.'),
380  );
381 
382  $num_arr = array();
383  $num_arr[0] = '- Select -';
384  for ($i = 1; $i <= 30; $i++) {
385  $num_arr[$i] = $i;
386  }
387 
388  $form['assessions'] = array(
389  '#type' => 'select',
390  '#title' => t('Number of times the populations were assessed (on average): *'),
391  '#options' => $num_arr,
392  );
393 
394  $treatment_options = drupal_map_assoc(array(
395  t('Seasonal environment'),
396  t('Antibiotic regime'),
397  t('Chemical administration'),
398  t('Disease status'),
399  t('Fertilizer regime'),
400  t('Fungicide regime'),
401  t('Gaseous regime'),
402  t('Gravity Growth hormone regime'),
403  t('Herbicide regime'),
404  t('Mechanical treatment'),
405  t('Mineral nutrient regime'),
406  t('Non-mineral nutrient regime'),
407  t('Salt regime'),
408  t('Watering regime'),
409  t('Pesticide regime'),
410  t('pH regime'),
411  t('Other perturbation'),
412  ));
413 
414  $form['treatment'] = array(
415  '#type' => 'fieldset',
416  '#title' => t('<div class="fieldset-title">Treatments:</div>'),
417  );
418 
419  $form['treatment']['check'] = array(
420  '#type' => 'checkbox',
421  '#title' => t('My Plantation experiment used treatments/regimes/perturbations.'),
422  );
423 
424  foreach ($treatment_options as $option) {
425  $form['treatment']["$option"] = array(
426  '#type' => 'checkbox',
427  '#title' => t("@opt", array('@opt' => $option)),
428  '#states' => array(
429  'visible' => array(
430  ':input[name="study_info[treatment][check]"]' => array('checked' => TRUE),
431  ),
432  ),
433  );
434  $form['treatment']["$option-description"] = array(
435  '#type' => 'textfield',
436  '#description' => t("@opt Description *", array('@opt' => $option)),
437  '#states' => array(
438  'visible' => array(
439  ':input[name="study_info[treatment][' . $option . ']"]' => array('checked' => TRUE),
440  ':input[name="study_info[treatment][check]"]' => array('checked' => TRUE),
441  ),
442  ),
443  );
444  }
445 }

◆ tpps_rooting()

tpps_rooting ( array &  $form)

This function creates fields for rooting information.

Parameters
array$formThe form to be populated.

Definition at line 453 of file page_2_helper.php.

453  {
454 
455  $form['rooting'] = array(
456  '#type' => 'fieldset',
457  '#title' => t('<div class="fieldset-title">Rooting Information:</div>'),
458  '#tree' => TRUE,
459  );
460 
461  $form['rooting']['option'] = array(
462  '#type' => 'select',
463  '#title' => t('Rooting Type: *'),
464  '#options' => array(
465  0 => t('- Select -'),
466  'Aeroponics' => t('Aeroponics'),
467  'Hydroponics' => t('Hydroponics'),
468  'Soil' => t('Soil'),
469  ),
470  );
471 
472  $form['rooting']['soil'] = array(
473  '#type' => 'fieldset',
474  '#states' => array(
475  'visible' => array(
476  ':input[name="study_info[rooting][option]"]' => array('value' => 'Soil'),
477  ),
478  ),
479  );
480 
481  $form['rooting']['soil']['type'] = array(
482  '#type' => 'select',
483  '#title' => t('Soil Type: *'),
484  '#options' => array(
485  0 => t('- Select -'),
486  'Sand' => t('Sand'),
487  'Peat' => t('Peat'),
488  'Clay' => t('Clay'),
489  'Mixed' => t('Mixed'),
490  'Other' => t('Other'),
491  ),
492  );
493 
494  $form['rooting']['soil']['other'] = array(
495  '#type' => 'textfield',
496  '#states' => array(
497  'visible' => array(
498  ':input[name="study_info[rooting][soil][type]"]' => array('value' => 'Other'),
499  ),
500  ),
501  );
502 
503  $form['rooting']['soil']['container'] = array(
504  '#type' => 'textfield',
505  '#title' => t('Soil Container Type: *'),
506  );
507 
508  tpps_control($form['rooting'], 'ph', 'pH');
509 
510  $treatment_options = drupal_map_assoc(array(
511  t('Seasonal Environment'),
512  t('Air temperature regime'),
513  t('Soil Temperature regime'),
514  t('Antibiotic regime'),
515  t('Chemical administration'),
516  t('Disease status'),
517  t('Fertilizer regime'),
518  t('Fungicide regime'),
519  t('Gaseous regime'),
520  t('Gravity Growth hormone regime'),
521  t('Mechanical treatment'),
522  t('Mineral nutrient regime'),
523  t('Humidity regime'),
524  t('Non-mineral nutrient regime'),
525  t('Radiation (light, UV-B, X-ray) regime'),
526  t('Rainfall regime'),
527  t('Salt regime'),
528  t('Watering regime'),
529  t('Water temperature regime'),
530  t('Pesticide regime'),
531  t('pH regime'),
532  t('other perturbation'),
533  ));
534 
535  $form['rooting']['treatment'] = array(
536  '#type' => 'fieldset',
537  '#title' => t('<div class="fieldset-title">Treatments: *</div>'),
538  );
539 
540  foreach ($treatment_options as $option) {
541  $form['rooting']['treatment']["$option"] = array(
542  '#type' => 'checkbox',
543  '#title' => t("@opt", array('@opt' => $option)),
544  );
545  $form['rooting']['treatment']["$option-description"] = array(
546  '#type' => 'textfield',
547  '#description' => t("@opt Description *", array('@opt' => $option)),
548  '#states' => array(
549  'visible' => array(
550  ':input[name="study_info[rooting][treatment][' . $option . ']"]' => array('checked' => TRUE),
551  ),
552  ),
553  );
554  }
555 }
tpps_control(array &$form, $type, $label)

◆ tpps_study_date()

tpps_study_date (   $type,
array &  $form,
array &  $form_state 
)

This function creates fields describing the study dates.

Parameters
string$typeThe type of date, 'Starting' or 'Ending'.
array$formThe form to be populated.
array$form_stateThe state of the form to be populated.
Returns
array The populated form.

Definition at line 21 of file page_2_helper.php.

21  {
22 
23  $form[$type . 'Date'] = array(
24  '#type' => 'fieldset',
25  '#tree' => TRUE,
26  );
27 
28  if ($type == "Ending") {
29  $form['EndingDate']['#states'] = array(
30  'invisible' => array(
31  array(
32  array(':input[name="StartingDate[month]"]' => array('value' => '0')),
33  'or',
34  array(':input[name="StartingDate[year]"]' => array('value' => '0')),
35  ),
36  ),
37  );
38  }
39  else {
40  $form[$type . 'Date']['#title'] = t('<div class="fieldset-title">Experiment/Analysis Dates</div>');
41  }
42 
43  $yearArr = array();
44  $yearArr[0] = '- Select -';
45  for ($i = 1970; $i <= 2018; $i++) {
46  $yearArr[$i] = $i;
47  }
48 
49  $monthArr = array(
50  0 => '- Select -',
51  'January' => 'January',
52  'February' => 'February',
53  'March' => 'March',
54  'April' => 'April',
55  'May' => 'May',
56  'June' => 'June',
57  'July' => 'July',
58  'August' => 'August',
59  'September' => 'September',
60  'October' => 'October',
61  'November' => 'November',
62  'December' => 'December',
63  );
64 
65  $form[$type . 'Date']['year'] = array(
66  '#type' => 'select',
67  '#title' => t("@type Year: *", array('@type' => $type)),
68  '#options' => $yearArr,
69  );
70 
71  $form[$type . 'Date']['month'] = array(
72  '#type' => 'select',
73  '#title' => t("@type Month: *", array('@type' => $type)),
74  '#options' => $monthArr,
75  '#states' => array(
76  'invisible' => array(
77  ':input[name="' . $type . 'Date[year]"]' => array('value' => '0'),
78  ),
79  ),
80  );
81 
82  if ($type == "Starting") {
83  $form['StartingDate']['year']['#ajax'] = array(
84  'callback' => 'tpps_date_year_callback',
85  'wrapper' => 'Endingyear',
86  );
87  $form['StartingDate']['month']['#ajax'] = array(
88  'callback' => 'tpps_date_month_callback',
89  'wrapper' => 'Endingmonth',
90  );
91  }
92  else {
93  $form['EndingDate']['year']['#ajax'] = array(
94  'callback' => 'tpps_date_month_callback',
95  'wrapper' => 'Endingmonth',
96  );
97  $form['EndingDate']['year']['#prefix'] = '<div id="Endingyear">';
98  $form['EndingDate']['year']['#suffix'] = '</div>';
99  $form['EndingDate']['month']['#prefix'] = '<div id="Endingmonth">';
100  $form['EndingDate']['month']['#suffix'] = '</div>';
101 
102  if (isset($form_state['values']['StartingDate']['year']) and $form_state['values']['StartingDate']['year'] != '0') {
103  $yearArr = array();
104  $yearArr[0] = '- Select -';
105  for ($i = $form_state['values']['StartingDate']['year']; $i <= 2018; $i++) {
106  $yearArr[$i] = $i;
107  }
108  $form['EndingDate']['year']['#options'] = $yearArr;
109  }
110  if (isset($form_state['values']['EndingDate']['year']) and $form_state['values']['EndingDate']['year'] == $form_state['values']['StartingDate']['year'] and isset($form_state['values']['StartingDate']['month']) and $form_state['values']['StartingDate']['month'] != '0') {
111  foreach ($monthArr as $key) {
112  if ($key != '0' and $key != $form_state['values']['StartingDate']['month']) {
113  unset($monthArr[$key]);
114  }
115  elseif ($key == $form_state['values']['StartingDate']['month']) {
116  break;
117  }
118  }
119  $form['EndingDate']['month']['#options'] = $monthArr;
120  }
121  }
122 
123  return $form;
124 }