1
|
<?php
|
2
|
/**
|
3
|
* @file
|
4
|
* Functions for dealing with CDM entities of type SpecimenOrOccurrences
|
5
|
* This file contains new functions which are to replace functions in
|
6
|
* occurrences.inc and should be merged with the latter one.
|
7
|
*
|
8
|
* @see http://www.mozilla.org/MPL/MPL-1.1.html
|
9
|
*
|
10
|
* @copyright
|
11
|
* (C) 2007-2021 EDIT
|
12
|
* European Distributed Institute of Taxonomy
|
13
|
* http://www.e-taxonomy.eu
|
14
|
*
|
15
|
* The contents of this module are subject to the Mozilla
|
16
|
* Public License Version 1.1.
|
17
|
* @author
|
18
|
* - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
|
19
|
*/
|
20
|
|
21
|
|
22
|
/**
|
23
|
* Composes the view on specimens and occurrences as derivate tree
|
24
|
* starting from the field unit including all derivatives.
|
25
|
*
|
26
|
* @param array $root_unit_dtos
|
27
|
* list of SpecimenOrObservationDTOs
|
28
|
*
|
29
|
* @return array
|
30
|
* The Drupal render array
|
31
|
*
|
32
|
* @ingroup compose
|
33
|
* @see CDM_SPECIMEN_LIST_VIEW_MODE_OPTION_DERIVATE_TREE
|
34
|
*
|
35
|
*/
|
36
|
function compose_specimen_table_top_down_new(array $root_unit_dtos) {
|
37
|
// add icons
|
38
|
$expand_icon = font_awesome_icon_markup(
|
39
|
'fa-plus-square-o',
|
40
|
[
|
41
|
'alt' => 'Show details',
|
42
|
'class' => ['expand_icon'],
|
43
|
]
|
44
|
);
|
45
|
$collapse_icon = font_awesome_icon_markup(
|
46
|
'fa-minus-square-o',
|
47
|
[
|
48
|
'alt' => 'Show details',
|
49
|
'class' => ['collapse_icon'],
|
50
|
]
|
51
|
);
|
52
|
|
53
|
$derivation_tree = derived_units_tree($root_unit_dtos);
|
54
|
|
55
|
$render_array = [];
|
56
|
$render_array['derived-unit-tree'] = $derivation_tree;
|
57
|
|
58
|
_add_js_derivation_tree('.derived-unit-tree');
|
59
|
|
60
|
return $render_array;
|
61
|
}
|
62
|
|
63
|
/**
|
64
|
* Creates the root levels and trees for all subordinate derivatives.
|
65
|
*
|
66
|
* See derived_units_sub_tree()
|
67
|
*
|
68
|
* @param array $root_unit_dtos
|
69
|
* list of SpecimenOrObservationDTOs
|
70
|
*
|
71
|
* @return array
|
72
|
* An array which can be used in render arrays to be passed to the
|
73
|
* theme_table() and theme_list().
|
74
|
*/
|
75
|
function derived_units_tree(array $root_unit_dtos) {
|
76
|
|
77
|
$root_items = [];
|
78
|
//we need one more item to contain the items of one level (fieldunit, derivate data etc.)
|
79
|
foreach ($root_unit_dtos as &$sob_dto) {
|
80
|
$field_unit_dto_render_array = compose_cdm_specimen_or_observation_dto_details_grid($sob_dto);
|
81
|
$root_item = [
|
82
|
'#prefix' => '<div class="derived-unit-tree">',
|
83
|
'#suffix' => '</div>',
|
84
|
'#type' => 'container',
|
85
|
'#attributes' => [
|
86
|
'class' => [
|
87
|
'derived-unit-item derived-unit-tree-root',
|
88
|
html_class_attribute_ref($sob_dto),
|
89
|
],
|
90
|
],
|
91
|
'div-container' => [
|
92
|
'root-item-and-sub-tree' => [
|
93
|
markup_to_render_array(derived_units_tree_node_header($sob_dto)
|
94
|
. '<div class="unit-content-wrapper">' // allows to apply the borders between .derived-unit-tree-root and .unit-content
|
95
|
. '<div class="unit-content">' . drupal_render($field_unit_dto_render_array) . '</div>'
|
96
|
. '</div>'),
|
97
|
],
|
98
|
],
|
99
|
|
100
|
];
|
101
|
if (isset($sob_dto->derivatives) && sizeof($sob_dto->derivatives) > 0) {
|
102
|
usort($sob_dto->derivatives, 'compare_specimen_or_observation_dtos');
|
103
|
// children are displayed in a nested list.
|
104
|
$root_item['div-container']['root-item-and-sub-tree'][] = derived_units_sub_tree($sob_dto->derivatives);
|
105
|
}
|
106
|
$root_items[] = $root_item;
|
107
|
}
|
108
|
|
109
|
return $root_items;
|
110
|
}
|
111
|
|
112
|
/**
|
113
|
* @param array $unit_dtos
|
114
|
*
|
115
|
* @return array
|
116
|
*/
|
117
|
function derived_units_sub_tree(array $unit_dtos) {
|
118
|
|
119
|
$list_items = derived_units_as_list_items($unit_dtos);
|
120
|
|
121
|
$derivation_tree = [
|
122
|
'#theme' => 'item_list',
|
123
|
'#type' => 'ul',
|
124
|
'#attributes' => [
|
125
|
'class' => CDM_SPECIMEN_LIST_VIEW_MODE_OPTION_DERIVATE_TREE . ' derived-unit-sub-tree',
|
126
|
],
|
127
|
'#items' => $list_items,
|
128
|
];
|
129
|
return $derivation_tree;
|
130
|
}
|
131
|
|
132
|
/**
|
133
|
* Creates render array items for FieldUnitDTO or DerivedUnitDTO.
|
134
|
*
|
135
|
* @param array $root_unit_dtos
|
136
|
* list of SpecimenOrObservationDTOs
|
137
|
*
|
138
|
* @return array
|
139
|
* An array which can be used in render arrays to be passed to the
|
140
|
* theme_table() and theme_list().
|
141
|
*/
|
142
|
function derived_units_as_list_items(array $root_unit_dtos) {
|
143
|
|
144
|
$list_items = [];
|
145
|
//we need one more item to contain the items of one level (fieldunit, derivate data etc.)
|
146
|
foreach ($root_unit_dtos as &$sob_dto) {
|
147
|
$item = [];
|
148
|
$item['class'] = ['derived-unit-item ', html_class_attribute_ref($sob_dto)];
|
149
|
// data" element of the array is used as the contents of the list item
|
150
|
$item['data'] = [];
|
151
|
$units_render_array = compose_cdm_specimen_or_observation_dto_details_grid($sob_dto);
|
152
|
$item['data'] = derived_units_tree_node_header($sob_dto)
|
153
|
. '<div class="unit-content">' . drupal_render($units_render_array) . '</div>';
|
154
|
if (isset($sob_dto->derivatives) && sizeof($sob_dto->derivatives) > 0) {
|
155
|
usort($sob_dto->derivatives, 'compare_specimen_or_observation_dtos');
|
156
|
// children are displayed in a nested list.
|
157
|
$item['children'] = derived_units_as_list_items($sob_dto->derivatives);
|
158
|
}
|
159
|
$list_items[] = $item;
|
160
|
}
|
161
|
|
162
|
return $list_items;
|
163
|
}
|
164
|
|
165
|
/**
|
166
|
* @param $sob_dto
|
167
|
*
|
168
|
* @return string
|
169
|
*/
|
170
|
function derived_units_tree_node_header($sob_dto) {
|
171
|
$link = cdm_internal_link(path_to_specimen($sob_dto->uuid), null);
|
172
|
return '<div class="unit-header"><div class="unit-label">' . $sob_dto->label . '<span class="page-link">' . $link . '</span></div></div>';
|
173
|
}
|
174
|
|
175
|
/**
|
176
|
* Compose grid of details tabled for a CDM SpecimenOrObservationDTO
|
177
|
*
|
178
|
* The resulting render array will contain separate DOM block level elements
|
179
|
* with header line for the various kind of information like, location,
|
180
|
* gathering, specimen/observation, DNA, etc.
|
181
|
*
|
182
|
*
|
183
|
* Subordinate derivatives will not be included. For showing the derivation
|
184
|
* hierarchy see methods like derived_units_sub_tree()
|
185
|
*
|
186
|
* compose_hook() implementation
|
187
|
*
|
188
|
* @param object $sob_dto
|
189
|
* the CDM FieldUnitDTO or DerivedUnitDTO to compose
|
190
|
* the render array for.
|
191
|
* @param bool $compact_mode
|
192
|
* Currently unused, but added for compatibility with
|
193
|
* compose_cdm_specimen_or_observation($specimen_or_observation,
|
194
|
* $isSpecimen_page = false, &$derivatives = null)
|
195
|
* @param array $derivatives
|
196
|
* the render array which contains the compositions of the derivatives
|
197
|
* of the supplied $specimenOrObservation
|
198
|
*
|
199
|
* @return array
|
200
|
* The render array for the SpecimenOrObservationDTO
|
201
|
*
|
202
|
* @ingroup compose
|
203
|
*/
|
204
|
function compose_cdm_specimen_or_observation_dto_details_grid($sob_dto, $compact_mode = FALSE, &$derivatives = NULL) {
|
205
|
$render_array = [];
|
206
|
if (!$sob_dto) {
|
207
|
return $render_array;
|
208
|
}
|
209
|
if ($sob_dto->type == 'FieldUnit') {
|
210
|
$render_array['field-unit'] = compose_cdm_field_unit_dto_details($sob_dto, $compact_mode);
|
211
|
if (isset($sob_dto->gatheringEvent)) {
|
212
|
$render_array['gathering'] = compose_cdm_gathering_dto_details($sob_dto->gatheringEvent, $compact_mode);
|
213
|
}
|
214
|
} else {
|
215
|
if(isset($sob_dto->derivationEvent)){
|
216
|
$render_array['derivation-event'] = compose_cdm_derivation_event($sob_dto->derivationEvent);
|
217
|
}
|
218
|
$render_array['storage'] = compose_cdm_derived_unit_dto_storage_details($sob_dto, $compact_mode);
|
219
|
$render_array['type-designations'] = compose_cdm_unit_dto_type_designations($sob_dto, $compact_mode);
|
220
|
if($sob_dto->type == 'DnaSample'){
|
221
|
// FIXME:
|
222
|
$render_array['dna-sample'] = compose_cdm_derived_unit_dto_sequences($sob_dto, $compact_mode);
|
223
|
} else if($sob_dto->type == 'MediaSpecimen' && isset_not_empty($sob_dto->mediaSpecimen)) {
|
224
|
$render_array['media-specimens'] = cdm_sob_dto_media_table($sob_dto->mediaSpecimen, $sob_dto, 'Media Specimens');
|
225
|
}
|
226
|
}
|
227
|
if(isset_not_empty($sob_dto->determinedNames)){
|
228
|
$render_array['determinations'] = compose_cdm_sob_dto_determinations($sob_dto, $compact_mode);
|
229
|
}
|
230
|
if(isset_not_empty($sob_dto->listOfMedia)){
|
231
|
$render_array['media'] = cdm_sob_dto_media_table($sob_dto->listOfMedia, $sob_dto, 'Media');;
|
232
|
}
|
233
|
|
234
|
return $render_array;
|
235
|
}
|
236
|
/**
|
237
|
* Data rows with details for a SpecimenOrObservationDTO to be used in a table
|
238
|
* @param object $sob_dto
|
239
|
* the CDM SpecimenOrObservationDTO
|
240
|
* @param bool $compact_mode
|
241
|
* Currently unused,
|
242
|
*
|
243
|
* @return array
|
244
|
* The data rows
|
245
|
*/
|
246
|
function sob_dto_details_rows($sob_dto, $compact_mode = FALSE) {
|
247
|
|
248
|
$table_row_data = [];
|
249
|
|
250
|
if (isset_not_empty($sob_dto->recordBase)) {
|
251
|
$label = cdm_term_representation($sob_dto->recordBase);
|
252
|
if($label == 'Dna Sample'){
|
253
|
$label == 'DNA Sample';
|
254
|
}
|
255
|
$table_row_data[0] = cdm_sob_dto_table_row(
|
256
|
cdm_occurrence_field_name_label('recordBase'),
|
257
|
$label);
|
258
|
}
|
259
|
if (isset_not_empty($sob_dto->kindOfUnit)) {
|
260
|
$table_row_data[] = cdm_sob_dto_table_row(
|
261
|
cdm_occurrence_field_name_label('kindOfUnit'),
|
262
|
cdm_term_representation($sob_dto->kindOfUnit));
|
263
|
}
|
264
|
if (isset_not_empty($sob_dto->preferredStableUri)) {
|
265
|
$table_row_data[] = cdm_sob_dto_table_row(
|
266
|
cdm_occurrence_field_name_label('preferredStableUri'),
|
267
|
cdm_external_uri($sob_dto->preferredStableUri, false));
|
268
|
}
|
269
|
if (isset_not_empty($sob_dto->sex)) {
|
270
|
$table_row_data[] = cdm_sob_dto_table_row(
|
271
|
cdm_occurrence_field_name_label('sex'),
|
272
|
cdm_term_representation($sob_dto->sex));
|
273
|
}
|
274
|
if (isset_not_empty($sob_dto->lifeStage)) {
|
275
|
$table_row_data[] = cdm_sob_dto_table_row(
|
276
|
cdm_occurrence_field_name_label('lifeStage'),
|
277
|
cdm_term_representation($sob_dto->lifeStage));
|
278
|
}
|
279
|
|
280
|
return $table_row_data;
|
281
|
}
|
282
|
|
283
|
/**
|
284
|
* Compose a table of details for a DerivationEventDTO.
|
285
|
*
|
286
|
* compose_hook() implementation
|
287
|
*
|
288
|
* @param object $derivation_event_dto
|
289
|
* the CDM DerivationEventDTO
|
290
|
* @param bool $compact_mode
|
291
|
* Currently unused,
|
292
|
*
|
293
|
* @return array
|
294
|
* The render array for the DerivationEventDTO
|
295
|
*
|
296
|
* @ingroup compose
|
297
|
*/
|
298
|
function compose_cdm_derivation_event($derivation_event_dto, $compact_mode = FALSE){
|
299
|
|
300
|
$details_array = [];
|
301
|
// $markup = t("Derivation") . ': ';
|
302
|
$markup = ucfirst(cdm_term_representation($derivation_event_dto->eventType));
|
303
|
if(isset_not_empty($derivation_event_dto->actor)){
|
304
|
$details_array[] = $derivation_event_dto->actor;
|
305
|
}
|
306
|
if(isset_not_empty($derivation_event_dto->institute)){
|
307
|
$details_array[] = $derivation_event_dto->institute;
|
308
|
}
|
309
|
if(isset_not_empty($derivation_event_dto->timePeriod)){
|
310
|
$details_array[] = timePeriodToString($derivation_event_dto->timePeriod);
|
311
|
}
|
312
|
$details_markup = join(', ', $details_array);
|
313
|
if($details_markup){
|
314
|
$markup .= ': ' . $details_markup;
|
315
|
}
|
316
|
$render_array = [
|
317
|
'#type' => 'container',
|
318
|
'#attributes' => [
|
319
|
'class' => [
|
320
|
'derivation-event',
|
321
|
html_class_attribute_ref($derivation_event_dto)
|
322
|
],
|
323
|
'style' => [
|
324
|
'grid-column-start: span 2'
|
325
|
]
|
326
|
],
|
327
|
'content' => markup_to_render_array($markup)
|
328
|
];
|
329
|
return $render_array;
|
330
|
}
|
331
|
|
332
|
/**
|
333
|
* Compose a table of details for a FieldUnitDTO.
|
334
|
*
|
335
|
* The resulting DOM block level element will have a header line and details.
|
336
|
*
|
337
|
* compose_hook() implementation
|
338
|
*
|
339
|
* @param object $fu_dto
|
340
|
* the CDM FieldUnitDTO
|
341
|
* @param bool $compact_mode
|
342
|
* Currently unused,
|
343
|
*
|
344
|
* @return array
|
345
|
* The render array for the SpecimenOrObservationDTO
|
346
|
*
|
347
|
* @ingroup compose
|
348
|
*/
|
349
|
function compose_cdm_field_unit_dto_details($fu_dto, $compact_mode = FALSE) {
|
350
|
|
351
|
$table_row_data = sob_dto_details_rows($fu_dto, $compact_mode);
|
352
|
|
353
|
if (isset_not_empty($fu_dto->individualCount)) {
|
354
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('individualCount'), $fu_dto->individualCount);
|
355
|
}
|
356
|
if (isset_not_empty($fu_dto->definition)) {
|
357
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('definition'), $fu_dto->definition);
|
358
|
}
|
359
|
if (isset_not_empty($fu_dto->fieldNumber)) {
|
360
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('fieldNumber'), $fu_dto->fieldNumber);
|
361
|
}
|
362
|
if (isset_not_empty($fu_dto->primaryCollector)) {
|
363
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('primaryCollector'), $fu_dto->primaryCollector);
|
364
|
}
|
365
|
if (isset_not_empty($fu_dto->fieldNotes)) {
|
366
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('fieldNotes'), $fu_dto->fieldNotes);
|
367
|
}
|
368
|
|
369
|
$heading = $table_row_data[0]['data'][1];
|
370
|
unset($table_row_data[0]);
|
371
|
return cdm_sob_dto_table(t($heading), $table_row_data, $fu_dto, 2);
|
372
|
}
|
373
|
|
374
|
/**
|
375
|
* Compose details table for a DerivedUnitDTO.
|
376
|
*
|
377
|
* The resulting DOM block level element will have a header line and details.
|
378
|
*
|
379
|
* compose_hook() implementation
|
380
|
*
|
381
|
* @param object $du_dto
|
382
|
* the CDM DerivedUnitDTO
|
383
|
* @param bool $compact_mode
|
384
|
* Currently unused,
|
385
|
*
|
386
|
* @return array
|
387
|
* The render array for the DerivedUnitDTO
|
388
|
*
|
389
|
* @ingroup compose
|
390
|
*/
|
391
|
function compose_cdm_derived_unit_dto_storage_details($du_dto, $compact_mode = FALSE) {
|
392
|
|
393
|
$table_row_data = sob_dto_details_rows($du_dto, $compact_mode);
|
394
|
|
395
|
if (isset($du_dto->accessionNumber)) {
|
396
|
$table_row_data[] = cdm_sob_dto_table_row(
|
397
|
cdm_occurrence_field_name_label('accessionNumber'),
|
398
|
$du_dto->accessionNumber);
|
399
|
}
|
400
|
if (isset($du_dto->collection)) {
|
401
|
$table_row_data[] = cdm_sob_dto_table_row(
|
402
|
cdm_occurrence_field_name_label('collection'),
|
403
|
render_collection_dto($du_dto->collection));
|
404
|
}
|
405
|
if (isset($du_dto->storedUnder)) {
|
406
|
$taxon_name = cdm_ws_get(CDM_WS_PORTAL_NAME, array($du_dto->storedUnder->uuid));
|
407
|
$table_row_data[] = cdm_sob_dto_table_row(
|
408
|
cdm_occurrence_field_name_label('storedUnder'),
|
409
|
render_taxon_or_name($taxon_name, path_to_name($taxon_name->uuid)));
|
410
|
}
|
411
|
if (isset($du_dto->exsiccatum)) {
|
412
|
$table_row_data[] = cdm_sob_dto_table_row(
|
413
|
cdm_occurrence_field_name_label('exsiccatum'),
|
414
|
$du_dto->exsiccatum);
|
415
|
}
|
416
|
if (isset($du_dto->catalogNumber)) {
|
417
|
$table_row_data[] = cdm_sob_dto_table_row(
|
418
|
cdm_occurrence_field_name_label('catalogNumber'),
|
419
|
$du_dto->catalogNumber);
|
420
|
}
|
421
|
if (isset($du_dto->barcode)) {
|
422
|
$table_row_data[] = cdm_sob_dto_table_row(
|
423
|
cdm_occurrence_field_name_label('barcode'),
|
424
|
$du_dto->barcode);
|
425
|
}
|
426
|
if (isset($du_dto->preservationMethod)) {
|
427
|
$table_row_data[] = cdm_sob_dto_table_row(
|
428
|
cdm_occurrence_field_name_label('preservationMethod'),
|
429
|
$du_dto->preservationMethod);
|
430
|
}
|
431
|
if (isset_not_empty($du_dto->characterData)) {
|
432
|
$table_row_data[] = cdm_sob_dto_table_row(
|
433
|
cdm_occurrence_field_name_label('characterData'),
|
434
|
icon_link(path_to_specimen($du_dto->uuid), '', FALSE), false);
|
435
|
}
|
436
|
|
437
|
$heading = $table_row_data[0]['data'][1];
|
438
|
unset($table_row_data[0]);
|
439
|
return cdm_sob_dto_table(t($heading), $table_row_data, $du_dto, 1);
|
440
|
}
|
441
|
|
442
|
/**
|
443
|
* Compose an render array from a CDM GatheringDTO.
|
444
|
*
|
445
|
* The resulting DOM block level element will have a header line and details.
|
446
|
*
|
447
|
* compose_hook() implementation
|
448
|
*
|
449
|
* @param object $gathering_dto
|
450
|
* the CDM GatheringDTO object
|
451
|
* @param bool $compact_mode
|
452
|
* Currently unused,
|
453
|
*
|
454
|
* @return array
|
455
|
* The render array for the GatheringDTO
|
456
|
*
|
457
|
* @ingroup compose
|
458
|
*/
|
459
|
function compose_cdm_gathering_dto_details($gathering_dto, $compact_mode = FALSE) {
|
460
|
|
461
|
$table_row_data = [];
|
462
|
if (isset_not_empty($gathering_dto->date)) {
|
463
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('date'),
|
464
|
partialToDate($gathering_dto->date));
|
465
|
}
|
466
|
if (isset_not_empty($gathering_dto->collector)) {
|
467
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('collector'),
|
468
|
$gathering_dto->collector);
|
469
|
}
|
470
|
if (isset_not_empty($gathering_dto->description)) {
|
471
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('description'),
|
472
|
$gathering_dto->description);
|
473
|
}
|
474
|
if (isset_not_empty($gathering_dto->locality)) {
|
475
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('locality'),
|
476
|
$gathering_dto->locality);
|
477
|
}
|
478
|
if (isset_not_empty($gathering_dto->country)) {
|
479
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('country'),
|
480
|
$gathering_dto->country);
|
481
|
}
|
482
|
if (isset_not_empty($gathering_dto->collectingMethod)) {
|
483
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('collectingMethod'),
|
484
|
$gathering_dto->collectingMethod);
|
485
|
}
|
486
|
if (isset($gathering_dto->exactLocation)) {
|
487
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('exactLocation'),
|
488
|
render_point($gathering_dto->exactLocation));
|
489
|
}
|
490
|
if (isset($gathering_dto->absoluteElevation)) {
|
491
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('absoluteElevation'),
|
492
|
statistical_values_from_gathering_event($gathering_dto, 'absoluteElevation'));
|
493
|
}
|
494
|
if (isset($gathering_dto->distanceToGround) && $gathering_dto->distanceToGround > 0) {
|
495
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('distanceToGround'),
|
496
|
statistical_values_from_gathering_event($gathering_dto, 'distanceToGround'));
|
497
|
}
|
498
|
if (isset($gathering_dto->distanceToWaterSurface) && $gathering_dto->distanceToWaterSurface > 0) {
|
499
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('distanceToWaterSurface'),
|
500
|
statistical_values_from_gathering_event($gathering_dto, 'distanceToWaterSurface'));
|
501
|
}
|
502
|
if (isset_not_empty($gathering_dto->collectingAreas)) {
|
503
|
$area_representations = [];
|
504
|
foreach ($gathering_dto->collectingAreas as $area) {
|
505
|
// $area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid));
|
506
|
$area_representations[] = $area;
|
507
|
}
|
508
|
if (!empty($area_representations)) {
|
509
|
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('collectingAreas'),
|
510
|
implode(', ', $area_representations)
|
511
|
);
|
512
|
}
|
513
|
}
|
514
|
|
515
|
return cdm_sob_dto_table(t("Gathering & Location"), $table_row_data, $gathering_dto, 1);
|
516
|
}
|
517
|
|
518
|
/**
|
519
|
* Compose an render array from the SpecimenOrObservationDTO.determinedNames.
|
520
|
*
|
521
|
* The resulting DOM block level element will have a header line and details.
|
522
|
*
|
523
|
* compose_hook() implementation
|
524
|
*
|
525
|
* @param object $sob_dto
|
526
|
* the CDM SpecimenOrObservationDTO
|
527
|
* @param bool $compact_mode
|
528
|
* Currently unused,
|
529
|
*
|
530
|
* @return array
|
531
|
* The render array for the SpecimenOrObservationDTO.determinedNames
|
532
|
*
|
533
|
* @ingroup compose
|
534
|
*/
|
535
|
function compose_cdm_sob_dto_determinations($sob_dto, $compact_mode = FALSE) {
|
536
|
|
537
|
$table_row_data = [];
|
538
|
|
539
|
foreach ($sob_dto->determinedNames as $name) {
|
540
|
$taxon_name = cdm_ws_get(CDM_WS_PORTAL_NAME, $name->uuid);
|
541
|
$table_row_data[] = cdm_sob_dto_table_row(NULL, render_taxon_or_name($taxon_name, url(path_to_name($taxon_name->uuid))));
|
542
|
}
|
543
|
|
544
|
$label = count($table_row_data) > 1 ? t("Identifications") : t("Identification");
|
545
|
return cdm_sob_dto_table($label, $table_row_data, $sob_dto, 1);
|
546
|
}
|
547
|
|
548
|
/**
|
549
|
* Compose an render array from the DerivedUnitDTO.specimenTypeDesignations.
|
550
|
*
|
551
|
* The resulting DOM block level element will have a header line and details.
|
552
|
*
|
553
|
* compose_hook() implementation
|
554
|
*
|
555
|
* @param object $unit_dto
|
556
|
* the CDM DerivedUnitDTO
|
557
|
* @param bool $compact_mode
|
558
|
* Currently unused,
|
559
|
*
|
560
|
* @return array
|
561
|
* The render array for the SpecimenOrObservationDTO.determinedNames
|
562
|
*
|
563
|
* @ingroup compose
|
564
|
*/
|
565
|
function compose_cdm_unit_dto_type_designations($unit_dto, $compact_mode = FALSE) {
|
566
|
|
567
|
$table_row_data = [];
|
568
|
|
569
|
if (isset_not_empty($unit_dto->specimenTypeDesignations)) {
|
570
|
$table_row_data[] = cdm_sob_dto_table_row(
|
571
|
NULL,
|
572
|
render_specimen_typedesignation_dto($unit_dto->specimenTypeDesignations));
|
573
|
}
|
574
|
|
575
|
return cdm_sob_dto_table(t('Type designations'), $table_row_data, $unit_dto, 5, 2);
|
576
|
}
|
577
|
|
578
|
/**
|
579
|
* @param $listOfMedia
|
580
|
* @param $sob_dto
|
581
|
* @param $heading
|
582
|
*
|
583
|
* @return array|null
|
584
|
*/
|
585
|
function cdm_sob_dto_media_table(array $listOfMedia, $sob_dto, $heading) {
|
586
|
$table_row_data = [];
|
587
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
588
|
$captionElements = array(
|
589
|
'title',
|
590
|
'#uri' => t('open media'),
|
591
|
);
|
592
|
$gallery_markup = compose_cdm_media_gallerie(array(
|
593
|
'mediaList' => $listOfMedia,
|
594
|
'galleryName' => $sob_dto->uuid,
|
595
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
596
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
597
|
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
|
598
|
'captionElements' => $captionElements,
|
599
|
'mediaLinkType' => 'LIGHTBOX',
|
600
|
'alternativeMediaUri' => NULL,
|
601
|
'galleryLinkUri' => NULL,
|
602
|
'showCaption' => true
|
603
|
));
|
604
|
$table_row_data[] = cdm_sob_dto_table_row(NULL, $gallery_markup);
|
605
|
$grid_col_span = count($listOfMedia) > 1 ? 2 : NULL;
|
606
|
return cdm_sob_dto_table(t($heading), $table_row_data, $sob_dto, 20, $grid_col_span);
|
607
|
}
|
608
|
|
609
|
/**
|
610
|
* Compose an render array from the DerivedUnitDTO.sequences.
|
611
|
*
|
612
|
* The resulting DOM block level element will have a header line and details.
|
613
|
*
|
614
|
* compose_hook() implementation
|
615
|
*
|
616
|
* @param object $unit_dto
|
617
|
* the CDM DerivedUnitDTO
|
618
|
* @param bool $compact_mode
|
619
|
* Currently unused,
|
620
|
*
|
621
|
* @return array
|
622
|
* The render array for the DerivedUnitDTO.sequences.
|
623
|
*
|
624
|
* @ingroup compose
|
625
|
*
|
626
|
* TODO see #3347 (services and REST service controller for molecular classes implemented)
|
627
|
*/
|
628
|
function compose_cdm_derived_unit_dto_sequences($unit_dto, $compact_mode = FALSE) {
|
629
|
|
630
|
$table_row_data = [];
|
631
|
if(isset_not_empty($unit_dto->sequences)){
|
632
|
foreach ($unit_dto->sequences as $sequence) {
|
633
|
if (isset($sequence->geneticAccessionNumber)) {
|
634
|
$table_row_data[] = cdm_sob_dto_table_row(
|
635
|
cdm_occurrence_field_name_label('geneticAccessionNumber'),
|
636
|
$sequence->geneticAccessionNumber);
|
637
|
}
|
638
|
// TODO ....
|
639
|
}
|
640
|
}
|
641
|
|
642
|
return cdm_sob_dto_table(t('Storage'), $table_row_data, $unit_dto, 1);
|
643
|
}
|
644
|
|
645
|
/**
|
646
|
* Creates a form array for showing details of SpecimenOrObservationDTO in a
|
647
|
* tabular form with heading.
|
648
|
*
|
649
|
* @param $table_heading
|
650
|
* @param array $table_row_data
|
651
|
* @param $sob_dto
|
652
|
* @param $weight
|
653
|
* The weight determining the order of the drupal render element
|
654
|
* @param $grid_col_span
|
655
|
* The number of grid colums the table should
|
656
|
*
|
657
|
* @return array|null
|
658
|
*/
|
659
|
function cdm_sob_dto_table($table_heading, array $table_row_data, $sob_dto, $weight = NULL, $grid_col_span = 1) {
|
660
|
|
661
|
if (count($table_row_data) > 0) {
|
662
|
$wrapper_style = '';
|
663
|
if($grid_col_span > 1){
|
664
|
$wrapper_style = ' style="grid-column-start: span ' . $grid_col_span. ';"';
|
665
|
}
|
666
|
$sob_table = [
|
667
|
'#theme' => 'table',
|
668
|
'#prefix' => '<div class="table-wrapper"' . $wrapper_style . '>',
|
669
|
'#suffix' => '</div>',
|
670
|
'#header' => [
|
671
|
[
|
672
|
'data' => $table_heading,
|
673
|
'colspan' => 2,
|
674
|
],
|
675
|
],
|
676
|
"#rows" => $table_row_data,
|
677
|
"#attributes" => [
|
678
|
"class" => [
|
679
|
'details-table',
|
680
|
'details-table-' . normalize_to_class_attribute($table_heading),
|
681
|
html_class_attribute_ref($sob_dto)
|
682
|
],
|
683
|
],
|
684
|
];
|
685
|
if ($weight) {
|
686
|
$sob_table['#weight'] = $weight;
|
687
|
}
|
688
|
return $sob_table;
|
689
|
}
|
690
|
return NULL;
|
691
|
}
|
692
|
|
693
|
function cdm_sob_dto_table_row($label, $value) {
|
694
|
if ($value) {
|
695
|
if($label) {
|
696
|
return [
|
697
|
'data' => [
|
698
|
[
|
699
|
'data' => str_replace(':', '', $label),
|
700
|
'class' => [
|
701
|
'label',
|
702
|
],
|
703
|
],
|
704
|
$value,
|
705
|
],
|
706
|
'no_striping' => TRUE,
|
707
|
];
|
708
|
} else {
|
709
|
// value spanning two columns
|
710
|
return [
|
711
|
'data' => [
|
712
|
[
|
713
|
'data' => $value,
|
714
|
'colspan' => 2,
|
715
|
]
|
716
|
],
|
717
|
'no_striping' => TRUE,
|
718
|
];
|
719
|
}
|
720
|
}
|
721
|
return NULL;
|
722
|
}
|