Revision ca7468b6
Added by Andreas Kohlbecker over 4 years ago
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()