Revision 886f6760
Added by Andreas Kohlbecker about 3 years ago
modules/cdm_dataportal/includes/occurrences_new.inc | ||
---|---|---|
77 | 77 |
$root_items = []; |
78 | 78 |
//we need one more item to contain the items of one level (fieldunit, derivate data etc.) |
79 | 79 |
foreach ($root_unit_dtos as &$sob_dto) { |
80 |
$field_unit_dto_render_array = compose_cdm_specimen_or_observation_dto($sob_dto); |
|
80 |
$field_unit_dto_render_array = compose_cdm_specimen_or_observation_dto_details_grid($sob_dto);
|
|
81 | 81 |
$root_item = [ |
82 | 82 |
'#prefix' => '<div class="derived-unit-tree">', |
83 | 83 |
'#suffix' => '</div>', |
... | ... | |
148 | 148 |
$item['class'] = ['derived-unit-item ', html_class_attribute_ref($sob_dto)]; |
149 | 149 |
// data" element of the array is used as the contents of the list item |
150 | 150 |
$item['data'] = []; |
151 |
$units_render_array = compose_cdm_specimen_or_observation_dto($sob_dto); |
|
151 |
$units_render_array = compose_cdm_specimen_or_observation_dto_details_grid($sob_dto);
|
|
152 | 152 |
$item['data'] = '<div class="unit-header"><div class="unit-label">' . $sob_dto->label . '</div></div>' |
153 | 153 |
. '<div class="unit-content">' . drupal_render($units_render_array) . '</div>'; |
154 | 154 |
if (isset($sob_dto->derivatives) && sizeof($sob_dto->derivatives) > 0) { |
... | ... | |
163 | 163 |
} |
164 | 164 |
|
165 | 165 |
/** |
166 |
* Compose an render array from a CDM SpecimenOrObservationDTO, without |
|
167 |
* subordinate derivatives. |
|
166 |
* Compose grid of details tabled for a CDM SpecimenOrObservationDTO |
|
168 | 167 |
* |
169 | 168 |
* The resulting render array will contain separate DOM block level elements |
170 | 169 |
* with header line for the various kind of information like, location, |
171 | 170 |
* gathering, specimen/observation, DNA, etc. |
172 | 171 |
* |
173 |
* For showing the derivation hierarchy see methods like |
|
174 |
* derived_units_sub_tree() |
|
172 |
* |
|
173 |
* Subordinate derivatives will not be included. For showing the derivation |
|
174 |
* hierarchy see methods like derived_units_sub_tree() |
|
175 | 175 |
* |
176 | 176 |
* compose_hook() implementation |
177 | 177 |
* |
... | ... | |
191 | 191 |
* |
192 | 192 |
* @ingroup compose |
193 | 193 |
*/ |
194 |
function compose_cdm_specimen_or_observation_dto($sob_dto, $compact_mode = FALSE, &$derivatives = NULL) { |
|
194 |
function compose_cdm_specimen_or_observation_dto_details_grid($sob_dto, $compact_mode = FALSE, &$derivatives = NULL) {
|
|
195 | 195 |
//TODO !!!! add derivation event information like method, etc |
196 | 196 |
$render_array = []; |
197 | 197 |
if (!$sob_dto) { |
... | ... | |
221 | 221 |
|
222 | 222 |
return $render_array; |
223 | 223 |
} |
224 |
/** |
|
225 |
* Data rows with details for a SpecimenOrObservationDTO to be used in a table |
|
226 |
* @param object $sob_dto |
|
227 |
* the CDM SpecimenOrObservationDTO |
|
228 |
* @param bool $compact_mode |
|
229 |
* Currently unused, |
|
230 |
* |
|
231 |
* @return array |
|
232 |
* The data rows |
|
233 |
*/ |
|
234 |
function sob_dto_details_rows($sob_dto, $compact_mode = FALSE) { |
|
235 |
|
|
236 |
$table_row_data = []; |
|
237 |
|
|
238 |
if (isset_not_empty($sob_dto->recordBase)) { |
|
239 |
$label = cdm_term_representation($sob_dto->recordBase); |
|
240 |
if($label == 'Dna Sample'){ |
|
241 |
$label == 'DNA Sample'; |
|
242 |
} |
|
243 |
$table_row_data[0] = cdm_sob_dto_table_row( |
|
244 |
cdm_occurrence_field_name_label('recordBase'), |
|
245 |
$label); |
|
246 |
} |
|
247 |
if (isset_not_empty($sob_dto->kindOfUnit)) { |
|
248 |
$table_row_data[] = cdm_sob_dto_table_row( |
|
249 |
cdm_occurrence_field_name_label('kindOfUnit'), |
|
250 |
cdm_term_representation($sob_dto->kindOfUnit)); |
|
251 |
} |
|
252 |
if (isset_not_empty($sob_dto->preferredStableUri)) { |
|
253 |
$table_row_data[] = cdm_sob_dto_table_row( |
|
254 |
cdm_occurrence_field_name_label('preferredStableUri'), |
|
255 |
cdm_external_uri($sob_dto->preferredStableUri, false)); |
|
256 |
} |
|
257 |
if (isset_not_empty($sob_dto->sex)) { |
|
258 |
$table_row_data[] = cdm_sob_dto_table_row( |
|
259 |
cdm_occurrence_field_name_label('sex'), |
|
260 |
cdm_term_representation($sob_dto->sex)); |
|
261 |
} |
|
262 |
if (isset_not_empty($sob_dto->lifeStage)) { |
|
263 |
$table_row_data[] = cdm_sob_dto_table_row( |
|
264 |
cdm_occurrence_field_name_label('lifeStage'), |
|
265 |
cdm_term_representation($sob_dto->lifeStage)); |
|
266 |
} |
|
267 |
|
|
268 |
return $table_row_data; |
|
269 |
} |
|
270 |
|
|
224 | 271 |
|
225 | 272 |
/** |
226 |
* Compose an render array from a CDM FieldUnitDTO, without subordinate |
|
227 |
* derivatives. |
|
273 |
* Compose a table of details for a FieldUnitDTO. |
|
228 | 274 |
* |
229 | 275 |
* The resulting DOM block level element will have a header line and details. |
230 | 276 |
* |
231 |
* For showing the derivation hierarchy see methods like |
|
232 |
* derived_units_sub_tree() |
|
233 |
* |
|
234 | 277 |
* compose_hook() implementation |
235 | 278 |
* |
236 | 279 |
* @param object $fu_dto |
237 | 280 |
* the CDM FieldUnitDTO |
238 |
* the render array for. |
|
239 | 281 |
* @param bool $compact_mode |
240 | 282 |
* Currently unused, |
241 | 283 |
* |
... | ... | |
246 | 288 |
*/ |
247 | 289 |
function compose_cdm_field_unit_dto_details($fu_dto, $compact_mode = FALSE) { |
248 | 290 |
|
249 |
$table_row_data = []; |
|
250 |
if (isset_not_empty($fu_dto->sex)) { |
|
251 |
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('sex'), cdm_term_representation($fu_dto->sex)); |
|
252 |
} |
|
253 |
if (isset_not_empty($fu_dto->lifeStage)) { |
|
254 |
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('lifeStage'), cdm_term_representation($fu_dto->lifeStage)); |
|
255 |
} |
|
256 |
if (isset_not_empty($fu_dto->kindOfUnit)) { |
|
257 |
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('kindOfUnit'), cdm_term_representation($fu_dto->kindOfUnit)); |
|
258 |
} |
|
291 |
$table_row_data = sob_dto_details_rows($fu_dto, $compact_mode); |
|
292 |
|
|
259 | 293 |
if (isset_not_empty($fu_dto->individualCount)) { |
260 | 294 |
$table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('individualCount'), $fu_dto->individualCount); |
261 | 295 |
} |
... | ... | |
275 | 309 |
return cdm_sob_dto_table(t("Field unit"), $table_row_data, $fu_dto, 2); |
276 | 310 |
} |
277 | 311 |
|
312 |
/** |
|
313 |
* Compose a table of details for a DerivedUnitDTO. |
|
314 |
* |
|
315 |
* The resulting DOM block level element will have a header line and details. |
|
316 |
* |
|
317 |
* compose_hook() implementation |
|
318 |
* |
|
319 |
* @param object $du_dto |
|
320 |
* the CDM DerivedUnitDTO |
|
321 |
* @param bool $compact_mode |
|
322 |
* Currently unused, |
|
323 |
* |
|
324 |
* @return array |
|
325 |
* The render array for the DerivedUnitDTO |
|
326 |
* |
|
327 |
* @ingroup compose |
|
328 |
*/ |
|
329 |
function compose_cdm_derived_unit_dto_details($du_dto, $compact_mode = FALSE) { |
|
330 |
|
|
331 |
$table_row_data = sob_dto_details_rows($du_dto, $compact_mode); |
|
332 |
|
|
333 |
if (isset_not_empty($du_dto->characterData)) { |
|
334 |
$table_row_data[] = cdm_sob_dto_table_row( |
|
335 |
cdm_occurrence_field_name_label('characterData'), |
|
336 |
icon_link(path_to_specimen($du_dto->uuid), '', FALSE), false); |
|
337 |
} |
|
338 |
|
|
339 |
return cdm_sob_dto_table(t("Field unit"), $table_row_data, $du_dto, 2); |
|
340 |
} |
|
341 |
|
|
278 | 342 |
/** |
279 | 343 |
* Compose an render array from a CDM GatheringDTO. |
280 | 344 |
* |
... | ... | |
430 | 494 |
*/ |
431 | 495 |
function compose_cdm_derived_unit_dto_storage_details($sob_dto, $compact_mode = FALSE) { |
432 | 496 |
|
433 |
$table_row_data = [];
|
|
497 |
$table_row_data = sob_dto_details_rows($sob_dto, $compact_mode);
|
|
434 | 498 |
|
499 |
if (isset($sob_dto->accessionNumber)) { |
|
500 |
$table_row_data[] = cdm_sob_dto_table_row( |
|
501 |
cdm_occurrence_field_name_label('accessionNumber'), |
|
502 |
$sob_dto->accessionNumber); |
|
503 |
} |
|
435 | 504 |
if (isset($sob_dto->collection)) { |
436 | 505 |
$table_row_data[] = cdm_sob_dto_table_row( |
437 | 506 |
cdm_occurrence_field_name_label('collection'), |
... | ... | |
443 | 512 |
cdm_occurrence_field_name_label('storedUnder'), |
444 | 513 |
render_taxon_or_name($taxon_name, path_to_name($taxon_name->uuid))); |
445 | 514 |
} |
446 |
if (isset($sob_dto->storedUnder)) { |
|
447 |
$taxon_name = cdm_ws_get(CDM_WS_PORTAL_NAME, array($sob_dto->storedUnder->uuid)); |
|
448 |
$table_row_data[] = cdm_sob_dto_table_row( |
|
449 |
cdm_occurrence_field_name_label('storedUnder'), |
|
450 |
render_taxon_or_name($taxon_name, path_to_name($taxon_name->uuid))); |
|
451 |
} |
|
452 | 515 |
return cdm_sob_dto_table(t('Storage'), $table_row_data, $sob_dto, 1); |
453 | 516 |
} |
454 | 517 |
|
Also available in: Unified diff
ref #7599 ref #6866 specimen details tables additional data for field units and derived units