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