1
|
<?php
|
2
|
/**
|
3
|
* @file
|
4
|
* Taxon Theming functions.
|
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
|
|
16
|
/**
|
17
|
* Returns HTML for misapplied names and invalid designations.
|
18
|
*
|
19
|
* Both relation types are currently treated the same!
|
20
|
*
|
21
|
* @param array $variables
|
22
|
* An associative array containing:
|
23
|
* - taxonRelationships
|
24
|
* - focusedTaxon
|
25
|
*
|
26
|
* @ingroup themeable
|
27
|
*/
|
28
|
function theme_cdm_taxonRelationships($variables) {
|
29
|
$taxonRelationships = $variables['taxonRelationships'];
|
30
|
$focusedTaxon = $variables['focusedTaxon'];
|
31
|
if (!$taxonRelationships) {
|
32
|
return;
|
33
|
}
|
34
|
|
35
|
RenderHints::pushToRenderStack('taxonRelationships');
|
36
|
$footnoteListKey = 'taxonRelationships';
|
37
|
RenderHints::setFootnoteListKey($footnoteListKey);
|
38
|
|
39
|
$misapplied = array();
|
40
|
$joinedAuthorTeams = array();
|
41
|
|
42
|
$taxon_relationship_types = variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT));
|
43
|
|
44
|
// Aggregate misapplied names having the same fullname:
|
45
|
foreach ($taxonRelationships as $taxonRelation) {
|
46
|
|
47
|
if (in_array($taxonRelation->type->uuid, $taxon_relationship_types)) {
|
48
|
|
49
|
if ($taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR) {
|
50
|
|
51
|
$name = $taxonRelation->fromTaxon->name->titleCache;
|
52
|
|
53
|
$authorteam = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $taxonRelation->fromTaxon->sec->uuid);
|
54
|
$authorteam = $authorteam->titleCache;
|
55
|
|
56
|
if (!isset($misapplied[$name])) {
|
57
|
// Render the first name found as representative for all others.
|
58
|
$misapplied[$name]['out'] = cdm_related_taxon($taxonRelation->fromTaxon, UUID_MISAPPLIED_NAME_FOR);
|
59
|
}
|
60
|
else {
|
61
|
// We need to add the anchors for all of the other mispplied names not
|
62
|
// being rendered explicitly.
|
63
|
$misapplied[$name]['out'] = uuid_anchor($taxonRelation->fromTaxon->uuid, $misapplied[$name]['out']);
|
64
|
}
|
65
|
|
66
|
// Collect all authors for this fullname.
|
67
|
if (isset($authorteam)) {
|
68
|
$misapplied[$name]['authorteam'][$authorteam] = '';
|
69
|
$joinedAuthorTeams[$authorteam] = 'sensu ' . theme('cdm_reference', array('reference' => $taxonRelation->fromTaxon->sec));
|
70
|
}
|
71
|
}
|
72
|
else {
|
73
|
// All relationsship types but misapplied_name_for
|
74
|
// invalid_designation_for.
|
75
|
$taxon_relationships_lines[] = cdm_taxonRelationship($taxonRelation, TRUE, _is_invers_taxonRelationship($taxonRelation, $focusedTaxon), TRUE);
|
76
|
}
|
77
|
}
|
78
|
}
|
79
|
|
80
|
// Sort the joinedAuthorTeams and create footnotes and footnotekeys.
|
81
|
ksort($joinedAuthorTeams);
|
82
|
foreach ($joinedAuthorTeams as $authorteam => $sensuCitation) {
|
83
|
$footnoteKey = FootnoteManager::addNewFootnote($footnoteListKey, $sensuCitation);
|
84
|
$joinedAuthorTeams[$authorteam] = '<span class="sensu">sensu ' . $authorteam . theme('cdm_footnote_key', array('footnoteKey' => $footnoteKey)) . '</span>';
|
85
|
}
|
86
|
|
87
|
// ---- Generate output ---- //
|
88
|
|
89
|
$out = '<div class="taxon-relationships">';
|
90
|
if (is_array($misapplied) && count($misapplied) > 0) {
|
91
|
$out .= '<ul class="misapplied">';
|
92
|
foreach ($misapplied as $misapplied_name) {
|
93
|
|
94
|
$out .= '<li class="synonym"><span class="misapplied">' . $misapplied_name['out'] . ' </span>';
|
95
|
|
96
|
if (isset($misapplied_name['authorteam'])) {
|
97
|
// Fill authors with the renderedFootnoteKey and sorting 'em.
|
98
|
foreach ($misapplied_name['authorteam'] as $authorteam => &$renderedFootnoteKey) {
|
99
|
$renderedFootnoteKey = $joinedAuthorTeams[$authorteam];
|
100
|
}
|
101
|
ksort($misapplied_name['authorteam']);
|
102
|
$out .= join('; ', $misapplied_name['authorteam']);
|
103
|
}
|
104
|
$out .= '</li>';
|
105
|
}
|
106
|
$out .= '</ul>';
|
107
|
}
|
108
|
|
109
|
if (isset($taxon_relationships_lines) && is_array($taxon_relationships_lines) && count($taxon_relationships_lines) > 0) {
|
110
|
$out .= '<ul class="taxonRelationships">';
|
111
|
foreach ($taxon_relationships_lines as $taxon_relationship_line) {
|
112
|
$out .= '<li class="synonym">' . $taxon_relationship_line . '</li>';
|
113
|
}
|
114
|
$out .= '</ul>';
|
115
|
}
|
116
|
|
117
|
$footnotes = theme('cdm_footnotes', array('footnoteListKey' => $footnoteListKey, 'enclosingTag' => 'li'));
|
118
|
$footnotes .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $footnoteListKey, 'enclosingTag' => 'li'));
|
119
|
|
120
|
// AK: why splitting footnotes at the sennsu string ??? this is weired and hacky
|
121
|
// TODO remove below dead code
|
122
|
// $tr_footnotes_exploded = explode('sensu', $tr_footnotes);
|
123
|
// $tr_footnotes_aux = '';
|
124
|
// foreach ($tr_footnotes_exploded as $element) {
|
125
|
// $tr_footnotes_aux .= $element;
|
126
|
// }
|
127
|
|
128
|
$out .= '<ul class="footnotes">' . $footnotes . '</ul>';
|
129
|
|
130
|
$out .= '</div>';
|
131
|
|
132
|
RenderHints::popFromRenderStack();
|
133
|
return $out;
|
134
|
}
|
135
|
|
136
|
/**
|
137
|
* @todo Please document this function.
|
138
|
* @see http://drupal.org/node/1354
|
139
|
*/
|
140
|
function theme_cdm_acceptedFor($variables) {
|
141
|
$accepted_for_uuid = $variables['acceptedFor'];
|
142
|
|
143
|
if(!is_uuid($accepted_for_uuid)){
|
144
|
return '';
|
145
|
}
|
146
|
|
147
|
RenderHints::pushToRenderStack('acceptedFor');
|
148
|
$out = '';
|
149
|
|
150
|
$synonym = cdm_ws_get(CDM_WS_PORTAL_TAXON, $accepted_for_uuid);
|
151
|
if ($synonym) {
|
152
|
$out .= '<span class="acceptedFor">';
|
153
|
$out .= t('is accepted for ');
|
154
|
if (isset($synonym->name->nomenclaturalReference)) {
|
155
|
$referenceUri = url(path_to_reference($synonym->name->nomenclaturalReference->uuid));
|
156
|
}
|
157
|
$out .= theme('cdm_taxonName', array(
|
158
|
'taxonName' => $synonym->name,
|
159
|
'nameLink' => NULL,
|
160
|
'refenceLink' => $referenceUri,
|
161
|
));
|
162
|
$out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $synonym));
|
163
|
$out .= '</span>';
|
164
|
}
|
165
|
RenderHints::popFromRenderStack();
|
166
|
return $out;
|
167
|
}
|
168
|
|
169
|
/**
|
170
|
* @todo document this function.
|
171
|
*/
|
172
|
function theme_cdm_list_of_taxa($variables) {
|
173
|
|
174
|
$records = $variables['records'];
|
175
|
$freetextSearchResults = $variables['freetextSearchResults'];
|
176
|
$show_classification = $variables['show_classification'];
|
177
|
|
178
|
RenderHints::pushToRenderStack('list_of_taxa');
|
179
|
|
180
|
$form_name = 'search_gallery';
|
181
|
// $default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
|
182
|
// $gallery_settings = variable_get($form_name, $default_values);
|
183
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
|
184
|
|
185
|
$showMedia_taxa = $gallery_settings['cdm_dataportal_show_taxon_thumbnails'];
|
186
|
$showMedia_synonyms = $gallery_settings['cdm_dataportal_show_synonym_thumbnails'];
|
187
|
// $showMedia_taxa =
|
188
|
// variable_get('cdm_dataportal_findtaxa_show_taxon_thumbnails', 1);
|
189
|
// $showMedia_synonyms =
|
190
|
// variable_get('cdm_dataportal_findtaxa_show_synonym_thumbnails', 0);
|
191
|
$classification_uuid = get_taxonomictree_uuid_selected();
|
192
|
|
193
|
// .. Well, for sure not as performant as before, but better than nothing.
|
194
|
$synonym_uuids = array();
|
195
|
$misappied_uuids = array();
|
196
|
foreach ($records as $taxon) {
|
197
|
if ($taxon->class == "Synonym") {
|
198
|
if (!array_key_exists($taxon->uuid, $synonym_uuids)) {
|
199
|
$synonym_uuids[$taxon->uuid] = $taxon->uuid;
|
200
|
}
|
201
|
}
|
202
|
elseif (!_cdm_dataportal_acceptedByCurrentView($taxon)) {
|
203
|
// Assuming that it is a misappied name, will be further examined below.
|
204
|
$misappied_uuids[$taxon->uuid] = $taxon->uuid;
|
205
|
}
|
206
|
}
|
207
|
|
208
|
// Batch service not jet implemented:
|
209
|
// $table_of_accepted = cdm_ws_property(CDM_WS_PORTAL_TAXON_ACCEPTED,
|
210
|
// join(',', $synonym_uuids));
|
211
|
// thus ...
|
212
|
$table_of_accepted = array();
|
213
|
|
214
|
foreach ($synonym_uuids as $relatedUuid) {
|
215
|
$table_of_accepted[$relatedUuid] = cdm_ws_get(CDM_WS_PORTAL_TAXON_ACCEPTED, array(
|
216
|
$relatedUuid,
|
217
|
$classification_uuid,
|
218
|
));
|
219
|
}
|
220
|
|
221
|
foreach ($misappied_uuids as $relatedUuid) {
|
222
|
$taxonRelations = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, array(
|
223
|
$relatedUuid,
|
224
|
));
|
225
|
foreach ($taxonRelations as $relation) {
|
226
|
if ($relation->type->uuid == UUID_MISAPPLIED_NAME_FOR && _cdm_dataportal_acceptedByCurrentView($relation->toTaxon)) {
|
227
|
$table_of_accepted[$relatedUuid][] = $relation->toTaxon;
|
228
|
}
|
229
|
}
|
230
|
}
|
231
|
|
232
|
$out = '<ul class="cdm_names" style="background-image: none;">';
|
233
|
$itemCnt = -1;
|
234
|
foreach ($records as $taxon) {
|
235
|
$itemCnt++;
|
236
|
if (isset($table_of_accepted[$taxon->uuid])) {
|
237
|
// Its a synonym or misapplied name.
|
238
|
$is_synonym = isset($synonym_uuids[$taxon->uuid]);
|
239
|
$class_name = $is_synonym ? "Synonym" : "misapplied-name";
|
240
|
|
241
|
$acceptedTaxa = $table_of_accepted[$taxon->uuid];
|
242
|
|
243
|
if (count($acceptedTaxa) == 1) {
|
244
|
|
245
|
$acceptedTaxon = $acceptedTaxa[0];
|
246
|
$taxonUri = uri_to_synonym($taxon->uuid, $acceptedTaxon->uuid, 'synonymy');
|
247
|
$referenceUri = '';
|
248
|
if (isset($acceptedTaxon->name->nomenclaturalReference)) {
|
249
|
$referenceUri = url(path_to_reference($acceptedTaxon->name->nomenclaturalReference->uuid));
|
250
|
}
|
251
|
$out .= '<li class="' . $class_name . '">' . theme('cdm_taxonName', array(
|
252
|
'taxonName' => $taxon->name,
|
253
|
'nameLink' => $taxonUri,
|
254
|
'refenceLink' => $referenceUri,
|
255
|
));
|
256
|
if (!$is_synonym) {
|
257
|
$out .= '<span class="sensu"> sensu ' . theme('cdm_reference', array('reference' => $taxon->sec)) . '</span>';
|
258
|
}
|
259
|
if ($show_classification) {
|
260
|
$classifications = get_classifications_for_taxon($taxon);
|
261
|
$classification_titles = array();
|
262
|
foreach ($classifications as $classification) {
|
263
|
if (isset($classification->titleCache)) {
|
264
|
$classification_titles[] = $classification->titleCache;
|
265
|
}
|
266
|
}
|
267
|
$out .= ' : <span class="classifications">' . implode(', ', $classification_titles) . '</span>';
|
268
|
}
|
269
|
$out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
|
270
|
if ($showMedia_synonyms) {
|
271
|
$out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $acceptedTaxon));
|
272
|
}
|
273
|
}
|
274
|
else {
|
275
|
|
276
|
// TODO avoid using Ajax in the cdm_dynabox .... why?
|
277
|
// TODO add media.
|
278
|
$out .= cdm_dynabox(
|
279
|
$taxon->uuid,
|
280
|
// taxon name as label
|
281
|
theme('cdm_taxonName', array(
|
282
|
'taxonName' => $taxon->name,
|
283
|
'nameLink' => NULL,
|
284
|
'refenceLink' => NULL,
|
285
|
'show_annotations' => FALSE,
|
286
|
)),
|
287
|
cdm_compose_url(CDM_WS_PORTAL_TAXON_ACCEPTED, array(
|
288
|
$taxon->uuid,
|
289
|
$classification_uuid,
|
290
|
)), 'cdm_list_of_taxa', 'Click for accepted taxon');
|
291
|
}
|
292
|
}
|
293
|
else {
|
294
|
// Its a Taxon.
|
295
|
$taxonUri = url(path_to_taxon($taxon->uuid));
|
296
|
$referenceUri = '';
|
297
|
if (isset($taxon->name->nomenclaturalReference)) {
|
298
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
299
|
}
|
300
|
$out .= '<li class="Taxon">' . theme('cdm_taxonName', array(
|
301
|
'taxonName' => $taxon->name,
|
302
|
'nameLink' => $taxonUri,
|
303
|
'refenceLink' => $referenceUri,
|
304
|
));
|
305
|
if ($show_classification) {
|
306
|
$classifications = get_classifications_for_taxon($taxon);
|
307
|
$classification_titles = array();
|
308
|
foreach ($classifications as $classification) {
|
309
|
if (isset($classification->titleCache)) {
|
310
|
$classification_titles[] = $classification->titleCache;
|
311
|
}
|
312
|
}
|
313
|
$out .= ' : <span class="classifications">' . implode(', ', $classification_titles) . '</span>';
|
314
|
}
|
315
|
$out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
|
316
|
|
317
|
if ($showMedia_taxa) {
|
318
|
$out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $taxon));
|
319
|
}
|
320
|
}
|
321
|
|
322
|
/*
|
323
|
* the score field will be empty in case of MultiTermQueries like
|
324
|
* WildcardQueries, since these are constant score by default
|
325
|
* since Lucene 2.9
|
326
|
*/
|
327
|
if(isset($freetextSearchResults[$itemCnt]) && $freetextSearchResults[$itemCnt]->score && $freetextSearchResults[$itemCnt]->maxScore){
|
328
|
$percentage = ( $freetextSearchResults[$itemCnt]->score / $freetextSearchResults[$itemCnt]->maxScore ) * 100;
|
329
|
$out .= '<div class="score-bar"><div class="score-bar-indicator" style="width:' . $percentage .'% "></div></div>';
|
330
|
$out .= '<div class="score-bar-value">' . number_format($percentage, 2) .'%</div>';
|
331
|
}
|
332
|
|
333
|
// Render highlighted fragments, these are made available by free text
|
334
|
// searches.
|
335
|
if (isset($freetextSearchResults[$itemCnt]->fieldHighlightMap)) {
|
336
|
$field_fragments = (array) $freetextSearchResults[$itemCnt]->fieldHighlightMap;
|
337
|
if (count($field_fragments) > 0) {
|
338
|
$fragments_out = '';
|
339
|
foreach ($field_fragments as $fieldName => $fragments) {
|
340
|
$fragments_out .= '... <span class="' . $fieldName. '">' . filter_xss(join(" ... ", $fragments), array('b') ) . '</span>';
|
341
|
}
|
342
|
$out .= '<div class="fragment_highlight">' . $fragments_out . ' ...</div>';
|
343
|
}
|
344
|
}
|
345
|
|
346
|
$out .= '</li>';
|
347
|
}
|
348
|
|
349
|
$out .= '</ul>';
|
350
|
RenderHints::popFromRenderStack();
|
351
|
|
352
|
return $out;
|
353
|
}
|
354
|
|
355
|
/**
|
356
|
* Renders a representation of the given taxon relationship.
|
357
|
*
|
358
|
* According name relationships are also being rendered.
|
359
|
*
|
360
|
* @param unknown_type $taxonRelationship
|
361
|
* @param boolean $doLinkTaxon
|
362
|
* whether to create a link to the related taxon
|
363
|
* @param boolean $inverse
|
364
|
* whether the $taxonRelationship should be treaded as invers relation
|
365
|
* @param unknown_type $showSecReference
|
366
|
* whether the secundum reference for the related taxon should be shown
|
367
|
*
|
368
|
* @return void|string
|
369
|
*/
|
370
|
function cdm_taxonRelationship($taxonRelationship, $doLinkTaxon = FALSE, $inverse = FALSE, $showSecReference = FALSE) {
|
371
|
|
372
|
// Validate object.
|
373
|
if (!(isset($taxonRelationship->toTaxon) && isset($taxonRelationship->fromTaxon) && isset($taxonRelationship->type))) {
|
374
|
return;
|
375
|
}
|
376
|
|
377
|
$reltype_uuid = $taxonRelationship->type->uuid;
|
378
|
$taxonRelationType = $taxonRelationship->type;
|
379
|
|
380
|
$reltype_representation = '';
|
381
|
|
382
|
if ($inverse) {
|
383
|
$toTaxon = $taxonRelationship->fromTaxon;
|
384
|
$fromTaxon = $taxonRelationship->toTaxon;
|
385
|
$relsign = $taxonRelationType->inverseRepresentation_L10n_abbreviatedLabel;
|
386
|
$reltype_representation = $taxonRelationType->inverseRepresentation_L10n;
|
387
|
}
|
388
|
else {
|
389
|
$toTaxon = $taxonRelationship->toTaxon;
|
390
|
$fromTaxon = $taxonRelationship->fromTaxon;
|
391
|
$relsign = $taxonRelationType->representation_L10n_abbreviatedLabel;
|
392
|
$reltype_representation = $taxonRelationType->representation_L10n;
|
393
|
}
|
394
|
|
395
|
return cdm_related_taxon($toTaxon, NULL, $relsign, $reltype_representation, $doLinkTaxon, $showSecReference);
|
396
|
}
|
397
|
|
398
|
/**
|
399
|
* Renders a representation of the given taxon relationship.
|
400
|
*
|
401
|
* According name relatinships are also being rendered.
|
402
|
*/
|
403
|
function cdm_related_taxon($taxon, $reltype_uuid = NULL, $relsign = NULL, $reltype_representation = NULL, $doLinkTaxon = FALSE, $showSecReference = FALSE) {
|
404
|
static $relsign_homo = '≡';
|
405
|
static $relsign_hetero = '=';
|
406
|
static $relsign_invalid = '–';
|
407
|
|
408
|
// 'taxonRelationships';
|
409
|
$footnoteListKey = NULL;
|
410
|
|
411
|
$name_prefix = '';
|
412
|
$name_postfix = '';
|
413
|
|
414
|
$skiptags = array();
|
415
|
|
416
|
if (!$relsign) {
|
417
|
|
418
|
$relsign = '';
|
419
|
switch ($reltype_uuid) {
|
420
|
case UUID_HETEROTYPIC_SYNONYM_OF:
|
421
|
case UUID_SYNONYM_OF:
|
422
|
$relsign = $relsign_hetero;
|
423
|
break;
|
424
|
|
425
|
case UUID_HOMOTYPIC_SYNONYM_OF:
|
426
|
$relsign = $relsign_homo;
|
427
|
break;
|
428
|
|
429
|
case UUID_MISAPPLIED_NAME_FOR:
|
430
|
case UUID_INVALID_DESIGNATION_FOR:
|
431
|
$skiptags[] = 'authors';
|
432
|
$relsign = $relsign_invalid;
|
433
|
$name_prefix = '"';
|
434
|
$name_postfix = '"';
|
435
|
break;
|
436
|
|
437
|
default:
|
438
|
$relsign = $relsign_invalid;
|
439
|
}
|
440
|
}
|
441
|
/*
|
442
|
Names with status invalid or nudum are to be displayed with the
|
443
|
$relsign_invalid, these names appear at the end of all names in their
|
444
|
homotypic group (ordered correctly by the java cdm_lib).
|
445
|
*/
|
446
|
if (isset($taxon->name->status) && is_array($taxon->name->status)) {
|
447
|
foreach ($taxon->name->status as $status) {
|
448
|
if ($status->type->uuid == UUID_NOMENCLATURALSTATUS_TYPE_INVALID || $status->type->uuid == UUID_NOMENCLATURALSTATUS_TYPE_NUDUM) {
|
449
|
$relsign = $relsign_invalid;
|
450
|
}
|
451
|
}
|
452
|
}
|
453
|
|
454
|
// Now rendering starts ..
|
455
|
RenderHints::pushToRenderStack('related_taxon');
|
456
|
|
457
|
if (isset($taxon->name->nomenclaturalReference)) {
|
458
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
459
|
}
|
460
|
$taxonUri = '';
|
461
|
if ($doLinkTaxon) {
|
462
|
$taxonUri = url(path_to_taxon($taxon->uuid, "synonymy"));
|
463
|
}
|
464
|
// Printing the taxonName and the handling the special case of annotations.
|
465
|
if (!isset($referenceUri)) {
|
466
|
$referenceUri = FALSE;
|
467
|
}
|
468
|
$out_taxon_part = theme('cdm_taxonName', array(
|
469
|
'taxonName' => $taxon->name,
|
470
|
'nameLink' => $taxonUri,
|
471
|
'refenceLink' => $referenceUri,
|
472
|
'show_annotations' => TRUE,
|
473
|
'is_type_designation' => FALSE,
|
474
|
'skiptags' => $skiptags,
|
475
|
));
|
476
|
$out_taxon_part .= theme('cdm_annotations_as_footnotekeys',
|
477
|
array('cdmBase_list' => array(
|
478
|
$taxon->name,
|
479
|
$taxon,
|
480
|
),
|
481
|
'footnote_list_key' => $footnoteListKey)
|
482
|
);
|
483
|
|
484
|
if ($showSecReference) {
|
485
|
$out_taxon_part .= ' sec. ' . theme('cdm_reference', array('reference' => $taxon->sec));
|
486
|
}
|
487
|
|
488
|
// Later homonym or treated as later homonym AND bloking names.
|
489
|
$from_name_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_FROM_NAMERELATIONS, $taxon->uuid);
|
490
|
$to_name_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
|
491
|
|
492
|
// First the FROM RELS.
|
493
|
// FIXME use UUID below instead of representation_L10n.
|
494
|
if ($from_name_relations) {
|
495
|
foreach ($from_name_relations as $element) {
|
496
|
$elementTitleCache = isset($element->toName->titleCache) ? $element->toName->titleCache : '';
|
497
|
$elementReferenceDateStart = isset($element->toName->nomenclaturalReference->datePublished->start) ? $element->toName->nomenclaturalReference->datePublished->start : '';
|
498
|
$elementUuid = isset($element->toName->uuid) ? $element->toName->uuid : '';
|
499
|
$elementTaxonBasesUuid = isset($element->toName->taxonBases[0]->uuid) ? $element->toName->taxonBases[0]->uuid : '';
|
500
|
$elementDateStart = isset($element->toName->datePublished->start) ? $element->toName->datePublished->start : '';
|
501
|
switch ($element->type->representation_L10n) {
|
502
|
case 'later homonym for':
|
503
|
if (isset($name_relations_html)) {
|
504
|
$name_relations_html .= 'nec ' . l($elementTitleCache . ' ' . substr($elementReferenceDateStart, 0, 4), 'cdm_dataportal/name/' . $elementUuid . '/' . $taxon->uuid . '/' . $elementTaxonBasesUuid);
|
505
|
}
|
506
|
else {
|
507
|
$name_relations_html = 'non ' . l($elementTitleCache . ' ' . substr($elementReferenceDateStart, 0, 4), 'cdm_dataportal/name/' . $elementUuid . '/' . $taxon->uuid . '/' . $elementTaxonBasesUuid) . ' ' . $elementDateStart;
|
508
|
}
|
509
|
break;
|
510
|
case 'treated as later homonym for':
|
511
|
if (isset($name_relations_html)) {
|
512
|
$name_relations_html = 'nec ' . l($elementTitleCache . ' ' . substr($elementReferenceDateStart, 0, 4), 'cdm_dataportal/name/' . $elementUuid);
|
513
|
}
|
514
|
else {
|
515
|
$name_relations_html = 'non ' . l($elementTitleCache . ' ' . substr($elementReferenceDateStart, 0, 4), 'cdm_dataportal/name/' . $elementUuid);
|
516
|
}
|
517
|
break;
|
518
|
}
|
519
|
}
|
520
|
// Second the TO RELS.
|
521
|
if ($to_name_relations) {
|
522
|
foreach ($to_name_relations as $element) {
|
523
|
$elementTitleCache = isset($element->fromName->titleCache) ? $element->fromName->titleCache : '';
|
524
|
$elementReferenceDateStart = isset($element->fromName->nomenclaturalReference->datePublished->start) ? $element->fromName->nomenclaturalReference->datePublished->start : '';
|
525
|
$elementUuid = isset($element->fromName->uuid) ? $element->fromName->uuid : '';
|
526
|
$elementTaxonBasesUuid = isset($element->fromName->taxonBases[0]->uuid) ? $element->fromName->taxonBases[0]->uuid : '';
|
527
|
$elementDateStart = isset($element->fromName->datePublished->start) ? $element->fromName->datePublished->start : '';
|
528
|
switch ($element->type->representation_L10n) {
|
529
|
case 'blocking name for':
|
530
|
if (isset($name_relations_html)) {
|
531
|
$name_relations_html .= 'nec ' . l($elementTitleCache . ' ' . substr($elementReferenceDateStart, 0, 4), 'cdm_dataportal/name/' . $elementUuid . '/' . $taxon->uuid . '/' . $elementTaxonBasesUuid);
|
532
|
}
|
533
|
else {
|
534
|
$name_relations_html = 'non ' . l($elementTitleCache . ' ' . substr($elementReferenceDateStart, 0, 4), 'cdm_dataportal/name/' . $elementUuid . '/' . $taxon->uuid . '/' . $elementTaxonBasesUuid) . ' ' . $elementDateStart;
|
535
|
}
|
536
|
break;
|
537
|
}
|
538
|
}
|
539
|
}
|
540
|
// Rels output.
|
541
|
if (isset($name_relations_html)) {
|
542
|
$name_relations_html = '[' . trim($name_relations_html) . ']';
|
543
|
}
|
544
|
}
|
545
|
// General output.
|
546
|
if (!isset($name_relations_html)) {
|
547
|
$name_relations_html = '';
|
548
|
}
|
549
|
$out = '<span class="relation_sign" title="' . $reltype_representation . '">' . $relsign . '</span>' . $name_prefix . $out_taxon_part . $name_postfix . ' ' . $name_relations_html;
|
550
|
$out = uuid_anchor($taxon->uuid, $out);
|
551
|
|
552
|
RenderHints::popFromRenderStack();
|
553
|
|
554
|
return $out;
|
555
|
}
|
556
|
|
557
|
/**
|
558
|
* @todo document this function.
|
559
|
*/
|
560
|
function theme_cdm_taxon_list_thumbnails($variables) {
|
561
|
|
562
|
$taxon = $variables['taxon'];
|
563
|
$out = '';
|
564
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
|
565
|
$showCaption = $gallery_settings['cdm_dataportal_show_thumbnail_captions'];
|
566
|
if ($showCaption) {
|
567
|
$captionElements = array(
|
568
|
'title',
|
569
|
'rights',
|
570
|
);
|
571
|
} else {
|
572
|
$captionElements = array();
|
573
|
}
|
574
|
|
575
|
$gallery_name = $taxon->uuid;
|
576
|
|
577
|
$mediaList = _load_media_for_taxon($taxon);
|
578
|
|
579
|
$galleryLinkUri = path_to_taxon($taxon->uuid, 'images');
|
580
|
|
581
|
$out .= theme('cdm_media_gallerie', array(
|
582
|
'mediaList' => $mediaList,
|
583
|
'galleryName' => $gallery_name,
|
584
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
585
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
586
|
'maxRows' => $gallery_settings['cdm_dataportal_media_maxRows'],
|
587
|
'captionElements' => $captionElements,
|
588
|
'mediaLinkType' => 'LIGHTBOX',
|
589
|
'alternativeMediaUri' => NULL,
|
590
|
'galleryLinkUri' => $galleryLinkUri,
|
591
|
));
|
592
|
|
593
|
return $out;
|
594
|
}
|