Revision ca7468b6
Added by Andreas Kohlbecker over 4 years ago
modules/cdm_dataportal/includes/occurrences.inc | ||
---|---|---|
989 | 989 |
* Creates an array from a list of FieldUnitDTOs. |
990 | 990 |
* |
991 | 991 |
* |
992 |
* @param object $specimenOrObservations
|
|
992 |
* @param object $fieldunit_dtos
|
|
993 | 993 |
* list of FieldUnitDTOs |
994 | 994 |
* @return array |
995 | 995 |
* An array containing the hierarchy of the field units corresponding to the taxon |
996 | 996 |
* |
997 | 997 |
* @ingroup compose |
998 | 998 |
*/ |
999 |
function compose_specimen_array(array $specimenOrObservations){
|
|
999 |
function compose_specimen_array(array $fieldunit_dtos){
|
|
1000 | 1000 |
$items_specimen = array(); |
1001 | 1001 |
$items = array(); |
1002 | 1002 |
|
1003 | 1003 |
//we need one more item to contain the items of one level (fieldunit, derivate data etc.) |
1004 |
foreach ($specimenOrObservations as &$specimenOrObservation) {
|
|
1004 |
foreach ($fieldunit_dtos as &$fieldunit_dto) {
|
|
1005 | 1005 |
|
1006 |
$items['data'] = $specimenOrObservation->listLabel ;
|
|
1007 |
$specimen = compose_cdm_specimen_or_observation_tree_entry($specimenOrObservation);
|
|
1006 |
$items['data'] = $fieldunit_dto->listLabel ;
|
|
1007 |
$specimen = compose_cdm_specimen_or_observation_tree_entry($fieldunit_dto);
|
|
1008 | 1008 |
$children = array(); |
1009 | 1009 |
$child = array(); |
1010 | 1010 |
$child['data'] =$specimen; |
1011 | 1011 |
// $children[] = create_specimen_array($specimenOrObservation->derivates); |
1012 |
if (isset($specimenOrObservation->derivates) && sizeof($specimenOrObservation->derivates) > 0){
|
|
1013 |
$child['children']= compose_specimen_array($specimenOrObservation->derivates);
|
|
1012 |
if (isset($fieldunit_dto->derivates) && sizeof($fieldunit_dto->derivates) > 0){
|
|
1013 |
$child['children']= compose_specimen_array($fieldunit_dto->derivates);
|
|
1014 | 1014 |
} |
1015 | 1015 |
$children[]=$child; |
1016 | 1016 |
$items['children'] = $children; |
... | ... | |
1410 | 1410 |
return $out; |
1411 | 1411 |
} |
1412 | 1412 |
|
1413 |
|
|
1414 |
/** |
|
1415 |
* Composes a BOTTOM-UP-SPECIMEN-TABLE |
|
1416 |
* @param $specimensOrObservations |
|
1417 |
* @return array |
|
1418 |
* A drupal render array with the following keys: |
|
1419 |
* - 'specimen_list' |
|
1420 |
* - 'pager' |
|
1421 |
* |
|
1422 |
* @ingroup Compose |
|
1423 |
*/ |
|
1424 |
function compose_specimens_table_bottom_up($specimensOrObservations) |
|
1425 |
{ |
|
1426 |
|
|
1427 |
// --- generate the specimen list as table |
|
1428 |
$specimen_table = array( |
|
1429 |
'#theme' => 'table', |
|
1430 |
'#weight' => 2, |
|
1431 |
// prefix attributes and rows with '#' to let it pass toF the theme function, |
|
1432 |
// otherwise it is handled as child render array |
|
1433 |
'#attributes' => array('class' => 'specimens'), |
|
1434 |
'#rows' => array(), |
|
1435 |
); |
|
1436 |
|
|
1437 |
if ($specimensOrObservations) { |
|
1438 |
|
|
1439 |
foreach ($specimensOrObservations as $specimenOrObservation) { |
|
1440 |
|
|
1441 |
$mediaList = array(); |
|
1442 |
if (is_array($specimenOrObservation->_fieldObjectMedia)) { |
|
1443 |
$mediaList = array_merge($mediaList, $specimenOrObservation->_fieldObjectMedia); |
|
1444 |
} |
|
1445 |
if (is_array($specimenOrObservation->_derivedUnitMedia)) { |
|
1446 |
$mediaList = array_merge($mediaList, $specimenOrObservation->_derivedUnitMedia); |
|
1447 |
} |
|
1448 |
|
|
1449 |
|
|
1450 |
// typelabel will contain the typeStatus |
|
1451 |
$type_label = ''; |
|
1452 |
$typeDesignationPager = cdm_ws_get(CDM_WS_OCCURRENCE . '/$0/specimenTypeDesignations', $specimenOrObservation->uuid); |
|
1453 |
if (isset($typeDesignationPager) and isset($typeDesignationPager->records)) { |
|
1454 |
$type_status = array(); |
|
1455 |
foreach ($typeDesignationPager->records as $typeDesignation) { |
|
1456 |
if (isset($typeDesignation->typeStatus->representation_L10n)) { |
|
1457 |
$type_status[] = $typeDesignation->typeStatus->representation_L10n; |
|
1458 |
} |
|
1459 |
} |
|
1460 |
$type_label = implode(', ', $type_status); |
|
1461 |
if ($type_label) { |
|
1462 |
$type_label .= ': '; |
|
1463 |
} |
|
1464 |
} |
|
1465 |
|
|
1466 |
// --- Specimen entry as dynamic label: |
|
1467 |
// -> Dynabox for the specimenOrObservation |
|
1468 |
$gallery_name = $specimenOrObservation->uuid; |
|
1469 |
|
|
1470 |
$derived_unit_ws_request = cdm_compose_url(CDM_WS_OCCURRENCE, array($specimenOrObservation->uuid)); |
|
1471 |
// --- Render associated media. |
|
1472 |
$gallery_html = ''; |
|
1473 |
if (count($mediaList) > 0) { |
|
1474 |
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME); |
|
1475 |
$captionElements = array( |
|
1476 |
'#uri' => t('open media'), |
|
1477 |
); |
|
1478 |
|
|
1479 |
$gallery_html = compose_cdm_media_gallerie(array( |
|
1480 |
'mediaList' => $mediaList, |
|
1481 |
'galleryName' => $gallery_name, |
|
1482 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'], |
|
1483 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'], |
|
1484 |
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null, |
|
1485 |
'captionElements' => $captionElements, |
|
1486 |
'mediaLinkType' => 'LIGHTBOX', |
|
1487 |
'alternativeMediaUri' => NULL, |
|
1488 |
'galleryLinkUri' => NULL, |
|
1489 |
)); |
|
1490 |
} |
|
1491 |
//here we should use the data we already have |
|
1492 |
$label_html = cdm_dynabox( |
|
1493 |
$specimenOrObservation->uuid, |
|
1494 |
$type_label . $specimenOrObservation->titleCache, |
|
1495 |
$derived_unit_ws_request, |
|
1496 |
'cdm_specimen_or_observation', |
|
1497 |
'Click for details', |
|
1498 |
array('div', 'div'), |
|
1499 |
array(), |
|
1500 |
null, // $content_element_selector |
|
1501 |
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').hide(); }', // open_callback |
|
1502 |
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').show(); }' // close_callback |
|
1503 |
); |
|
1504 |
|
|
1505 |
// --- Render associated media. |
|
1506 |
$gallery_html = ''; |
|
1507 |
if (count($mediaList) > 0) { |
|
1508 |
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME); |
|
1509 |
$captionElements = array( |
|
1510 |
'#uri' => t('open media'), |
|
1511 |
); |
|
1512 |
|
|
1513 |
$gallery_html = compose_cdm_media_gallerie(array( |
|
1514 |
'mediaList' => $mediaList, |
|
1515 |
'galleryName' => $gallery_name, |
|
1516 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'], |
|
1517 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'], |
|
1518 |
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null, |
|
1519 |
'captionElements' => $captionElements, |
|
1520 |
'mediaLinkType' => 'LIGHTBOX', |
|
1521 |
'alternativeMediaUri' => NULL, |
|
1522 |
'galleryLinkUri' => NULL, |
|
1523 |
)); |
|
1524 |
} |
|
1525 |
|
|
1526 |
$specimen_table['#rows'][] = array( |
|
1527 |
// An array of table rows. Every row is an array of cells, or an associative array |
|
1528 |
'data' => array( |
|
1529 |
// Each cell can be either a string or an associative array |
|
1530 |
$label_html . $gallery_html |
|
1531 |
), |
|
1532 |
'class' => array( |
|
1533 |
'descriptionElement', |
|
1534 |
'descriptionElement_IndividualsAssociation' |
|
1535 |
), |
|
1536 |
); |
|
1537 |
} |
|
1538 |
} |
|
1539 |
|
|
1540 |
return $specimen_table; |
|
1541 |
} |
|
1542 |
|
modules/cdm_dataportal/includes/pages.inc | ||
---|---|---|
248 | 248 |
return $render_array; |
249 | 249 |
} |
250 | 250 |
|
251 |
/** |
|
252 |
* Composes a BOTTOM-UP-SPECIMEN-TABLE |
|
253 |
* @param $specimensOrObservations |
|
254 |
* @return array |
|
255 |
* A drupal render array with the following keys: |
|
256 |
* - 'specimen_list' |
|
257 |
* - 'pager' |
|
258 |
* |
|
259 |
* @ingroup Compose |
|
260 |
*/ |
|
261 |
function compose_specimens_table_bottom_up($specimensOrObservations) |
|
262 |
{ |
|
263 |
|
|
264 |
// --- generate the specimen list as table |
|
265 |
$specimen_table = array( |
|
266 |
'#theme' => 'table', |
|
267 |
'#weight' => 2, |
|
268 |
// prefix attributes and rows with '#' to let it pass toF the theme function, |
|
269 |
// otherwise it is handled as child render array |
|
270 |
'#attributes' => array('class' => 'specimens'), |
|
271 |
'#rows' => array(), |
|
272 |
); |
|
273 |
|
|
274 |
if ($specimensOrObservations) { |
|
275 |
|
|
276 |
foreach ($specimensOrObservations as $specimenOrObservation) { |
|
277 |
|
|
278 |
$mediaList = array(); |
|
279 |
if (is_array($specimenOrObservation->_fieldObjectMedia)) { |
|
280 |
$mediaList = array_merge($mediaList, $specimenOrObservation->_fieldObjectMedia); |
|
281 |
} |
|
282 |
if (is_array($specimenOrObservation->_derivedUnitMedia)) { |
|
283 |
$mediaList = array_merge($mediaList, $specimenOrObservation->_derivedUnitMedia); |
|
284 |
} |
|
285 |
|
|
286 |
|
|
287 |
// typelabel will contain the typeStatus |
|
288 |
$type_label = ''; |
|
289 |
$typeDesignationPager = cdm_ws_get(CDM_WS_OCCURRENCE . '/$0/specimenTypeDesignations', $specimenOrObservation->uuid); |
|
290 |
if (isset($typeDesignationPager) and isset($typeDesignationPager->records)) { |
|
291 |
$type_status = array(); |
|
292 |
foreach ($typeDesignationPager->records as $typeDesignation) { |
|
293 |
if (isset($typeDesignation->typeStatus->representation_L10n)) { |
|
294 |
$type_status[] = $typeDesignation->typeStatus->representation_L10n; |
|
295 |
} |
|
296 |
} |
|
297 |
$type_label = implode(', ', $type_status); |
|
298 |
if ($type_label) { |
|
299 |
$type_label .= ': '; |
|
300 |
} |
|
301 |
} |
|
302 |
|
|
303 |
// --- Specimen entry as dynamic label: |
|
304 |
// -> Dynabox for the specimenOrObservation |
|
305 |
$gallery_name = $specimenOrObservation->uuid; |
|
306 |
|
|
307 |
$derived_unit_ws_request = cdm_compose_url(CDM_WS_OCCURRENCE, array($specimenOrObservation->uuid)); |
|
308 |
// --- Render associated media. |
|
309 |
$gallery_html = ''; |
|
310 |
if (count($mediaList) > 0) { |
|
311 |
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME); |
|
312 |
$captionElements = array( |
|
313 |
'#uri' => t('open media'), |
|
314 |
); |
|
315 |
|
|
316 |
$gallery_html = compose_cdm_media_gallerie(array( |
|
317 |
'mediaList' => $mediaList, |
|
318 |
'galleryName' => $gallery_name, |
|
319 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'], |
|
320 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'], |
|
321 |
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null, |
|
322 |
'captionElements' => $captionElements, |
|
323 |
'mediaLinkType' => 'LIGHTBOX', |
|
324 |
'alternativeMediaUri' => NULL, |
|
325 |
'galleryLinkUri' => NULL, |
|
326 |
)); |
|
327 |
} |
|
328 |
//here we should use the data we already have |
|
329 |
$label_html = cdm_dynabox( |
|
330 |
$specimenOrObservation->uuid, |
|
331 |
$type_label . $specimenOrObservation->titleCache, |
|
332 |
$derived_unit_ws_request, |
|
333 |
'cdm_specimen_or_observation', |
|
334 |
'Click for details', |
|
335 |
array('div', 'div'), |
|
336 |
array(), |
|
337 |
null, // $content_element_selector |
|
338 |
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').hide(); }', // open_callback |
|
339 |
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').show(); }' // close_callback |
|
340 |
); |
|
341 |
|
|
342 |
// --- Render associated media. |
|
343 |
$gallery_html = ''; |
|
344 |
if (count($mediaList) > 0) { |
|
345 |
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME); |
|
346 |
$captionElements = array( |
|
347 |
'#uri' => t('open media'), |
|
348 |
); |
|
349 |
|
|
350 |
$gallery_html = compose_cdm_media_gallerie(array( |
|
351 |
'mediaList' => $mediaList, |
|
352 |
'galleryName' => $gallery_name, |
|
353 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'], |
|
354 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'], |
|
355 |
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null, |
|
356 |
'captionElements' => $captionElements, |
|
357 |
'mediaLinkType' => 'LIGHTBOX', |
|
358 |
'alternativeMediaUri' => NULL, |
|
359 |
'galleryLinkUri' => NULL, |
|
360 |
)); |
|
361 |
} |
|
362 |
|
|
363 |
$specimen_table['#rows'][] = array( |
|
364 |
// An array of table rows. Every row is an array of cells, or an associative array |
|
365 |
'data' => array( |
|
366 |
// Each cell can be either a string or an associative array |
|
367 |
$label_html . $gallery_html |
|
368 |
), |
|
369 |
'class' => array( |
|
370 |
'descriptionElement', |
|
371 |
'descriptionElement_IndividualsAssociation' |
|
372 |
), |
|
373 |
); |
|
374 |
} |
|
375 |
} |
|
376 |
|
|
377 |
return $specimen_table; |
|
378 |
} |
|
379 | 251 |
|
380 | 252 |
/** |
381 | 253 |
* Creates the drupal render array for the table showing all derivated which are |
Also available in: Unified diff
ref #8403 moving compose_specimens_table_bottom_up() to occurences.inc and renaming parameter in compose_specimen_array()