Go to the source code of this file.
Define the helper functions for the Plant Accession page.
Definition in file page_3_helper.php.
◆ tpps_accession_pop_groups()
tpps_accession_pop_groups |
( |
|
$row, |
|
|
array & |
$options |
|
) |
| |
This function processes a single row of an accession file.
This function populates the pop_groups attribute of the options array with the names of all the selected population groups from an accession file. This function is meant to be used with tpps_file_iterator().
- Parameters
-
mixed | $row | The item yielded by the TPPS file generator. |
array | $options | Additional options set when calling tpps_file_iterator(). |
Definition at line 154 of file page_3_helper.php.
155 $groups = &$options[
'pop_groups'];
156 $col = current($options[
'columns']);
157 if (array_search($row[$col], $groups) === FALSE) {
158 $groups[] = $row[$col];
◆ tpps_study_location()
tpps_study_location |
( |
array & |
$form, |
|
|
array & |
$form_state |
|
) |
| |
This function creates fields describing the study location.
- Parameters
-
array | $form | The form to be populated. |
array | $form_state | The state of the form to be populated. |
- Returns
- array The populated form.
Definition at line 19 of file page_3_helper.php.
21 $form[
'study_location'] = array(
22 '#type' =>
'fieldset',
23 '#title' => t(
'<div class="fieldset-title">Study Location:</div>'),
25 '#collapsible' => TRUE,
26 '#description' => t(
'This should be the location(s) of your common garden, plantation, etc.'),
27 '#prefix' =>
'<div id="common-garden-loc">',
28 '#suffix' =>
'</div>',
31 $form[
'study_location'][
'type'] = array(
33 '#title' => t(
'Coordinate Projection: *'),
39 2 => t(
'Custom Location (brief description)'),
42 'callback' =>
'tpps_update_locations',
43 'wrapper' =>
'common-garden-loc',
45 '#attributes' => array(
46 'data-toggle' => array(
'tooltip'),
47 'data-placement' => array(
'right'),
48 'title' => array(
'Please select a Coordinate Projection, or select "Custom Location", to enter a custom study location'),
58 '#type' =>
'textfield',
59 '#title' =>
'Location !num: *',
63 $field[
'#description'] = t(
'Accepted formats: <br>Degrees Minutes Seconds: 41° 48\' 27.7" N, 72° 15\' 14.4" W<br>Degrees Decimal Minutes: 41° 48.462\' N, 72° 15.24\' W<br>Decimal Degrees: 41.8077° N, 72.2540° W<br>');
67 'label' =>
'Location',
68 'title' =>
'Study Location(s):',
69 'parents' => array(
'study_location'),
70 'callback' =>
'tpps_update_locations',
72 'wrapper' =>
'common-garden-loc',
73 'substitute_fields' => array(
78 $form[
'study_location'][
'locations'][
'#states'] = array(
80 ':input[name="study_location[type]"]' => array(
'value' =>
'0'),
84 if ($type != 2 and $type != 0) {
85 $form[
'study_location'][
'map-button'] = array(
87 '#title' =>
'Click here to update map',
88 '#value' =>
'Click here to update map',
89 '#button_type' =>
'button',
90 '#name' =>
'study_locations_map_button',
91 '#executes_submit_callback' => FALSE,
92 '#prefix' =>
'<div id="study_location_map">',
93 '#suffix' =>
'</div>',
95 'callback' =>
'tpps_study_location_map_ajax',
96 'wrapper' =>
'study_location_map',
103 if ($form_state[
'triggering_element'][
'#name'] ==
'study_locations_map_button' and $type != 2 and !empty($locs) and !empty($locs[
'number'])) {
105 $valid_coords = TRUE;
106 for ($i = 1; $i <= $locs[
'number']; $i++) {
107 if (empty($locs[$i])) {
108 $valid_coords = FALSE;
109 drupal_set_message(t(
'Location %num is required', array(
'%num' => $i)),
'error');
112 $raw_coord = $locs[$i];
114 if ($standard_coordinate) {
115 $parts = explode(
',', $standard_coordinate);
123 $valid_coords = FALSE;
124 drupal_set_message(t(
'Location %num: Invalid coordinates', array(
'%num' => $i)),
'error');
127 if (!empty($coords) and $valid_coords) {
128 $map_api_key = variable_get(
'tpps_maps_api_key', NULL);
129 $map_api_tools =
"<script src=\"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js\"></script><script src=\"https://maps.googleapis.com/maps/api/js?key=$map_api_key&callback=initMap\" 130 async defer></script>" 131 .
"<div id=\"_map_wrapper\"></div>";
132 drupal_add_js(array(
'tpps' => array(
'tree_info' => $coords)),
'setting');
133 drupal_add_js(array(
'tpps' => array(
'study_locations' => TRUE)),
'setting');
135 $form[
'study_location'][
'map-button'][
'#suffix'] = $map_api_tools;
tpps_standard_coord($raw_coordinate)