1
|
<?php
|
2
|
// $Id$
|
3
|
|
4
|
/*
|
5
|
* Copyright (C) 2007 EDIT
|
6
|
* European Distributed Institute of Taxonomy
|
7
|
* http://www.e-taxonomy.eu
|
8
|
*/
|
9
|
|
10
|
function _add_js_thickbox(){
|
11
|
// ---- jQuery ThickBox:
|
12
|
/*
|
13
|
* bug: compat-1.0.js && thickbox.js line 237 .trigger("unload")
|
14
|
* -> event is not triggered because of problems with compat-1.0.js'
|
15
|
* see INSTALL.txt
|
16
|
*
|
17
|
*/
|
18
|
|
19
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/thickbox.js');
|
20
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_thickbox.css');
|
21
|
|
22
|
}
|
23
|
|
24
|
function tagNameParts($name, $numOfNameTokens){
|
25
|
|
26
|
$out = '<span class="name">';
|
27
|
|
28
|
$token = strtok($name, " \n\t");
|
29
|
$i = 0;
|
30
|
$noSpace = true;
|
31
|
while($token != false){
|
32
|
if($i == $numOfNameTokens){
|
33
|
$out .= '</span> <span class="authors">';
|
34
|
$noSpace = true;
|
35
|
}
|
36
|
$out .= ($noSpace?'':' ').$token;
|
37
|
$noSpace = false;
|
38
|
$token = strtok(" \n\t");
|
39
|
$i++;
|
40
|
}
|
41
|
return $out.'</span>';
|
42
|
}
|
43
|
|
44
|
/**
|
45
|
* Renders the full name string (complete scientific name including the author team)
|
46
|
*
|
47
|
* @param NameTO $nameTO the taxon name
|
48
|
*/
|
49
|
function theme_cdm_name($nameTO, $displayNomRef = true){
|
50
|
|
51
|
//TODO: - take the different subtypes of eu.etaxonomy.cdm.model.name.TaxonNameBase into account?
|
52
|
$class = ''; //name'; //($nameTO->secUuid ? 'taxon' : 'taxonname');
|
53
|
|
54
|
|
55
|
if(!$nameTO){
|
56
|
return '<span class="error">Invalid NameTO</span>';
|
57
|
}
|
58
|
|
59
|
$hasNomRef = $nameTO->nomenclaturalReference->fullCitation;
|
60
|
//FIXME class="'.$class.' below seems to be unused
|
61
|
if(!$nameTO->taggedName || !count($nameTO->taggedName)){
|
62
|
$out .= '<span class="'.$class.'">'.$nameTO->fullname.'</span>';
|
63
|
} else {
|
64
|
$skip = $hasNomRef ? array('reference') : array();
|
65
|
$out .= '<span class="'.$class.'">'.cdm_taggedtext2html($nameTO->taggedName, 'span', ' ', $skip).'</span>';
|
66
|
}
|
67
|
|
68
|
if($displayNomRef && $hasNomRef){
|
69
|
$out .= (str_beginsWith($nameTO->nomenclaturalReference->fullCitation, 'in') ? ' ':', ');
|
70
|
$out .= theme('cdm_nomenclaturalReferenceSTO', $nameTO->nomenclaturalReference);
|
71
|
}
|
72
|
|
73
|
if($nameTO->status){
|
74
|
$out .= ', '.cdm_dataportal_t($nameTO->status);
|
75
|
}
|
76
|
|
77
|
return $out;
|
78
|
}
|
79
|
|
80
|
/**
|
81
|
* Renders the given TaxonTO. The $enclosingTag (if not set false)
|
82
|
* will get the following class attributes:
|
83
|
* - name
|
84
|
* - accepted (only if $ptaxon is an accepted name)
|
85
|
*
|
86
|
* @param TaxonTO $taxon
|
87
|
* @param boolean $displayNomRef whether to display the nomenclatural reference
|
88
|
* @param boolean $noSecundum defaults to false. If set to true the secundum part is omitted.
|
89
|
* @param string $enclosingTag defaults to span.
|
90
|
* @return string of XHTML
|
91
|
*
|
92
|
* usage: taxon_detail, theme_ptname_link
|
93
|
*/
|
94
|
function theme_cdm_taxon($taxonTO, $displayNomRef = true, $noSecundum = true, $enclosingTag = 'span'){
|
95
|
|
96
|
|
97
|
$refSecundum = false;
|
98
|
if(!$noSecundum){
|
99
|
$ref_sec = cdm_ws_get(CDM_WS_SIMPLE_REFERENCE ,$taxonTO->secUuid);
|
100
|
if($ref_sec){
|
101
|
$refSecundum = str_trunk($ref_sec->fullcitation, 40, '...');
|
102
|
}
|
103
|
}
|
104
|
|
105
|
$out = theme('cdm_name', $taxonTO->name, $displayNomRef);
|
106
|
|
107
|
$out .=($refSecundum ? ' <span class="secundum">sec. '.$refSecundum.'</span>': '');
|
108
|
|
109
|
//TODO: .$ptaxon->namePhrase;
|
110
|
|
111
|
if($enclosingTag){
|
112
|
$out = '<'.$enclosingTag.' class="taxon'.($taxonTO->accepted === true ? ' accepted':'').'">'.$out.'</'.$enclosingTag.'>';
|
113
|
}
|
114
|
|
115
|
return $out;
|
116
|
}
|
117
|
|
118
|
/**
|
119
|
* Renders a link to the taxon detail page for the given $taxon
|
120
|
*
|
121
|
* @param TaxonTO $taxon
|
122
|
*/
|
123
|
function theme_cdm_taxon_link($taxonTO, $fragment = NULL, $showNomRef = true){
|
124
|
|
125
|
if($fragment){
|
126
|
$fragment = '#'.$fragment;
|
127
|
}
|
128
|
|
129
|
if(!$taxon->accepted) {
|
130
|
$out = 'ERROR: theme_cdm_taxon_link() - taxon is not accepted';
|
131
|
}
|
132
|
|
133
|
$name_html = theme('cdm_taxon', $taxonTO, false, true, '');
|
134
|
$out = l($name_html, cdm_dataportal_taxon_path($taxonTO->uuid), array('class'=>'accepted'), '', $fragment, FALSE, TRUE);
|
135
|
|
136
|
if($showNomRef){
|
137
|
$out .=' '.theme('cdm_nomenclaturalReferenceSTO', $taxonTO->name->nomenclaturalReference);
|
138
|
}
|
139
|
|
140
|
return $out;
|
141
|
}
|
142
|
|
143
|
function theme_cdm_related_taxon($taxonSTO, $reltype_uuid = '', $displayNomRef = true){
|
144
|
|
145
|
$relsign = '';
|
146
|
$name_prefix = '';
|
147
|
$name_postfix = '';
|
148
|
switch ($reltype_uuid){
|
149
|
case UUID_HOMOTYPIC_SYNONYM_OF:
|
150
|
$relsign = '≡';
|
151
|
break;
|
152
|
case UUID_MISAPPLIED_NAME_FOR:
|
153
|
case UUID_INVALID_DESIGNATION_FOR:
|
154
|
$relsign = '–'; // – — −
|
155
|
$name_prefix = '"';
|
156
|
$name_postfix = '"';
|
157
|
break;
|
158
|
default :
|
159
|
$relsign = '=';
|
160
|
}
|
161
|
|
162
|
$out = '<span class="relation_sign">'.$relsign.'</span>'.$name_prefix.theme('cdm_taxon',$taxonSTO, $displayNomRef).$name_postfix;
|
163
|
return $out;
|
164
|
|
165
|
}
|
166
|
|
167
|
|
168
|
function theme_select_secuuid($element) {
|
169
|
|
170
|
$default_uuid = variable_get($element['#varname'], false);
|
171
|
|
172
|
$tree = cdm_taxontree_build_tree(null, false); // get root nodes
|
173
|
$secUuids = array();
|
174
|
foreach($tree as $node){
|
175
|
$secUuids[] = $node->secUuid;
|
176
|
}
|
177
|
cdm_api_secref_cache_prefetch($secUuids);
|
178
|
|
179
|
theme('cdm_taxontree_add_scripts');
|
180
|
drupal_add_js('$(document).ready(function() {$(\'ul.cdm_taxontree\').cdm_taxontree(
|
181
|
{
|
182
|
widget: true,
|
183
|
element_name: \''.$element['#varname'].'\', //
|
184
|
multiselect: '.($element['#multiple']?'true':'false').', //
|
185
|
}
|
186
|
);});', 'inline');
|
187
|
|
188
|
$out = '<div class="cdm_taxontree_widget">';
|
189
|
$out .= '<div class="taxontree">'.theme('cdm_taxontree', $tree, NULL, FALSE, 'cdm_taxontree_node_reference').'</div>';
|
190
|
$out .= $element['#children'].'<div style="clear: both;" /></div>';
|
191
|
|
192
|
return theme(
|
193
|
'form_element',
|
194
|
array(
|
195
|
'#title' => $element['#title'],
|
196
|
'#description' => $element['#description'],
|
197
|
'#id' => $element['#id'],
|
198
|
'#required' => $element['#required'],
|
199
|
'#error' => $element['#error'],
|
200
|
),
|
201
|
$out
|
202
|
);
|
203
|
}
|
204
|
|
205
|
function theme_cdm_dynabox($label, $content_url, $theme, $enclosingtag = 'li'){
|
206
|
$cdm_proxy_url = url('cdm_api/proxy/'.urlencode($content_url)."/$theme");
|
207
|
$out .= '<li class="dynabox"><span class="label">'.$label.'</span>';
|
208
|
$out .= '<ul class="dynabox_content" title="'.$cdm_proxy_url.'"><li><img class="loading" src="'.drupal_get_path('module', 'cdm_dataportal').'/images/loading_circle_grey_16.gif" style="display:none;"></li></ul>';
|
209
|
return $out;
|
210
|
}
|
211
|
|
212
|
function theme_cdm_listof_taxa($taxonSTOs){
|
213
|
|
214
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_dynabox.js');
|
215
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/cdm_dataportal.css');
|
216
|
|
217
|
$out = '<ul class="cdm_names" style="background-image: none;">';
|
218
|
foreach($taxonSTOs as $taxon){
|
219
|
if(_cdm_dataportal_acceptetByCurrentView($taxon)){
|
220
|
$out .= '<li>'.theme('cdm_taxon_link', $taxon).'</li>';
|
221
|
} else {
|
222
|
$out .= theme('cdm_dynabox', theme('cdm_name', $taxon->name), cdm_compose_url(CDM_WS_ACCEPTED_TAXON, array($taxon->uuid)), 'cdm_listof_taxa');
|
223
|
}
|
224
|
}
|
225
|
$out .= '</ul>';
|
226
|
return $out;
|
227
|
}
|
228
|
|
229
|
function theme_cdm_alternative_taxa($taxonSTOs){
|
230
|
$out = '<ul class="cdm_names" style="background-image: none;">';
|
231
|
foreach($taxonSTOs as $taxon){
|
232
|
$out .= '<li>'.theme('cdm_taxon_link', $taxon).'</li>';
|
233
|
}
|
234
|
$out .= '</ul>';
|
235
|
return $out;
|
236
|
}
|
237
|
|
238
|
|
239
|
function theme_cdm_credits(){
|
240
|
$secRef_array = _cdm_dataportal_currentSecRef_array();
|
241
|
return '<span class="sec_reference_citation">'.$secRef_array['citation'].'</span>'
|
242
|
.( $secRef_array['year'] ? ' <span class="year">'.$secRef_array['year'].'</span>' : '')
|
243
|
.( $secRef_array['authorship'] ? '<div class="author">'.$secRef_array['authorship'].'</div>' : '');
|
244
|
}
|
245
|
|
246
|
|
247
|
function theme_cdm_fullreference($referenceTO){
|
248
|
$out = $referenceTO->authorship;
|
249
|
|
250
|
if($referenceTO->fullCitation){
|
251
|
$out .= ' '.$referenceTO->fullCitation;
|
252
|
}
|
253
|
if($referenceTO->microReference){
|
254
|
$out .= ' : '.$referenceTO->microReference;
|
255
|
}
|
256
|
if($referenceTO->year){
|
257
|
$out .= '. '.$referenceTO->year;
|
258
|
}
|
259
|
|
260
|
return $out;
|
261
|
}
|
262
|
|
263
|
/**
|
264
|
* Enter description here...
|
265
|
*
|
266
|
* @param unknown_type $referenceSTO a referenceSTO or referenceTO instance
|
267
|
* @param unknown_type $cssClass
|
268
|
* @param unknown_type $separator
|
269
|
* @param unknown_type $enclosingTag
|
270
|
* @return unknown
|
271
|
*/
|
272
|
function theme_cdm_nomenclaturalReferenceSTO($referenceSTO, $cssClass = '', $separator = '<br />' , $enclosingTag = 'li'){
|
273
|
|
274
|
if(isset($referenceSTO->microReference)){
|
275
|
// well it is a ReferenceTO
|
276
|
$nomref_citation = theme('cdm_fullreference', $referenceSTO);
|
277
|
} else {
|
278
|
// it is ReferenceSTO
|
279
|
$nomref_citation = $referenceSTO->fullCitation;
|
280
|
}
|
281
|
|
282
|
_add_js_thickbox();
|
283
|
|
284
|
// find media representations for inline display and high quality for download
|
285
|
// assuming that there is only one protologue per name only the first media is used
|
286
|
/* TODO currently it is assumed that high quality representations are tiffs
|
287
|
* which is only true for the cichoriea portal
|
288
|
*/
|
289
|
if( count($referenceSTO->media[0]->representations) > 0 ){
|
290
|
foreach($referenceSTO->media[0]->representations as $representation){
|
291
|
$mimeType = $representation->mimeType;
|
292
|
if(($mimeType == 'image/png' || $mimeType == 'image/jpeg' || $mimeType == 'image/gif')
|
293
|
&& count($representation->representationParts) > 0){
|
294
|
$representation_inline = $representation;
|
295
|
} else if($representation->mimeType == 'image/tiff'
|
296
|
&& count($representation->representationParts) > 0){
|
297
|
$representation_highquality = $representation;
|
298
|
}
|
299
|
}
|
300
|
}
|
301
|
|
302
|
if($representation_inline) {
|
303
|
$attributes = array('class'=>'thickbox', 'rel'=>'protologues-'.$referenceSTO->uuid);
|
304
|
for($i = 0; $part = $representation_inline->representationParts[$i]; $i++){
|
305
|
if($i == 0){
|
306
|
$out = l($nomref_citation, $part->uri, $attributes, NULL, NULL, TRUE);
|
307
|
} else {
|
308
|
$out .= l('', $part->uri, $attributes, NULL, NULL, TRUE);
|
309
|
}
|
310
|
}
|
311
|
} else {
|
312
|
// no media available, so display just the citation string
|
313
|
$out = $nomref_citation;
|
314
|
}
|
315
|
return $out;
|
316
|
}
|
317
|
|
318
|
function theme_cdm_taxon_page($taxonTO){
|
319
|
$out = '';
|
320
|
|
321
|
|
322
|
$out .= theme('cdm_homotypicSynonyms', $taxonTO->homotypicSynonyms, $taxonTO->typeDesignations, $taxonTO->nameTypeDesignations);
|
323
|
|
324
|
foreach($taxonTO->heterotypicSynonymyGroups as $hs_group){
|
325
|
$out .= theme('cdm_heterotypicSynonymyGroup', $hs_group);
|
326
|
}
|
327
|
|
328
|
$out .= theme('cdm_taxonRelations', $taxonTO->taxonRelations);
|
329
|
|
330
|
return $out;
|
331
|
}
|
332
|
|
333
|
function theme_cdm_homotypicSynonyms($synonymRelationshipTOs, $specimenTypeDesignations = false, $nameTypeDesignations = false){
|
334
|
|
335
|
$out = '';
|
336
|
$out = '<ul class="homotypicSynonyms">';
|
337
|
|
338
|
foreach($synonymRelationshipTOs as $synonym){
|
339
|
$out .= '<li class="synonym">'.theme('cdm_related_taxon', $synonym->synoynm, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
|
340
|
}
|
341
|
if($specimenTypeDesignations){
|
342
|
$out .= theme('cdm_typedesignations', $specimenTypeDesignations, $nameTypeDesignations);
|
343
|
}
|
344
|
|
345
|
$out .= '</ul>';
|
346
|
return $out;
|
347
|
}
|
348
|
|
349
|
function theme_cdm_heterotypicSynonymyGroup($homotypicGroupTO){
|
350
|
$out = '';
|
351
|
$out = '<ul class="heterotypicSynonymyGroup">';
|
352
|
|
353
|
$is_first_entry = true;
|
354
|
foreach($homotypicGroupTO->taxa as $taxonSTO){
|
355
|
if($is_first_entry){
|
356
|
$is_first_entry = false;
|
357
|
// is first list entry
|
358
|
$out .= '<li class="firstentry synonym">'.theme('cdm_related_taxon',$taxonSTO, UUID_HETEROTYPIC_SYNONYM_OF).'</li>';
|
359
|
} else {
|
360
|
$out .= '<li class="synonym">'.theme('cdm_related_taxon',$taxonSTO, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
|
361
|
}
|
362
|
}
|
363
|
|
364
|
if(isset($homotypicGroupTO->typeDesignations)){
|
365
|
$out .= theme('cdm_typedesignations', $homotypicGroupTO->typeDesignations);
|
366
|
}
|
367
|
|
368
|
$out .= '</ul>';
|
369
|
|
370
|
return $out;
|
371
|
}
|
372
|
|
373
|
/**
|
374
|
* renders misapplied names and invalid designations.
|
375
|
* Both relation types are currently treated the same!
|
376
|
*
|
377
|
* @param unknown_type $TaxonRelationshipTOs
|
378
|
* @return unknown
|
379
|
*/
|
380
|
function theme_cdm_taxonRelations($TaxonRelationshipTOs){
|
381
|
|
382
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.cluetip.js');
|
383
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.dimensions.js');
|
384
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.hoverIntent.js');
|
385
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.cluetip.css');
|
386
|
|
387
|
drupal_add_js ("$(document).ready(function(){
|
388
|
$('.cluetip').css({color: '#0062C2'}).cluetip({
|
389
|
splitTitle: '|',
|
390
|
showTitle: true,
|
391
|
activation: 'hover',
|
392
|
arrows: true,
|
393
|
dropShadow: false,
|
394
|
cluetipClass: 'rounded'
|
395
|
});
|
396
|
});", 'inline');
|
397
|
|
398
|
// aggregate misapplied named having the same fullname:
|
399
|
$misapplied = array();
|
400
|
foreach($TaxonRelationshipTOs as $taxonRelation){
|
401
|
if(true || $taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR ){
|
402
|
|
403
|
$sensu_reference_list = cdm_ws_get(CDM_WS_SIMPLE_REFERENCE ,$taxonRelation->taxon->secUuid);
|
404
|
$sensu_reference = $sensu_reference_list[0];
|
405
|
$name = $taxonRelation->taxon->name->fullname;
|
406
|
if(!isset($misapplied[$name])){
|
407
|
$misapplied[$name] = '<span class="misapplied">'.theme('cdm_related_taxon',$taxonRelation->taxon, UUID_MISAPPLIED_NAME_FOR, false).'</span>';
|
408
|
} else {
|
409
|
$misapplied[$name] .= ';';
|
410
|
}
|
411
|
$misapplied[$name] .= ' <span class="sensu cluetip no-print" title="|sensu '.htmlspecialchars(theme('cdm_fullreference',$sensu_reference )).'|">sensu '
|
412
|
.$sensu_reference->authorship.'</span>'
|
413
|
.'<span class="reference only-print">sensu '.theme('cdm_fullreference',$sensu_reference ).'</span>'
|
414
|
;
|
415
|
}
|
416
|
}
|
417
|
// generate output
|
418
|
$out = '<ul class="misapplied">';
|
419
|
foreach($misapplied as $misapplied_name){
|
420
|
$out .= '<li class="synonym">'.$misapplied_name.'</li>';
|
421
|
}
|
422
|
$out .= '</ul>';
|
423
|
return $out;
|
424
|
}
|
425
|
|
426
|
|
427
|
function theme_cdm_typedesignations($specimenTypeDesignations, $nameTypeDesignations = array()){
|
428
|
|
429
|
$out = '<ul class="typeDesignations">';
|
430
|
|
431
|
foreach($nameTypeDesignations as $ntd){
|
432
|
$out .= '<li class="nameTypeDesignation"><span class="status">'.$ntd->status->text.'</span> - '.theme('cdm_name', $ntd->typeSpecies, false);
|
433
|
$out .= theme('cdm_typedesignations', $ntd->typeSpecimens);
|
434
|
$out .= '</li>';
|
435
|
}
|
436
|
|
437
|
foreach($specimenTypeDesignations as $std){
|
438
|
$out .= '<li class="specimenTypeDesignation">';
|
439
|
$out .= '<span class="status">'.$std->status->text.'</span> - '.$std->typeSpecimen->specimenLabel;
|
440
|
$out .= theme('cdm_specimen', $std->typeSpecimen);
|
441
|
$out .= '</li>';
|
442
|
}
|
443
|
|
444
|
$out .= '</ul>';
|
445
|
|
446
|
return $out;
|
447
|
}
|
448
|
|
449
|
function theme_cdm_specimen($specimen){
|
450
|
|
451
|
// rights,
|
452
|
//$specimen->specimenLabel
|
453
|
//$specimen->uuid
|
454
|
|
455
|
|
456
|
_add_js_thickbox();
|
457
|
|
458
|
$out = '';
|
459
|
if(isset($specimen->media[0])){
|
460
|
|
461
|
$image_url = drupal_get_path('module', 'cdm_dataportal').'/images/external_link.gif';
|
462
|
// thickbox has problems reading the first url parameter, so a litte hack is needed here:
|
463
|
// adding a meningless patameter &tb_hack=1& ....
|
464
|
$out .= ' <a href="#TB_inline?tb_hack=1&width=300&height=330&inlineId=specimen_media_'.$specimen->uuid.'" class="thickbox">'
|
465
|
.'<img src="'.$image_url.'" title="'.t('Show media').'" /></a>';
|
466
|
|
467
|
$out .= '<div id="specimen_media_'.$specimen->uuid.'" class="tickbox_content"><table>';
|
468
|
|
469
|
$media_row = '<tr class="media_data">';
|
470
|
$meta_row = '<tr class="meta_data">';
|
471
|
|
472
|
foreach($specimen->media as $media){
|
473
|
foreach($media->representations as $representation){
|
474
|
|
475
|
//TODO this this is PART 2/2 of a HACK - select preferred representation by mimetype and size
|
476
|
//
|
477
|
if(true || $representation->mimeType == 'image/jpeg'){
|
478
|
foreach($representation->representationParts as $part){
|
479
|
// get media uri conversion rules if the module is installed and activated
|
480
|
if(module_exists('cdm_mediauri')){
|
481
|
$muris = cdm_mediauri_conversion($part->uri);
|
482
|
}
|
483
|
// --- handle media preview rules
|
484
|
if(isset($muris['preview'])){
|
485
|
|
486
|
$a_child = '<img src="'.$muris['preview']['uri'].'" class="preview" '
|
487
|
.($muris['preview']['size_x'] ? 'width="'.$muris['preview']['size_x'].'"' : '')
|
488
|
.($muris['preview']['size_y'] ? 'width="'.$muris['preview']['size_y'].'"' : '')
|
489
|
.'/>';
|
490
|
} else {
|
491
|
$a_child = '<img src="'.$image_url.'" />';
|
492
|
}
|
493
|
|
494
|
// --- handle web application rules
|
495
|
$webapp = '';
|
496
|
if(isset($muris['webapp'])){
|
497
|
if($muris['webapp']['embed_html']){
|
498
|
// embed in same page
|
499
|
$webapp = $muris['webapp']['embed_html'];
|
500
|
} else {
|
501
|
$webapp = l(t('web application'), $muris['webapp']['uri']);
|
502
|
}
|
503
|
}
|
504
|
$media_row .= '<td><a href="'.$part->uri.'" target="'.$part->uuid.'">'.$a_child.'</a></td>';
|
505
|
$meta_row .= '<td><span class="label">'.check_plain($specimen->specimenLabel).'</span><div class="webapp">'.$webapp.'</div></td>';
|
506
|
} // END parts
|
507
|
//TODO this is PART 2/2 of a hack
|
508
|
break;
|
509
|
} // END representations
|
510
|
} // END media
|
511
|
}
|
512
|
$out .= $media_row.'</tr>';
|
513
|
$out .= $meta_row.'</tr>';
|
514
|
|
515
|
$out .= '</div></table>';
|
516
|
}
|
517
|
return $out;
|
518
|
}
|
519
|
|
520
|
|
521
|
function theme_cdm_search_results($resultPageSTO, $path, $parameters){
|
522
|
|
523
|
drupal_set_title(t('Search Results'));
|
524
|
|
525
|
$out = '';
|
526
|
if(count($resultPageSTO->results) > 0){
|
527
|
$out = theme('cdm_listof_taxa', $resultPageSTO->results);
|
528
|
$out .= theme('cdm_pager', $resultPageSTO, $path, $parameters);
|
529
|
} else {
|
530
|
$out = '<h4 calss="error">Sorry, no matching entries found.</h4>';
|
531
|
}
|
532
|
return $out;
|
533
|
}
|
534
|
|
535
|
function theme_cdm_pager(&$resultPageSTO, $path, $parameters, $neighbors = 2){
|
536
|
$out = '';
|
537
|
|
538
|
if ($resultPageSTO->totalPageCount > 1) {
|
539
|
|
540
|
$viewportsize = $neighbors * 2 + 1;
|
541
|
|
542
|
|
543
|
$out .= '<div class="pager">';
|
544
|
if($resultPageSTO->pageNumber > 1){
|
545
|
$out .= theme('cdm_pager_link', t('« first'), 1, $resultPageSTO, $path, $parameters, array('class' => 'pager-first'));
|
546
|
$out .= theme('cdm_pager_link', t('‹ previous'), $resultPageSTO->pageNumber - 1, $resultPageSTO, $path, $parameters, array('class' => 'pager-previous'));
|
547
|
}
|
548
|
|
549
|
if($resultPageSTO->totalPageCount <= $viewportsize || $resultPageSTO->pageNumber <= $neighbors){
|
550
|
$first_number = 1;
|
551
|
} else if($resultPageSTO->pageNumber >= $resultPageSTO->totalPageCount - $neighbors){
|
552
|
$first_number = $resultPageSTO->totalPageCount - $viewportsize;
|
553
|
} else {
|
554
|
$first_number = $resultPageSTO->pageNumber - $neighbors;
|
555
|
}
|
556
|
|
557
|
if($first_number > 1){
|
558
|
$out .= '<div class="pager-list-dots-left">...</div>';
|
559
|
}
|
560
|
for($i = $first_number; $i < $first_number + $viewportsize; $i++){
|
561
|
$out .= theme('cdm_pager_link', $i, $i, $resultPageSTO, $path, $parameters, array('class' => 'pager-first'));
|
562
|
}
|
563
|
if($i < $resultPageSTO->totalPageCount){
|
564
|
$out .= '<div class="pager-list-dots-right">...</div>';
|
565
|
}
|
566
|
|
567
|
if($resultPageSTO->pageNumber < $resultPageSTO->totalPageCount){
|
568
|
$out .= theme('cdm_pager_link', t('next ›'), $resultPageSTO->pageNumber + 1, $resultPageSTO, $path, $parameters, array('class' => 'pager-next'));
|
569
|
$out .= theme('cdm_pager_link', t('last »'), $resultPageSTO->totalPageCount, $resultPageSTO, $path, $parameters, array('class' => 'pager-last'));
|
570
|
}
|
571
|
$out .= '</div>';
|
572
|
|
573
|
return $out;
|
574
|
}
|
575
|
}
|
576
|
|
577
|
function theme_cdm_pager_link($text, $linkPageNumber, &$resultPageSTO, $path, $parameters = array(), $attributes) {
|
578
|
|
579
|
$out = '';
|
580
|
|
581
|
if ($linkPageNumber == $resultPageSTO->pageNumber) {
|
582
|
$out = '<strong>'.$text.'</strong>';
|
583
|
} else {
|
584
|
// <a class="pager-next active" title="Go to page 3" href="/node?page=2">3</a>
|
585
|
$parameters['page'] = $linkPageNumber;
|
586
|
$out = l($text, $path, $attributes, compose_url_prameterstr($parameters));
|
587
|
}
|
588
|
|
589
|
|
590
|
return $out;
|
591
|
}
|