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