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 |
2d6348e5
|
Patrick Plitzner
|
$detail_html .= "<strong>Specimen page: $specimenPageLink</strong><br>";
|
36 |
a7a302a0
|
Patric Plitzner
|
}
|
37 |
|
|
|
38 |
30845bda
|
Andreas Kohlbecker
|
if($is_specimen_page) {
|
39 |
|
|
if($specimen->citation){
|
40 |
|
|
$detail_html .= "<br>".create_label("Citation") . $specimen->citation . "<br>";
|
41 |
fdc85125
|
Patric Plitzner
|
}
|
42 |
b810158e
|
Patric Plitzner
|
}
|
43 |
30845bda
|
Andreas Kohlbecker
|
if($specimen->preferredStableUri){
|
44 |
48b1eaa7
|
Patrick Plitzner
|
$stableIdentifierLink = l($specimen->preferredStableUri, $specimen->preferredStableUri, array('attributes' => array('target' => '_blank')));
|
45 |
907cc9b4
|
Patrick Plitzner
|
$detail_html .= create_label("Preferred stable URI") . $stableIdentifierLink . "<br>";
|
46 |
1cefb4e5
|
Patrick Plitzner
|
}
|
47 |
30845bda
|
Andreas Kohlbecker
|
if($is_specimen_page){
|
48 |
fdc85125
|
Patric Plitzner
|
// associated taxa
|
49 |
30845bda
|
Andreas Kohlbecker
|
if($specimen->associatedTaxa){
|
50 |
3dd58832
|
Patric Plitzner
|
$detail_html .= "<br>";
|
51 |
fa09fe7d
|
Patrick Plitzner
|
$detail_html .= create_label("Associated with");
|
52 |
|
|
if(sizeof($specimen->associatedTaxa)>1){
|
53 |
|
|
$detail_html .= "<br>";
|
54 |
|
|
}
|
55 |
|
|
foreach($specimen->associatedTaxa as $associatedTaxon){
|
56 |
|
|
$detail_html .= l($associatedTaxon->second, path_to_taxon($associatedTaxon->first, "specimens"));//$associatedTaxon->second."<br>";
|
57 |
|
|
}
|
58 |
|
|
$detail_html .= "<br>";
|
59 |
fdc85125
|
Patric Plitzner
|
}
|
60 |
b810158e
|
Patric Plitzner
|
}
|
61 |
fa09fe7d
|
Patrick Plitzner
|
// - type information
|
62 |
b810158e
|
Patric Plitzner
|
$types = "";
|
63 |
30845bda
|
Andreas Kohlbecker
|
if (isset($specimen->types)) {
|
64 |
56d58f9b
|
Patric Plitzner
|
//typed taxa
|
65 |
30845bda
|
Andreas Kohlbecker
|
foreach ($specimen->types as $typeStatus => $typedTaxa) {
|
66 |
b0efd824
|
Patrick Plitzner
|
if($specimen->types){
|
67 |
a5b11885
|
Patrick Plitzner
|
if($typeStatus == NULL){
|
68 |
|
|
$detail_html .= "<i>no type status set:</i> ";
|
69 |
|
|
}
|
70 |
|
|
else{
|
71 |
|
|
$detail_html .= "<i>".$typeStatus."</i> of ";
|
72 |
|
|
}
|
73 |
b0efd824
|
Patrick Plitzner
|
foreach($typedTaxa as $typedTaxon){
|
74 |
|
|
$detail_html .= $typedTaxon." ";
|
75 |
fdc85125
|
Patric Plitzner
|
}
|
76 |
b0efd824
|
Patrick Plitzner
|
$detail_html .= "<br>";
|
77 |
fdc85125
|
Patric Plitzner
|
}
|
78 |
b810158e
|
Patric Plitzner
|
}
|
79 |
|
|
}
|
80 |
30845bda
|
Andreas Kohlbecker
|
$derivateDataDTO = $specimen->derivateDataDTO;
|
81 |
b810158e
|
Patric Plitzner
|
// - specimen scans
|
82 |
65a4de51
|
Patrick Plitzner
|
$specimenScans = create_html_links($derivateDataDTO->specimenScans, true);
|
83 |
b810158e
|
Patric Plitzner
|
// - molecular data
|
84 |
|
|
$molecularData = "";
|
85 |
|
|
if ($derivateDataDTO->molecularDataList) {
|
86 |
|
|
foreach ($derivateDataDTO->molecularDataList as $molecular) {
|
87 |
|
|
//provider link
|
88 |
|
|
if (isset($molecular->providerLink)) {
|
89 |
65a4de51
|
Patrick Plitzner
|
$molecularData .= create_html_link($molecular->providerLink, true);
|
90 |
2c23b054
|
Patrick Plitzner
|
} else {
|
91 |
|
|
$molecularData .= "[no provider]";
|
92 |
b810158e
|
Patric Plitzner
|
}
|
93 |
|
|
//contig link
|
94 |
2c23b054
|
Patrick Plitzner
|
if (isset($molecular->contigFiles)) {
|
95 |
b810158e
|
Patric Plitzner
|
$molecularData .= "[";
|
96 |
2c23b054
|
Patrick Plitzner
|
if (sizeof($molecular->contigFiles) > 0) {
|
97 |
b810158e
|
Patric Plitzner
|
foreach ($molecular->contigFiles as $contigFile) {
|
98 |
2c23b054
|
Patrick Plitzner
|
if (isset($contigFile->contigLink)) {
|
99 |
|
|
if (isset($contigFile->contigLink->uri) and $contigFile->contigLink->uri != null) {
|
100 |
|
|
$molecularData .= create_html_link($contigFile->contigLink, true) . " ";
|
101 |
37ab3ddc
|
Patric Plitzner
|
}
|
102 |
2c23b054
|
Patrick Plitzner
|
}
|
103 |
|
|
else {
|
104 |
|
|
$molecularData .= "no contig ";
|
105 |
|
|
}
|
106 |
|
|
//primer links
|
107 |
|
|
if(isset($contigFile->primerLinks)) {
|
108 |
65a4de51
|
Patrick Plitzner
|
$molecularData .= create_html_links($contigFile->primerLinks, true);
|
109 |
b810158e
|
Patric Plitzner
|
}
|
110 |
|
|
}
|
111 |
|
|
}
|
112 |
5eafa5ff
|
Patric Plitzner
|
$molecularData = rtrim($molecularData, " ");
|
113 |
b810158e
|
Patric Plitzner
|
$molecularData .= "]";
|
114 |
|
|
}
|
115 |
|
|
//FIXME separate with comma (remove trailing comma)
|
116 |
|
|
}
|
117 |
|
|
}
|
118 |
|
|
// - detail images
|
119 |
65a4de51
|
Patrick Plitzner
|
$detailImages = create_html_links($derivateDataDTO->detailImages, true);
|
120 |
b810158e
|
Patric Plitzner
|
|
121 |
|
|
if ($types) {
|
122 |
30845bda
|
Andreas Kohlbecker
|
$detail_html .= $is_specimen_page?"<br>":"";
|
123 |
a0bbccce
|
Patrick Plitzner
|
$detail_html .= create_label("Type(s)") . $types . "<br>";
|
124 |
b810158e
|
Patric Plitzner
|
}
|
125 |
30845bda
|
Andreas Kohlbecker
|
if ($specimenScans and !$is_specimen_page) {
|
126 |
3dd58832
|
Patric Plitzner
|
$detail_html .= create_label("Specimen Scans") . $specimenScans . "<br>";
|
127 |
b810158e
|
Patric Plitzner
|
}
|
128 |
8d9d64a5
|
Patric Plitzner
|
//specimen scan image gallery
|
129 |
30845bda
|
Andreas Kohlbecker
|
if($is_specimen_page and isset($derivateDataDTO->specimenScanUuids) and !empty($derivateDataDTO->specimenScanUuids)) {
|
130 |
8d9d64a5
|
Patric Plitzner
|
$detail_html .= addImageGallery("Specimen scans", $derivateDataDTO->specimenScanUuids);
|
131 |
|
|
}
|
132 |
|
|
|
133 |
b810158e
|
Patric Plitzner
|
if ($molecularData) {
|
134 |
30845bda
|
Andreas Kohlbecker
|
$detail_html .= $is_specimen_page?"<br>":"";
|
135 |
3dd58832
|
Patric Plitzner
|
$detail_html .= create_label("Molecular Data") . $molecularData . "<br>";
|
136 |
b810158e
|
Patric Plitzner
|
}
|
137 |
8d9d64a5
|
Patric Plitzner
|
|
138 |
30845bda
|
Andreas Kohlbecker
|
if ($detailImages and !$is_specimen_page) {
|
139 |
3dd58832
|
Patric Plitzner
|
$detail_html .= create_label("Detail Images") . $detailImages . "<br>";
|
140 |
b810158e
|
Patric Plitzner
|
}
|
141 |
|
|
|
142 |
8d9d64a5
|
Patric Plitzner
|
//detail image gallery
|
143 |
30845bda
|
Andreas Kohlbecker
|
if($is_specimen_page and isset($derivateDataDTO->detailImageUuids) and !empty($derivateDataDTO->detailImageUuids)){
|
144 |
8d9d64a5
|
Patric Plitzner
|
$detail_html .= addImageGallery("Detail Images", $derivateDataDTO->detailImageUuids);
|
145 |
|
|
}
|
146 |
|
|
|
147 |
b810158e
|
Patric Plitzner
|
//character data
|
148 |
30845bda
|
Andreas Kohlbecker
|
if ($specimen->characterData) {
|
149 |
|
|
$detail_html .= $is_specimen_page?"<br>":"";
|
150 |
a442acb8
|
Patric Plitzner
|
$detail_html .= create_label("Character Data");
|
151 |
30845bda
|
Andreas Kohlbecker
|
if($is_specimen_page) {
|
152 |
b810158e
|
Patric Plitzner
|
$detail_html .= "<br>";
|
153 |
30845bda
|
Andreas Kohlbecker
|
foreach ($specimen->characterData as $characterStatePair) {
|
154 |
a442acb8
|
Patric Plitzner
|
$detail_html .= "<i>" . $characterStatePair->first . "</i>:" . $characterStatePair->second;
|
155 |
|
|
$detail_html .= "<br>";
|
156 |
|
|
}
|
157 |
|
|
}
|
158 |
|
|
else{
|
159 |
|
|
$detail_html .= l("detail page", $pathToSpecimen,array('attributes' => array('target'=>'_blank')));
|
160 |
216abf0b
|
Patric Plitzner
|
$detail_html .= "<br>";
|
161 |
b810158e
|
Patric Plitzner
|
}
|
162 |
|
|
}
|
163 |
8d9d64a5
|
Patric Plitzner
|
return $detail_html;
|
164 |
|
|
}
|
165 |
8c1d6d72
|
Patric Plitzner
|
|
166 |
8d9d64a5
|
Patric Plitzner
|
function addImageGallery($galleryName, $imageUuids){
|
167 |
b5c89485
|
Patric Plitzner
|
$images = array();
|
168 |
8d9d64a5
|
Patric Plitzner
|
foreach ($imageUuids as $uuid) {
|
169 |
|
|
$images[] = cdm_ws_get(CDM_WS_PORTAL_MEDIA, $uuid);
|
170 |
8c1d6d72
|
Patric Plitzner
|
}
|
171 |
7cf177d0
|
Patrick Plitzner
|
|
172 |
|
|
$gallery_html = '';
|
173 |
|
|
if (count($imageUuids) > 0) {
|
174 |
|
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
175 |
|
|
$captionElements = array(
|
176 |
|
|
'title',
|
177 |
|
|
'rights',
|
178 |
|
|
);
|
179 |
|
|
$alternativeMediaUris = array();
|
180 |
|
|
foreach($images as $image){
|
181 |
e2eaa6c7
|
Patrick Plitzner
|
$mediaUri = getMediaUri($image);
|
182 |
|
|
if($mediaUri){
|
183 |
|
|
$alternativeMediaUris[] = $mediaUri;
|
184 |
|
|
}
|
185 |
|
|
else{
|
186 |
7cf177d0
|
Patrick Plitzner
|
$alternativeMediaUris[] = path_to_media($image->uuid);
|
187 |
e2eaa6c7
|
Patrick Plitzner
|
}
|
188 |
7cf177d0
|
Patrick Plitzner
|
}
|
189 |
|
|
|
190 |
a9815578
|
Andreas Kohlbecker
|
$gallery_html = compose_cdm_media_gallerie(array(
|
191 |
7cf177d0
|
Patrick Plitzner
|
'mediaList' => $images,
|
192 |
|
|
'galleryName' => $galleryName,
|
193 |
|
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
194 |
|
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
195 |
|
|
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
|
196 |
|
|
'captionElements' => $captionElements,
|
197 |
|
|
'mediaLinkType' => 'LIGHTBOX',
|
198 |
|
|
'alternativeMediaUri' => $alternativeMediaUris,
|
199 |
|
|
'galleryLinkUri' => NULL,
|
200 |
|
|
));
|
201 |
|
|
}
|
202 |
|
|
return "<br>".create_label($galleryName)."<br>".$gallery_html;
|
203 |
b810158e
|
Patric Plitzner
|
}
|
204 |
|
|
|
205 |
e2eaa6c7
|
Patrick Plitzner
|
function getMediaUri($media){
|
206 |
|
|
if(isset($media->representations) && sizeof($media->representations)==1
|
207 |
|
|
&& isset($media->representations[0]->parts) &&
|
208 |
|
|
sizeof($media->representations[0]->parts)==1) {
|
209 |
|
|
return $media->representations[0]->parts[0]->uri;
|
210 |
|
|
}
|
211 |
|
|
return null;
|
212 |
|
|
}
|
213 |
|
|
|
214 |
8d9d64a5
|
Patric Plitzner
|
|
215 |
3dd58832
|
Patric Plitzner
|
/**
|
216 |
5a079dbf
|
Andreas Kohlbecker
|
* Formats the given string to a label for displaying key-object pairs in HTML
|
217 |
3dd58832
|
Patric Plitzner
|
* @return string
|
218 |
|
|
*/
|
219 |
|
|
function create_label($label)
|
220 |
|
|
{
|
221 |
|
|
return "<span class='specimen_table_label'>".$label.": </span>";
|
222 |
|
|
}
|
223 |
|
|
|
224 |
f19f47fa
|
Andreas Kohlbecker
|
/**
|
225 |
|
|
* Compose an render array from a CDM DerivedUnitFacade object.
|
226 |
|
|
*
|
227 |
|
|
* compose_hook() implementation
|
228 |
235fc94b
|
Andreas Kohlbecker
|
*
|
229 |
|
|
* @param object $specimenOrObservation
|
230 |
|
|
* the CDM instance of type SpecimenOrObservation to compose
|
231 |
|
|
* the render array for
|
232 |
|
|
* @param array $derivatives
|
233 |
|
|
* the render array which contains the compositions of the derivatives
|
234 |
|
|
* of the supplied $specimenOrObservation
|
235 |
|
|
*
|
236 |
|
|
* @return array
|
237 |
|
|
* the supplied render array $derivatives to which the composition of the supplied
|
238 |
|
|
* $specimenOrObservation has been added to
|
239 |
5b26b91a
|
Andreas Kohlbecker
|
*
|
240 |
|
|
* @ingroup compose
|
241 |
f19f47fa
|
Andreas Kohlbecker
|
*/
|
242 |
bd814ea2
|
Andreas Kohlbecker
|
function compose_cdm_specimen_or_observation($specimenOrObservation, &$derivatives = null) {
|
243 |
f846e7e7
|
Andreas Kohlbecker
|
|
244 |
eeb98da8
|
Andreas Kohlbecker
|
$exclude_occurrence_fields = &drupal_static(__FUNCTION__);
|
245 |
|
|
if (!isset($exclude_occurrence_fields)) {
|
246 |
|
|
$exclude_occurrence_fields = array(
|
247 |
5b30a682
|
Andreas Kohlbecker
|
'derivationEvents',
|
248 |
eeb98da8
|
Andreas Kohlbecker
|
'titleCache',
|
249 |
f19f47fa
|
Andreas Kohlbecker
|
'protectedTitleCache',
|
250 |
eeb98da8
|
Andreas Kohlbecker
|
'derivedUnitMedia',
|
251 |
|
|
'created',
|
252 |
f67ffd4e
|
Andreas Kohlbecker
|
'publish',
|
253 |
eeb98da8
|
Andreas Kohlbecker
|
'updated',
|
254 |
|
|
'class',
|
255 |
5b3557f9
|
Andreas Kohlbecker
|
'uuid',
|
256 |
f19f47fa
|
Andreas Kohlbecker
|
''
|
257 |
eeb98da8
|
Andreas Kohlbecker
|
);
|
258 |
|
|
}
|
259 |
|
|
|
260 |
f846e7e7
|
Andreas Kohlbecker
|
|
261 |
98450eb2
|
Andreas Kohlbecker
|
// only show uuid it the user is logged in
|
262 |
a67e7364
|
Andreas Kohlbecker
|
if(user_is_logged_in() && ($a_idx = array_search('uuid', $exclude_occurrence_fields)) !== FALSE ) {
|
263 |
|
|
unset($exclude_occurrence_fields[$a_idx]);
|
264 |
98450eb2
|
Andreas Kohlbecker
|
}
|
265 |
9b9037f3
|
Andreas Kohlbecker
|
|
266 |
6fbdb943
|
Andreas Kohlbecker
|
if (!isset($derivatives)) {
|
267 |
|
|
$derivatives = array();
|
268 |
f846e7e7
|
Andreas Kohlbecker
|
}
|
269 |
|
|
|
270 |
6fbdb943
|
Andreas Kohlbecker
|
$descriptions = null;
|
271 |
0796d2f9
|
Andreas Kohlbecker
|
$derivedFrom = null;
|
272 |
f19f47fa
|
Andreas Kohlbecker
|
|
273 |
6fbdb943
|
Andreas Kohlbecker
|
if (is_object($specimenOrObservation)) {
|
274 |
f846e7e7
|
Andreas Kohlbecker
|
|
275 |
|
|
// request again for deeper initialization
|
276 |
|
|
$specimenOrObservation = cdm_ws_get("portal/" . CDM_WS_OCCURRENCE, $specimenOrObservation->uuid);
|
277 |
9b9037f3
|
Andreas Kohlbecker
|
|
278 |
15b7c460
|
Andreas Kohlbecker
|
|
279 |
9b9037f3
|
Andreas Kohlbecker
|
$type_label = $specimenOrObservation->class;
|
280 |
15b7c460
|
Andreas Kohlbecker
|
RenderHints::setFootnoteListKey($type_label . '-' . $specimenOrObservation->uuid);
|
281 |
|
|
|
282 |
9b9037f3
|
Andreas Kohlbecker
|
// collect typeStatus as label
|
283 |
|
|
if (isset($specimenOrObservation->specimenTypeDesignations)) {
|
284 |
|
|
$type_status = array();
|
285 |
|
|
foreach ($specimenOrObservation->specimenTypeDesignations as $typeDesignation) {
|
286 |
0820cdc0
|
Andreas Kohlbecker
|
if (isset($typeDesignation->typeStatus->representation_L10n)) {
|
287 |
9b9037f3
|
Andreas Kohlbecker
|
$type_status[] = $typeDesignation->typeStatus->representation_L10n;
|
288 |
|
|
}
|
289 |
|
|
}
|
290 |
0820cdc0
|
Andreas Kohlbecker
|
if (count($type_status) > 0) {
|
291 |
c6787c7d
|
Andreas Kohlbecker
|
$type_label = implode(', ', $type_status);
|
292 |
cb7db01d
|
Andreas Kohlbecker
|
}
|
293 |
9b9037f3
|
Andreas Kohlbecker
|
}
|
294 |
|
|
|
295 |
0820cdc0
|
Andreas Kohlbecker
|
$title = $type_label . ': ' . $specimenOrObservation->titleCache;
|
296 |
6fbdb943
|
Andreas Kohlbecker
|
|
297 |
f846e7e7
|
Andreas Kohlbecker
|
$groups = array();
|
298 |
|
|
// --- add initialized fields
|
299 |
f19f47fa
|
Andreas Kohlbecker
|
foreach (get_object_vars($specimenOrObservation) as $field => $value) {
|
300 |
|
|
if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
|
301 |
6fbdb943
|
Andreas Kohlbecker
|
switch ($field) {
|
302 |
|
|
|
303 |
|
|
/* ---- java.lang.Object --- */
|
304 |
|
|
case 'class':
|
305 |
0820cdc0
|
Andreas Kohlbecker
|
if ($value != '' /* FieldUnit' */) {
|
306 |
6fbdb943
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
307 |
|
|
}
|
308 |
0820cdc0
|
Andreas Kohlbecker
|
break;
|
309 |
4ae6064e
|
Andreas Kohlbecker
|
|
310 |
|
|
case 'markers':
|
311 |
|
|
$dd_elements = array();
|
312 |
|
|
foreach ($value as $marker) {
|
313 |
|
|
$dd_elements[] = compose_cdm_marker($marker);
|
314 |
|
|
}
|
315 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
316 |
|
|
break;
|
317 |
f19f47fa
|
Andreas Kohlbecker
|
|
318 |
4ae6064e
|
Andreas Kohlbecker
|
|
319 |
5b30a682
|
Andreas Kohlbecker
|
case 'annotations':
|
320 |
|
|
$dd_elements = array();
|
321 |
|
|
foreach ($value as $annotation) {
|
322 |
|
|
// TODO respect annotation type filter settings
|
323 |
|
|
$dd_elements[] = $annotation->text;
|
324 |
|
|
}
|
325 |
|
|
@_description_list_group_add($groups, t('Notes'), $dd_elements);
|
326 |
|
|
break;
|
327 |
eeb98da8
|
Andreas Kohlbecker
|
|
328 |
6fbdb943
|
Andreas Kohlbecker
|
/* ---- SpecimenOrObservationBase --- */
|
329 |
|
|
case 'sex':
|
330 |
|
|
case 'lifeStage':
|
331 |
06d6b7fa
|
Andreas Kohlbecker
|
case 'kindOfUnit':
|
332 |
6fbdb943
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->representation_L10n);
|
333 |
f846e7e7
|
Andreas Kohlbecker
|
break;
|
334 |
|
|
|
335 |
6fbdb943
|
Andreas Kohlbecker
|
case 'definition':
|
336 |
|
|
// TODO
|
337 |
|
|
break;
|
338 |
|
|
|
339 |
a9ed34ad
|
Andreas Kohlbecker
|
case 'preferredStableUri':
|
340 |
|
|
|
341 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), array(array('#markup' => cdm_external_uri($value, false))));
|
342 |
|
|
break;
|
343 |
|
|
|
344 |
9b9037f3
|
Andreas Kohlbecker
|
case 'specimenTypeDesignations':
|
345 |
4c75b2d9
|
Andreas Kohlbecker
|
@_description_list_group_add(
|
346 |
|
|
$groups,
|
347 |
|
|
cdm_occurrence_field_name_label($field),
|
348 |
|
|
array(
|
349 |
0820cdc0
|
Andreas Kohlbecker
|
'#markup' => theme('cdm_typedesignations', array('typeDesignations' => $value)),
|
350 |
4c75b2d9
|
Andreas Kohlbecker
|
)
|
351 |
|
|
);
|
352 |
9b9037f3
|
Andreas Kohlbecker
|
break;
|
353 |
|
|
|
354 |
6fbdb943
|
Andreas Kohlbecker
|
case 'determinations':
|
355 |
f19f47fa
|
Andreas Kohlbecker
|
$dd_elements = array();
|
356 |
42133a60
|
Andreas Kohlbecker
|
$glue = ', ';
|
357 |
9b9037f3
|
Andreas Kohlbecker
|
|
358 |
0820cdc0
|
Andreas Kohlbecker
|
foreach ($value as $determinationEvent) {
|
359 |
|
|
$timeperiod_string = NULL;
|
360 |
|
|
if (isset($determinationEvent->timeperiod)) {
|
361 |
|
|
$timeperiod_string = timePeriodToString($determinationEvent->timeperiod);
|
362 |
|
|
}
|
363 |
|
|
$weight = isset($determinationEvent->preferred) && $determinationEvent->preferred == 1 ? '0' : ($timeperiod_string ? $timeperiod_string : '1');
|
364 |
|
|
// check key exists
|
365 |
|
|
while (array_key_exists($weight, $dd_elements)) {
|
366 |
|
|
$weight .= '0';
|
367 |
|
|
}
|
368 |
|
|
|
369 |
|
|
$taxon_name = '';
|
370 |
|
|
$name_link = '';
|
371 |
|
|
if ($determinationEvent->taxonName) {
|
372 |
|
|
$taxon_name = $determinationEvent->taxonName;
|
373 |
|
|
} else if ($determinationEvent->taxon) {
|
374 |
|
|
$taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
|
375 |
|
|
$name_link = path_to_taxon($determinationEvent->taxon->uuid);
|
376 |
|
|
}
|
377 |
|
|
if ($taxon_name) {
|
378 |
63c3ac73
|
Andreas Kohlbecker
|
$taxon_html = render_taxon_or_name($taxon_name, $name_link);
|
379 |
3dd58832
|
Patric Plitzner
|
$dd_elements[$weight] = $taxon_html;
|
380 |
0820cdc0
|
Andreas Kohlbecker
|
}
|
381 |
|
|
if (isset($determinationEvent->modifier)) {
|
382 |
|
|
$dd_elements[$weight] .= cdm_term_representation($determinationEvent->modifier);
|
383 |
|
|
}
|
384 |
|
|
if ($timeperiod_string) {
|
385 |
|
|
$dd_elements[$weight] .= $glue . $timeperiod_string;
|
386 |
|
|
}
|
387 |
|
|
if (isset($determinationEvent->actor->titleCache)) {
|
388 |
|
|
$dd_elements[$weight] .= $glue . $determinationEvent->actor->titleCache;
|
389 |
|
|
}
|
390 |
|
|
if (isset($determinationEvent->description)) {
|
391 |
|
|
$dd_elements[$weight] .= $glue . $determinationEvent->description;
|
392 |
|
|
}
|
393 |
1b04a204
|
Andreas Kohlbecker
|
}
|
394 |
9b9037f3
|
Andreas Kohlbecker
|
ksort($dd_elements);
|
395 |
f19f47fa
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('determinations'), $dd_elements);
|
396 |
1b04a204
|
Andreas Kohlbecker
|
break;
|
397 |
f846e7e7
|
Andreas Kohlbecker
|
|
398 |
f19f47fa
|
Andreas Kohlbecker
|
case 'descriptions':
|
399 |
bfb2b81a
|
Andreas Kohlbecker
|
$occurrence_featureTree = cdm_get_occurrence_featureTree();
|
400 |
|
|
$dd_elements = array();
|
401 |
|
|
|
402 |
a7a96336
|
Andreas Kohlbecker
|
foreach ($value as $description) {
|
403 |
bfb2b81a
|
Andreas Kohlbecker
|
$description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, $description->uuid);
|
404 |
a67e7364
|
Andreas Kohlbecker
|
// if($description->imageGallery == TRUE) {
|
405 |
|
|
// continue;
|
406 |
|
|
// }
|
407 |
fae36a2a
|
Andreas Kohlbecker
|
$elements_by_feature = _mergeFeatureTreeDescriptions($occurrence_featureTree->root->childNodes, $description->elements);
|
408 |
1b756c5f
|
Andreas Kohlbecker
|
$description_render_elements = _block_get_renderable_array(make_feature_block_list($elements_by_feature, null));
|
409 |
9b9037f3
|
Andreas Kohlbecker
|
$dd_elements[] = $description_render_elements;
|
410 |
bfb2b81a
|
Andreas Kohlbecker
|
}
|
411 |
|
|
|
412 |
f19f47fa
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
413 |
6fbdb943
|
Andreas Kohlbecker
|
break;
|
414 |
|
|
|
415 |
f846e7e7
|
Andreas Kohlbecker
|
case 'sources':
|
416 |
0820cdc0
|
Andreas Kohlbecker
|
$dd_elements = array();
|
417 |
|
|
foreach ($value as $identifiable_source) {
|
418 |
|
|
$dd_elements[] = theme('cdm_OriginalSource', array('source' => $identifiable_source));
|
419 |
|
|
}
|
420 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
421 |
|
|
break;
|
422 |
0796d2f9
|
Andreas Kohlbecker
|
|
423 |
f19f47fa
|
Andreas Kohlbecker
|
|
424 |
0796d2f9
|
Andreas Kohlbecker
|
/* ---- DerivedUnitBase --- */
|
425 |
|
|
case 'derivedFrom':
|
426 |
|
|
$derivedFrom = $value;
|
427 |
f19f47fa
|
Andreas Kohlbecker
|
break;
|
428 |
6fbdb943
|
Andreas Kohlbecker
|
|
429 |
|
|
case 'collection':
|
430 |
|
|
$sub_dl_groups = array();
|
431 |
f19f47fa
|
Andreas Kohlbecker
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1);
|
432 |
0820cdc0
|
Andreas Kohlbecker
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2);
|
433 |
964c2f69
|
Andreas Kohlbecker
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3);
|
434 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4);
|
435 |
6fbdb943
|
Andreas Kohlbecker
|
// TODO "superCollection"
|
436 |
|
|
// TODO may have media
|
437 |
|
|
|
438 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
|
439 |
0820cdc0
|
Andreas Kohlbecker
|
array(
|
440 |
|
|
array('#markup' => $value->titleCache),
|
441 |
|
|
array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
|
442 |
|
|
)
|
443 |
f19f47fa
|
Andreas Kohlbecker
|
);
|
444 |
6fbdb943
|
Andreas Kohlbecker
|
break;
|
445 |
|
|
|
446 |
0820cdc0
|
Andreas Kohlbecker
|
case 'storedUnder':
|
447 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('storedUnder'), render_taxon_or_name($value));
|
448 |
|
|
break;
|
449 |
6fbdb943
|
Andreas Kohlbecker
|
|
450 |
|
|
|
451 |
0820cdc0
|
Andreas Kohlbecker
|
/* ---- Specimen --- */
|
452 |
|
|
case 'sequences':
|
453 |
|
|
$dd_elements = array();
|
454 |
|
|
foreach ($value as $sequence) {
|
455 |
|
|
$dd_elements[] = compose_cdm_sequence($sequence);
|
456 |
|
|
}
|
457 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
458 |
0de9cf51
|
Andreas Kohlbecker
|
break;
|
459 |
|
|
|
460 |
0820cdc0
|
Andreas Kohlbecker
|
// TODO preservation
|
461 |
|
|
// TODO exsiccatum
|
462 |
6fbdb943
|
Andreas Kohlbecker
|
|
463 |
|
|
|
464 |
|
|
/* ---- FieldObservation --- */
|
465 |
|
|
case 'gatheringEvent':
|
466 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collector'), $value->actor->titleCache);
|
467 |
7aedf624
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, t('Gathering time'), timePeriodToString($value->timeperiod));
|
468 |
f19f47fa
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description);
|
469 |
5b30a682
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('locality'), $value->locality->text);
|
470 |
6fbdb943
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('country'), $value->country->representation_L10n);
|
471 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingMethod'), $value->collectingMethod);
|
472 |
74ee6b54
|
Andreas Kohlbecker
|
if (isset($value->absoluteElevation)) {
|
473 |
5a079dbf
|
Andreas Kohlbecker
|
$min_max_markup = min_max_measure($value, 'absoluteElevation');
|
474 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('absoluteElevation'), $min_max_markup);
|
475 |
74ee6b54
|
Andreas Kohlbecker
|
}
|
476 |
|
|
if (isset($value->distanceToGround)) {
|
477 |
5a079dbf
|
Andreas Kohlbecker
|
$min_max_markup = min_max_measure($value, 'distanceToGround');
|
478 |
74ee6b54
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToGround'), $min_max_markup);
|
479 |
|
|
}
|
480 |
|
|
if (isset($value->distanceToWaterSurface)) {
|
481 |
5a079dbf
|
Andreas Kohlbecker
|
$min_max_markup = min_max_measure($value, 'distanceToWaterSurface');
|
482 |
74ee6b54
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToWaterSurface'), $min_max_markup);
|
483 |
|
|
}
|
484 |
|
|
|
485 |
2228f46b
|
Andreas Kohlbecker
|
if (isset($value->collectingAreas) && count($value->collectingAreas) > 0) {
|
486 |
6fbdb943
|
Andreas Kohlbecker
|
$area_representations = array();
|
487 |
0820cdc0
|
Andreas Kohlbecker
|
foreach ($value->collectingAreas as $area) {
|
488 |
30845bda
|
Andreas Kohlbecker
|
$area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid));
|
489 |
6fbdb943
|
Andreas Kohlbecker
|
}
|
490 |
30845bda
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'),
|
491 |
|
|
array(
|
492 |
|
|
array('#markup' => implode(', ', $area_representations))
|
493 |
|
|
)
|
494 |
|
|
);
|
495 |
6fbdb943
|
Andreas Kohlbecker
|
}
|
496 |
c08f7882
|
Andreas Kohlbecker
|
if (isset($value->exactLocation) && $value->exactLocation->sexagesimalString) {
|
497 |
6fbdb943
|
Andreas Kohlbecker
|
$sub_dl_groups = array();
|
498 |
f19f47fa
|
Andreas Kohlbecker
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1);
|
499 |
9abfeeb1
|
Andreas Kohlbecker
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('longitude'), round($value->exactLocation->longitude, 7), '°', 2);
|
500 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('latitude'), round($value->exactLocation->latitude, 7), '°', 3);
|
501 |
6fbdb943
|
Andreas Kohlbecker
|
if (isset($value->exactLocation->referenceSystem)) {
|
502 |
|
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('referenceSystem'), $value->exactLocation->referenceSystem->representation_L10n, '', 4);
|
503 |
|
|
}
|
504 |
f19f47fa
|
Andreas Kohlbecker
|
|
505 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'),
|
506 |
0820cdc0
|
Andreas Kohlbecker
|
array(
|
507 |
|
|
array('#markup' => $value->exactLocation->sexagesimalString),
|
508 |
f19f47fa
|
Andreas Kohlbecker
|
array(
|
509 |
0820cdc0
|
Andreas Kohlbecker
|
'#theme' => 'description_list',
|
510 |
|
|
'#groups' => $sub_dl_groups
|
511 |
|
|
),
|
512 |
|
|
)
|
513 |
6fbdb943
|
Andreas Kohlbecker
|
);
|
514 |
f19f47fa
|
Andreas Kohlbecker
|
}
|
515 |
|
|
break;
|
516 |
|
|
|
517 |
f846e7e7
|
Andreas Kohlbecker
|
default:
|
518 |
0820cdc0
|
Andreas Kohlbecker
|
if (is_object($value) || is_array($value)) {
|
519 |
bd814ea2
|
Andreas Kohlbecker
|
drupal_set_message("Unhandled type in compose_cdm_specimen_or_observation() for field " . $field, "warning");
|
520 |
f846e7e7
|
Andreas Kohlbecker
|
} else {
|
521 |
|
|
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
522 |
|
|
}
|
523 |
f19f47fa
|
Andreas Kohlbecker
|
|
524 |
|
|
}
|
525 |
|
|
|
526 |
|
|
}
|
527 |
f846e7e7
|
Andreas Kohlbecker
|
} // END of loop over $derivedUnitFacade fields
|
528 |
|
|
|
529 |
0820cdc0
|
Andreas Kohlbecker
|
// Extensions
|
530 |
|
|
$extensions = cdm_ws_fetch_all(CDM_WS_PORTAL_OCCURRENCE . '/' . $specimenOrObservation->uuid . '/extensions', array($specimenOrObservation->uuid));
|
531 |
|
|
if ($extensions && count($extensions)) {
|
532 |
|
|
|
533 |
|
|
$extensions_render_array = compose_extensions($extensions);
|
534 |
|
|
@_description_list_group_add($groups, t('Extensions') . ':',
|
535 |
|
|
$extensions_render_array,
|
536 |
|
|
'', 100);
|
537 |
|
|
}
|
538 |
|
|
|
539 |
f846e7e7
|
Andreas Kohlbecker
|
|
540 |
eeb98da8
|
Andreas Kohlbecker
|
// template_preprocess_description_list() is not worting by weight so we do it right here
|
541 |
|
|
uasort($groups, 'element_sort');
|
542 |
|
|
|
543 |
f846e7e7
|
Andreas Kohlbecker
|
$occurrence_elements = array(
|
544 |
f19f47fa
|
Andreas Kohlbecker
|
'#title' => $title,
|
545 |
|
|
'#theme' => 'description_list',
|
546 |
6fbdb943
|
Andreas Kohlbecker
|
'#groups' => $groups,
|
547 |
f19f47fa
|
Andreas Kohlbecker
|
'#attributes' => array('class' => html_class_attribute_ref($specimenOrObservation)),
|
548 |
f846e7e7
|
Andreas Kohlbecker
|
);
|
549 |
|
|
$derivatives[] = $occurrence_elements;
|
550 |
c9d996cd
|
Andreas Kohlbecker
|
// all footnotes which has been assembled so far (e.g. from typeDesignations) to here
|
551 |
15b7c460
|
Andreas Kohlbecker
|
$foonote_li_elements = theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'span'));
|
552 |
c9d996cd
|
Andreas Kohlbecker
|
if (!empty($foonote_li_elements)) {
|
553 |
|
|
$derivatives[] = array(
|
554 |
5dd1c644
|
Andreas Kohlbecker
|
'#markup' => '<div class="footnotes">' . $foonote_li_elements . '</div>',
|
555 |
c9d996cd
|
Andreas Kohlbecker
|
);
|
556 |
|
|
}
|
557 |
f846e7e7
|
Andreas Kohlbecker
|
|
558 |
|
|
// --- recurse into originals
|
559 |
0796d2f9
|
Andreas Kohlbecker
|
if (!isset($derivedFrom)) {
|
560 |
|
|
$derivedFrom = cdm_ws_get(
|
561 |
6fbdb943
|
Andreas Kohlbecker
|
CDM_WS_OCCURRENCE,
|
562 |
|
|
array($specimenOrObservation->uuid, 'derivedFrom')
|
563 |
|
|
);
|
564 |
|
|
}
|
565 |
|
|
|
566 |
0796d2f9
|
Andreas Kohlbecker
|
if (isset($derivedFrom)) {
|
567 |
|
|
if (isset($derivedFrom->originals)) {
|
568 |
|
|
$derived_from_label = t('derived');
|
569 |
6644c262
|
Andreas Kohlbecker
|
$preposition = t('from');
|
570 |
0796d2f9
|
Andreas Kohlbecker
|
if(isset($derivedFrom->type)){
|
571 |
0de9cf51
|
Andreas Kohlbecker
|
$derived_from_label = $derivedFrom->type->representation_L10n;
|
572 |
6644c262
|
Andreas Kohlbecker
|
if($derivedFrom->type->uuid == UUID_DERIVATIONEVENTTYPE_ACCESSIONING){
|
573 |
|
|
$preposition = t('of');
|
574 |
|
|
}
|
575 |
0796d2f9
|
Andreas Kohlbecker
|
}
|
576 |
4554da02
|
Andreas Kohlbecker
|
if (count($groups) > 0) {
|
577 |
eeb98da8
|
Andreas Kohlbecker
|
// TODO annotations
|
578 |
|
|
|
579 |
4554da02
|
Andreas Kohlbecker
|
// only display the derived from information when the derivative has any element which will be diplayed
|
580 |
|
|
$derivatives[] = array(
|
581 |
6644c262
|
Andreas Kohlbecker
|
'#markup' => '<div class="derived_from">' . $derived_from_label . ' ' . $preposition . ': </div>',
|
582 |
4554da02
|
Andreas Kohlbecker
|
);
|
583 |
|
|
}
|
584 |
0796d2f9
|
Andreas Kohlbecker
|
foreach ($derivedFrom->originals as $original) {
|
585 |
bd814ea2
|
Andreas Kohlbecker
|
compose_cdm_specimen_or_observation($original, $derivatives);
|
586 |
0796d2f9
|
Andreas Kohlbecker
|
}
|
587 |
f846e7e7
|
Andreas Kohlbecker
|
}
|
588 |
|
|
}
|
589 |
f1f05758
|
Andreas Kohlbecker
|
|
590 |
f846e7e7
|
Andreas Kohlbecker
|
} // END of $specimenOrObservation exists
|
591 |
c70b93c3
|
Andreas Kohlbecker
|
|
592 |
f846e7e7
|
Andreas Kohlbecker
|
return $derivatives;
|
593 |
f1f05758
|
Andreas Kohlbecker
|
}
|
594 |
0de9cf51
|
Andreas Kohlbecker
|
|
595 |
0820cdc0
|
Andreas Kohlbecker
|
|
596 |
0de9cf51
|
Andreas Kohlbecker
|
/**
|
597 |
|
|
* Compose an render array from a CDM Sequence object.
|
598 |
|
|
*
|
599 |
|
|
* compose_hook() implementation
|
600 |
|
|
*
|
601 |
|
|
* @param object $sequence
|
602 |
|
|
* CDM instance of type Sequence
|
603 |
|
|
* @return array
|
604 |
|
|
* A render array containing the fields of the supplied $sequence
|
605 |
5b26b91a
|
Andreas Kohlbecker
|
*
|
606 |
|
|
* @ingroup compose
|
607 |
0de9cf51
|
Andreas Kohlbecker
|
*/
|
608 |
|
|
function compose_cdm_sequence($sequence) {
|
609 |
|
|
|
610 |
eeb98da8
|
Andreas Kohlbecker
|
$exclude_sequence_fields = &drupal_static(__FUNCTION__);
|
611 |
|
|
if (!isset($exclude_sequence_fields)) {
|
612 |
|
|
$exclude_sequence_fields = array(
|
613 |
0de9cf51
|
Andreas Kohlbecker
|
'titleCache',
|
614 |
|
|
'protectedTitleCache',
|
615 |
|
|
'microReference',
|
616 |
|
|
'created',
|
617 |
|
|
'updated',
|
618 |
|
|
'class',
|
619 |
eeb98da8
|
Andreas Kohlbecker
|
);
|
620 |
|
|
}
|
621 |
0de9cf51
|
Andreas Kohlbecker
|
|
622 |
|
|
$groups = array();
|
623 |
|
|
|
624 |
eeb98da8
|
Andreas Kohlbecker
|
// -- retrieve additional data if neesscary
|
625 |
1083804e
|
Andreas Kohlbecker
|
// TODO below call disabled since sequences are not yet supported,
|
626 |
a950f2f9
|
Andreas Kohlbecker
|
// see #3347 (services and REST service controller for molecular classes implemented)
|
627 |
|
|
//
|
628 |
|
|
// cdm_load_annotations($sequence);
|
629 |
eeb98da8
|
Andreas Kohlbecker
|
|
630 |
0de9cf51
|
Andreas Kohlbecker
|
foreach (get_object_vars($sequence) as $field => $value) {
|
631 |
eeb98da8
|
Andreas Kohlbecker
|
|
632 |
|
|
|
633 |
|
|
if (!in_array($field, $exclude_sequence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
|
634 |
0de9cf51
|
Andreas Kohlbecker
|
switch ($field) {
|
635 |
|
|
|
636 |
1083804e
|
Andreas Kohlbecker
|
case 'geneticAccessionNumber';
|
637 |
1b57b3c1
|
Andreas Kohlbecker
|
$dd_elements = array();
|
638 |
|
|
foreach ($value as $accession) {
|
639 |
|
|
if (isset($accession->uri) ){
|
640 |
|
|
$dd_elements[] = l($accession->accessionNumber, $accession->uri);
|
641 |
|
|
} else {
|
642 |
|
|
$dd_elements[] = $accession->accessionNumber;
|
643 |
|
|
}
|
644 |
0de9cf51
|
Andreas Kohlbecker
|
}
|
645 |
1b57b3c1
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 1);
|
646 |
0de9cf51
|
Andreas Kohlbecker
|
break;
|
647 |
|
|
|
648 |
|
|
|
649 |
1083804e
|
Andreas Kohlbecker
|
case 'locus': // 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.
|
650 |
1b57b3c1
|
Andreas Kohlbecker
|
if (isset($value->name)) {
|
651 |
2196c738
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->name, NULL, 3);
|
652 |
1b57b3c1
|
Andreas Kohlbecker
|
}
|
653 |
|
|
if (isset($value->description)) {
|
654 |
2196c738
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field) . ' ' . t('description') , $value->description, NULL, 4);
|
655 |
1b57b3c1
|
Andreas Kohlbecker
|
}
|
656 |
|
|
break;
|
657 |
|
|
|
658 |
1083804e
|
Andreas Kohlbecker
|
case 'consensusSequence':
|
659 |
0de9cf51
|
Andreas Kohlbecker
|
// 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 |
|
|
@_description_list_group_add(
|
662 |
|
|
$groups,
|
663 |
|
|
cdm_occurrence_field_name_label($field),
|
664 |
|
|
array(
|
665 |
|
|
array(
|
666 |
1083804e
|
Andreas Kohlbecker
|
'#markup' => '<div class="sequence-length">' . $value->length . ' ' . t('pb'). '</div><div>' . wordwrap($value->string, 70, '</br>', TRUE) . '</div>',
|
667 |
0de9cf51
|
Andreas Kohlbecker
|
'#wrapper_attributes' => array('class'=>'dna-sequence')
|
668 |
|
|
)
|
669 |
|
|
),
|
670 |
2196c738
|
Andreas Kohlbecker
|
5);
|
671 |
0de9cf51
|
Andreas Kohlbecker
|
break;
|
672 |
|
|
|
673 |
1083804e
|
Andreas Kohlbecker
|
case 'dnaSample': // FIXME 3.3 implement
|
674 |
|
|
break;
|
675 |
|
|
case 'singleReads': // FIXME 3.3 implement
|
676 |
|
|
break;
|
677 |
|
|
case 'contigFile': // FIXME 3.3 implement - Media
|
678 |
|
|
break;
|
679 |
|
|
case 'pherograms': // FIXME 3.3 implement - Media
|
680 |
|
|
break;
|
681 |
|
|
case 'haplotype': // FIXME 3.3 implement
|
682 |
|
|
break;
|
683 |
|
|
case 'dateSequenced': // FIXME 3.3 now in SingelRead
|
684 |
2196c738
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, t('Sequencing date'), timePeriodToString($value), NULL, 6);
|
685 |
0de9cf51
|
Andreas Kohlbecker
|
break;
|
686 |
|
|
|
687 |
|
|
case 'barcode': // boolean
|
688 |
2196c738
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value ? 'Yes': 'No', NULL, 7);
|
689 |
0de9cf51
|
Andreas Kohlbecker
|
break;
|
690 |
1083804e
|
Andreas Kohlbecker
|
case 'barcodeSequencePart': // FIXME 3.3 implement, compose sequence
|
691 |
|
|
break;
|
692 |
0de9cf51
|
Andreas Kohlbecker
|
|
693 |
|
|
case 'citation':
|
694 |
|
|
@_description_list_group_add($groups,
|
695 |
|
|
cdm_occurrence_field_name_label($field),
|
696 |
1b57b3c1
|
Andreas Kohlbecker
|
theme('cdm_reference', array('reference' =>$value, 'microReference' => $sequence->microReference)),
|
697 |
0de9cf51
|
Andreas Kohlbecker
|
NULL,
|
698 |
2196c738
|
Andreas Kohlbecker
|
8
|
699 |
0de9cf51
|
Andreas Kohlbecker
|
);
|
700 |
|
|
break;
|
701 |
|
|
|
702 |
1b57b3c1
|
Andreas Kohlbecker
|
case 'publishedIn':
|
703 |
|
|
@_description_list_group_add($groups,
|
704 |
|
|
cdm_occurrence_field_name_label($field),
|
705 |
|
|
theme('cdm_reference', array('reference'=>$value)),
|
706 |
|
|
NULL,
|
707 |
|
|
7
|
708 |
|
|
);
|
709 |
daef68e9
|
Andreas Kohlbecker
|
break;
|
710 |
eeb98da8
|
Andreas Kohlbecker
|
|
711 |
|
|
case 'rights':
|
712 |
|
|
array_merge($groups, cdm_rights_as_dl_groups($value));
|
713 |
daef68e9
|
Andreas Kohlbecker
|
break;
|
714 |
eeb98da8
|
Andreas Kohlbecker
|
|
715 |
|
|
case 'annotations':
|
716 |
|
|
$dd_elements = array();
|
717 |
|
|
foreach ($value as $annotation) {
|
718 |
|
|
// TODO respect annotation type filter settings
|
719 |
|
|
$dd_elements[] = $annotation->text;
|
720 |
|
|
}
|
721 |
|
|
@_description_list_group_add($groups, t('Notes'), $dd_elements, NULL, 9);
|
722 |
1b57b3c1
|
Andreas Kohlbecker
|
break;
|
723 |
|
|
|
724 |
4ae6064e
|
Andreas Kohlbecker
|
case 'markers':
|
725 |
|
|
$dd_elements = array();
|
726 |
|
|
foreach ($value as $marker) {
|
727 |
|
|
$dd_elements[] = compose_cdm_marker($marker);
|
728 |
|
|
}
|
729 |
|
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 10);
|
730 |
|
|
break;
|
731 |
|
|
|
732 |
0de9cf51
|
Andreas Kohlbecker
|
case 'chromatograms':
|
733 |
1b57b3c1
|
Andreas Kohlbecker
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
|
734 |
0de9cf51
|
Andreas Kohlbecker
|
array(
|
735 |
a9815578
|
Andreas Kohlbecker
|
'#markup'=>compose_cdm_media_gallerie(array('medialist'=>$value)),
|
736 |
2196c738
|
Andreas Kohlbecker
|
),
|
737 |
|
|
NULL,
|
738 |
4ae6064e
|
Andreas Kohlbecker
|
11);
|
739 |
0de9cf51
|
Andreas Kohlbecker
|
break;
|
740 |
|
|
|
741 |
|
|
default:
|
742 |
|
|
if(is_object($value) || is_array($value)){
|
743 |
|
|
drupal_set_message("Unhandled type in compose_cdm_sequence() for field " . $field, "warning");
|
744 |
|
|
} else {
|
745 |
eeb98da8
|
Andreas Kohlbecker
|
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 20);
|
746 |
0de9cf51
|
Andreas Kohlbecker
|
}
|
747 |
|
|
}
|
748 |
|
|
}
|
749 |
|
|
}
|
750 |
|
|
|
751 |
eeb98da8
|
Andreas Kohlbecker
|
// template_preprocess_description_list() is not worting by weight so we do it right here
|
752 |
|
|
uasort($groups, 'element_sort');
|
753 |
|
|
|
754 |
0de9cf51
|
Andreas Kohlbecker
|
$sequence_elements = array(
|
755 |
|
|
'#theme' => 'description_list',
|
756 |
|
|
'#groups' => $groups
|
757 |
|
|
);
|
758 |
|
|
|
759 |
|
|
return $sequence_elements;
|
760 |
|
|
}
|
761 |
1083804e
|
Andreas Kohlbecker
|
|