Revision f19f47fa
Added by Andreas Kohlbecker about 9 years ago
7.x/modules/cdm_dataportal/includes/occurrences.inc | ||
---|---|---|
1 | 1 |
<?php |
2 |
/**
|
|
3 |
* @file
|
|
4 |
* Functions for dealing with CDM entities of type SpeciemenOrOccurrences
|
|
5 |
*
|
|
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>
|
|
2 |
/** |
|
3 |
* @file |
|
4 |
* Functions for dealing with CDM entities of type SpeciemenOrOccurrences |
|
5 |
* |
|
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 | 17 |
*/ |
18 | 18 |
|
19 |
/**
|
|
20 |
* Compose an render array from a CDM DerivedUnitFacade object.
|
|
21 |
*
|
|
22 |
* compose_hook() implementation
|
|
19 |
/** |
|
20 |
* Compose an render array from a CDM DerivedUnitFacade object. |
|
21 |
* |
|
22 |
* compose_hook() implementation |
|
23 | 23 |
* |
24 | 24 |
* @param object $specimenOrObservation |
25 | 25 |
* the CDM instance of type SpecimenOrObservation to compose |
... | ... | |
33 | 33 |
* $specimenOrObservation has been added to |
34 | 34 |
* |
35 | 35 |
* @ingroup compose |
36 |
*/
|
|
36 |
*/ |
|
37 | 37 |
function compose_cdm_specimenOrObservation($specimenOrObservation, &$derivatives = null) { |
38 | 38 |
|
39 | 39 |
$exclude_occurrence_fields = &drupal_static(__FUNCTION__); |
40 | 40 |
if (!isset($exclude_occurrence_fields)) { |
41 | 41 |
$exclude_occurrence_fields = array( |
42 | 42 |
'derivationEvents', |
43 |
'extensions', // TODO ignored for now, how to handle extensions?
|
|
43 |
'extensions', // TODO ignored for now, how to handle extensions? |
|
44 | 44 |
'titleCache', |
45 |
'protectedTitleCache',
|
|
45 |
'protectedTitleCache', |
|
46 | 46 |
'derivedUnitMedia', |
47 | 47 |
'created', |
48 | 48 |
'publish', |
49 | 49 |
'updated', |
50 | 50 |
'class', |
51 | 51 |
'uuid', |
52 |
''
|
|
52 |
'' |
|
53 | 53 |
); |
54 | 54 |
} |
55 | 55 |
|
... | ... | |
65 | 65 |
|
66 | 66 |
$descriptions = null; |
67 | 67 |
$derivedFrom = null; |
68 |
|
|
68 |
|
|
69 | 69 |
if (is_object($specimenOrObservation)) { |
70 | 70 |
|
71 | 71 |
// request again for deeper initialization |
... | ... | |
88 | 88 |
} |
89 | 89 |
} |
90 | 90 |
|
91 |
$title = $type_label . ': '. $specimenOrObservation->titleCache;
|
|
91 |
$title = $type_label . ': '. $specimenOrObservation->titleCache; |
|
92 | 92 |
|
93 | 93 |
$groups = array(); |
94 | 94 |
// --- add initialized fields |
95 |
foreach (get_object_vars($specimenOrObservation) as $field => $value) {
|
|
96 |
if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
|
|
95 |
foreach (get_object_vars($specimenOrObservation) as $field => $value) { |
|
96 |
if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) { |
|
97 | 97 |
switch ($field) { |
98 | 98 |
|
99 | 99 |
/* ---- java.lang.Object --- */ |
... | ... | |
110 | 110 |
} |
111 | 111 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements); |
112 | 112 |
break; |
113 |
|
|
113 |
|
|
114 | 114 |
|
115 | 115 |
case 'annotations': |
116 | 116 |
$dd_elements = array(); |
... | ... | |
143 | 143 |
break; |
144 | 144 |
|
145 | 145 |
case 'determinations': |
146 |
$dd_elements = array();
|
|
146 |
$dd_elements = array(); |
|
147 | 147 |
$glue = ', '; |
148 | 148 |
|
149 | 149 |
foreach ($value as $determinationEvent){ |
... | ... | |
156 | 156 |
while (array_key_exists($weight, $dd_elements)) { |
157 | 157 |
$weight .= '0'; |
158 | 158 |
} |
159 |
$taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
|
|
160 |
$taxon_html = theme('cdm_taxonName',
|
|
161 |
array(
|
|
162 |
'taxonName' => $taxon_name,
|
|
163 |
'nameLink' => path_to_taxon($determinationEvent->taxon->uuid),
|
|
159 |
$taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid); |
|
160 |
$taxon_html = theme('cdm_taxonName', |
|
161 |
array( |
|
162 |
'taxonName' => $taxon_name, |
|
163 |
'nameLink' => path_to_taxon($determinationEvent->taxon->uuid), |
|
164 | 164 |
) |
165 | 165 |
); |
166 | 166 |
$dd_elements[$weight] = $taxon_html; |
... | ... | |
172 | 172 |
} |
173 | 173 |
if (isset($determinationEvent->actor->titleCache)) { |
174 | 174 |
$dd_elements[$weight] .= $glue . $determinationEvent->actor->titleCache; |
175 |
}
|
|
176 |
if (isset($determinationEvent->description)) {
|
|
175 |
} |
|
176 |
if (isset($determinationEvent->description)) { |
|
177 | 177 |
$dd_elements[$weight] .= $glue . $determinationEvent->description; |
178 |
}
|
|
178 |
} |
|
179 | 179 |
} |
180 | 180 |
ksort($dd_elements); |
181 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('determinations'), $dd_elements);
|
|
181 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('determinations'), $dd_elements); |
|
182 | 182 |
break; |
183 | 183 |
|
184 |
case 'descriptions':
|
|
184 |
case 'descriptions': |
|
185 | 185 |
$descriptions = $value; |
186 | 186 |
$occurrence_featureTree = cdm_get_occurrence_featureTree(); |
187 | 187 |
$dd_elements = array(); |
... | ... | |
192 | 192 |
// continue; |
193 | 193 |
// } |
194 | 194 |
$elements_by_feature = _mergeFeatureTreeDescriptions($occurrence_featureTree->root->childNodes, $description->elements); |
195 |
$rendered_description = theme(
|
|
196 |
'cdm_feature_nodes',
|
|
195 |
$rendered_description = theme( |
|
196 |
'cdm_feature_nodes', |
|
197 | 197 |
array('mergedFeatureNodes' => $elements_by_feature) |
198 | 198 |
); |
199 | 199 |
$description_render_elements = array(); |
... | ... | |
202 | 202 |
$dd_elements[] = $description_render_elements; |
203 | 203 |
} |
204 | 204 |
|
205 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
|
205 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements); |
|
206 | 206 |
break; |
207 | 207 |
|
208 | 208 |
case 'sources': |
... | ... | |
213 | 213 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements); |
214 | 214 |
break; |
215 | 215 |
|
216 |
|
|
216 |
|
|
217 | 217 |
/* ---- DerivedUnitBase --- */ |
218 | 218 |
case 'derivedFrom': |
219 | 219 |
$derivedFrom = $value; |
220 |
break;
|
|
220 |
break; |
|
221 | 221 |
|
222 | 222 |
case 'collection': |
223 | 223 |
$sub_dl_groups = array(); |
224 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1);
|
|
224 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1); |
|
225 | 225 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2); |
226 | 226 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3); |
227 | 227 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4); |
... | ... | |
233 | 233 |
array('#markup' => $value->titleCache), |
234 | 234 |
array('#theme' => 'description_list', '#groups' => $sub_dl_groups) |
235 | 235 |
) |
236 |
);
|
|
236 |
); |
|
237 | 237 |
break; |
238 | 238 |
|
239 | 239 |
case 'storedUnder': |
... | ... | |
258 | 258 |
case 'gatheringEvent': |
259 | 259 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collector'), $value->actor->titleCache); |
260 | 260 |
@_description_list_group_add($groups, t('Gathering time'), timePeriodToString($value->timeperiod)); |
261 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description);
|
|
261 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description); |
|
262 | 262 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('locality'), $value->locality->text); |
263 | 263 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('country'), $value->country->representation_L10n); |
264 | 264 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingMethod'), $value->collectingMethod); |
... | ... | |
275 | 275 |
} |
276 | 276 |
if (isset($value->exactLocation)) { |
277 | 277 |
$sub_dl_groups = array(); |
278 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1);
|
|
278 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1); |
|
279 | 279 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('longitude'), round($value->exactLocation->longitude, 7), '°', 2); |
280 | 280 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('latitude'), round($value->exactLocation->latitude, 7), '°', 3); |
281 | 281 |
if (isset($value->exactLocation->referenceSystem)) { |
282 | 282 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('referenceSystem'), $value->exactLocation->referenceSystem->representation_L10n, '', 4); |
283 | 283 |
} |
284 |
|
|
285 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'),
|
|
286 |
array(
|
|
287 |
array('#markup' => $value->exactLocation->sexagesimalString),
|
|
288 |
array(
|
|
289 |
'#theme' => 'description_list',
|
|
290 |
'#groups' => $sub_dl_groups
|
|
291 |
),
|
|
284 |
|
|
285 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'), |
|
286 |
array( |
|
287 |
array('#markup' => $value->exactLocation->sexagesimalString), |
|
288 |
array( |
|
289 |
'#theme' => 'description_list', |
|
290 |
'#groups' => $sub_dl_groups |
|
291 |
), |
|
292 | 292 |
) |
293 | 293 |
); |
294 |
}
|
|
295 |
break;
|
|
296 |
|
|
294 |
} |
|
295 |
break; |
|
296 |
|
|
297 | 297 |
default: |
298 | 298 |
if(is_object($value) || is_array($value)){ |
299 |
drupal_set_message("Unhandled type in compose_cdm_specimenOrObservation() for field " . $field, "warning");
|
|
299 |
drupal_set_message("Unhandled type in compose_cdm_specimenOrObservation() for field " . $field, "warning"); |
|
300 | 300 |
} else { |
301 | 301 |
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value); |
302 | 302 |
} |
303 |
|
|
304 |
}
|
|
305 |
|
|
306 |
}
|
|
303 |
|
|
304 |
} |
|
305 |
|
|
306 |
} |
|
307 | 307 |
} // END of loop over $derivedUnitFacade fields |
308 | 308 |
|
309 | 309 |
|
... | ... | |
311 | 311 |
uasort($groups, 'element_sort'); |
312 | 312 |
|
313 | 313 |
$occurrence_elements = array( |
314 |
'#title' => $title,
|
|
315 |
'#theme' => 'description_list',
|
|
314 |
'#title' => $title, |
|
315 |
'#theme' => 'description_list', |
|
316 | 316 |
'#groups' => $groups, |
317 |
'#attributes' => array('class' => html_class_atttibute_ref($specimenOrObservation)),
|
|
317 |
'#attributes' => array('class' => html_class_attribute_ref($specimenOrObservation)),
|
|
318 | 318 |
); |
319 | 319 |
$derivatives[] = $occurrence_elements; |
320 | 320 |
// all footnotes which has been assembled so far (e.g. from typeDesignations) to here |
Also available in: Unified diff
basic implementation of #4314 (taxon page: display of bibliography in a block on the taxon page)