1 |
806baeb2
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
// $Id$
|
3 |
|
|
|
4 |
|
|
/**
|
5 |
|
|
* Copyright (C) 2007 EDIT
|
6 |
|
|
* European Distributed Institute of Taxonomy
|
7 |
|
|
* http://www.e-taxonomy.eu
|
8 |
|
|
*
|
9 |
|
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
10 |
|
|
* See http://www.mozilla.org/MPL/MPL-1.1.html for the full license terms.
|
11 |
|
|
*/
|
12 |
|
|
|
13 |
|
|
function theme_cdm_search_results($pager, $path, $parameters){
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
$showThumbnails = $_SESSION['pageoptions']['searchtaxa']['showThumbnails'];
|
17 |
|
|
if( !is_numeric($showThumbnails)){
|
18 |
|
|
$showThumbnails = 1;
|
19 |
|
|
}
|
20 |
|
|
$setSessionUri = url('cdm_api/setvalue/session').'/pageoptions|searchtaxa|showThumbnails/';
|
21 |
|
|
drupal_add_js('$(document).ready(function() {
|
22 |
|
|
|
23 |
|
|
// init
|
24 |
|
|
if('.$showThumbnails.' == 1){
|
25 |
|
|
$(\'.media_gallery\').show(20);
|
26 |
|
|
} else {
|
27 |
|
|
$(\'.media_gallery\').hide(20);
|
28 |
|
|
}
|
29 |
|
|
// add change hander
|
30 |
|
|
$(\'#showThumbnails\').change(
|
31 |
|
|
function(event){
|
32 |
|
|
var state = 0;
|
33 |
|
|
if($(this).is(\':checked\')){
|
34 |
|
|
$(\'.media_gallery\').show(20);
|
35 |
|
|
state = 1;
|
36 |
|
|
} else {
|
37 |
|
|
$(\'.media_gallery\').hide(20);
|
38 |
|
|
}
|
39 |
|
|
// store state in session variable
|
40 |
|
|
var uri = \''.$setSessionUri.'\' + state;
|
41 |
|
|
jQuery.get(uri);
|
42 |
|
|
});
|
43 |
|
|
});', "inline");
|
44 |
|
|
|
45 |
|
|
drupal_set_title(t('Search Results'));
|
46 |
|
|
|
47 |
|
|
$out = ''; //l('Advanced Search', '/cdm_dataportal/search');
|
48 |
|
|
|
49 |
|
|
$out = '<div class="page_options"><form name="pageoptions"><input id="showThumbnails" type="checkbox" name="showThumbnails" '.($showThumbnails == 1? 'checked="checked"': '').'> '.t('Show Thumbnails').'</form></div>';
|
50 |
|
|
if(count($pager->records) > 0){
|
51 |
|
|
$out .= theme('cdm_list_of_taxa', $pager->records);
|
52 |
|
|
$out .= theme('cdm_pager', $pager, $path, $parameters);
|
53 |
|
|
} else {
|
54 |
|
|
$out = '<h4 class="error">Sorry, no matching entries found.</h4>';
|
55 |
|
|
}
|
56 |
|
|
return $out;
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
/**
|
61 |
|
|
* renders misapplied names and invalid designations.
|
62 |
|
|
* Both relation types are currently treated the same!
|
63 |
|
|
*
|
64 |
|
|
* @param unknown_type $taxonRelationships
|
65 |
|
|
* @return unknown
|
66 |
|
|
*/
|
67 |
|
|
function theme_cdm_taxonRelations($taxonRelationships){
|
68 |
|
|
|
69 |
|
|
if(!$taxonRelationships){
|
70 |
|
|
return;
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
_add_js_cluetip();
|
74 |
|
|
|
75 |
|
|
// aggregate misapplied names having the same fullname:
|
76 |
|
|
$misapplied = array();
|
77 |
|
|
foreach($taxonRelationships as $taxonRelation){
|
78 |
|
|
if(true || $taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR ){
|
79 |
|
|
|
80 |
|
|
$name = $taxonRelation->fromTaxon->name->titleCache;
|
81 |
|
|
$authorteam = $taxonRelation->fromTaxon->sec->authorTeam->titleCache;
|
82 |
|
|
|
83 |
|
|
if(!isset($misapplied[$name])){
|
84 |
|
|
$misapplied[$name]['out'] = '<span class="misapplied">'.theme('cdm_related_taxon',$taxonRelation->fromTaxon, UUID_MISAPPLIED_NAME_FOR, false).'</span>';
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
// collect all authors for this fullname
|
88 |
|
|
if(isset($authorteam)){
|
89 |
|
|
$misapplied[$name]['authorteam'][$authorteam] = ' <span class="sensu cluetip no-print" title="|sensu '.htmlspecialchars(theme('cdm_reference',$taxonRelation->fromTaxon->sec )).'|">sensu '
|
90 |
|
|
.$authorteam.'</span>'
|
91 |
|
|
.'<span class="reference only-print">sensu '.theme('cdm_reference', $taxonRelation->fromTaxon->sec ).'</span>';
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
}
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
// generate output
|
98 |
|
|
$out = '<ul class="misapplied">';
|
99 |
|
|
foreach($misapplied as $misapplied_name){
|
100 |
|
|
$out .= '<li class="synonym">'.$misapplied_name['out'] . " ";
|
101 |
|
|
// sorting authors
|
102 |
|
|
if(isset($misapplied_name['authorteam'])){
|
103 |
|
|
ksort($misapplied_name['authorteam']);
|
104 |
|
|
$out .= join('; ', $misapplied_name['authorteam']);
|
105 |
|
|
}
|
106 |
|
|
$out .= '</li>';
|
107 |
|
|
}
|
108 |
|
|
$out .= '</ul>';
|
109 |
|
|
return $out;
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
function theme_cdm_acceptedFor($renderPath = false){
|
113 |
|
|
$out = '';
|
114 |
|
|
if(!$renderPath){
|
115 |
|
|
$renderPath = 'acceptedFor';
|
116 |
|
|
}
|
117 |
|
|
if(isset($_REQUEST['acceptedFor'])){
|
118 |
|
|
|
119 |
|
|
$synonym = cdm_ws_get(CDM_WS_TAXON, $_REQUEST['acceptedFor']);
|
120 |
|
|
|
121 |
|
|
if($synonym){
|
122 |
|
|
$out .= '<span class="acceptedFor">';
|
123 |
|
|
$out .= t('is accepted for ');
|
124 |
|
|
if(isset($synonym->name->nomenclaturalReference)){
|
125 |
|
|
$referenceUri = url(path_to_reference($synonym->name->nomenclaturalReference->uuid));
|
126 |
|
|
}
|
127 |
|
|
$out .= theme('cdm_taxonName', $synonym->name, null, $referenceUri, $renderPath);
|
128 |
|
|
$out .= '</span>';
|
129 |
|
|
}
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
return $out;
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
function theme_cdm_list_of_taxa($records, $showMedia = false){
|
136 |
|
|
|
137 |
|
|
$renderPath = 'list_of_taxa';
|
138 |
|
|
|
139 |
|
|
$showMedia_taxa = variable_get('cdm_dataportal_findtaxa_show_taxon_thumbnails', 1);
|
140 |
|
|
$showMedia_synonyms = variable_get('cdm_dataportal_findtaxa_show_synonym_thumbnails', 0);
|
141 |
|
|
|
142 |
|
|
// .. well, for sure not as performant as before, but better than nothing.
|
143 |
|
|
$synonym_uuids = array();
|
144 |
|
|
foreach($records as $taxon){
|
145 |
|
|
if($taxon->class != "Taxon"){
|
146 |
|
|
if(!array_key_exists($taxon->uuid, $synonym_uuids)){
|
147 |
|
|
$synonym_uuids[$taxon->uuid] = $taxon->uuid;
|
148 |
|
|
}
|
149 |
|
|
}
|
150 |
|
|
}
|
151 |
|
|
// batch service not jet implemented:
|
152 |
|
|
// $table_of_accepted = cdm_ws_property(CDM_WS_TAXON_ACCEPTED, join(',', $synonym_uuids));
|
153 |
|
|
// thus ...
|
154 |
|
|
$table_of_accepted = array();
|
155 |
|
|
foreach($synonym_uuids as $synUuid){
|
156 |
|
|
$table_of_accepted[$synUuid] = cdm_ws_get(CDM_WS_TAXON_ACCEPTED, $synUuid);
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
$out = '<ul class="cdm_names" style="background-image: none;">';
|
160 |
|
|
|
161 |
|
|
foreach($records as $taxon){
|
162 |
|
|
// its a Taxon
|
163 |
|
|
if($taxon->class == "Taxon"){
|
164 |
|
|
$taxonUri = url(path_to_taxon($taxon->uuid));
|
165 |
|
|
if(isset($taxon->name->nomenclaturalReference)){
|
166 |
|
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
167 |
|
|
}
|
168 |
|
|
$out .= '<li class="Taxon">'.theme('cdm_taxonName', $taxon->name, $taxonUri, $referenceUri, $renderPath);
|
169 |
|
|
if($showMedia_taxa){
|
170 |
|
|
$out .= theme('cdm_taxon_list_thumbnails', $taxon);
|
171 |
|
|
}
|
172 |
|
|
$out .= '</li>';
|
173 |
|
|
} else {
|
174 |
|
|
// its a synonym
|
175 |
|
|
$uuid = $taxon->uuid;
|
176 |
|
|
$acceptedTaxa = $table_of_accepted[$uuid];
|
177 |
|
|
if(count($acceptedTaxa) == 1){
|
178 |
|
|
$acceptedTaxon = $acceptedTaxa[0];
|
179 |
|
|
$taxonUri = uri_to_synonym($taxon->uuid, $acceptedTaxon->uuid, 'synonymy');
|
180 |
|
|
if(isset($acceptedTaxon->name->nomenclaturalReference)){
|
181 |
|
|
$referenceUri = url(path_to_reference($acceptedTaxon->name->nomenclaturalReference->uuid));
|
182 |
|
|
}
|
183 |
|
|
$out .= '<li class="Synonym">'.theme('cdm_taxonName', $taxon->name, $taxonUri, $referenceUri, $renderPath);
|
184 |
|
|
if($showMedia_synonyms){
|
185 |
|
|
$out .= theme('cdm_taxon_list_thumbnails', $acceptedTaxon);
|
186 |
|
|
}
|
187 |
|
|
$out .= '</li>';
|
188 |
|
|
} else {
|
189 |
|
|
//TODO avoid using Ajax in the cdm_dynabox
|
190 |
|
|
//TODO add media
|
191 |
|
|
$out .= theme('cdm_dynabox', theme('cdm_taxonName', $taxon->name, null, null, $renderPath), cdm_compose_url(CDM_WS_TAXON_ACCEPTED, array($taxon->uuid)), 'cdm_list_of_taxa');
|
192 |
|
|
}
|
193 |
|
|
}
|
194 |
|
|
}
|
195 |
|
|
$out .= '</ul>';
|
196 |
|
|
return $out;
|
197 |
|
|
}
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
function theme_cdm_related_taxon($taxon, $reltype_uuid = '', $displayNomRef = true){
|
201 |
|
|
|
202 |
|
|
$relsign = '';
|
203 |
|
|
$name_prefix = '';
|
204 |
|
|
$name_postfix = '';
|
205 |
|
|
switch ($reltype_uuid){
|
206 |
|
|
case UUID_HETEROTYPIC_SYNONYM_OF:
|
207 |
|
|
case UUID_SYNONYM_OF:
|
208 |
|
|
$relsign = '=';
|
209 |
|
|
break;
|
210 |
|
|
case UUID_HOMOTYPIC_SYNONYM_OF:
|
211 |
|
|
$relsign = '≡';
|
212 |
|
|
break;
|
213 |
|
|
case UUID_MISAPPLIED_NAME_FOR:
|
214 |
|
|
case UUID_INVALID_DESIGNATION_FOR:
|
215 |
|
|
$relsign = '–'; // – — −
|
216 |
|
|
$name_prefix = '"';
|
217 |
|
|
$name_postfix = '"';
|
218 |
|
|
break;
|
219 |
|
|
default :
|
220 |
|
|
$relsign = '–';
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
$renderPath = 'related_taxon';
|
224 |
|
|
|
225 |
|
|
//$taxonUri = url(path_to_taxon($taxon->uuid));
|
226 |
|
|
if($taxon->name->nomenclaturalReference){
|
227 |
|
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
228 |
|
|
}
|
229 |
|
|
$nameHtml = theme('cdm_taxonName', $taxon->name, $taxonUri, $referenceUri, $renderPath);
|
230 |
|
|
|
231 |
|
|
$out = '<span class="relation_sign">'.$relsign.'</span>'.$name_prefix . $nameHtml . $name_postfix;
|
232 |
|
|
|
233 |
|
|
return uuid_anchor($taxon->uuid, $out);
|
234 |
|
|
|
235 |
|
|
}
|
236 |
|
|
|
237 |
|
|
|
238 |
|
|
|
239 |
|
|
|
240 |
|
|
/**
|
241 |
|
|
*/
|
242 |
|
|
function theme_cdm_taxon_list_thumbnails($taxon){
|
243 |
|
|
|
244 |
|
|
$gallery_name = $taxon->uuid;
|
245 |
|
|
|
246 |
|
|
$showCaption = variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 1);
|
247 |
|
|
$prefMimeTypeRegex = 'image:.*';
|
248 |
|
|
$prefMediaQuality = '*';
|
249 |
|
|
|
250 |
|
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
|
251 |
|
|
|
252 |
|
|
if($showCaption){
|
253 |
|
|
//$captionElements = array('title', '#uri'=>t('open Image'));
|
254 |
|
|
$captionElements = array('title', 'rights');
|
255 |
|
|
}
|
256 |
|
|
|
257 |
|
|
$galleryLinkUri = path_to_taxon($taxon->uuid).'/images';
|
258 |
|
|
$selectShowMedia = variable_get('cdm_dataportal_show_media', 0);
|
259 |
|
|
if ($selectShowMedia == 0){
|
260 |
|
|
$mediaList = cdm_ws_get(CDM_WS_TAXON_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
|
261 |
|
|
}else{
|
262 |
|
|
$mediaList = cdm_ws_get(CDM_WS_TAXON_SUBTREE_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
|
263 |
|
|
}
|
264 |
|
|
//$mediaList = cdm_ws_get(CDM_WS_TAXONOMY_MEDIA, array(variable_get('cdm_taxonomictree_uuid', false), $taxon ->rank, $taxon->uuid ));
|
265 |
|
|
$out .= theme('cdm_media_gallerie', $mediaList, $gallery_name ,
|
266 |
|
|
$gallery_settings['cdm_dataportal_media_maxextend'],
|
267 |
|
|
$gallery_settings['cdm_dataportal_media_cols'],
|
268 |
|
|
$gallery_settings['cdm_dataportal_media_maxRows'],
|
269 |
|
|
$captionElements, 'LIGHTBOX', null, $galleryLinkUri);
|
270 |
|
|
|
271 |
|
|
return $out;
|
272 |
|
|
}
|
273 |
|
|
|
274 |
|
|
|