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
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.imagetool.min.js');
|
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
|
/**
|
25
|
* TODO if getting fragment from request is possible remove $_REQUEST['highlite'] HACK
|
26
|
* NOT WORKING since fragments are not available to the server
|
27
|
function fragment(){
|
28
|
global $fragment;
|
29
|
if(!$fragment){
|
30
|
$fragment = substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '#'));
|
31
|
}
|
32
|
return $fragment;
|
33
|
}
|
34
|
*/
|
35
|
|
36
|
function uuid_anchor($uuid, $innerHTML){
|
37
|
$highlite = $_REQUEST['highlite'] == $uuid;
|
38
|
return '<a name="'.$uuid.'" ></a><span class="'.($highlite ? 'highlite' : '').'">'.$innerHTML.'</span>';
|
39
|
}
|
40
|
|
41
|
/**
|
42
|
* Enter description here...
|
43
|
*
|
44
|
* @param unknown_type $name
|
45
|
* @param unknown_type $numOfNameTokens
|
46
|
* @return unknown
|
47
|
* @deprecated looks like this is not used anymore
|
48
|
*/
|
49
|
function tagNameParts($name, $numOfNameTokens){
|
50
|
|
51
|
|
52
|
$out = '<span class="name">';
|
53
|
|
54
|
$token = strtok($name, " \n\t");
|
55
|
$i = 0;
|
56
|
$noSpace = true;
|
57
|
while($token != false){
|
58
|
if($i == $numOfNameTokens){
|
59
|
$out .= '</span> <span class="authors">';
|
60
|
$noSpace = true;
|
61
|
}
|
62
|
$out .= ($noSpace?'':' ').$token;
|
63
|
$noSpace = false;
|
64
|
$token = strtok(" \n\t");
|
65
|
$i++;
|
66
|
}
|
67
|
return $out.'</span>';
|
68
|
}
|
69
|
|
70
|
/**
|
71
|
* Almost any cdmObject may be annotated. Therefore we provide a generic way to display
|
72
|
* as well as create or update annotations.
|
73
|
*
|
74
|
* TODO it should be configurable which objects can be annotated as this might differ in dataportals
|
75
|
*
|
76
|
*/
|
77
|
function theme_cdm_annotation($baseTO){
|
78
|
if(!$baseTO->uuid){
|
79
|
return;
|
80
|
}else{
|
81
|
|
82
|
|
83
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_annotations.js');
|
84
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.form.js');
|
85
|
|
86
|
$annotatableUuid = $baseTO->uuid;
|
87
|
$annotationUrl = cdm_compose_url(CDM_WS_ANNOTATIONS, array($annotatableUuid));
|
88
|
|
89
|
$annotationProxyUrl = url('cdm_api/proxy/'. urlencode($annotationUrl).'/cdm_annotation_content');
|
90
|
|
91
|
$out = ' <span class="annotation">';
|
92
|
$out .= '<span class="annotation_toggle" rel="'.$annotationProxyUrl.'">+</span>';
|
93
|
|
94
|
|
95
|
$out .= '<div class="annotation_box"></div>';
|
96
|
$out .= '</span>';
|
97
|
|
98
|
return $out;
|
99
|
|
100
|
}
|
101
|
}
|
102
|
|
103
|
function theme_cdm_annotation_content($AnnotationTO){
|
104
|
|
105
|
|
106
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_annotations.js');
|
107
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.form.js');
|
108
|
|
109
|
|
110
|
$out .= theme('cdm_list_of_annotations', $AnnotationTO->annotationElements);
|
111
|
|
112
|
$annotationUrl = cdm_compose_url(CDM_WS_ANNOTATIONS, array($AnnotationTO->uuid));
|
113
|
$annotationProxyUrl = url('cdm_api/proxy/'. urlencode($annotationUrl).'/cdm_annotation_post');
|
114
|
|
115
|
// TODO users have to be authenticated to the dataportal to be able to write annotations
|
116
|
$out .= '
|
117
|
<div class="annotation_create">
|
118
|
<form action="'.$annotationProxyUrl.'" method="POST">
|
119
|
<textarea name="annotation"></textarea>
|
120
|
<input type="hidden" name="commentator" value="">
|
121
|
<input type="submit" value="'.t('Save annotation').'" />
|
122
|
</form>
|
123
|
</div>
|
124
|
';
|
125
|
|
126
|
return $out;
|
127
|
}
|
128
|
|
129
|
function theme_cdm_list_of_annotations($annotationElements){
|
130
|
|
131
|
$out = '<ul class="annotation_list">';
|
132
|
|
133
|
foreach ($annotationElements as $key => $row){
|
134
|
$created[$key] = $row;
|
135
|
}
|
136
|
array_multisort($created, SORT_ASC, $annotationElements);
|
137
|
|
138
|
foreach ($annotationElements as $annotation){
|
139
|
$out .= '<li>' . $annotation->text . '</li>';
|
140
|
}
|
141
|
|
142
|
$out .= '</ul>';
|
143
|
|
144
|
return $out;
|
145
|
|
146
|
}
|
147
|
|
148
|
/**
|
149
|
* Renders the full name string (complete scientific name including the author team)
|
150
|
*
|
151
|
* @param NameTO $nameTO the taxon name
|
152
|
*/
|
153
|
function theme_cdm_name($nameTO, $displayAuthor = true, $displayNomRef = true, $displayStatus = true, $displayDescription = true){
|
154
|
|
155
|
//TODO: - take the different subtypes of eu.etaxonomy.cdm.model.name.TaxonNameBase into account?
|
156
|
$class = 'fullname'; //name'; //($nameTO->secUuid ? 'taxon' : 'taxonname');
|
157
|
|
158
|
if(!$nameTO){
|
159
|
return '<span class="error">Invalid NameTO</span>';
|
160
|
}
|
161
|
|
162
|
|
163
|
$hasNomRef = $nameTO->nomenclaturalReference->fullCitation;
|
164
|
//FIXME class="'.$class.' below seems to be unused
|
165
|
if(!$nameTO->taggedName || !count($nameTO->taggedName)){
|
166
|
$out .= '<span class="'.$class.'">'.$nameTO->fullname.'</span>';
|
167
|
} else {
|
168
|
$skip = $hasNomRef ? array('reference') : array();
|
169
|
if(!$displayAuthor){
|
170
|
$skip[] = 'authors';
|
171
|
}
|
172
|
$out .= '<span class="'.$class.'">'.cdm_taggedtext2html($nameTO->taggedName, 'span', ' ', $skip).'</span>';
|
173
|
}
|
174
|
|
175
|
if($displayNomRef && $hasNomRef){
|
176
|
$out .= '<span class="reference">';
|
177
|
$out .= theme('cdm_nomenclaturalReferenceSTO', $nameTO->nomenclaturalReference);
|
178
|
$out .= '</span>';
|
179
|
}
|
180
|
|
181
|
if($displayStatus){
|
182
|
if(isset($nameTO->status[0])){
|
183
|
foreach($nameTO->status as $key => $status){
|
184
|
$out .= ', '.$status->term;
|
185
|
}
|
186
|
}
|
187
|
}
|
188
|
|
189
|
if($displayDescription && !empty($nameTO->descriptions)){
|
190
|
foreach($nameTO->descriptions as $DescriptionTO){
|
191
|
if(!empty($DescriptionTO)){
|
192
|
foreach($DescriptionTO->elements as $DescriptionElementSTO){
|
193
|
$out .= theme("cdm_descriptionElement", $DescriptionElementSTO);
|
194
|
}
|
195
|
}
|
196
|
}
|
197
|
}
|
198
|
|
199
|
// testing annotations for taxon names
|
200
|
//$out .= theme('cdm_annotation', $nameTO);
|
201
|
|
202
|
return $out;
|
203
|
}
|
204
|
|
205
|
function theme_cdm_descriptionElement($DescriptionElementSTO){
|
206
|
$out = "";
|
207
|
|
208
|
_add_js_thickbox();
|
209
|
|
210
|
$uuid = $DescriptionElementSTO->uuid;
|
211
|
$type = $DescriptionElementSTO->mediaType;
|
212
|
$medias = $DescriptionElementSTO->media;
|
213
|
|
214
|
foreach($medias as $media){
|
215
|
$prefRepresentations = cdm_preferred_media_representations($media, array('image/gif', 'image/jpeg', 'image/png'), 300, 400);
|
216
|
$representation_inline = array_shift($prefRepresentations);
|
217
|
if($representation_inline) {
|
218
|
$attributes = array('class'=>'thickbox', 'rel'=>'descriptionElement-'.$uuid, 'title'=>$type->term);
|
219
|
for($i = 0; $part = $representation_inline->representationParts[$i]; $i++){
|
220
|
if($i == 0){
|
221
|
$image_url = drupal_get_path('module', 'cdm_dataportal').'/images/'.$type->term.'-media.png';
|
222
|
$media = '<img src="'.$image_url.'" height="14px" alt="'.$type->term.'" />';
|
223
|
$out .= l($media, $part->uri, $attributes, NULL, NULL, TRUE, TRUE);
|
224
|
} else {
|
225
|
$out .= l('', $part->uri, $attributes, NULL, NULL, TRUE);
|
226
|
}
|
227
|
}
|
228
|
} else {
|
229
|
// no media available, so display just the type term
|
230
|
$out .= $type->term;
|
231
|
}
|
232
|
}
|
233
|
return $out;
|
234
|
}
|
235
|
|
236
|
function theme_cdm_descriptionElement_distribution($featureTo){
|
237
|
|
238
|
$out .= '<img src="'.$featureTo->url.'" alt="No distribution map available." />';
|
239
|
return $out;
|
240
|
|
241
|
}
|
242
|
|
243
|
/**
|
244
|
* Renders the given TaxonTO. The $enclosingTag (if not set false)
|
245
|
* will get the following class attributes:
|
246
|
* - name
|
247
|
* - accepted (only if $ptaxon is an accepted name)
|
248
|
*
|
249
|
* @param TaxonTO $taxon
|
250
|
* @param boolean $displayNomRef whether to display the nomenclatural reference
|
251
|
* @param boolean $noSecundum defaults to false. If set to true the secundum part is omitted.
|
252
|
* @param string $enclosingTag defaults to span.
|
253
|
* @return string of XHTML
|
254
|
*
|
255
|
* usage: taxon_detail, theme_ptname_link
|
256
|
*/
|
257
|
function theme_cdm_taxon($taxonTO, $displayNomRef = true, $displayStatus = true, $displayDescription = true, $noSecundum = true, $enclosingTag = 'span', $uuidAnchor = TRUE){
|
258
|
|
259
|
$refSecundum = false;
|
260
|
if(!$noSecundum){
|
261
|
$ref_sec = cdm_ws_get(CDM_WS_SIMPLE_REFERENCE ,$taxonTO->secUuid);
|
262
|
if($ref_sec){
|
263
|
$refSecundum = str_trunk($ref_sec->fullCitation, 40, '...');
|
264
|
}
|
265
|
}
|
266
|
$out = theme('cdm_name', $taxonTO->name, true, $displayNomRef, $displayStatus, $displayDescription);
|
267
|
// append secundum information
|
268
|
$out .=($refSecundum ? ' <span class="secundum">sec. '.$refSecundum.'</span>' : '');
|
269
|
// add uuid anchor
|
270
|
if($uuidAnchor === TRUE){
|
271
|
$out = uuid_anchor($taxonTO->uuid, $out);
|
272
|
}
|
273
|
//TODO: .$ptaxon->namePhrase;
|
274
|
if($enclosingTag){
|
275
|
$out = '<'.$enclosingTag.' class="taxon'.($taxonTO->accepted === true ? ' accepted':'').'">'.$out.'</'.$enclosingTag.'>';
|
276
|
}
|
277
|
|
278
|
return $out;
|
279
|
}
|
280
|
|
281
|
/**
|
282
|
* Renders a link to the taxon detail page for the given $taxon
|
283
|
*
|
284
|
* @param TaxonTO $taxon
|
285
|
*/
|
286
|
function theme_cdm_taxon_link($taxonTO, $fragment = NULL, $showNomRef = true){
|
287
|
|
288
|
if($fragment){
|
289
|
$fragment = '#'.$fragment;
|
290
|
}
|
291
|
|
292
|
if(!$taxon->accepted) {
|
293
|
$out = 'ERROR: theme_cdm_taxon_link() - taxon is not accepted';
|
294
|
}
|
295
|
|
296
|
$name_html = theme('cdm_taxon', $taxonTO, $showNomRef, true, false, true, '', FALSE);
|
297
|
$out = l($name_html, cdm_dataportal_taxon_path($taxonTO->uuid), array('class'=>'accepted'), null, $fragment, FALSE, TRUE);
|
298
|
|
299
|
/*
|
300
|
if($showNomRef){
|
301
|
$out .= theme('cdm_nomenclaturalReferenceSTO', $taxonTO->name->nomenclaturalReference);
|
302
|
}
|
303
|
*/
|
304
|
return $out;
|
305
|
}
|
306
|
|
307
|
/**
|
308
|
* Renders a link to the misapplied taxon detail page for the given $taxon
|
309
|
*
|
310
|
* @param TaxonTO $taxon
|
311
|
*/
|
312
|
function theme_cdm_taxon_misapplied_link($taxonTO, $fragment = NULL, $showNomRef = true){
|
313
|
|
314
|
if($fragment){
|
315
|
$fragment = '#'.$fragment;
|
316
|
}
|
317
|
|
318
|
if(!$taxon->accepted) {
|
319
|
$out = 'ERROR: theme_cdm_taxon_link() - taxon is not accepted';
|
320
|
}
|
321
|
|
322
|
$name_html = theme('cdm_taxon', $taxonTO, $showNomRef, true, false, true, '', FALSE);
|
323
|
$out = '"';
|
324
|
$out .= l($name_html, cdm_dataportal_taxon_path($taxonTO->uuid), array('class'=>'accepted'), null, $fragment, FALSE, TRUE);
|
325
|
$out .= '"';
|
326
|
|
327
|
/*
|
328
|
if($showNomRef){
|
329
|
$out .= theme('cdm_nomenclaturalReferenceSTO', $taxonTO->name->nomenclaturalReference);
|
330
|
}
|
331
|
*/
|
332
|
return $out;
|
333
|
}
|
334
|
|
335
|
|
336
|
/**
|
337
|
* Renders a link to the taxon detail page for the given $taxon
|
338
|
*
|
339
|
* @param TaxonTO $taxon
|
340
|
*/
|
341
|
function theme_cdm_synonym_link($taxonTO, $accepted_uuid, $showNomRef = true, $showStatus = true){
|
342
|
|
343
|
$name_html = theme('cdm_taxon', $taxonTO, $showNomRef, $showStatus, false, true, '', FALSE);
|
344
|
$out = l($name_html, cdm_dataportal_taxon_path($accepted_uuid), array('class'=>'synonym'), 'highlite='.$taxonTO->uuid, $taxonTO->uuid, FALSE, TRUE);
|
345
|
|
346
|
/*
|
347
|
if($showNomRef){
|
348
|
$out .= theme('cdm_nomenclaturalReferenceSTO', $taxonTO->name->nomenclaturalReference);
|
349
|
}
|
350
|
|
351
|
if($showStatus){
|
352
|
$out .= theme('cdm_nomenclaturalStatusSTO', $taxonTO->name->status, "nomStatus");
|
353
|
}*/
|
354
|
|
355
|
return $out;
|
356
|
}
|
357
|
|
358
|
function theme_cdm_related_taxon($taxonSTO, $reltype_uuid = '', $displayNomRef = true){
|
359
|
|
360
|
$relsign = '';
|
361
|
$name_prefix = '';
|
362
|
$name_postfix = '';
|
363
|
switch ($reltype_uuid){
|
364
|
case UUID_HOMOTYPIC_SYNONYM_OF:
|
365
|
$relsign = '≡';
|
366
|
break;
|
367
|
case UUID_MISAPPLIED_NAME_FOR:
|
368
|
case UUID_INVALID_DESIGNATION_FOR:
|
369
|
$relsign = '–'; // – — −
|
370
|
$name_prefix = '"';
|
371
|
$name_postfix = '"';
|
372
|
break;
|
373
|
default :
|
374
|
$relsign = '=';
|
375
|
}
|
376
|
|
377
|
$out = '<span class="relation_sign">'.$relsign.'</span>'.$name_prefix.theme('cdm_taxon',$taxonSTO, $displayNomRef).$name_postfix;
|
378
|
return $out;
|
379
|
|
380
|
}
|
381
|
|
382
|
|
383
|
function theme_select_secuuid($element) {
|
384
|
|
385
|
$default_uuid = variable_get($element['#varname'], false);
|
386
|
|
387
|
$tree = cdm_taxontree_build_tree(null, false); // get root nodes
|
388
|
$secUuids = array();
|
389
|
foreach($tree as $node){
|
390
|
$secUuids[] = $node->secUuid;
|
391
|
}
|
392
|
cdm_api_secref_cache_prefetch($secUuids);
|
393
|
|
394
|
theme('cdm_taxontree_add_scripts');
|
395
|
drupal_add_js('$(document).ready(function() {$(\'ul.cdm_taxontree\').cdm_taxontree(
|
396
|
{
|
397
|
widget: true,
|
398
|
element_name: \''.$element['#varname'].'\', //
|
399
|
multiselect: '.($element['#multiple']?'true':'false').', //
|
400
|
}
|
401
|
);});', 'inline');
|
402
|
|
403
|
$out = '<div class="cdm_taxontree_widget">';
|
404
|
$out .= '<div class="taxontree">'.theme('cdm_taxontree', $tree, NULL, FALSE, 'cdm_taxontree_node_reference').'</div>';
|
405
|
$out .= $element['#children'].'<div style="clear: both;" /></div>';
|
406
|
|
407
|
return theme(
|
408
|
'form_element',
|
409
|
array(
|
410
|
'#title' => $element['#title'],
|
411
|
'#description' => $element['#description'],
|
412
|
'#id' => $element['#id'],
|
413
|
'#required' => $element['#required'],
|
414
|
'#error' => $element['#error'],
|
415
|
),
|
416
|
$out
|
417
|
);
|
418
|
}
|
419
|
|
420
|
function theme_cdm_dynabox($label, $content_url, $theme, $enclosingtag = 'li'){
|
421
|
$cdm_proxy_url = url('cdm_api/proxy/'.urlencode($content_url)."/$theme");
|
422
|
$out .= '<li class="dynabox"><span class="label" alt="'.t('Click for accepted taxon').'">'.$label.'</span>';
|
423
|
$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>';
|
424
|
return $out;
|
425
|
}
|
426
|
|
427
|
function theme_cdm_list_of_taxa($taxonSTOs){
|
428
|
|
429
|
$out = '<ul class="cdm_names" style="background-image: none;">';
|
430
|
|
431
|
$synonym_uuids = array();
|
432
|
foreach($taxonSTOs as $taxon){
|
433
|
if(!_cdm_dataportal_acceptedByCurrentView($taxon)){
|
434
|
if(!array_key_exists($taxon->uuid, $synonym_uuids)){
|
435
|
$synonym_uuids[$taxon->uuid] = $taxon->uuid;
|
436
|
}
|
437
|
}
|
438
|
}
|
439
|
$table_of_accepted = cdm_ws_get(CDM_WS_ACCEPTED_TAXON, join(',', $synonym_uuids));
|
440
|
|
441
|
foreach($taxonSTOs as $taxon){
|
442
|
if(_cdm_dataportal_acceptedByCurrentView($taxon)){
|
443
|
$out .= '<li>'.theme('cdm_taxon_link', $taxon).'</li>';
|
444
|
} else {
|
445
|
$uuid = $taxon->uuid;
|
446
|
$acceptedTaxa = $table_of_accepted->$uuid;
|
447
|
if(count($acceptedTaxa) == 1){
|
448
|
$out .= '<li>'.theme('cdm_synonym_link', $taxon, $acceptedTaxa[0]->uuid ).'</li>';
|
449
|
} else {
|
450
|
//TODO avoid using AHAH ion the cdm_dynabox
|
451
|
$out .= theme('cdm_dynabox', theme('cdm_name', $taxon->name), cdm_compose_url(CDM_WS_ACCEPTED_TAXON, array($taxon->uuid)), 'cdm_list_of_taxa');
|
452
|
}
|
453
|
}
|
454
|
}
|
455
|
$out .= '</ul>';
|
456
|
return $out;
|
457
|
|
458
|
|
459
|
|
460
|
/*
|
461
|
// drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_dynabox.js');
|
462
|
// drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/cdm_dataportal.css');
|
463
|
//
|
464
|
$out = '<ul class="cdm_names" style="background-image: none;">';
|
465
|
|
466
|
//get all accepted for synonyms in one blow to reduce overhead
|
467
|
/* disabled! Not implemented in cdmlib-remote. Did someone forget
|
468
|
* to commit???
|
469
|
$synonym_uuids = array();
|
470
|
foreach($taxonSTOs as $taxon){
|
471
|
if(!_cdm_dataportal_acceptedByCurrentView($taxon)){
|
472
|
if(!array_key_exists($taxon->uuid, $synonym_uuids)){
|
473
|
$synonym_uuids[$taxon->uuid] = $taxon->uuid;
|
474
|
}
|
475
|
}
|
476
|
}
|
477
|
$table_of_accepted = cdm_ws_get(CDM_WS_ACCEPTED_TAXON, join(',', $synonym_uuids));
|
478
|
*/
|
479
|
/*
|
480
|
// get the secUuid of the actual taxonomy.
|
481
|
// TODO: this is not generic and can be applied if there is one taxonomy only
|
482
|
$root = cdm_ws_get(CDM_WS_TREENODE_ROOT);
|
483
|
$rootSecUuid = $root[0]->secUuid;
|
484
|
|
485
|
// RUDE HACK: group misappliedNames by filtering identical names but differing secUuids.
|
486
|
$misapplied = array();
|
487
|
foreach($taxonSTOs as $taxon){
|
488
|
if($taxon->secUuid != $rootSecUuid){
|
489
|
// is misapplied name
|
490
|
if(! in_array($taxon->name->uuid, $misapplied)){
|
491
|
$misapplied[$taxon->name->uuid]['printed'] = 0;
|
492
|
}
|
493
|
}
|
494
|
}
|
495
|
|
496
|
foreach($taxonSTOs as $taxon){
|
497
|
if(_cdm_dataportal_acceptedByCurrentView($taxon)){
|
498
|
|
499
|
if($taxon->secUuid == $rootSecUuid){
|
500
|
$out .= '<li>'.theme('cdm_taxon_link', $taxon).'</li>';
|
501
|
}
|
502
|
else if(! $misapplied[$taxon->name->uuid]['printed']){
|
503
|
// RUDE HACK for misapplied names, paging not correct with this
|
504
|
$out .= '<li>'.theme('cdm_taxon_misapplied_link', $taxon).'</li>';
|
505
|
$misapplied[$taxon->name->uuid]['printed'] = 1;
|
506
|
|
507
|
}
|
508
|
}
|
509
|
else {
|
510
|
// get accepted taxa for this taxon
|
511
|
$table_of_accepted = cdm_ws_get(CDM_WS_ACCEPTED_TAXON, $taxon->uuid);
|
512
|
if(count($table_of_accepted) == 1){
|
513
|
$out .= '<li>'.theme('cdm_synonym_link', $taxon, $table_of_accepted[0]->uuid ).'<li>';
|
514
|
}
|
515
|
else {
|
516
|
//TODO avoid using AHAH ion the cdm_dynabox
|
517
|
$out .= theme('cdm_dynabox', theme('cdm_name', $taxon->name), cdm_compose_url(CDM_WS_ACCEPTED_TAXON, array($taxon->uuid)), 'cdm_list_of_taxa');
|
518
|
}
|
519
|
}
|
520
|
}
|
521
|
$out .= '</ul>';
|
522
|
return $out;*/
|
523
|
}
|
524
|
|
525
|
function theme_cdm_alternative_taxa($taxonSTOs){
|
526
|
$out = '<ul class="cdm_names" style="background-image: none;">';
|
527
|
foreach($taxonSTOs as $taxon){
|
528
|
$out .= '<li>'.theme('cdm_taxon_link', $taxon).'</li>';
|
529
|
}
|
530
|
$out .= '</ul>';
|
531
|
return $out;
|
532
|
}
|
533
|
|
534
|
|
535
|
function theme_cdm_credits(){
|
536
|
$secRef_array = _cdm_dataportal_currentSecRef_array();
|
537
|
return '<span class="sec_reference_citation">'.$secRef_array['citation'].'</span>'
|
538
|
.( $secRef_array['year'] ? ' <span class="year">'.$secRef_array['year'].'</span>' : '')
|
539
|
.( $secRef_array['authorship'] ? '<div class="author">'.$secRef_array['authorship'].'</div>' : '');
|
540
|
}
|
541
|
|
542
|
|
543
|
function theme_cdm_fullreference($referenceTO){
|
544
|
|
545
|
if($referenceTO->fullCitation){
|
546
|
$out = $referenceTO->fullCitation;
|
547
|
}else{
|
548
|
$out = $referenceTO->authorship;
|
549
|
}
|
550
|
if($referenceTO->microReference){
|
551
|
$out .= ' : '.$referenceTO->microReference;
|
552
|
}
|
553
|
/*
|
554
|
if($referenceTO->year){
|
555
|
$out .= '. '.$referenceTO->year;
|
556
|
}
|
557
|
*/
|
558
|
return $out;
|
559
|
}
|
560
|
|
561
|
/**
|
562
|
* Enter description here...
|
563
|
*
|
564
|
* @param unknown_type $referenceSTO a referenceSTO or referenceTO instance
|
565
|
* @param unknown_type $cssClass
|
566
|
* @param unknown_type $separator
|
567
|
* @param unknown_type $enclosingTag
|
568
|
* @return unknown
|
569
|
*/
|
570
|
function theme_cdm_nomenclaturalReferenceSTO($referenceSTO, $cssClass = '', $separator = '<br />' , $enclosingTag = 'li'){
|
571
|
|
572
|
if(isset($referenceSTO->microReference)){
|
573
|
// well it is a ReferenceTO
|
574
|
$nomref_citation = theme('cdm_fullreference', $referenceSTO);
|
575
|
} else {
|
576
|
// it is ReferenceSTO
|
577
|
$nomref_citation = $referenceSTO->fullCitation;
|
578
|
}
|
579
|
|
580
|
_add_js_thickbox();
|
581
|
if(!empty($nomref_citation)){
|
582
|
$nomref_citation = (str_beginsWith($nomref_citation, 'in') ? ' ':', ') . $nomref_citation;
|
583
|
}
|
584
|
// find media representations for inline display and high quality for download
|
585
|
// assuming that there is only one protologue per name only the first media is used
|
586
|
|
587
|
// if( count($referenceSTO->media[0]->representations) > 0 ){
|
588
|
// foreach($referenceSTO->media[0]->representations as $representation){
|
589
|
// $mimeType = $representation->mimeType;
|
590
|
// if(($mimeType == 'image/png' || $mimeType == 'image/jpeg' || $mimeType == 'image/gif')
|
591
|
// && count($representation->representationParts) > 0){
|
592
|
// $representation_inline = $representation;
|
593
|
// } else if($representation->mimeType == 'image/tiff'
|
594
|
// && count($representation->representationParts) > 0){
|
595
|
// $representation_highquality = $representation;
|
596
|
// }
|
597
|
// }
|
598
|
// }
|
599
|
$prefRepresentations = cdm_preferred_media_representations($referenceSTO->media[0], array('image/gif', 'image/jpeg', 'image/png'), 300, 400);
|
600
|
$representation_inline = array_shift($prefRepresentations);
|
601
|
if($representation_inline) {
|
602
|
$attributes = array('class'=>'thickbox', 'rel'=>'protologues-'.$referenceSTO->uuid);
|
603
|
for($i = 0; $part = $representation_inline->representationParts[$i]; $i++){
|
604
|
if($i == 0){
|
605
|
$out = l($nomref_citation, $part->uri, $attributes, NULL, NULL, TRUE);
|
606
|
} else {
|
607
|
$out .= l('', $part->uri, $attributes, NULL, NULL, TRUE);
|
608
|
}
|
609
|
}
|
610
|
} else {
|
611
|
// no media available, so display just the citation string
|
612
|
$out = $nomref_citation;
|
613
|
/*
|
614
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/thickbox.js');
|
615
|
|
616
|
$attributes = array('class'=>'thickbox');
|
617
|
$out .= l("TEST", "http://wp5.e-taxonomy.eu/dataportal/cichorieae/media/protolog/test.pdf", $attributes, NULL, NULL, FALSE);
|
618
|
*/
|
619
|
}
|
620
|
return $out;
|
621
|
}
|
622
|
|
623
|
function theme_cdm_nomenclaturalStatusSTO($statusSTO, $cssClass = '', $enclosingTag = 'span'){
|
624
|
|
625
|
$out = "<$enclosingTag" . ($cssClass == '' ? '' : ' class="' . $cssClass . '"') . ">";
|
626
|
foreach ($statusSTO as $status){
|
627
|
$out .= ", " . $status->term;
|
628
|
}
|
629
|
$out .= "</$enclosingTag>";
|
630
|
|
631
|
return $out;
|
632
|
}
|
633
|
|
634
|
/**
|
635
|
* default title for a taxon page
|
636
|
*
|
637
|
* @param NameTO $nameTO
|
638
|
* @return the formatted taxon name
|
639
|
*/
|
640
|
function theme_cdm_taxon_page_title($nameTO){
|
641
|
return theme('cdm_name', $nameTO);
|
642
|
}
|
643
|
|
644
|
/**
|
645
|
* A wrapper function that groups available information to show by default, when
|
646
|
* a taxon page is requested by the browser.
|
647
|
* Individual themeing has to decide what this page should include (see methods beneath)
|
648
|
* and what information should go into tabs or should not be shown at all.
|
649
|
*
|
650
|
* It is headed by the name of the accepted taxon without author and reference.
|
651
|
*
|
652
|
*/
|
653
|
function theme_cdm_taxon_page_general($taxonTO, $referenceInTitle = false){
|
654
|
$out = '';
|
655
|
|
656
|
$prependedSynonyms = $referenceInTitle ? array() : array($taxonTO);
|
657
|
|
658
|
// start with synonymy
|
659
|
$out .= theme('cdm_taxon_page_synonymy', $taxonTO);
|
660
|
|
661
|
// display name relations
|
662
|
if(variable_get('cdm_dataportal_display_name_relations', 1)){
|
663
|
$out .= theme('cdm_nameRelations', $taxonTO->name->nameRelations);
|
664
|
}
|
665
|
|
666
|
// show the featureTree
|
667
|
$out .= theme('cdm_taxon_page_description', $taxonTO);
|
668
|
|
669
|
return $out;
|
670
|
}
|
671
|
|
672
|
|
673
|
/**
|
674
|
* Outputs all descriptive data and shows the preferred picture of the
|
675
|
* accepted taxon.
|
676
|
*
|
677
|
*/
|
678
|
function theme_cdm_taxon_page_description($taxonTO){
|
679
|
return theme('cdm_featureTree', $taxonTO->featureTree);
|
680
|
}
|
681
|
|
682
|
/**
|
683
|
* Show whole synonymy for the accepted taxon. Synonymy list is headed by the complete scientific name
|
684
|
* of the accepted taxon with nomenclatural reference.
|
685
|
*
|
686
|
*/
|
687
|
function theme_cdm_taxon_page_synonymy($taxonTO){
|
688
|
$out .= theme('cdm_homotypicSynonyms', $taxonTO->homotypicSynonyms, $taxonTO->typeDesignations, $prependedSynonyms);
|
689
|
|
690
|
foreach($taxonTO->heterotypicSynonymyGroups as $HomotypicTaxonGroupSTO){
|
691
|
$out .= theme('cdm_heterotypicSynonymyGroup', $HomotypicTaxonGroupSTO);
|
692
|
}
|
693
|
$out .= theme('cdm_taxonRelations', $taxonTO->taxonRelations);
|
694
|
|
695
|
return $out;
|
696
|
}
|
697
|
|
698
|
/**
|
699
|
* Show the collection of images stored with the accepted taxon
|
700
|
*
|
701
|
*/
|
702
|
function theme_cdm_taxon_page_images(){
|
703
|
|
704
|
}
|
705
|
|
706
|
/**
|
707
|
* Show a reference in it's atomized form
|
708
|
*
|
709
|
*/
|
710
|
function theme_cdm_reference_page(){
|
711
|
|
712
|
}
|
713
|
|
714
|
/**
|
715
|
* Show a synonym page
|
716
|
*
|
717
|
* TODO what should show on this page exactly?
|
718
|
*
|
719
|
*/
|
720
|
function theme_cdm_synonym_page(){
|
721
|
|
722
|
}
|
723
|
|
724
|
|
725
|
|
726
|
|
727
|
function theme_cdm_homotypicSynonyms($synonymRelationshipTOs, $typeDesignations = false, $prependedSynonyms = array()){
|
728
|
|
729
|
$out = '';
|
730
|
$out = '<ul class="homotypicSynonyms">';
|
731
|
|
732
|
if(!empty($prependedSynonyms)){
|
733
|
foreach($prependedSynonyms as $taxon){
|
734
|
$out .= '<li class="synonym">'.theme('cdm_related_taxon', $taxon, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
|
735
|
}
|
736
|
}
|
737
|
|
738
|
foreach($synonymRelationshipTOs as $synonym){
|
739
|
$out .= '<li class="synonym">'.theme('cdm_related_taxon', $synonym->synoynm, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
|
740
|
}
|
741
|
if($typeDesignations){
|
742
|
$out .= theme('cdm_typedesignations', $typeDesignations);
|
743
|
}
|
744
|
|
745
|
$out .= '</ul>';
|
746
|
return $out;
|
747
|
}
|
748
|
|
749
|
function theme_cdm_homotypicSynonymLine($taxonSTO){
|
750
|
$out = '';
|
751
|
$out .= '<li class="synonym">'.theme('cdm_related_taxon', $taxonSTO, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
|
752
|
return $out;
|
753
|
}
|
754
|
|
755
|
function theme_cdm_heterotypicSynonymyGroup($HomotypicTaxonGroupSTO){
|
756
|
$out = '';
|
757
|
$out = '<ul class="heterotypicSynonymyGroup">';
|
758
|
|
759
|
$is_first_entry = true;
|
760
|
foreach($HomotypicTaxonGroupSTO->taxa as $taxonSTO){
|
761
|
if($is_first_entry){
|
762
|
$is_first_entry = false;
|
763
|
// is first list entry
|
764
|
$out .= '<li class="firstentry synonym">'.theme('cdm_related_taxon',$taxonSTO, UUID_HETEROTYPIC_SYNONYM_OF).'</li>';
|
765
|
} else {
|
766
|
$out .= '<li class="synonym">'.theme('cdm_related_taxon',$taxonSTO, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
|
767
|
}
|
768
|
}
|
769
|
|
770
|
if(isset($HomotypicTaxonGroupSTO->typeDesignations)){
|
771
|
$out .= theme('cdm_typedesignations', $HomotypicTaxonGroupSTO->typeDesignations);
|
772
|
}
|
773
|
|
774
|
$out .= '</ul>';
|
775
|
|
776
|
return $out;
|
777
|
}
|
778
|
|
779
|
/**
|
780
|
* renders misapplied names and invalid designations.
|
781
|
* Both relation types are currently treated the same!
|
782
|
*
|
783
|
* @param unknown_type $TaxonRelationshipTOs
|
784
|
* @return unknown
|
785
|
*/
|
786
|
function theme_cdm_taxonRelations($TaxonRelationshipTOs){
|
787
|
|
788
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.cluetip.js');
|
789
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.dimensions.js');
|
790
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.hoverIntent.js');
|
791
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.cluetip.css');
|
792
|
|
793
|
drupal_add_js ("$(document).ready(function(){
|
794
|
$('.cluetip').css({color: '#0062C2'}).cluetip({
|
795
|
splitTitle: '|',
|
796
|
showTitle: true,
|
797
|
activation: 'hover',
|
798
|
arrows: true,
|
799
|
dropShadow: false,
|
800
|
cluetipClass: 'rounded'
|
801
|
});
|
802
|
});", 'inline');
|
803
|
|
804
|
// aggregate misapplied names having the same fullname:
|
805
|
$misapplied = array();
|
806
|
foreach($TaxonRelationshipTOs as $taxonRelation){
|
807
|
if(true || $taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR ){
|
808
|
|
809
|
$sensu_reference_list = cdm_ws_get(CDM_WS_SIMPLE_REFERENCE ,$taxonRelation->taxon->secUuid);
|
810
|
$sensu_reference = $sensu_reference_list[0];
|
811
|
$name = $taxonRelation->taxon->name->fullname;
|
812
|
if(!isset($misapplied[$name])){
|
813
|
$misapplied[$name]['out'] = '<span class="misapplied">'.theme('cdm_related_taxon',$taxonRelation->taxon, UUID_MISAPPLIED_NAME_FOR, false).'</span>';
|
814
|
}
|
815
|
|
816
|
// collect all authors for this fullname
|
817
|
$misapplied[$name]['authorship'][$sensu_reference->authorship] = ' <span class="sensu cluetip no-print" title="|sensu '.htmlspecialchars(theme('cdm_fullreference',$sensu_reference )).'|">sensu '
|
818
|
.$sensu_reference->authorship.'</span>'
|
819
|
.'<span class="reference only-print">sensu '.theme('cdm_fullreference',$sensu_reference ).'</span>'
|
820
|
;
|
821
|
|
822
|
/*
|
823
|
$misapplied[$name]['out'] .= ' <span class="sensu cluetip no-print" title="|sensu '.htmlspecialchars(theme('cdm_fullreference',$sensu_reference )).'|">sensu '
|
824
|
.$sensu_reference->authorship.'</span>'
|
825
|
.'<span class="reference only-print">sensu '.theme('cdm_fullreference',$sensu_reference ).'</span>'
|
826
|
;*/
|
827
|
|
828
|
}
|
829
|
}
|
830
|
|
831
|
// generate output
|
832
|
$out = '<ul class="misapplied">';
|
833
|
foreach($misapplied as $misapplied_name){
|
834
|
$out .= '<li class="synonym">'.$misapplied_name['out'] . " ";
|
835
|
// sorting authors
|
836
|
ksort($misapplied_name['authorship']);
|
837
|
$out .= join('; ', $misapplied_name['authorship']);
|
838
|
$out .= '</li>';
|
839
|
}
|
840
|
$out .= '</ul>';
|
841
|
return $out;
|
842
|
}
|
843
|
|
844
|
function theme_cdm_nameRelations($NameRelationshipTOs){
|
845
|
|
846
|
$out = '';
|
847
|
|
848
|
foreach($NameRelationshipTOs as $NameRelationshipTO){
|
849
|
|
850
|
$block->module = 'cdm_dataportal';
|
851
|
|
852
|
$type = isset($NameRelationshipTO->type->term) ? $NameRelationshipTO->type->term : 'Name relation';
|
853
|
|
854
|
$block->delta = $type;
|
855
|
$block->subject = t(ucfirst($block->delta));
|
856
|
$block->delta = str_replace(' ', '_', strtolower($block->delta));
|
857
|
|
858
|
$block->content = '<ul class="nameRelationships '.$block->delta.'">';
|
859
|
$relatedNames = array();
|
860
|
foreach($NameRelationshipTO->relatedNames as $name){
|
861
|
$relatedNames[] = theme('cdm_name', $name);
|
862
|
}
|
863
|
|
864
|
$block->content .= implode(', ', $relatedNames);
|
865
|
|
866
|
$out .= theme('block', $block);
|
867
|
|
868
|
}
|
869
|
return $out;
|
870
|
}
|
871
|
|
872
|
/**
|
873
|
* FIXME this definitively has to be in another spot. just didn't know where to put it right now.
|
874
|
*
|
875
|
* @param String $a a typeDesignation status
|
876
|
* @param String $b another typeDesignation status
|
877
|
*/
|
878
|
function compare_specimenTypeDesignationStatus($a, $b){
|
879
|
/* this is the desired sort oder as of now:
|
880
|
* Holotype
|
881
|
* Isotype
|
882
|
* Lectotype
|
883
|
* Isolectotype
|
884
|
* Syntype
|
885
|
*
|
886
|
* TODO
|
887
|
* Basically, what we are trying to do is, we define an ordered array of TypeDesignation-states
|
888
|
* and use the index of this array for comparison. This array has to be filled with the cdm-
|
889
|
* TypeDesignation states and the order should be parameterisable inside the dataportal.
|
890
|
*/
|
891
|
// make that static for now
|
892
|
$typeOrder = array('Holotype', 'Isotype', 'Lectotype', 'Isolectotype', 'Syntype');
|
893
|
|
894
|
$aQuantifier = array_search($a->status->text, $typeOrder);
|
895
|
$bQuantifier = array_search($b->status->text, $typeOrder);
|
896
|
|
897
|
if ($aQuantifier == $bQuantifier) {
|
898
|
// sort alphabetically
|
899
|
return ($a->status->text < $b->status->text) ? -1 : 1;
|
900
|
}
|
901
|
return ($aQuantifier < $bQuantifier) ? -1 : 1;
|
902
|
|
903
|
}
|
904
|
|
905
|
function theme_cdm_typedesignations($typeDesignations = array()){
|
906
|
|
907
|
$out = '<ul class="typeDesignations">';
|
908
|
|
909
|
$specimenTypeDesignations = array();
|
910
|
foreach($typeDesignations as $variant => $typeDesignation){
|
911
|
if($typeDesignation->typeSpecimen){
|
912
|
// specimenTypeDesignations should be ordered. collect theme here only
|
913
|
$specimenTypeDesignations[] = $typeDesignation;
|
914
|
}else if($typeDesignation->typeSpeciesName){
|
915
|
$out .= '<li class="nameTypeDesignation"><span class="status">Type</span>: '.theme('cdm_name', $typeDesignation->typeSpeciesName, false);
|
916
|
$out .= '</li>';
|
917
|
}
|
918
|
}
|
919
|
|
920
|
if(!empty($specimenTypeDesignations)){
|
921
|
// sorting might be different for dataportals so this has to be parameterized
|
922
|
usort($specimenTypeDesignations, "compare_specimenTypeDesignationStatus");
|
923
|
foreach($specimenTypeDesignations as $std){
|
924
|
|
925
|
$typeReference = '';
|
926
|
if($std->reference){
|
927
|
$typeReference .= ' (' . t('designated by');
|
928
|
$typeReference .= ' <span class="typeReference cluetip no-print" title="|'. htmlspecialchars(theme('cdm_fullreference',$std->reference )) .'|">';
|
929
|
$typeReference .= $std->reference->authorship . ' ' . $std->reference->year;
|
930
|
$typeReference .= '</span>';
|
931
|
$typeReference .= ')';
|
932
|
$typeReference .= '<span class="reference only-print">(designated by '.theme('cdm_fullreference',$std->reference ).')</span>';
|
933
|
}
|
934
|
|
935
|
$out .= '<li class="specimenTypeDesignation">';
|
936
|
$out .= '<span class="status">'.(($std->status->text) ? $std->status->text : t('Type')) .$typeReference.'</span>: '.$std->typeSpecimen->specimenLabel;
|
937
|
$out .= theme('cdm_specimen', $std->typeSpecimen);
|
938
|
$out .= '</li>';
|
939
|
}
|
940
|
}
|
941
|
|
942
|
$out .= '</ul>';
|
943
|
|
944
|
return $out;
|
945
|
}
|
946
|
|
947
|
function theme_cdm_specimen($specimen){
|
948
|
|
949
|
_add_js_thickbox();
|
950
|
|
951
|
$out = '';
|
952
|
if(isset($specimen->media[0])){
|
953
|
|
954
|
$image_url = drupal_get_path('module', 'cdm_dataportal').'/images/external_link.gif';
|
955
|
// thickbox has problems reading the first url parameter, so a litte hack is needed here:
|
956
|
// adding a meaningless patameter &tb_hack=1& ....
|
957
|
$out .= ' <a href="#TB_inline?tb_hack=1&width=300&height=330&inlineId=specimen_media_'.$specimen->uuid.'" class="thickbox">'
|
958
|
.'<img src="'.$image_url.'" title="'.t('Show media').'" /></a>';
|
959
|
|
960
|
$out .= '<div id="specimen_media_'.$specimen->uuid.'" class="tickbox_content"><table>';
|
961
|
|
962
|
$media_row = '<tr class="media_data">';
|
963
|
$meta_row = '<tr class="meta_data">';
|
964
|
|
965
|
foreach($specimen->media as $media){
|
966
|
foreach($media->representations as $representation){
|
967
|
|
968
|
//TODO this this is PART 2/2 of a HACK - select preferred representation by mimetype and size
|
969
|
//
|
970
|
if(true || $representation->mimeType == 'image/jpeg'){
|
971
|
foreach($representation->representationParts as $part){
|
972
|
// get media uri conversion rules if the module is installed and activated
|
973
|
if(module_exists('cdm_mediauri')){
|
974
|
$muris = cdm_mediauri_conversion($part->uri);
|
975
|
}
|
976
|
// --- handle media preview rules
|
977
|
if(isset($muris['preview'])){
|
978
|
|
979
|
$a_child = '<img src="'.$muris['preview']['uri'].'" class="preview" '
|
980
|
.($muris['preview']['size_x'] ? 'width="'.$muris['preview']['size_x'].'"' : '')
|
981
|
.($muris['preview']['size_y'] ? 'width="'.$muris['preview']['size_y'].'"' : '')
|
982
|
.'/>';
|
983
|
} else {
|
984
|
$a_child = '<img src="'.$part->uri.'" />';
|
985
|
}
|
986
|
|
987
|
// --- handle web application rules
|
988
|
$webapp = '';
|
989
|
if(isset($muris['webapp'])){
|
990
|
if($muris['webapp']['embed_html']){
|
991
|
// embed in same page
|
992
|
$webapp = $muris['webapp']['embed_html'];
|
993
|
} else {
|
994
|
$webapp = l(t('web application'), $muris['webapp']['uri']);
|
995
|
}
|
996
|
}
|
997
|
$media_row .= '<td><a href="'.$part->uri.'" target="'.$part->uuid.'">'.$a_child.'</a></td>';
|
998
|
$meta_row .= '<td><span class="label">'.check_plain($specimen->specimenLabel).'</span><div class="webapp">'.$webapp.'</div></td>';
|
999
|
} // END parts
|
1000
|
//TODO this is PART 2/2 of a hack
|
1001
|
break;
|
1002
|
} // END representations
|
1003
|
} // END media
|
1004
|
}
|
1005
|
$out .= $media_row.'</tr>';
|
1006
|
$out .= $meta_row.'</tr>';
|
1007
|
|
1008
|
$out .= '</div></table>';
|
1009
|
}
|
1010
|
return $out;
|
1011
|
}
|
1012
|
|
1013
|
|
1014
|
|
1015
|
|
1016
|
function theme_cdm_featureTree($featureTree){
|
1017
|
/*
|
1018
|
* ->featureTree{
|
1019
|
* ->descriptions{
|
1020
|
* ->DescriptionTo{
|
1021
|
* ->label
|
1022
|
* ->sources{}
|
1023
|
* ->elements{}
|
1024
|
* ->features{
|
1025
|
* ->FeatureTo{
|
1026
|
* ->descriptionElements{
|
1027
|
* ->DescriptionElementSTO{}
|
1028
|
* ->uuid
|
1029
|
* ->type
|
1030
|
*/
|
1031
|
|
1032
|
$descriptions = $featureTree->descriptions;
|
1033
|
foreach($descriptions as $descriptionTO){
|
1034
|
$features = $descriptionTO->features;
|
1035
|
foreach($features as $featureTo){
|
1036
|
$descriptionElements = $featureTo->descriptionElements;
|
1037
|
// process $descriptionElements with content only
|
1038
|
if(is_array($descriptionElements) && count($descriptionElements) > 0){
|
1039
|
$block->module = 'cdm_dataportal';
|
1040
|
|
1041
|
$feature = isset($featureTo->feature->term) ? $featureTo->feature->term : 'Feature';
|
1042
|
|
1043
|
|
1044
|
|
1045
|
$block->delta = $feature;
|
1046
|
$block->subject = t(ucfirst($block->delta));
|
1047
|
$block->delta = generalizeString($block->delta);
|
1048
|
|
1049
|
$block->content = theme('cdm_descriptionElements', $descriptionElements, $block->delta);
|
1050
|
// set anchor
|
1051
|
$out .= '<a name="'.$block->delta.'"></a>';
|
1052
|
$out .= theme('block', $block);
|
1053
|
|
1054
|
|
1055
|
|
1056
|
// TODO HACK
|
1057
|
if($feature == 'Distribution'){
|
1058
|
// ob_start();
|
1059
|
// echo "<pre>";
|
1060
|
// print_r($featureTo->url);
|
1061
|
// echo "</pre>";
|
1062
|
// ob_flush();
|
1063
|
$out .= theme('cdm_descriptionElement_distribution', $featureTo);
|
1064
|
}
|
1065
|
|
1066
|
}
|
1067
|
}
|
1068
|
}
|
1069
|
return $out;
|
1070
|
}
|
1071
|
|
1072
|
function theme_cdm_featureTreeToc($featureTree){
|
1073
|
|
1074
|
|
1075
|
$out = '<div class="featureTOC">';
|
1076
|
$out .= '<h2>' . t('Table of Content') .'</h2>';
|
1077
|
$out .= '<ul>';
|
1078
|
|
1079
|
$descriptions = $featureTree->descriptions;
|
1080
|
foreach($descriptions as $descriptionTO){
|
1081
|
$features = $descriptionTO->features;
|
1082
|
foreach($features as $featureTo){
|
1083
|
$descriptionElements = $featureTo->descriptionElements;
|
1084
|
// process $descriptionElements with content only
|
1085
|
if(is_array($descriptionElements) && count($descriptionElements) > 0){
|
1086
|
|
1087
|
$feature = isset($featureTo->feature->term) ? $featureTo->feature->term : 'Feature';
|
1088
|
|
1089
|
$out .= '<li><a href="#'.generalizeString($feature).'">'.t(ucfirst($feature)).'</a></li>';
|
1090
|
}
|
1091
|
}
|
1092
|
}
|
1093
|
$out .= '</ul></div>';
|
1094
|
|
1095
|
return $out;
|
1096
|
}
|
1097
|
|
1098
|
/**
|
1099
|
* Replaces all occurrences of space characters with an underscore and tronsforms the given
|
1100
|
* string to lowercase.
|
1101
|
*
|
1102
|
* @param String $string
|
1103
|
* @return the transformed string
|
1104
|
*/
|
1105
|
function generalizeString($string){
|
1106
|
return str_replace(' ', '_', strtolower($string));
|
1107
|
}
|
1108
|
|
1109
|
function theme_cdm_descriptionElements($descriptionElements, $feature){
|
1110
|
|
1111
|
$out .= '<ul class="description" id="'.$feature.'">';
|
1112
|
|
1113
|
foreach($descriptionElements as $descriptionElementSTO){
|
1114
|
if($descriptionElementSTO->classType == 'TextData'){
|
1115
|
$out .= '<li class="descriptionText">' . $descriptionElementSTO->description;
|
1116
|
if(isset($descriptionElementSTO->reference)){
|
1117
|
$out .= '<br> <span class="descriptionReference">'.theme('cdm_fullreference', $descriptionElementSTO->reference).'</span>';
|
1118
|
}
|
1119
|
$out .= '</li>';
|
1120
|
}else if($descriptionElementSTO->classType == 'Distribution'){
|
1121
|
$out .= '<li>' . $descriptionElementSTO->area->term . '</li>';
|
1122
|
}else{
|
1123
|
$out .= '<li>No method for rendering unknown description class: '.$descriptionElementSTO->classType.'</li>';
|
1124
|
}
|
1125
|
|
1126
|
}
|
1127
|
$out .= '</ul>';
|
1128
|
return $out;
|
1129
|
}
|
1130
|
|
1131
|
|
1132
|
function theme_cdm_search_results($resultPageSTO, $path, $parameters){
|
1133
|
|
1134
|
drupal_set_title(t('Search Results'));
|
1135
|
|
1136
|
$out = '';
|
1137
|
if(count($resultPageSTO->results) > 0){
|
1138
|
$out = theme('cdm_list_of_taxa', $resultPageSTO->results);
|
1139
|
$out .= theme('cdm_pager', $resultPageSTO, $path, $parameters);
|
1140
|
} else {
|
1141
|
$out = '<h4 calss="error">Sorry, no matching entries found.</h4>';
|
1142
|
}
|
1143
|
return $out;
|
1144
|
}
|
1145
|
|
1146
|
function theme_cdm_pager(&$resultPageSTO, $path, $parameters, $neighbors = 2){
|
1147
|
$out = '';
|
1148
|
|
1149
|
if ($resultPageSTO->totalPageCount > 1) {
|
1150
|
|
1151
|
$viewportsize = $neighbors * 2 + 1;
|
1152
|
if($resultPageSTO->totalPageCount <= $viewportsize){
|
1153
|
$viewportsize = $resultPageSTO->totalPageCount;
|
1154
|
}
|
1155
|
|
1156
|
$out .= '<div class="pager">';
|
1157
|
if($resultPageSTO->pageNumber > 1){
|
1158
|
$out .= theme('cdm_pager_link', t('« first'), 1, $resultPageSTO, $path, $parameters, array('class' => 'pager-first'));
|
1159
|
$out .= theme('cdm_pager_link', t('‹ previous'), $resultPageSTO->pageNumber - 1, $resultPageSTO, $path, $parameters, array('class' => 'pager-previous'));
|
1160
|
}
|
1161
|
|
1162
|
if($resultPageSTO->totalPageCount <= $viewportsize || $resultPageSTO->pageNumber <= $neighbors){
|
1163
|
$first_number = 1;
|
1164
|
} else if($resultPageSTO->pageNumber >= $resultPageSTO->totalPageCount - $neighbors){
|
1165
|
$first_number = $resultPageSTO->totalPageCount - $viewportsize;
|
1166
|
} else {
|
1167
|
$first_number = $resultPageSTO->pageNumber - $neighbors;
|
1168
|
}
|
1169
|
|
1170
|
if($first_number > 1){
|
1171
|
$out .= '<div class="pager-list-dots-left">...</div>';
|
1172
|
}
|
1173
|
|
1174
|
|
1175
|
for($i = $first_number; ($i == $resultPageSTO->totalPageCount) || ($i < $first_number + $viewportsize); $i++){
|
1176
|
$out .= theme('cdm_pager_link', $i, $i, $resultPageSTO, $path, $parameters, array('class' => 'pager-first'));
|
1177
|
}
|
1178
|
if($i < $resultPageSTO->totalPageCount){
|
1179
|
$out .= '<div class="pager-list-dots-right">...</div>';
|
1180
|
}
|
1181
|
|
1182
|
if($resultPageSTO->pageNumber < $resultPageSTO->totalPageCount){
|
1183
|
$out .= theme('cdm_pager_link', t('next ›'), $resultPageSTO->pageNumber + 1, $resultPageSTO, $path, $parameters, array('class' => 'pager-next'));
|
1184
|
$out .= theme('cdm_pager_link', t('last »'), $resultPageSTO->totalPageCount, $resultPageSTO, $path, $parameters, array('class' => 'pager-last'));
|
1185
|
}
|
1186
|
$out .= '</div>';
|
1187
|
|
1188
|
return $out;
|
1189
|
}
|
1190
|
}
|
1191
|
|
1192
|
function theme_cdm_pager_link($text, $linkPageNumber, &$resultPageSTO, $path, $parameters = array(), $attributes) {
|
1193
|
|
1194
|
$out = '';
|
1195
|
|
1196
|
if ($linkPageNumber == $resultPageSTO->pageNumber) {
|
1197
|
$out = '<strong>'.$text.'</strong>';
|
1198
|
} else {
|
1199
|
// <a class="pager-next active" title="Go to page 3" href="/node?page=2">3</a>
|
1200
|
$parameters['page'] = $linkPageNumber;
|
1201
|
$out = l($text, $path, $attributes, compose_url_prameterstr($parameters));
|
1202
|
}
|
1203
|
|
1204
|
|
1205
|
return $out;
|
1206
|
}
|