1 |
c70b93c3
|
Andreas Kohlbecker
|
<?php
|
2 |
f19f47fa
|
Andreas Kohlbecker
|
/**
|
3 |
|
|
* @file
|
4 |
bff67f14
|
Patric Plitzner
|
* Functions for dealing with CDM entities of type SpecimenOrOccurrences
|
5 |
f19f47fa
|
Andreas Kohlbecker
|
*
|
6 |
|
|
* @copyright
|
7 |
|
|
* (C) 2007-2012 EDIT
|
8 |
|
|
* European Distributed Institute of Taxonomy
|
9 |
|
|
* http://www.e-taxonomy.eu
|
10 |
|
|
*
|
11 |
|
|
* The contents of this module are subject to the Mozilla
|
12 |
|
|
* Public License Version 1.1.
|
13 |
|
|
* @see http://www.mozilla.org/MPL/MPL-1.1.html
|
14 |
|
|
*
|
15 |
|
|
* @author
|
16 |
|
|
* - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
|
17 |
c70b93c3
|
Andreas Kohlbecker
|
*/
|
18 |
|
|
|
19 |
b810158e
|
Patric Plitzner
|
|
20 |
|
|
/**
|
21 |
30845bda
|
Andreas Kohlbecker
|
* Provides the HTML markup for a specimen page
|
22 |
|
|
*
|
23 |
|
|
* @param $specimen
|
24 |
|
|
*
|
25 |
b810158e
|
Patric Plitzner
|
* @return string
|
26 |
30845bda
|
Andreas Kohlbecker
|
* The markup for a specimen page
|
27 |
b810158e
|
Patric Plitzner
|
*/
|
28 |
30845bda
|
Andreas Kohlbecker
|
function render_cdm_specimen_page($specimen, $is_specimen_page = false)
|
29 |
b810158e
|
Patric Plitzner
|
{
|
30 |
|
|
$detail_html = "";
|
31 |
|
|
//link to specimen page
|
32 |
30845bda
|
Andreas Kohlbecker
|
$pathToSpecimen = path_to_specimen($specimen->uuid);
|
33 |
|
|
if (!$is_specimen_page) {
|
34 |
|
|
$specimenPageLink = l($specimen->accessionNumber, $pathToSpecimen, array('attributes' => array('target' => '_blank')));
|
35 |
25fc25ca
|
Patrick Plitzner
|
$detail_html .= "<strong>Specimen summary: $specimenPageLink</strong><br>";
|
36 |
a7a302a0
|
Patric Plitzner
|
}
|
37 |
|
|
|
38 |
b3ac03bf
|
Katja Luther
|
|
39 |
30845bda
|
Andreas Kohlbecker
|
if($is_specimen_page) {
|
40 |
|
|
if($specimen->citation){
|
41 |
6a660dc3
|
Patrick Plitzner
|
$detail_html .= "<br>".$specimen->citation."<br>";
|
42 |
b3ac03bf
|
Katja Luther
|
|
43 |
fdc85125
|
Patric Plitzner
|
}
|
44 |
b810158e
|
Patric Plitzner
|
}
|
45 |
c10f70e4
|
Katja Luther
|
if ($specimen->preferredStableUri) {
|
46 |
|
|
$stableIdentifierLink = l($specimen->preferredStableUri, $specimen->preferredStableUri, array('attributes' => array('target' => '_blank')));
|
47 |
907cc9b4
|
Patrick Plitzner
|
$detail_html .= create_label("Preferred stable URI") . $stableIdentifierLink . "<br>";
|
48 |
1cefb4e5
|
Patrick Plitzner
|
}
|
49 |
c10f70e4
|
Katja Luther
|
if ($is_specimen_page) {
|
50 |
fdc85125
|
Patric Plitzner
|
// associated taxa
|
51 |
c10f70e4
|
Katja Luther
|
if ($specimen->associatedTaxa) {
|
52 |
3dd58832
|
Patric Plitzner
|
$detail_html .= "<br>";
|
53 |
c10f70e4
|
Katja Luther
|
$detail_html .= create_label("Associated with");
|
54 |
|
|
if (sizeof($specimen->associatedTaxa) > 1) {
|
55 |
|
|
$detail_html .= "<br>";
|
56 |
|
|
}
|
57 |
|
|
foreach ($specimen->associatedTaxa as $associatedTaxon) {
|
58 |
|
|
$detail_html .= l($associatedTaxon->second, path_to_taxon($associatedTaxon->first, "specimens"));//$associatedTaxon->second."<br>";
|
59 |
|
|
}
|
60 |
fa09fe7d
|
Patrick Plitzner
|
$detail_html .= "<br>";
|
61 |
fdc85125
|
Patric Plitzner
|
}
|
62 |
b810158e
|
Patric Plitzner
|
}
|
63 |
c10f70e4
|
Katja Luther
|
// - type information
|
64 |
b810158e
|
Patric Plitzner
|
$types = "";
|
65 |
30845bda
|
Andreas Kohlbecker
|
if (isset($specimen->types)) {
|
66 |
56d58f9b
|
Patric Plitzner
|
//typed taxa
|
67 |
30845bda
|
Andreas Kohlbecker
|
foreach ($specimen->types as $typeStatus => $typedTaxa) {
|
68 |
b0efd824
|
Patrick Plitzner
|
if($specimen->types){
|
69 |
269e42e0
|
Patrick Plitzner
|
if(empty($typeStatus) || $typeStatus == "_empty_"|| $typeStatus == ""){
|
70 |
31ab4cf9
|
Patrick Plitzner
|
$detail_html .= "<i>Type for:</i> ";
|
71 |
269e42e0
|
Patrick Plitzner
|
} else {
|
72 |
|
|
$detail_html .= "<i>".$typeStatus."</i> of ";
|
73 |
a5b11885
|
Patrick Plitzner
|
}
|
74 |
b0efd824
|
Patrick Plitzner
|
foreach($typedTaxa as $typedTaxon){
|
75 |
|
|
$detail_html .= $typedTaxon." ";
|
76 |
b3ac03bf
|
Katja Luther
|
|
77 |
c10f70e4
|
Katja Luther
|
}
|
78 |
|
|
} else {
|
79 |
|
|
$types .= $typeStatus . " ";
|
80 |
|
|
|
81 |
fdc85125
|
Patric Plitzner
|
}
|
82 |
b810158e
|
Patric Plitzner
|
}
|
83 |
|
|
}
|
84 |
30845bda
|
Andreas Kohlbecker
|
$derivateDataDTO = $specimen->derivateDataDTO;
|
85 |
b810158e
|
Patric Plitzner
|
// - specimen scans
|
86 |
65a4de51
|
Patrick Plitzner
|
$specimenScans = create_html_links($derivateDataDTO->specimenScans, true);
|
87 |
b810158e
|
Patric Plitzner
|
// - molecular data
|
88 |
|
|
$molecularData = "";
|
89 |
|
|
if ($derivateDataDTO->molecularDataList) {
|
90 |
|
|
foreach ($derivateDataDTO->molecularDataList as $molecular) {
|
91 |
|
|
//provider link
|
92 |
|
|
if (isset($molecular->providerLink)) {
|
93 |
65a4de51
|
Patrick Plitzner
|
$molecularData .= create_html_link($molecular->providerLink, true);
|
94 |
2c23b054
|
Patrick Plitzner
|
} else {
|
95 |
|
|
$molecularData .= "[no provider]";
|
96 |
b810158e
|
Patric Plitzner
|
}
|
97 |
|
|
//contig link
|
98 |
2c23b054
|
Patrick Plitzner
|
if (isset($molecular->contigFiles)) {
|
99 |
b810158e
|
Patric Plitzner
|
$molecularData .= "[";
|
100 |
2c23b054
|
Patrick Plitzner
|
if (sizeof($molecular->contigFiles) > 0) {
|
101 |
b810158e
|
Patric Plitzner
|
foreach ($molecular->contigFiles as $contigFile) {
|
102 |
2c23b054
|
Patrick Plitzner
|
if (isset($contigFile->contigLink)) {
|
103 |
|
|
if (isset($contigFile->contigLink->uri) and $contigFile->contigLink->uri != null) {
|
104 |
|
|
$molecularData .= create_html_link($contigFile->contigLink, true) . " ";
|
105 |
37ab3ddc
|
Patric Plitzner
|
}
|
106 |
c10f70e4
|
Katja Luther
|
} else {
|
107 |
2c23b054
|
Patrick Plitzner
|
$molecularData .= "no contig ";
|
108 |
|
|
}
|
109 |
|
|
//primer links
|
110 |
c10f70e4
|
Katja Luther
|
if (isset($contigFile->primerLinks)) {
|
111 |
65a4de51
|
Patrick Plitzner
|
$molecularData .= create_html_links($contigFile->primerLinks, true);
|
112 |
b810158e
|
Patric Plitzner
|
}
|
113 |
|
|
}
|
114 |
|
|
}
|
115 |
5eafa5ff
|
Patric Plitzner
|
$molecularData = rtrim($molecularData, " ");
|
116 |
b810158e
|
Patric Plitzner
|
$molecularData .= "]";
|
117 |
|
|
}
|
118 |
|
|
//FIXME separate with comma (remove trailing comma)
|
119 |
|
|
}
|
120 |
|
|
}
|
121 |
|
|
// - detail images
|
122 |
65a4de51
|
Patrick Plitzner
|
$detailImages = create_html_links($derivateDataDTO->detailImages, true);
|
123 |
b810158e
|
Patric Plitzner
|
|
124 |
|
|
if ($types) {
|
125 |
c10f70e4
|
Katja Luther
|
$detail_html .= $is_specimen_page ? "<br>" : "";
|
126 |
a0bbccce
|
Patrick Plitzner
|
$detail_html .= create_label("Type(s)") . $types . "<br>";
|
127 |
b810158e
|
Patric Plitzner
|
}
|
128 |
30845bda
|
Andreas Kohlbecker
|
if ($specimenScans and !$is_specimen_page) {
|
129 |
3dd58832
|
Patric Plitzner
|
$detail_html .= create_label("Specimen Scans") . $specimenScans . "<br>";
|
130 |
b810158e
|
Patric Plitzner
|
}
|
131 |
8d9d64a5
|
Patric Plitzner
|
//specimen scan image gallery
|
132 |
c10f70e4
|
Katja Luther
|
if ($is_specimen_page and isset($derivateDataDTO->specimenScanUuids) and !empty($derivateDataDTO->specimenScanUuids)) {
|
133 |
8d9d64a5
|
Patric Plitzner
|
$detail_html .= addImageGallery("Specimen scans", $derivateDataDTO->specimenScanUuids);
|
134 |
|
|
}
|
135 |
|
|
|
136 |
b810158e
|
Patric Plitzner
|
if ($molecularData) {
|
137 |
c10f70e4
|
Katja Luther
|
$detail_html .= $is_specimen_page ? "<br>" : "";
|
138 |
3dd58832
|
Patric Plitzner
|
$detail_html .= create_label("Molecular Data") . $molecularData . "<br>";
|
139 |
b810158e
|
Patric Plitzner
|
}
|
140 |
8d9d64a5
|
Patric Plitzner
|
|
141 |
30845bda
|
Andreas Kohlbecker
|
if ($detailImages and !$is_specimen_page) {
|
142 |
3dd58832
|
Patric Plitzner
|
$detail_html .= create_label("Detail Images") . $detailImages . "<br>";
|
143 |
b810158e
|
Patric Plitzner
|
}
|
144 |
|
|
|
145 |
8d9d64a5
|
Patric Plitzner
|
//detail image gallery
|
146 |
c10f70e4
|
Katja Luther
|
if ($is_specimen_page and isset($derivateDataDTO->detailImageUuids) and !empty($derivateDataDTO->detailImageUuids)) {
|
147 |
8d9d64a5
|
Patric Plitzner
|
$detail_html .= addImageGallery("Detail Images", $derivateDataDTO->detailImageUuids);
|
148 |
|
|
}
|
149 |
|
|
|
150 |
b810158e
|
Patric Plitzner
|
//character data
|
151 |
30845bda
|
Andreas Kohlbecker
|
if ($specimen->characterData) {
|
152 |
c10f70e4
|
Katja Luther
|
$detail_html .= $is_specimen_page ? "<br>" : "";
|
153 |
a442acb8
|
Patric Plitzner
|
$detail_html .= create_label("Character Data");
|
154 |
c10f70e4
|
Katja Luther
|
if ($is_specimen_page) {
|
155 |
b810158e
|
Patric Plitzner
|
$detail_html .= "<br>";
|
156 |
30845bda
|
Andreas Kohlbecker
|
foreach ($specimen->characterData as $characterStatePair) {
|
157 |
a442acb8
|
Patric Plitzner
|
$detail_html .= "<i>" . $characterStatePair->first . "</i>:" . $characterStatePair->second;
|
158 |
|
|
$detail_html .= "<br>";
|
159 |
|
|
}
|
160 |
c10f70e4
|
Katja Luther
|
} else {
|
161 |
|
|
$detail_html .= l("detail page", $pathToSpecimen, array('attributes' => array('target' => '_blank')));
|
162 |
216abf0b
|
Patric Plitzner
|
$detail_html .= "<br>";
|
163 |
b810158e
|
Patric Plitzner
|
}
|
164 |
|
|
}
|
165 |
8d9d64a5
|
Patric Plitzner
|
return $detail_html;
|
166 |
|
|
}
|
167 |
8c1d6d72
|
Patric Plitzner
|
|
168 |
c10f70e4
|
Katja Luther
|
function addImageGallery($galleryName, $imageUuids)
|
169 |
|
|
{
|
170 |
b5c89485
|
Patric Plitzner
|
$images = array();
|
171 |
8d9d64a5
|
Patric Plitzner
|
foreach ($imageUuids as $uuid) {
|
172 |
|
|
$images[] = cdm_ws_get(CDM_WS_PORTAL_MEDIA, $uuid);
|
173 |
8c1d6d72
|
Patric Plitzner
|
}
|
174 |
7cf177d0
|
Patrick Plitzner
|
|
175 |
|
|
$gallery_html = '';
|
176 |
|
|
if (count($imageUuids) > 0) {
|
177 |
|
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
178 |
|
|
$captionElements = array(
|
179 |
|
|
'title',
|
180 |
|
|
'rights',
|
181 |
|
|
);
|
182 |
|
|
$alternativeMediaUris = array();
|
183 |
c10f70e4
|
Katja Luther
|
foreach ($images as $image) {
|
184 |
|
|
$mediaUri = getMediaUri($image);
|
185 |
|
|
if ($mediaUri) {
|
186 |
|
|
$alternativeMediaUris[] = $mediaUri;
|
187 |
|
|
} else {
|
188 |
|
|
$alternativeMediaUris[] = path_to_media($image->uuid);
|
189 |
|
|
}
|
190 |
7cf177d0
|
Patrick Plitzner
|
}
|
191 |
|
|
|
192 |
a9815578
|
Andreas Kohlbecker
|
$gallery_html = compose_cdm_media_gallerie(array(
|
193 |
7cf177d0
|
Patrick Plitzner
|
'mediaList' => $images,
|
194 |
|
|
'galleryName' => $galleryName,
|
195 |
|
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
196 |
|
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
197 |
|
|
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
|
198 |
|
|
'captionElements' => $captionElements,
|
199 |
|
|
'mediaLinkType' => 'LIGHTBOX',
|
200 |
|
|
'alternativeMediaUri' => $alternativeMediaUris,
|
201 |
|
|
'galleryLinkUri' => NULL,
|
202 |
|
|
));
|
203 |
|
|
}
|
204 |
c10f70e4
|
Katja Luther
|
return "<br>" . create_label($galleryName) . "<br>" . $gallery_html;
|
205 |
b810158e
|
Patric Plitzner
|
}
|
206 |
|
|
|
207 |
c10f70e4
|
Katja Luther
|
function getMediaUri($media)
|
208 |
|
|
{
|
209 |
|
|
if (isset($media->representations) && sizeof($media->representations) == 1
|
210 |
|
|
&& isset($media->representations[0]->parts) &&
|
211 |
|
|
sizeof($media->representations[0]->parts) == 1) {
|
212 |
|
|
return $media->representations[0]->parts[0]->uri;
|
213 |
|
|
}
|
214 |
|
|
return null;
|
215 |
e2eaa6c7
|
Patrick Plitzner
|
}
|
216 |
|
|
|
217 |
8d9d64a5
|
Patric Plitzner
|
|
218 |
3dd58832
|
Patric Plitzner
|
/**
|
219 |
5a079dbf
|
Andreas Kohlbecker
|
* Formats the given string to a label for displaying key-object pairs in HTML
|
220 |
3dd58832
|
Patric Plitzner
|
* @return string
|
221 |
|
|
*/
|
222 |
|
|
function create_label($label)
|
223 |
|
|
{
|
224 |
c10f70e4
|
Katja Luther
|
return "<span class='specimen_table_label'>" . $label . ": </span>";
|
225 |
3dd58832
|
Patric Plitzner
|
}
|
226 |
|
|
|
227 |
f19f47fa
|
Andreas Kohlbecker
|
/**
|
228 |
|
|
* Compose an render array from a CDM DerivedUnitFacade object.
|
229 |
|
|
*
|
230 |
|
|
* compose_hook() implementation
|
231 |
235fc94b
|
Andreas Kohlbecker
|
*
|
232 |
|
|
* @param object $specimenOrObservation
|
233 |
|
|
* the CDM instance of type SpecimenOrObservation to compose
|
234 |
|
|
* the render array for
|
235 |
|
|
* @param array $derivatives
|
236 |
|
|
* the render array which contains the compositions of the derivatives
|
237 |
|
|
* of the supplied $specimenOrObservation
|
238 |
|
|
*
|
239 |
|
|
* @return array
|
240 |
|
|
* the supplied render array $derivatives to which the composition of the supplied
|
241 |
|
|
* $specimenOrObservation has been added to
|
242 |
5b26b91a
|
Andreas Kohlbecker
|
*
|
243 |
|
|
* @ingroup compose
|
244 |
f19f47fa
|
Andreas Kohlbecker
|
*/
|
245 |
|
|
|
246 |
98262d29
|
Katja Luther
|
function compose_cdm_specimen_or_observation($specimenOrObservation, &$derivatives = null)
|
247 |
|
|
{
|
248 |
c10f70e4
|
Katja Luther
|
$exclude_occurrence_fields = &drupal_static(__FUNCTION__);
|
249 |
|
|
if (!isset($exclude_occurrence_fields)) {
|
250 |
|
|
$exclude_occurrence_fields = array(
|
251 |
d3f77ada
|
Katja Luther
|
'derivationEvents',
|
252 |
c10f70e4
|
Katja Luther
|
'titleCache',
|
253 |
|
|
'protectedTitleCache',
|
254 |
|
|
'derivedUnitMedia',
|
255 |
|
|
'created',
|
256 |
|
|
'publish',
|
257 |
|
|
'updated',
|
258 |
|
|
'class',
|
259 |
|
|
'uuid',
|
260 |
d3f77ada
|
Katja Luther
|
''
|
261 |
c10f70e4
|
Katja Luther
|
);
|
262 |
|
|
}
|
263 |
f846e7e7
|
Andreas Kohlbecker
|
|
264 |
9b9037f3
|
Andreas Kohlbecker
|
|
265 |
c10f70e4
|
Katja Luther
|
// only show uuid it the user is logged in
|
266 |
d3f77ada
|
Katja Luther
|
if(user_is_logged_in() && ($a_idx = array_search('uuid', $exclude_occurrence_fields)) !== FALSE ) {
|
267 |
c10f70e4
|
Katja Luther
|
unset($exclude_occurrence_fields[$a_idx]);
|
268 |
|
|
}
|
269 |
15b7c460
|
Andreas Kohlbecker
|
|
270 |
c10f70e4
|
Katja Luther
|
if (!isset($derivatives)) {
|
271 |
|
|
$derivatives = array();
|
272 |
|
|
}
|
273 |
15b7c460
|
Andreas Kohlbecker
|
|
274 |
c10f70e4
|
Katja Luther
|
$descriptions = null;
|
275 |
|
|
$derivedFrom = null;
|
276 |
|
|
|
277 |
|
|
if (is_object($specimenOrObservation)) {
|
278 |
|
|
|
279 |
|
|
// request again for deeper initialization
|
280 |
d3f77ada
|
Katja Luther
|
$specimenOrObservation = cdm_ws_get("portal/" . CDM_WS_OCCURRENCE, $specimenOrObservation->uuid);
|
281 |
c10f70e4
|
Katja Luther
|
|
282 |
|
|
|
283 |
d3f77ada
|
Katja Luther
|
$type_label = $specimenOrObservation->class;
|
284 |
c10f70e4
|
Katja Luther
|
RenderHints::setFootnoteListKey($type_label . '-' . $specimenOrObservation->uuid);
|
285 |
|
|
|
286 |
|
|
// collect typeStatus as label
|
287 |
|
|
if (isset($specimenOrObservation->specimenTypeDesignations)) {
|
288 |
|
|
$type_status = array();
|
289 |
|
|
foreach ($specimenOrObservation->specimenTypeDesignations as $typeDesignation) {
|
290 |
|
|
if (isset($typeDesignation->typeStatus->representation_L10n)) {
|
291 |
|
|
$type_status[] = $typeDesignation->typeStatus->representation_L10n;
|
292 |
|
|
}
|
293 |
|
|
}
|
294 |
|
|
if (count($type_status) > 0) {
|
295 |
|
|
$type_label = implode(', ', $type_status);
|
296 |
|
|
}
|
297 |
9b9037f3
|
Andreas Kohlbecker
|
}
|
298 |
|
|
|
299 |
c10f70e4
|
Katja Luther
|
$title = $type_label . ': ' . $specimenOrObservation->titleCache;
|
300 |
|
|
|
301 |
|
|
$groups = array();
|
302 |
|
|
// --- add initialized fields
|
303 |
|
|
foreach (get_object_vars($specimenOrObservation) as $field => $value) {
|
304 |
|
|
if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
|
305 |
|
|
switch ($field) {
|
306 |
d3f77ada
|
Katja Luther
|
|
307 |
c10f70e4
|
Katja Luther
|
/* ---- java.lang.Object --- */
|
308 |
|
|
case 'class':
|
309 |
|
|
if ($value != '' /* FieldUnit' */) {
|
310 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
311 |
|
|
}
|
312 |
|
|
break;
|
313 |
6fbdb943
|
Andreas Kohlbecker
|
|
314 |
c10f70e4
|
Katja Luther
|
case 'markers':
|
315 |
|
|
$dd_elements = array();
|
316 |
|
|
foreach ($value as $marker) {
|
317 |
|
|
$dd_elements[] = compose_cdm_marker($marker);
|
318 |
|
|
}
|
319 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
320 |
|
|
break;
|
321 |
4ae6064e
|
Andreas Kohlbecker
|
|
322 |
f19f47fa
|
Andreas Kohlbecker
|
|
323 |
c10f70e4
|
Katja Luther
|
case 'annotations':
|
324 |
|
|
$dd_elements = array();
|
325 |
|
|
foreach ($value as $annotation) {
|
326 |
|
|
// TODO respect annotation type filter settings
|
327 |
|
|
$dd_elements[] = $annotation->text;
|
328 |
|
|
}
|
329 |
|
|
@_description_list_group_add($groups, t('Notes'), $dd_elements);
|
330 |
|
|
break;
|
331 |
|
|
|
332 |
|
|
/* ---- SpecimenOrObservationBase --- */
|
333 |
|
|
case 'sex':
|
334 |
|
|
case 'lifeStage':
|
335 |
|
|
case 'kindOfUnit':
|
336 |
d3f77ada
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->representation_L10n);
|
337 |
c10f70e4
|
Katja Luther
|
break;
|
338 |
|
|
|
339 |
|
|
case 'definition':
|
340 |
|
|
// TODO
|
341 |
|
|
break;
|
342 |
|
|
|
343 |
|
|
case 'preferredStableUri':
|
344 |
|
|
|
345 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), array(array('#markup' => cdm_external_uri($value, false))));
|
346 |
|
|
break;
|
347 |
|
|
|
348 |
|
|
case 'specimenTypeDesignations':
|
349 |
|
|
@_description_list_group_add(
|
350 |
|
|
$groups,
|
351 |
|
|
cdm_occurrence_field_name_label($field),
|
352 |
|
|
array(
|
353 |
|
|
'#markup' => theme('cdm_typedesignations', array('typeDesignations' => $value)),
|
354 |
|
|
)
|
355 |
|
|
);
|
356 |
|
|
break;
|
357 |
|
|
|
358 |
|
|
case 'determinations':
|
359 |
|
|
$dd_elements = array();
|
360 |
|
|
$glue = ', ';
|
361 |
|
|
|
362 |
|
|
foreach ($value as $determinationEvent) {
|
363 |
|
|
$timeperiod_string = NULL;
|
364 |
|
|
if (isset($determinationEvent->timeperiod)) {
|
365 |
|
|
$timeperiod_string = timePeriodToString($determinationEvent->timeperiod);
|
366 |
|
|
}
|
367 |
|
|
$weight = isset($determinationEvent->preferred) && $determinationEvent->preferred == 1 ? '0' : ($timeperiod_string ? $timeperiod_string : '1');
|
368 |
|
|
// check key exists
|
369 |
|
|
while (array_key_exists($weight, $dd_elements)) {
|
370 |
|
|
$weight .= '0';
|
371 |
|
|
}
|
372 |
4ae6064e
|
Andreas Kohlbecker
|
|
373 |
c10f70e4
|
Katja Luther
|
$taxon_name = '';
|
374 |
|
|
$name_link = '';
|
375 |
|
|
if ($determinationEvent->taxonName) {
|
376 |
|
|
$taxon_name = $determinationEvent->taxonName;
|
377 |
|
|
} else if ($determinationEvent->taxon) {
|
378 |
|
|
$taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
|
379 |
|
|
$name_link = path_to_taxon($determinationEvent->taxon->uuid);
|
380 |
|
|
}
|
381 |
|
|
if ($taxon_name) {
|
382 |
|
|
$taxon_html = render_taxon_or_name($taxon_name, $name_link);
|
383 |
|
|
$dd_elements[$weight] = $taxon_html;
|
384 |
|
|
}
|
385 |
|
|
if (isset($determinationEvent->modifier)) {
|
386 |
|
|
$dd_elements[$weight] .= cdm_term_representation($determinationEvent->modifier);
|
387 |
|
|
}
|
388 |
|
|
if ($timeperiod_string) {
|
389 |
|
|
$dd_elements[$weight] .= $glue . $timeperiod_string;
|
390 |
|
|
}
|
391 |
|
|
if (isset($determinationEvent->actor->titleCache)) {
|
392 |
|
|
$dd_elements[$weight] .= $glue . $determinationEvent->actor->titleCache;
|
393 |
|
|
}
|
394 |
|
|
if (isset($determinationEvent->description)) {
|
395 |
|
|
$dd_elements[$weight] .= $glue . $determinationEvent->description;
|
396 |
|
|
}
|
397 |
|
|
}
|
398 |
|
|
ksort($dd_elements);
|
399 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('determinations'), $dd_elements);
|
400 |
|
|
break;
|
401 |
f846e7e7
|
Andreas Kohlbecker
|
|
402 |
c10f70e4
|
Katja Luther
|
case 'descriptions':
|
403 |
|
|
$occurrence_featureTree = cdm_get_occurrence_featureTree();
|
404 |
|
|
$dd_elements = array();
|
405 |
bfb2b81a
|
Andreas Kohlbecker
|
|
406 |
c10f70e4
|
Katja Luther
|
foreach ($value as $description) {
|
407 |
|
|
$description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, $description->uuid);
|
408 |
a67e7364
|
Andreas Kohlbecker
|
// if($description->imageGallery == TRUE) {
|
409 |
|
|
// continue;
|
410 |
|
|
// }
|
411 |
c10f70e4
|
Katja Luther
|
$elements_by_feature = _mergeFeatureTreeDescriptions($occurrence_featureTree->root->childNodes, $description->elements);
|
412 |
|
|
$description_render_elements = _block_get_renderable_array(make_feature_block_list($elements_by_feature, null));
|
413 |
|
|
$dd_elements[] = $description_render_elements;
|
414 |
|
|
}
|
415 |
6fbdb943
|
Andreas Kohlbecker
|
|
416 |
c10f70e4
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
417 |
|
|
break;
|
418 |
6fbdb943
|
Andreas Kohlbecker
|
|
419 |
c10f70e4
|
Katja Luther
|
case 'sources':
|
420 |
|
|
$dd_elements = array();
|
421 |
|
|
foreach ($value as $identifiable_source) {
|
422 |
|
|
$dd_elements[] = theme('cdm_OriginalSource', array('source' => $identifiable_source));
|
423 |
|
|
}
|
424 |
d3f77ada
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
425 |
c10f70e4
|
Katja Luther
|
break;
|
426 |
|
|
|
427 |
|
|
|
428 |
|
|
/* ---- DerivedUnitBase --- */
|
429 |
|
|
case 'derivedFrom':
|
430 |
|
|
$derivedFrom = $value;
|
431 |
|
|
break;
|
432 |
|
|
|
433 |
|
|
case 'collection':
|
434 |
|
|
$sub_dl_groups = array();
|
435 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1);
|
436 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2);
|
437 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3);
|
438 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4);
|
439 |
|
|
// TODO "superCollection"
|
440 |
|
|
// TODO may have media
|
441 |
|
|
|
442 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
|
443 |
|
|
array(
|
444 |
|
|
array('#markup' => $value->titleCache),
|
445 |
|
|
array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
|
446 |
|
|
)
|
447 |
|
|
);
|
448 |
|
|
break;
|
449 |
|
|
|
450 |
|
|
case 'storedUnder':
|
451 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('storedUnder'), render_taxon_or_name($value));
|
452 |
|
|
break;
|
453 |
|
|
|
454 |
|
|
|
455 |
|
|
/* ---- Specimen --- */
|
456 |
|
|
case 'sequences':
|
457 |
|
|
$dd_elements = array();
|
458 |
|
|
foreach ($value as $sequence) {
|
459 |
|
|
$dd_elements[] = compose_cdm_sequence($sequence);
|
460 |
|
|
}
|
461 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
462 |
|
|
break;
|
463 |
|
|
|
464 |
|
|
// TODO preservation
|
465 |
|
|
// TODO exsiccatum
|
466 |
|
|
|
467 |
|
|
|
468 |
|
|
/* ---- FieldObservation --- */
|
469 |
|
|
case 'gatheringEvent':
|
470 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collector'), $value->actor->titleCache);
|
471 |
|
|
@_description_list_group_add($groups, t('Gathering time'), timePeriodToString($value->timeperiod));
|
472 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description);
|
473 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('locality'), $value->locality->text);
|
474 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('country'), $value->country->representation_L10n);
|
475 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingMethod'), $value->collectingMethod);
|
476 |
|
|
if (isset($value->absoluteElevation)) {
|
477 |
|
|
$min_max_markup = min_max_measure($value, 'absoluteElevation');
|
478 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('absoluteElevation'), $min_max_markup);
|
479 |
|
|
}
|
480 |
|
|
if (isset($value->distanceToGround)) {
|
481 |
|
|
$min_max_markup = min_max_measure($value, 'distanceToGround');
|
482 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToGround'), $min_max_markup);
|
483 |
|
|
}
|
484 |
|
|
if (isset($value->distanceToWaterSurface)) {
|
485 |
|
|
$min_max_markup = min_max_measure($value, 'distanceToWaterSurface');
|
486 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToWaterSurface'), $min_max_markup);
|
487 |
|
|
}
|
488 |
6fbdb943
|
Andreas Kohlbecker
|
|
489 |
2228f46b
|
Andreas Kohlbecker
|
if (isset($value->collectingAreas) && count($value->collectingAreas) > 0) {
|
490 |
c10f70e4
|
Katja Luther
|
$area_representations = array();
|
491 |
|
|
foreach ($value->collectingAreas as $area) {
|
492 |
|
|
$area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid));
|
493 |
|
|
}
|
494 |
d3f77ada
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'),
|
495 |
|
|
array(
|
496 |
|
|
array('#markup' => implode(', ', $area_representations))
|
497 |
|
|
)
|
498 |
|
|
);
|
499 |
c10f70e4
|
Katja Luther
|
}
|
500 |
|
|
if (isset($value->exactLocation) && $value->exactLocation->sexagesimalString) {
|
501 |
|
|
$sub_dl_groups = array();
|
502 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1);
|
503 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('longitude'), round($value->exactLocation->longitude, 7), '°', 2);
|
504 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('latitude'), round($value->exactLocation->latitude, 7), '°', 3);
|
505 |
|
|
if (isset($value->exactLocation->referenceSystem)) {
|
506 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('referenceSystem'), $value->exactLocation->referenceSystem->representation_L10n, '', 4);
|
507 |
|
|
}
|
508 |
6fbdb943
|
Andreas Kohlbecker
|
|
509 |
c10f70e4
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'),
|
510 |
|
|
array(
|
511 |
|
|
array('#markup' => $value->exactLocation->sexagesimalString),
|
512 |
|
|
array(
|
513 |
|
|
'#theme' => 'description_list',
|
514 |
|
|
'#groups' => $sub_dl_groups
|
515 |
|
|
),
|
516 |
|
|
)
|
517 |
|
|
);
|
518 |
|
|
}
|
519 |
|
|
break;
|
520 |
|
|
|
521 |
|
|
default:
|
522 |
|
|
if (is_object($value) || is_array($value)) {
|
523 |
d3f77ada
|
Katja Luther
|
drupal_set_message("Unhandled type in compose_cdm_specimen_or_observation() for field " . $field, "warning");
|
524 |
c10f70e4
|
Katja Luther
|
} else {
|
525 |
|
|
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
526 |
|
|
}
|
527 |
74ee6b54
|
Andreas Kohlbecker
|
|
528 |
c10f70e4
|
Katja Luther
|
}
|
529 |
f19f47fa
|
Andreas Kohlbecker
|
|
530 |
f846e7e7
|
Andreas Kohlbecker
|
}
|
531 |
c10f70e4
|
Katja Luther
|
} // END of loop over $derivedUnitFacade fields
|
532 |
f19f47fa
|
Andreas Kohlbecker
|
|
533 |
c10f70e4
|
Katja Luther
|
// Extensions
|
534 |
d3f77ada
|
Katja Luther
|
$extensions = cdm_ws_fetch_all(CDM_WS_PORTAL_OCCURRENCE . '/' . $specimenOrObservation->uuid . '/extensions', array($specimenOrObservation->uuid));
|
535 |
c10f70e4
|
Katja Luther
|
if ($extensions && count($extensions)) {
|
536 |
|
|
|
537 |
|
|
$extensions_render_array = compose_extensions($extensions);
|
538 |
|
|
@_description_list_group_add($groups, t('Extensions') . ':',
|
539 |
|
|
$extensions_render_array,
|
540 |
|
|
'', 100);
|
541 |
f19f47fa
|
Andreas Kohlbecker
|
}
|
542 |
|
|
|
543 |
f846e7e7
|
Andreas Kohlbecker
|
|
544 |
c10f70e4
|
Katja Luther
|
// template_preprocess_description_list() is not worting by weight so we do it right here
|
545 |
|
|
uasort($groups, 'element_sort');
|
546 |
0820cdc0
|
Andreas Kohlbecker
|
|
547 |
c10f70e4
|
Katja Luther
|
$occurrence_elements = array(
|
548 |
|
|
'#title' => $title,
|
549 |
|
|
'#theme' => 'description_list',
|
550 |
|
|
'#groups' => $groups,
|
551 |
|
|
'#attributes' => array('class' => html_class_attribute_ref($specimenOrObservation)),
|
552 |
|
|
);
|
553 |
|
|
$derivatives[] = $occurrence_elements;
|
554 |
|
|
// all footnotes which has been assembled so far (e.g. from typeDesignations) to here
|
555 |
|
|
$foonote_li_elements = theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'span'));
|
556 |
|
|
if (!empty($foonote_li_elements)) {
|
557 |
d3f77ada
|
Katja Luther
|
$derivatives[] = array(
|
558 |
|
|
'#markup' => '<div class="footnotes">' . $foonote_li_elements . '</div>',
|
559 |
c10f70e4
|
Katja Luther
|
);
|
560 |
|
|
}
|
561 |
0820cdc0
|
Andreas Kohlbecker
|
|
562 |
c10f70e4
|
Katja Luther
|
// --- recurse into originals
|
563 |
|
|
if (!isset($derivedFrom)) {
|
564 |
|
|
$derivedFrom = cdm_ws_get(
|
565 |
|
|
CDM_WS_OCCURRENCE,
|
566 |
|
|
array($specimenOrObservation->uuid, 'derivedFrom')
|
567 |
|
|
);
|
568 |
|
|
}
|
569 |
f846e7e7
|
Andreas Kohlbecker
|
|
570 |
d3f77ada
|
Katja Luther
|
if (isset($derivedFrom)) {
|
571 |
|
|
if (isset($derivedFrom->originals)) {
|
572 |
|
|
$derived_from_label = t('derived');
|
573 |
|
|
$preposition = t('from');
|
574 |
|
|
if(isset($derivedFrom->type)){
|
575 |
c10f70e4
|
Katja Luther
|
$derived_from_label = $derivedFrom->type->representation_L10n;
|
576 |
d3f77ada
|
Katja Luther
|
if($derivedFrom->type->uuid == UUID_DERIVATIONEVENTTYPE_ACCESSIONING){
|
577 |
|
|
$preposition = t('of');
|
578 |
c10f70e4
|
Katja Luther
|
}
|
579 |
|
|
}
|
580 |
|
|
if (count($groups) > 0) {
|
581 |
|
|
// TODO annotations
|
582 |
eeb98da8
|
Andreas Kohlbecker
|
|
583 |
c10f70e4
|
Katja Luther
|
// only display the derived from information when the derivative has any element which will be diplayed
|
584 |
|
|
$derivatives[] = array(
|
585 |
d3f77ada
|
Katja Luther
|
'#markup' => '<div class="derived_from">' . $derived_from_label . ' ' . $preposition . ': </div>',
|
586 |
c10f70e4
|
Katja Luther
|
);
|
587 |
|
|
}
|
588 |
d3f77ada
|
Katja Luther
|
foreach ($derivedFrom->originals as $original) {
|
589 |
|
|
compose_cdm_specimen_or_observation($original, $derivatives);
|
590 |
|
|
}
|
591 |
c10f70e4
|
Katja Luther
|
}
|
592 |
0796d2f9
|
Andreas Kohlbecker
|
}
|
593 |
f1f05758
|
Andreas Kohlbecker
|
|
594 |
c10f70e4
|
Katja Luther
|
} // END of $specimenOrObservation exists
|
595 |
c70b93c3
|
Andreas Kohlbecker
|
|
596 |
c10f70e4
|
Katja Luther
|
return $derivatives;
|
597 |
f1f05758
|
Andreas Kohlbecker
|
}
|
598 |
0de9cf51
|
Andreas Kohlbecker
|
|
599 |
0820cdc0
|
Andreas Kohlbecker
|
|
600 |
0de9cf51
|
Andreas Kohlbecker
|
/**
|
601 |
|
|
* Compose an render array from a CDM Sequence object.
|
602 |
|
|
*
|
603 |
|
|
* compose_hook() implementation
|
604 |
|
|
*
|
605 |
|
|
* @param object $sequence
|
606 |
|
|
* CDM instance of type Sequence
|
607 |
|
|
* @return array
|
608 |
|
|
* A render array containing the fields of the supplied $sequence
|
609 |
5b26b91a
|
Andreas Kohlbecker
|
*
|
610 |
|
|
* @ingroup compose
|
611 |
0de9cf51
|
Andreas Kohlbecker
|
*/
|
612 |
52f57468
|
Katja Luther
|
function compose_cdm_sequence($sequence, $isSpecimenPage = false)
|
613 |
c10f70e4
|
Katja Luther
|
{
|
614 |
|
|
|
615 |
|
|
$exclude_sequence_fields = &drupal_static(__FUNCTION__);
|
616 |
|
|
if (!isset($exclude_sequence_fields)) {
|
617 |
|
|
$exclude_sequence_fields = array(
|
618 |
|
|
'titleCache',
|
619 |
|
|
'protectedTitleCache',
|
620 |
|
|
'microReference',
|
621 |
|
|
'created',
|
622 |
|
|
'updated',
|
623 |
|
|
'class',
|
624 |
52f57468
|
Katja Luther
|
'dnaMarker'
|
625 |
c10f70e4
|
Katja Luther
|
);
|
626 |
|
|
}
|
627 |
0de9cf51
|
Andreas Kohlbecker
|
|
628 |
c10f70e4
|
Katja Luther
|
$groups = array();
|
629 |
0de9cf51
|
Andreas Kohlbecker
|
|
630 |
c10f70e4
|
Katja Luther
|
// -- retrieve additional data if neesscary
|
631 |
|
|
// TODO below call disabled since sequences are not yet supported,
|
632 |
|
|
// see #3347 (services and REST service controller for molecular classes implemented)
|
633 |
|
|
//
|
634 |
|
|
// cdm_load_annotations($sequence);
|
635 |
eeb98da8
|
Andreas Kohlbecker
|
|
636 |
c10f70e4
|
Katja Luther
|
foreach (get_object_vars($sequence) as $field => $value) {
|
637 |
eeb98da8
|
Andreas Kohlbecker
|
|
638 |
|
|
|
639 |
c10f70e4
|
Katja Luther
|
if (!in_array($field, $exclude_sequence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
|
640 |
|
|
switch ($field) {
|
641 |
0de9cf51
|
Andreas Kohlbecker
|
|
642 |
c10f70e4
|
Katja Luther
|
case 'geneticAccessionNumber';
|
643 |
52f57468
|
Katja Luther
|
|
644 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 2);
|
645 |
c10f70e4
|
Katja Luther
|
break;
|
646 |
|
|
|
647 |
|
|
|
648 |
52f57468
|
Katja Luther
|
/*case 'dnaMarker': // FIXME 3.3 now dnaMarker (DefinedTerm) if multiple amplifications where used to build this consensus sequence it may be the super set of the markers used in amplification.
|
649 |
|
|
/*if (isset($value->name)) {
|
650 |
c10f70e4
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->name, NULL, 3);
|
651 |
|
|
}
|
652 |
|
|
if (isset($value->description)) {
|
653 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field) . ' ' . t('description'), $value->description, NULL, 4);
|
654 |
|
|
}
|
655 |
52f57468
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field) , $value, NULL, 4);
|
656 |
c10f70e4
|
Katja Luther
|
break;
|
657 |
52f57468
|
Katja Luther
|
*/
|
658 |
c10f70e4
|
Katja Luther
|
case 'consensusSequence':
|
659 |
|
|
// format in genbank style, force linebreaks after each 70 nucleotites
|
660 |
|
|
// see also http://stackoverflow.com/questions/499137/css-how-can-i-force-a-long-string-without-any-blank-to-be-wrapped-in-xul-and
|
661 |
52f57468
|
Katja Luther
|
if ($value->length > 0) {
|
662 |
|
|
@_description_list_group_add(
|
663 |
|
|
$groups,
|
664 |
|
|
cdm_occurrence_field_name_label($field),
|
665 |
c10f70e4
|
Katja Luther
|
array(
|
666 |
52f57468
|
Katja Luther
|
array(
|
667 |
|
|
'#markup' => '<div class="sequence-length">' . $value->length . ' ' . t('pb') . '</div><div>' . wordwrap($value->string, 70, '</br>', TRUE) . '</div>',
|
668 |
|
|
'#wrapper_attributes' => array('class' => 'dna-sequence')
|
669 |
|
|
)
|
670 |
|
|
),
|
671 |
|
|
5);
|
672 |
|
|
}
|
673 |
c10f70e4
|
Katja Luther
|
break;
|
674 |
|
|
|
675 |
|
|
case 'dnaSample': // FIXME 3.3 implement
|
676 |
|
|
break;
|
677 |
|
|
case 'singleReads': // FIXME 3.3 implement
|
678 |
|
|
break;
|
679 |
|
|
case 'contigFile': // FIXME 3.3 implement - Media
|
680 |
|
|
break;
|
681 |
|
|
case 'pherograms': // FIXME 3.3 implement - Media
|
682 |
|
|
break;
|
683 |
|
|
case 'haplotype': // FIXME 3.3 implement
|
684 |
|
|
break;
|
685 |
|
|
case 'dateSequenced': // FIXME 3.3 now in SingelRead
|
686 |
|
|
@_description_list_group_add($groups, t('Sequencing date'), timePeriodToString($value), NULL, 6);
|
687 |
|
|
break;
|
688 |
|
|
|
689 |
|
|
case 'barcode': // boolean
|
690 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value ? 'Yes' : 'No', NULL, 7);
|
691 |
|
|
break;
|
692 |
|
|
case 'barcodeSequencePart': // FIXME 3.3 implement, compose sequence
|
693 |
|
|
break;
|
694 |
|
|
|
695 |
|
|
case 'citation':
|
696 |
|
|
@_description_list_group_add($groups,
|
697 |
|
|
cdm_occurrence_field_name_label($field),
|
698 |
|
|
theme('cdm_reference', array('reference' => $value, 'microReference' => $sequence->microReference)),
|
699 |
|
|
NULL,
|
700 |
|
|
8
|
701 |
|
|
);
|
702 |
|
|
break;
|
703 |
|
|
|
704 |
|
|
case 'publishedIn':
|
705 |
|
|
@_description_list_group_add($groups,
|
706 |
|
|
cdm_occurrence_field_name_label($field),
|
707 |
|
|
theme('cdm_reference', array('reference' => $value)),
|
708 |
|
|
NULL,
|
709 |
|
|
7
|
710 |
|
|
);
|
711 |
|
|
break;
|
712 |
|
|
|
713 |
|
|
case 'rights':
|
714 |
|
|
array_merge($groups, cdm_rights_as_dl_groups($value));
|
715 |
|
|
break;
|
716 |
|
|
|
717 |
|
|
case 'annotations':
|
718 |
|
|
$dd_elements = array();
|
719 |
|
|
foreach ($value as $annotation) {
|
720 |
|
|
// TODO respect annotation type filter settings
|
721 |
|
|
$dd_elements[] = $annotation->text;
|
722 |
|
|
}
|
723 |
|
|
@_description_list_group_add($groups, t('Notes'), $dd_elements, NULL, 9);
|
724 |
|
|
break;
|
725 |
|
|
|
726 |
|
|
case 'markers':
|
727 |
|
|
$dd_elements = array();
|
728 |
|
|
foreach ($value as $marker) {
|
729 |
|
|
$dd_elements[] = compose_cdm_marker($marker);
|
730 |
|
|
}
|
731 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 10);
|
732 |
|
|
break;
|
733 |
|
|
|
734 |
|
|
case 'chromatograms':
|
735 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
|
736 |
|
|
array(
|
737 |
|
|
'#markup' => compose_cdm_media_gallerie(array('medialist' => $value)),
|
738 |
|
|
),
|
739 |
|
|
NULL,
|
740 |
|
|
11);
|
741 |
|
|
break;
|
742 |
|
|
|
743 |
|
|
default:
|
744 |
|
|
if (is_object($value) || is_array($value)) {
|
745 |
|
|
drupal_set_message("Unhandled type in compose_cdm_sequence() for field " . $field, "warning");
|
746 |
|
|
} else {
|
747 |
8e15d0fb
|
Katja Luther
|
if (!is_array($value) && strpos($value, 'http:') !== false ){
|
748 |
|
|
//make links for urls
|
749 |
|
|
$value = l($value, $value, array('attributes' => array('target' => '_blank')));
|
750 |
|
|
$value = markup_to_render_array($value);
|
751 |
|
|
}
|
752 |
|
|
|
753 |
58c1a035
|
Katja Luther
|
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 20);
|
754 |
c10f70e4
|
Katja Luther
|
}
|
755 |
1b57b3c1
|
Andreas Kohlbecker
|
}
|
756 |
c10f70e4
|
Katja Luther
|
}
|
757 |
0de9cf51
|
Andreas Kohlbecker
|
}
|
758 |
|
|
|
759 |
c10f70e4
|
Katja Luther
|
// template_preprocess_description_list() is not worting by weight so we do it right here
|
760 |
|
|
uasort($groups, 'element_sort');
|
761 |
52f57468
|
Katja Luther
|
if ($isSpecimenPage) {
|
762 |
|
|
$sequence_elements = array(
|
763 |
|
|
'#title' => $sequence->dnaMarker,
|
764 |
|
|
'#theme' => 'description_list',
|
765 |
|
|
'#groups' => $groups
|
766 |
|
|
);
|
767 |
|
|
} else{
|
768 |
|
|
$sequence_elements = array(
|
769 |
|
|
'#title' => $sequence->dnaMarker -> titleCache,
|
770 |
|
|
'#theme' => 'description_list',
|
771 |
|
|
'#groups' => $groups
|
772 |
|
|
);
|
773 |
|
|
}
|
774 |
0de9cf51
|
Andreas Kohlbecker
|
|
775 |
c10f70e4
|
Katja Luther
|
return $sequence_elements;
|
776 |
0de9cf51
|
Andreas Kohlbecker
|
}
|
777 |
267da0d1
|
Katja Luther
|
/**
|
778 |
|
|
* Creates an array from a list of FieldUnitDTOs.
|
779 |
|
|
*
|
780 |
|
|
*
|
781 |
|
|
* @param object $specimenOrObservations
|
782 |
|
|
* list of FieldUnitDTOs
|
783 |
|
|
* @return array
|
784 |
|
|
* An array containing the hierarchy of the field units corresponding to the taxon
|
785 |
|
|
*
|
786 |
|
|
* @ingroup compose
|
787 |
|
|
*/
|
788 |
106e1cf9
|
Katja Luther
|
function compose_specimen_array(array $specimenOrObservations){
|
789 |
267da0d1
|
Katja Luther
|
$items_specimen = array();
|
790 |
|
|
$items = array();
|
791 |
276f39f6
|
Katja Luther
|
|
792 |
267da0d1
|
Katja Luther
|
//we need one more item to contain the items of one level (fieldunit, derivate data etc.)
|
793 |
|
|
foreach ($specimenOrObservations as &$specimenOrObservation) {
|
794 |
416bc78f
|
Katja Luther
|
|
795 |
|
|
$items['data'] = $specimenOrObservation->listLabel ;
|
796 |
106e1cf9
|
Katja Luther
|
$specimen = compose_cdm_specimen_or_observation_tree_entry($specimenOrObservation);
|
797 |
267da0d1
|
Katja Luther
|
$children = array();
|
798 |
|
|
$child = array();
|
799 |
|
|
$child['data'] =$specimen;
|
800 |
|
|
// $children[] = create_specimen_array($specimenOrObservation->derivates);
|
801 |
|
|
if (isset($specimenOrObservation->derivates) && sizeof($specimenOrObservation->derivates) > 0){
|
802 |
106e1cf9
|
Katja Luther
|
$child['children']= compose_specimen_array($specimenOrObservation->derivates);
|
803 |
267da0d1
|
Katja Luther
|
}
|
804 |
|
|
$children[]=$child;
|
805 |
|
|
$items['children'] = $children;
|
806 |
|
|
$items_specimen[] = $items;
|
807 |
|
|
}
|
808 |
|
|
return $items_specimen;
|
809 |
|
|
}
|
810 |
|
|
|
811 |
|
|
|
812 |
|
|
/**
|
813 |
|
|
* Compose an render array from a CDM DerivedUnitFacade object.
|
814 |
|
|
*
|
815 |
|
|
* compose_hook() implementation
|
816 |
|
|
*
|
817 |
|
|
* @param object $specimenOrObservation
|
818 |
|
|
* the CDM instance of type SpecimenOrObservation to compose
|
819 |
|
|
* the render array for
|
820 |
|
|
* @param array $derivatives
|
821 |
|
|
* the render array which contains the compositions of the derivatives
|
822 |
|
|
* of the supplied $specimenOrObservation
|
823 |
|
|
*
|
824 |
|
|
* @return array
|
825 |
|
|
* the supplied render array $derivatives to which the composition of the supplied
|
826 |
|
|
* $specimenOrObservation has been added to
|
827 |
|
|
*
|
828 |
|
|
* @ingroup compose
|
829 |
|
|
*/
|
830 |
|
|
|
831 |
58c1a035
|
Katja Luther
|
function compose_cdm_specimen_or_observation_tree_entry($specimen_or_observation)
|
832 |
267da0d1
|
Katja Luther
|
{
|
833 |
|
|
$exclude_occurrence_fields = &drupal_static(__FUNCTION__);
|
834 |
|
|
if (!isset($exclude_occurrence_fields)) {
|
835 |
|
|
$exclude_occurrence_fields = array(
|
836 |
|
|
'type',
|
837 |
|
|
'derivationEvent',
|
838 |
|
|
'taxonRelatedDerivedUnits',
|
839 |
7965ef92
|
Katja Luther
|
'label',
|
840 |
267da0d1
|
Katja Luther
|
'titleCache',
|
841 |
7965ef92
|
Katja Luther
|
'listLabel',
|
842 |
267da0d1
|
Katja Luther
|
'protectedTitleCache',
|
843 |
|
|
'class',
|
844 |
|
|
'uuid',
|
845 |
52f57468
|
Katja Luther
|
'collectionDTO',
|
846 |
|
|
'derivates'
|
847 |
267da0d1
|
Katja Luther
|
);
|
848 |
|
|
}
|
849 |
|
|
$items = array();
|
850 |
|
|
|
851 |
|
|
// only show uuid it the user is logged in
|
852 |
|
|
if (user_is_logged_in() && ($a_idx = array_search('uuid', $exclude_occurrence_fields)) !== FALSE) {
|
853 |
|
|
// unset($exclude_occurrence_fields[$a_idx]);
|
854 |
|
|
}
|
855 |
|
|
|
856 |
|
|
|
857 |
58c1a035
|
Katja Luther
|
if (is_object($specimen_or_observation)) {
|
858 |
267da0d1
|
Katja Luther
|
|
859 |
58c1a035
|
Katja Luther
|
$type_label = $specimen_or_observation->recordBase;
|
860 |
|
|
RenderHints::setFootnoteListKey($type_label . '-' . $specimen_or_observation->uuid);
|
861 |
267da0d1
|
Katja Luther
|
|
862 |
|
|
// collect typeStatus as label
|
863 |
58c1a035
|
Katja Luther
|
if (isset($specimen_or_observation->specimenTypeDesignations)) {
|
864 |
267da0d1
|
Katja Luther
|
$type_status = array();
|
865 |
58c1a035
|
Katja Luther
|
foreach ($specimen_or_observation->specimenTypeDesignations as $typeDesignation) {
|
866 |
267da0d1
|
Katja Luther
|
if (isset($typeDesignation->typeStatus->representation_L10n)) {
|
867 |
|
|
$type_status[] = $typeDesignation->typeStatus->representation_L10n;
|
868 |
|
|
}
|
869 |
|
|
}
|
870 |
|
|
if (count($type_status) > 0) {
|
871 |
|
|
$type_label = implode(', ', $type_status);
|
872 |
|
|
}
|
873 |
|
|
}
|
874 |
|
|
|
875 |
58c1a035
|
Katja Luther
|
$title = $type_label . ': ' . $specimen_or_observation->titleCache;
|
876 |
7965ef92
|
Katja Luther
|
$items['data'] = $title;
|
877 |
267da0d1
|
Katja Luther
|
|
878 |
|
|
$groups = array();
|
879 |
|
|
$items['children'] = $groups;
|
880 |
|
|
$children_items = array();
|
881 |
|
|
// --- add initialized fields
|
882 |
58c1a035
|
Katja Luther
|
foreach (get_object_vars($specimen_or_observation) as $field => $value) {
|
883 |
267da0d1
|
Katja Luther
|
$child_item = array();
|
884 |
|
|
|
885 |
|
|
if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
|
886 |
|
|
switch ($field) {
|
887 |
|
|
|
888 |
|
|
/* ---- SpecimenOrObservationBase --- */
|
889 |
106e1cf9
|
Katja Luther
|
|
890 |
267da0d1
|
Katja Luther
|
case 'kindOfUnit':
|
891 |
52f57468
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 1);
|
892 |
267da0d1
|
Katja Luther
|
break;
|
893 |
|
|
|
894 |
|
|
|
895 |
|
|
case 'preferredStableUri':
|
896 |
|
|
|
897 |
7965ef92
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), array(array('#markup' => cdm_external_uri($value, false))));
|
898 |
267da0d1
|
Katja Luther
|
break;
|
899 |
|
|
|
900 |
|
|
case 'specimenTypeDesignations':
|
901 |
f1239704
|
Katja Luther
|
@_description_list_group_add(
|
902 |
|
|
$groups,
|
903 |
267da0d1
|
Katja Luther
|
cdm_occurrence_field_name_label($field),
|
904 |
|
|
array(
|
905 |
|
|
'#markup' => theme('cdm_typedesignations', array('typeDesignations' => $value)),
|
906 |
|
|
)
|
907 |
|
|
);
|
908 |
|
|
break;
|
909 |
|
|
|
910 |
|
|
|
911 |
f1239704
|
Katja Luther
|
|
912 |
7965ef92
|
Katja Luther
|
case 'listOfMedia':
|
913 |
|
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
914 |
|
|
$captionElements = array(
|
915 |
|
|
'#uri' => t('open media'),
|
916 |
|
|
);
|
917 |
|
|
$gallery_html = compose_cdm_media_gallerie(array(
|
918 |
|
|
'mediaList' => $value,
|
919 |
58c1a035
|
Katja Luther
|
'galleryName' => $specimen_or_observation->label,
|
920 |
7965ef92
|
Katja Luther
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
921 |
|
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
922 |
|
|
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
|
923 |
|
|
'captionElements' => $captionElements,
|
924 |
|
|
'mediaLinkType' => 'LIGHTBOX',
|
925 |
|
|
'alternativeMediaUri' => NULL,
|
926 |
|
|
'galleryLinkUri' => NULL,
|
927 |
|
|
));
|
928 |
|
|
|
929 |
276f39f6
|
Katja Luther
|
//@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $gallery_html);
|
930 |
7965ef92
|
Katja Luther
|
break;
|
931 |
267da0d1
|
Katja Luther
|
|
932 |
|
|
|
933 |
|
|
|
934 |
|
|
/* ---- DerivedUnitBase --- */
|
935 |
|
|
|
936 |
1083804e
|
Andreas Kohlbecker
|
|
937 |
267da0d1
|
Katja Luther
|
case 'collection':
|
938 |
7965ef92
|
Katja Luther
|
|
939 |
267da0d1
|
Katja Luther
|
$sub_dl_groups = array();
|
940 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1);
|
941 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2);
|
942 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3);
|
943 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4);
|
944 |
|
|
// TODO "superCollection"
|
945 |
|
|
// TODO may have media
|
946 |
|
|
|
947 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
|
948 |
|
|
array(
|
949 |
|
|
array('#markup' => $value->titleCache),
|
950 |
|
|
array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
|
951 |
|
|
)
|
952 |
|
|
);
|
953 |
7965ef92
|
Katja Luther
|
|
954 |
267da0d1
|
Katja Luther
|
break;
|
955 |
|
|
|
956 |
|
|
|
957 |
|
|
|
958 |
|
|
|
959 |
|
|
/* ---- Specimen --- */
|
960 |
|
|
case 'sequences':
|
961 |
|
|
$dd_elements = array();
|
962 |
|
|
foreach ($value as $sequence) {
|
963 |
52f57468
|
Katja Luther
|
$dd_elements[] = compose_cdm_sequence($sequence, true);
|
964 |
|
|
$dd_elements[] = "";
|
965 |
267da0d1
|
Katja Luther
|
}
|
966 |
a0f26798
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements,'', 100);
|
967 |
267da0d1
|
Katja Luther
|
break;
|
968 |
|
|
|
969 |
|
|
// TODO preservation
|
970 |
|
|
// TODO exsiccatum
|
971 |
|
|
|
972 |
|
|
|
973 |
|
|
/* ---- FieldObservation --- */
|
974 |
|
|
case 'gatheringEvent':
|
975 |
|
|
|
976 |
52f57468
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collector'), $value->collector);
|
977 |
267da0d1
|
Katja Luther
|
@_description_list_group_add($groups, t('Gathering time'), timePeriodToString($value->timeperiod));
|
978 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description);
|
979 |
52f57468
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('locality'), $value->locality);
|
980 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('country'), $value->country);
|
981 |
267da0d1
|
Katja Luther
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingMethod'), $value->collectingMethod);
|
982 |
|
|
if (isset($value->absoluteElevation)) {
|
983 |
|
|
$min_max_markup = min_max_measure($value, 'absoluteElevation');
|
984 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('absoluteElevation'), $min_max_markup);
|
985 |
|
|
}
|
986 |
276f39f6
|
Katja Luther
|
if (isset($value->distanceToGround) && $value->distanceToGround >0) {
|
987 |
267da0d1
|
Katja Luther
|
$min_max_markup = min_max_measure($value, 'distanceToGround');
|
988 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToGround'), $min_max_markup);
|
989 |
|
|
}
|
990 |
276f39f6
|
Katja Luther
|
if (isset($value->distanceToWaterSurface) && $value->distanceToWaterSurface > 0) {
|
991 |
267da0d1
|
Katja Luther
|
$min_max_markup = min_max_measure($value, 'distanceToWaterSurface');
|
992 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToWaterSurface'), $min_max_markup);
|
993 |
|
|
}
|
994 |
|
|
|
995 |
|
|
if (isset($value->collectingAreas)) {
|
996 |
|
|
$area_representations = array();
|
997 |
|
|
foreach ($value->collectingAreas as $area) {
|
998 |
52f57468
|
Katja Luther
|
// $area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid));
|
999 |
|
|
$area_representations[] = $area;
|
1000 |
267da0d1
|
Katja Luther
|
}
|
1001 |
|
|
if (!empty($area_representations))
|
1002 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'),
|
1003 |
|
|
array(
|
1004 |
|
|
array('#markup' => implode(', ', $area_representations))
|
1005 |
|
|
)
|
1006 |
|
|
);
|
1007 |
|
|
}
|
1008 |
106e1cf9
|
Katja Luther
|
if (isset($value->exactLocation) ) {
|
1009 |
267da0d1
|
Katja Luther
|
$sub_dl_groups = array();
|
1010 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1);
|
1011 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('longitude'), round($value->exactLocation->longitude, 7), '°', 2);
|
1012 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('latitude'), round($value->exactLocation->latitude, 7), '°', 3);
|
1013 |
|
|
if (isset($value->exactLocation->referenceSystem)) {
|
1014 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('referenceSystem'), $value->exactLocation->referenceSystem->representation_L10n, '', 4);
|
1015 |
|
|
}
|
1016 |
106e1cf9
|
Katja Luther
|
if ( isSet($value->exactLocation->sexagesimalString)){
|
1017 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'),
|
1018 |
267da0d1
|
Katja Luther
|
array(
|
1019 |
106e1cf9
|
Katja Luther
|
array('#markup' => $value->exactLocation->sexagesimalString),
|
1020 |
|
|
array(
|
1021 |
|
|
'#theme' => 'description_list',
|
1022 |
|
|
'#groups' => $sub_dl_groups
|
1023 |
|
|
),
|
1024 |
|
|
)
|
1025 |
|
|
);
|
1026 |
|
|
}
|
1027 |
267da0d1
|
Katja Luther
|
}
|
1028 |
|
|
|
1029 |
|
|
break;
|
1030 |
|
|
|
1031 |
|
|
/* ---- DerivationEvent --- */
|
1032 |
|
|
case 'derivationEvents':
|
1033 |
|
|
//@_description_list_group_add($groups, t('Association type'), $value->description);
|
1034 |
|
|
break;
|
1035 |
|
|
|
1036 |
|
|
|
1037 |
|
|
default:
|
1038 |
|
|
if (is_object($value) || is_array($value)) {
|
1039 |
52f57468
|
Katja Luther
|
drupal_set_message("Unhandled type in compose_cdm_specimenOrObservation() for field " . $field, "warning");
|
1040 |
267da0d1
|
Katja Luther
|
} else {
|
1041 |
|
|
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
1042 |
|
|
}
|
1043 |
|
|
|
1044 |
|
|
}
|
1045 |
|
|
|
1046 |
|
|
|
1047 |
|
|
}
|
1048 |
|
|
} // END of loop over $derivedUnitFacade fields
|
1049 |
|
|
|
1050 |
|
|
|
1051 |
|
|
|
1052 |
|
|
// template_preprocess_description_list() is not worting by weight so we do it right here
|
1053 |
|
|
uasort($groups, 'element_sort');
|
1054 |
|
|
|
1055 |
|
|
$occurrence_elements = array(
|
1056 |
|
|
// '#title' => $title,
|
1057 |
|
|
'#theme' => 'description_list',
|
1058 |
|
|
'#groups' => $groups,
|
1059 |
58c1a035
|
Katja Luther
|
'#attributes' => array('class' => html_class_attribute_ref($specimen_or_observation)),
|
1060 |
267da0d1
|
Katja Luther
|
);
|
1061 |
|
|
$output = drupal_render($occurrence_elements);
|
1062 |
106e1cf9
|
Katja Luther
|
if (isset($gallery_html)){
|
1063 |
|
|
$output .= $gallery_html;
|
1064 |
|
|
}
|
1065 |
58c1a035
|
Katja Luther
|
if (!($specimen_or_observation->type == 'FieldUnit')){
|
1066 |
|
|
$pathToSpecimen = path_to_specimen($specimen_or_observation->uuid);
|
1067 |
a0f26798
|
Katja Luther
|
$output .= l("detail page", $pathToSpecimen, array('attributes' => array('target' => '_blank')));
|
1068 |
|
|
}
|
1069 |
106e1cf9
|
Katja Luther
|
|
1070 |
416bc78f
|
Katja Luther
|
|
1071 |
267da0d1
|
Katja Luther
|
|
1072 |
|
|
|
1073 |
|
|
|
1074 |
|
|
|
1075 |
|
|
|
1076 |
|
|
|
1077 |
|
|
|
1078 |
|
|
|
1079 |
|
|
} // END of $specimenOrObservation exists
|
1080 |
|
|
|
1081 |
|
|
return $output;
|
1082 |
|
|
}
|