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