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/thickbox.js');
|
20
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/js/thickbox/cdm_thickbox.css');
|
21
|
}
|
22
|
|
23
|
function _add_js_lightbox($galleryID){
|
24
|
/*
|
25
|
* Important Notice:
|
26
|
* The jquery.lightbox-0.5.js has been modified in order to allow using the "alt" attribute
|
27
|
* for captions instead of the "title" attribute
|
28
|
*/
|
29
|
$lightBoxBasePath = drupal_get_path('module', 'cdm_dataportal') .'/js/jquery-lightbox-0.5';
|
30
|
drupal_add_js($lightBoxBasePath.'/js/jquery.lightbox-0.5.js');
|
31
|
drupal_add_css($lightBoxBasePath.'/css/jquery.lightbox-0.5.css');
|
32
|
drupal_add_js ('$(document).ready(function() {
|
33
|
$(\'#'.$galleryID.' a.lightbox\').lightBox({
|
34
|
fixedNavigation: true,
|
35
|
imageLoading: \''.$lightBoxBasePath.'/images/lightbox-ico-loading.gif\',
|
36
|
imageBtnPrev: \''.$lightBoxBasePath.'/images/lightbox-btn-prev.gif\',
|
37
|
imageBtnNext: \''.$lightBoxBasePath.'/images/lightbox-btn-next.gif\',
|
38
|
imageBtnClose: \''.$lightBoxBasePath.'/images/lightbox-btn-close.gif\',
|
39
|
imageBlank: \''.$lightBoxBasePath.'/images/lightbox-blank.gif\'
|
40
|
});
|
41
|
});
|
42
|
', 'inline');
|
43
|
}
|
44
|
|
45
|
function _add_js_footnotes(){
|
46
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/footnotes.js');
|
47
|
}
|
48
|
|
49
|
|
50
|
function _add_js_cluetip(){
|
51
|
|
52
|
//TODO replace by http://www.socialembedded.com/labs/jQuery-Tooltip-Plugin/jQuery-Tooltip-Plugin.html
|
53
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.cluetip.js');
|
54
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.dimensions.js');
|
55
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.hoverIntent.js');
|
56
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/js/cluetip/jquery.cluetip.css');
|
57
|
drupal_add_js ("$(document).ready(function(){
|
58
|
$('.cluetip').css({color: '#0062C2'}).cluetip({
|
59
|
splitTitle: '|',
|
60
|
showTitle: true,
|
61
|
activation: 'hover',
|
62
|
sicky: true,
|
63
|
arrows: true,
|
64
|
dropShadow: false,
|
65
|
cluetipClass: 'rounded'
|
66
|
});
|
67
|
});", 'inline');
|
68
|
}
|
69
|
|
70
|
function _add_js_ahah(){
|
71
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/ahah-content.js');
|
72
|
}
|
73
|
|
74
|
|
75
|
/**
|
76
|
* TODO if getting fragment from request is possible remove $_REQUEST['highlite'] HACK
|
77
|
* NOT WORKING since fragments are not available to the server
|
78
|
function fragment(){
|
79
|
global $fragment;
|
80
|
if(!$fragment){
|
81
|
$fragment = substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '#'));
|
82
|
}
|
83
|
return $fragment;
|
84
|
}
|
85
|
*/
|
86
|
|
87
|
function uuid_anchor($uuid, $innerHTML){
|
88
|
$highlite = $_REQUEST['highlite'] == $uuid;
|
89
|
return '<a name="'.$uuid.'" ></a><span class="'.($highlite ? 'highlite' : '').'">'.$innerHTML.'</span>';
|
90
|
}
|
91
|
|
92
|
/**
|
93
|
* Enter description here...
|
94
|
*
|
95
|
* @param unknown_type $name
|
96
|
* @param unknown_type $numOfNameTokens
|
97
|
* @return unknown
|
98
|
* @deprecated looks like this is not used anymore
|
99
|
*/
|
100
|
function tagNameParts($name, $numOfNameTokens){
|
101
|
|
102
|
$out = '<span class="name">';
|
103
|
|
104
|
$token = strtok($name, " \n\t");
|
105
|
$i = 0;
|
106
|
$noSpace = true;
|
107
|
while($token != false){
|
108
|
if($i == $numOfNameTokens){
|
109
|
$out .= '</span> <span class="authors">';
|
110
|
$noSpace = true;
|
111
|
}
|
112
|
$out .= ($noSpace?'':' ').$token;
|
113
|
$noSpace = false;
|
114
|
$token = strtok(" \n\t");
|
115
|
$i++;
|
116
|
}
|
117
|
return $out.'</span>';
|
118
|
}
|
119
|
|
120
|
/**
|
121
|
* Converts an array of TagedText items into a sequence of corresponding html tags whereas
|
122
|
* each item will provided with a class attribute which set to the key of the TaggedText item.
|
123
|
*
|
124
|
* @param array $taggedtxt
|
125
|
* @param String $tag
|
126
|
* @param String $glue the string by which the chained text tokens are concatenated together.
|
127
|
* Default is a blank character
|
128
|
* @return String of HTML
|
129
|
*/
|
130
|
function theme_cdm_taggedtext2html(array &$taggedtxt, $tag = 'span', $glue = ' ', $skiptags = array()){
|
131
|
$out = '';
|
132
|
$i = 0;
|
133
|
foreach($taggedtxt as $tt){
|
134
|
if(!in_array($tt->type, $skiptags) && strlen($tt->text) > 0){
|
135
|
$out .= (strlen($out) > 0 && ++$i < count($taggedtxt)? $glue : '').'<'.$tag.' class="'.$tt->type.'">'.t($tt->text).'</'.$tag.'>';
|
136
|
}
|
137
|
}
|
138
|
return $out;
|
139
|
}
|
140
|
|
141
|
/**
|
142
|
* Almost any cdmObject may be annotated. Therefore we provide a generic way to display
|
143
|
* as well as create or update annotations.
|
144
|
*
|
145
|
* TODO it should be configurable which objects can be annotated as this might differ in dataportals
|
146
|
*
|
147
|
*/
|
148
|
function theme_cdm_annotation($cdmBase){
|
149
|
if(!$cdmBase->uuid){
|
150
|
return;
|
151
|
}else{
|
152
|
|
153
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_annotations.js');
|
154
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.form.js');
|
155
|
|
156
|
$annotatableUuid = $cdmBase->uuid;
|
157
|
//FIXME annotations only available as property of e.g. taxon, name, ...
|
158
|
$annotationUrl = cdm_compose_url(CDM_WS_ANNOTATIONS, array($annotatableUuid));
|
159
|
|
160
|
$annotationProxyUrl = url('cdm_api/proxy/'. urlencode($annotationUrl).'/cdm_annotation_content');
|
161
|
|
162
|
$out = ' <span class="annotation">';
|
163
|
$out .= '<span class="annotation_toggle" rel="'.$annotationProxyUrl.'">+</span>';
|
164
|
|
165
|
|
166
|
$out .= '<div class="annotation_box"></div>';
|
167
|
$out .= '</span>';
|
168
|
|
169
|
return $out;
|
170
|
|
171
|
}
|
172
|
}
|
173
|
|
174
|
function theme_cdm_annotation_content($AnnotationTO){
|
175
|
|
176
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_annotations.js');
|
177
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.form.js');
|
178
|
|
179
|
$out .= theme('cdm_list_of_annotations', $AnnotationTO->annotationElements);
|
180
|
|
181
|
$annotationUrl = cdm_compose_url(CDM_WS_ANNOTATIONS, array($AnnotationTO->uuid));
|
182
|
$annotationProxyUrl = url('cdm_api/proxy/'. urlencode($annotationUrl).'/cdm_annotation_post');
|
183
|
|
184
|
// TODO users have to be authenticated to the dataportal to be able to write annotations
|
185
|
$out .= '
|
186
|
<div class="annotation_create">
|
187
|
<form action="'.$annotationProxyUrl.'" method="POST">
|
188
|
<textarea name="annotation"></textarea>
|
189
|
<input type="hidden" name="commentator" value="">
|
190
|
<input type="submit" value="'.t('Save annotation').'" />
|
191
|
</form>
|
192
|
</div>
|
193
|
';
|
194
|
|
195
|
return $out;
|
196
|
}
|
197
|
|
198
|
function theme_cdm_list_of_annotations($annotationElements){
|
199
|
|
200
|
$out = '<ul class="annotation_list">';
|
201
|
|
202
|
foreach ($annotationElements as $key => $row){
|
203
|
$created[$key] = $row;
|
204
|
}
|
205
|
array_multisort($created, SORT_ASC, $annotationElements);
|
206
|
|
207
|
foreach ($annotationElements as $annotation){
|
208
|
$out .= '<li>' . $annotation->text . '</li>';
|
209
|
}
|
210
|
|
211
|
$out .= '</ul>';
|
212
|
|
213
|
return $out;
|
214
|
|
215
|
}
|
216
|
|
217
|
function theme_cdm_media($descriptionElement, $mimeTypePreference){
|
218
|
$out = "";
|
219
|
|
220
|
_add_js_thickbox();
|
221
|
|
222
|
$uuid = $descriptionElement->uuid;
|
223
|
$feature = $descriptionElement->feature;
|
224
|
$medias = $descriptionElement->media;
|
225
|
|
226
|
foreach($medias as $media){
|
227
|
$prefRepresentations = cdm_preferred_media_representations($media, $mimeTypePreference, 300, 400);
|
228
|
$mediaRepresentation = array_shift($prefRepresentations);
|
229
|
if($mediaRepresentation) {
|
230
|
|
231
|
$contentTypeDirectory = media_content_type_dir($mediaRepresentation);
|
232
|
|
233
|
$out .= theme('cdm_media_mime_' . $contentTypeDirectory, $mediaRepresentation, $feature);
|
234
|
|
235
|
// $attributes = array('class'=>'thickbox', 'rel'=>'descriptionElement-'.$uuid, 'title'=>$feature->term);
|
236
|
// for($i = 0; $part = $mediaRepresentation->representationParts[$i]; $i++){
|
237
|
// if($i == 0){
|
238
|
// $image_url = drupal_get_path('module', 'cdm_dataportal').'/images/'.$feature->term.'-media.png';
|
239
|
// $media = '<img src="'.$image_url.'" height="14px" alt="'.$feature->term.'" />';
|
240
|
// $out .= l($media, $part->uri, $attributes, NULL, NULL, TRUE, TRUE);
|
241
|
// } else {
|
242
|
// $out .= l('', $part->uri, $attributes, NULL, NULL, TRUE);
|
243
|
// }
|
244
|
// }
|
245
|
} else {
|
246
|
// no media available, so display just the type term
|
247
|
$out .= $feature->representation_L10n;
|
248
|
}
|
249
|
}
|
250
|
return $out;
|
251
|
|
252
|
}
|
253
|
|
254
|
function theme_cdm_mediaTypeTerm($feature){
|
255
|
$icon_url = drupal_get_path('module', 'cdm_dataportal').'/images/'.$feature->representation_L10n.'-media.png';
|
256
|
return '<img src="'.$icon_url.'" height="14px" alt="'.$feature->representation_L10n.'" />';
|
257
|
}
|
258
|
|
259
|
function theme_cdm_media_mime_application($mediaRepresentation, $feature){
|
260
|
|
261
|
foreach($mediaRepresentation->parts as $part){
|
262
|
$attributes = array('title'=> theme('cdm_feature_name', $feature->representation_L10n), 'target'=>'_blank');
|
263
|
//$attributes = array('title'=>$feature->representation_L10n, 'target'=>'_blank');
|
264
|
//$attributes = array('title'=>'original publication', 'target'=>'_blank');
|
265
|
$out .= l(theme('cdm_mediaTypeTerm', $feature), $part->uri, $attributes, NULL, NULL, TRUE, TRUE);
|
266
|
}
|
267
|
return $out;
|
268
|
}
|
269
|
|
270
|
function theme_cdm_media_mime_image($mediaRepresentation, $feature){
|
271
|
$out = '';
|
272
|
//TODO thickbox is not used anymore -> delete ?
|
273
|
$attributes = array('class'=>'thickbox', 'rel'=>'representation-'.$representation->uuid, 'title'=>$feature->representation_L10n);
|
274
|
for($i = 0; $part = $representation->representationParts[$i]; $i++){
|
275
|
if($i == 0){
|
276
|
|
277
|
$out .= l(theme('cdm_mediaTypeTerm', $feature), $part->uri, $attributes, NULL, NULL, TRUE, TRUE);
|
278
|
} else {
|
279
|
$out .= l('', $part->uri, $attributes, NULL, NULL, TRUE);
|
280
|
}
|
281
|
}
|
282
|
return $out;
|
283
|
}
|
284
|
|
285
|
function theme_cdm_media_mime_text($representation, $feature){
|
286
|
|
287
|
foreach($representation->parts as $part){
|
288
|
$attributes = array('title'=> theme('cdm_feature_name', $feature->representation_L10n), 'target'=>'_blank');
|
289
|
//$attributes = array('title'=>t('original publication'), 'target'=>'_blank');
|
290
|
$out .= l(theme('cdm_mediaTypeTerm', $feature), $part->uri, $attributes, NULL, NULL, TRUE, TRUE);
|
291
|
}
|
292
|
return $out;
|
293
|
}
|
294
|
|
295
|
|
296
|
function theme_cdm_media_caption($media, $elements = array('title', 'description', 'artist', 'location', 'rights'), $fileUri = null){
|
297
|
|
298
|
$media_metadata = cdm_read_media_metadata($media);
|
299
|
|
300
|
$out = '<dl class="media-caption">';
|
301
|
//title
|
302
|
if($media_metadata['title'] && (!$elements || array_search('title', $elements)!== false)){
|
303
|
$out .= '<dt class = "title">' . t('Title') . '</dt> <dd class = "title">' . $media_metadata['title'] . '</dd>';
|
304
|
//unset($media_metadata['title']);
|
305
|
}
|
306
|
//description
|
307
|
if($media_metadata['description'] && (!$elements || array_search('description', $elements)!== false)){
|
308
|
$out .= '<dt class = "description">' . t('Description') . '</dt> <dd class = "description">' . $media_metadata['description'] . '</dd>';
|
309
|
//unset($media_metadata['description']);
|
310
|
}
|
311
|
//artist
|
312
|
if($media_metadata['artist'] && (!$elements || array_search('artist', $elements)!== false)){
|
313
|
//$out .= '<span class = "artist">' . ($media_metadata['artist'] ? 'Artist: ' . $media_metadata['artist'] . '</span>' . '<br>' : '');
|
314
|
$out .= '<dt class = "artist">' . t('Artist') . '</dt> <dd class = "astist">' . $media_metadata['artist'] . '</dd>';
|
315
|
}
|
316
|
//location
|
317
|
if(!$elements || array_search('location', $elements)!== false){
|
318
|
$location = '';
|
319
|
$location .= $media_metadata['location']['sublocation'];
|
320
|
if ($location && $media_metadata['location']['city']){
|
321
|
$location .= ', ';
|
322
|
}
|
323
|
$location .= $media_metadata['location']['city'];
|
324
|
if ($location && $media_metadata['location']['province']){
|
325
|
$location .= ', ';
|
326
|
}
|
327
|
$location .= $media_metadata['location']['province'];
|
328
|
if ($location && $media_metadata['location']['country']){
|
329
|
$location .= ' (' . $media_metadata['location']['country'] . ')';
|
330
|
} else {
|
331
|
$location .= $media_metadata['location']['country'];
|
332
|
}
|
333
|
if ($location){
|
334
|
$out .= '<dt class = "location">' . t('Location') . '</dt> <dd class = "location">' . $location . '</dd>';
|
335
|
}
|
336
|
}
|
337
|
//rights
|
338
|
if(!$elements || array_search('rights', $elements)!== false){
|
339
|
$rights = '';
|
340
|
//copyrights
|
341
|
$cnt = count($media_metadata['rights']['copyright']['agentNames']);
|
342
|
if($cnt > 0){
|
343
|
$rights .= '<dt class="rights">©</dt> <dd class="rights"> ';
|
344
|
for($i = 0; $i < $cnt; $i++){
|
345
|
$rights .= $media_metadata['rights']['copyright']['agentNames'][$i];
|
346
|
if($i+1 < $cnt){
|
347
|
$rights .= ' / ';
|
348
|
}
|
349
|
}
|
350
|
$rights .= '</dd>';
|
351
|
}
|
352
|
//license
|
353
|
$cnt = count($media_metadata['rights']['license']['agentNames']);
|
354
|
if($cnt > 0){
|
355
|
$rights .= '<dt class ="license">' . t('License') . '</dt> <dd class = "license">';
|
356
|
for($i = 0; $i < $cnt; $i++){
|
357
|
$rights .= $media_metadata['rights']['license']['agentNames'][$i];
|
358
|
if ($i+1 < $cnt){
|
359
|
$rights .= ' / ';
|
360
|
}
|
361
|
}
|
362
|
$rights .= '</dd>';
|
363
|
}
|
364
|
if($rights){
|
365
|
$out .= $rights . '</dt>';
|
366
|
}
|
367
|
}
|
368
|
//TODO add all other metadata elemenst generically
|
369
|
$out .= '</dl>';
|
370
|
//return value
|
371
|
return $out;
|
372
|
}
|
373
|
|
374
|
/**
|
375
|
*/
|
376
|
function theme_cdm_taxon_list_thumbnails($taxon){
|
377
|
|
378
|
$gallery_name = $taxon->uuid;
|
379
|
|
380
|
$showCaption = variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 1);
|
381
|
$prefMimeTypeRegex = 'image:.*';
|
382
|
$prefMediaQuality = '*';
|
383
|
//$cols = variable_get('cdm_dataportal_findtaxa_media_cols', 3);
|
384
|
//$maxRows = variable_get('cdm_dataportal_findtaxa_media_maxRows', 1);
|
385
|
//$maxExtend = variable_get('cdm_dataportal_findtaxa_media_maxextend', 120);
|
386
|
|
387
|
if($showCaption){
|
388
|
//$captionElements = array('title', '#uri'=>t('open Image'));
|
389
|
$captionElements = array('title', 'rights');
|
390
|
}
|
391
|
|
392
|
$galleryLinkUri = path_to_taxon($taxon->uuid).'/images';
|
393
|
$selectShowMedia = variable_get('cdm_dataportal_show_media', 0);
|
394
|
if ($selectShowMedia == 0){
|
395
|
$mediaList = cdm_ws_get(CDM_WS_TAXON_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
|
396
|
}else{
|
397
|
$mediaList = cdm_ws_get(CDM_WS_TAXON_SUBTREE_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
|
398
|
}
|
399
|
//$mediaList = cdm_ws_get(CDM_WS_TAXONOMY_MEDIA, array(variable_get('cdm_taxonomictree_uuid', false), $taxon ->rank, $taxon->uuid ));
|
400
|
//$out .= theme('cdm_media_gallerie', $mediaList, $gallery_name ,$maxExtend, $cols, $maxRows, $captionElements, 'LIGHTBOX', null, $galleryLinkUri);
|
401
|
|
402
|
|
403
|
$out .= theme('cdm_media_gallery_wrapper', $mediaList, $gallery_name, CDM_DATAPORTAL_SEARCH_GALLERY_FORM_NAME);
|
404
|
|
405
|
return $out;
|
406
|
}
|
407
|
|
408
|
|
409
|
function theme_cdm_media_gallery_wrapper($media_list, $gallery_name, $gallery_config_form_name){
|
410
|
$caption_elements = array('title', 'rights');
|
411
|
$default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
|
412
|
$gallery_settings = variable_get('description_gallery', $gallery_settings);
|
413
|
|
414
|
return theme('cdm_media_gallerie',
|
415
|
$media_list,
|
416
|
$gallery_name,
|
417
|
$gallery_settings['cdm_dataportal_media_maxextend'],
|
418
|
$gallery_settings['cdm_dataportal_media_cols'],
|
419
|
$gallery_settings['cdm_dataportal_media_maxRows'],
|
420
|
$caption_elements);
|
421
|
}
|
422
|
|
423
|
/**
|
424
|
* @param $mediaList an array of Media entities
|
425
|
* @param $maxExtend
|
426
|
* @param $cols
|
427
|
* @param $maxRows
|
428
|
* @param $captionElements an array possible values are like in the following example: array('title', 'description', 'file', 'filename'),
|
429
|
* to add a link to the caption: array('titlecache', '#uri'=>t('open Image'));
|
430
|
* @param $mediaLinkType valid values:
|
431
|
* "NONE": do not link the images,
|
432
|
* "LIGHTBOX": open the link in a light box,
|
433
|
* "NORMAL": link to the image page or to the $alternativeMediaUri if it is defined
|
434
|
* @param $alternativeMediaUri an array of alternative URIs to link the images wich will overwrite the URIs of the media parts.
|
435
|
* The order of URI in this array must correspond with the order of images in $mediaList
|
436
|
* @param $galleryLinkUri an URI to link the the hint on more images to; if null no link is created
|
437
|
* @return unknown_type
|
438
|
*/
|
439
|
function theme_cdm_media_gallerie($mediaList, $galleryName, $maxExtend = 150, $cols = 4, $maxRows = false, $captionElements = array('title'),
|
440
|
$mediaLinkType = 'LIGHTBOX', $alternativeMediaUri = null, $galleryLinkUri = null ){
|
441
|
|
442
|
if(!is_array($captionElements)){
|
443
|
$captionElements = array();
|
444
|
}
|
445
|
//TODO correctly handle multiple media representation parts
|
446
|
$_SESSION['cdm']['last_gallery']= substr($_SERVER['REQUEST_URI'],strpos($_SERVER['REQUEST_URI'], "?q=")+3);
|
447
|
// prevent from errors
|
448
|
if(!isset($mediaList[0])){
|
449
|
return;
|
450
|
}
|
451
|
|
452
|
$galleryID = "media_gallery_".$galleryName;
|
453
|
|
454
|
// prepare media links
|
455
|
$doLink = false;
|
456
|
$linkAttributes = null;
|
457
|
if($mediaLinkType != 'NONE'){
|
458
|
$doLink = true;
|
459
|
}
|
460
|
if($mediaLinkType == 'LIGHTBOX'){
|
461
|
$doLink = true;
|
462
|
//_add_js_thickbox();
|
463
|
//$linkAttributes = array("class"=>"thickbox", "rel"=>"media_gallerie".$galleryName);
|
464
|
_add_js_lightbox($galleryID);
|
465
|
$linkAttributes = array("class"=>"lightbox");
|
466
|
}
|
467
|
|
468
|
// render the media gallery grid
|
469
|
$out = '<table id="'.$galleryID.'" class="media_gallery">';
|
470
|
$out .= '<colgroup>';
|
471
|
for($c = 0; $c < $cols; $c++){
|
472
|
$out .= '<col width="'.(100 / $cols).'%">';
|
473
|
}
|
474
|
$out .= '</colgroup>';
|
475
|
|
476
|
for($r = 0; ($r < $maxRows || !$maxRows) && count($mediaList) > 0; $r++){
|
477
|
$captionParts = array();
|
478
|
$out .= '<tr>';
|
479
|
for($c = 0; $c < $cols; $c++){
|
480
|
$media = array_shift($mediaList);
|
481
|
if(isset($media->representations[0]->parts[0])){
|
482
|
$contentTypeDirectory = media_content_type_dir($media->representations[0], 'image');
|
483
|
$mediaIndex++;
|
484
|
$mediaPartHtml = theme('cdm_media_gallerie_'.$contentTypeDirectory, $media->representations[0]->parts[0], $maxExtend, TRUE);
|
485
|
|
486
|
// --- compose Media Link
|
487
|
$mediaLinkUri = false;
|
488
|
if($alternativeMediaUri){
|
489
|
if(isset($alternativeMediaUri[$mediaIndex])){
|
490
|
$mediaLinkUri = $alternativeMediaUri[$mediaIndex];
|
491
|
}
|
492
|
if(is_string($alternativeMediaUri)){
|
493
|
$mediaLinkUri = $alternativeMediaUri;
|
494
|
}
|
495
|
} else {
|
496
|
$mediaLinkUri = $media->representations[0]->parts[0]->uri;
|
497
|
}
|
498
|
|
499
|
// generate gallery caption
|
500
|
_add_js_ahah();
|
501
|
$content_url = cdm_compose_url(CDM_WS_MEDIA, $media->uuid);
|
502
|
$cdm_proxy_url = url('cdm_api/proxy/'.urlencode($content_url)."/cdm_media_caption/".join(',',$captionElements));
|
503
|
$captionPartHtml = '<div class="ahah-content" rel="'.$cdm_proxy_url.'"><span class="loading" style="display: none;">Loading ....</span></div>';
|
504
|
|
505
|
// generate & add caption to lightbox
|
506
|
$lightBoxCaptionElements = null;
|
507
|
$cdm_proxy_url = url('cdm_api/proxy/'.urlencode($content_url)."/cdm_media_caption"); //.($lightBoxCaptionElements?'/'.join (',',$lightBoxCaptionElements):''));
|
508
|
$linkAttributes['alt'] = '<div class="ahah-content" rel="'.$cdm_proxy_url.'"><span class="loading" style="display: none;">Loading ....</span></div>';
|
509
|
|
510
|
if(isset($captionElements['#uri'])){
|
511
|
$captionPartHtml .= '<div>'.l($captionElements['#uri'], path_to_media($media->uuid), null, null, null, FALSE, TRUE).'</div>';
|
512
|
}
|
513
|
$captionParts[] = $captionPartHtml;
|
514
|
|
515
|
// --- surround imagePart with link
|
516
|
if($doLink){
|
517
|
$mediaPartHtml = l($mediaPartHtml, $mediaLinkUri, $linkAttributes, null, null, FALSE, TRUE);
|
518
|
}
|
519
|
|
520
|
} else {
|
521
|
$mediaPartHtml = '';
|
522
|
$captionParts[] = '';
|
523
|
}
|
524
|
$out .= '<td>'.$mediaPartHtml.'</td>';
|
525
|
}
|
526
|
$out .= '</tr>'; // end of media parts
|
527
|
if(isset($captionElements[0])){
|
528
|
$out .= '<tr>';
|
529
|
// add caption row
|
530
|
foreach($captionParts as $captionPartHtml){
|
531
|
$out .= '<td>'.$captionPartHtml.'</td>';
|
532
|
}
|
533
|
$out .= '</tr>';
|
534
|
}
|
535
|
}
|
536
|
if($galleryLinkUri){
|
537
|
if(count($mediaList) > 0){
|
538
|
$moreHtml = count($mediaList).' '.t('more in gallery');
|
539
|
} else {
|
540
|
$moreHtml = t('open gallery');
|
541
|
}
|
542
|
$moreHtml = l($moreHtml, $galleryLinkUri);
|
543
|
$out .= '<tr><td colspan="'.$cols.'">'.$moreHtml.'</td></tr>';
|
544
|
}
|
545
|
$out .= '</table>';
|
546
|
return $out;
|
547
|
}
|
548
|
|
549
|
function theme_cdm_media_gallerie_image($mediaRepresentationPart, $maxExtend, $addPassePartout = FALSE, $attributes = null){
|
550
|
//TODO merge with theme_cdm_media_mime_image?
|
551
|
|
552
|
if(isset($mediaRepresentationPart)){
|
553
|
|
554
|
$h = $mediaRepresentationPart->height;
|
555
|
$w = $mediaRepresentationPart->width;
|
556
|
if($w == 0 || $h == 0){
|
557
|
$image_uri = str_replace(' ','%20',$mediaRepresentationPart->uri); //take url and replace spaces
|
558
|
$imageDimensions = getimagesize_remote($image_uri);
|
559
|
if(!$imageDimensions){
|
560
|
return '<div>'.t('Image unavailable, uri:').$mediaRepresentationPart->uri.'</div>';
|
561
|
}
|
562
|
$w = $imageDimensions[0];
|
563
|
$h = $imageDimensions[1];
|
564
|
}
|
565
|
$margins = '0 0 0 0';
|
566
|
$ratio = $w / $h;
|
567
|
if($ratio > 1){
|
568
|
$displayHeight = round($maxExtend / $ratio);
|
569
|
$displayWidth = $maxExtend;
|
570
|
$m = round(($maxExtend - $displayHeight) / 2);
|
571
|
$margins = 'margin:'.$m.'px 0 '.$m.'px 0;';
|
572
|
} else {
|
573
|
$displayHeight = $maxExtend;
|
574
|
$displayWidth = round($maxExtend * $ratio);
|
575
|
$m = round(($maxExtend - $displayWidth) / 2);
|
576
|
$margins = 'margin:0 '.$m.'px 0 '.$m.'px;';
|
577
|
}
|
578
|
|
579
|
// turn attributes array into string
|
580
|
$attrStr = ' ';
|
581
|
//$attributes['title'] = 'h:'.$h.', w:'.$w.',ratio:'.$ratio;
|
582
|
if(is_array($attributes)){
|
583
|
foreach($attributes as $name=>$value){
|
584
|
$attrStr .= $name.'="'.$value.'" ';
|
585
|
}
|
586
|
}
|
587
|
|
588
|
//return '<img src="'."http://wp5.e-taxonomy.eu/dataportal/cichorieae/media/photos/Lapsana_communis_A_01.jpg".'" width="'.$maxExtend.'" height="'.$maxExtend.'" />';
|
589
|
if($addPassePartout){
|
590
|
$out .= '<div class="image-passe-partout" style="width:'.$maxExtend.'px; height:'.$maxExtend.'px;">';
|
591
|
} else {
|
592
|
// do not add margins if no pass partout is shown
|
593
|
$margins = '';
|
594
|
}
|
595
|
$out .= '<img src="'.$mediaRepresentationPart->uri.'" width="'.$displayWidth.'" height="'.$displayHeight.'" style="'.$margins.'"'.$attrStr.' />';
|
596
|
|
597
|
if($addPassePartout){
|
598
|
$out .= '</div>';
|
599
|
}
|
600
|
return $out;
|
601
|
}
|
602
|
|
603
|
}
|
604
|
|
605
|
function theme_cdm_openlayers_image($mediaRepresentationPart, $maxExtend){
|
606
|
|
607
|
// see http://trac.openlayers.org/wiki/UsingCustomTiles#UsingTilesWithoutaProjection
|
608
|
// and http://trac.openlayers.org/wiki/SettingZoomLevels
|
609
|
|
610
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/OpenLayers/OpenLayers.js', 'core', 'header');
|
611
|
|
612
|
//TODO megre code below with code from theme_cdm_media_gallerie_image
|
613
|
//var_dump("MEDIA URI: " . $mediaRepresentationPart->uri);
|
614
|
//TODO merge code below with code from theme_cdm_media_gallerie_image
|
615
|
$w = $mediaRepresentationPart->width;
|
616
|
$h = $mediaRepresentationPart->height;
|
617
|
|
618
|
if($w == 0 || $h == 0){
|
619
|
$image_uri = str_replace(' ','%20',$mediaRepresentationPart->uri); //take url and replace spaces
|
620
|
$imageDimensions = getimagesize_remote($image_uri);
|
621
|
if(!$imageDimensions){
|
622
|
return '<div>'.t('Image unavailable, uri:').$mediaRepresentationPart->uri.'</div>';
|
623
|
}
|
624
|
$w = $imageDimensions[0];
|
625
|
$h = $imageDimensions[1];
|
626
|
}
|
627
|
|
628
|
// calculate maxResolution (default is 360 deg / 256 px) and the bounds
|
629
|
if($w > $h){
|
630
|
$lat = 90;
|
631
|
$lon = 90 * ($h / $w);
|
632
|
$maxRes = $w / $maxExtend;
|
633
|
} else {
|
634
|
$lat = 90 * ($w / $h);
|
635
|
$lon = 90;
|
636
|
$maxRes = $h / $maxExtend ;
|
637
|
}
|
638
|
|
639
|
$maxRes *= 1;
|
640
|
drupal_add_js('
|
641
|
var map;
|
642
|
|
643
|
var imageLayerOptions={
|
644
|
maxResolution: '.$maxRes.',
|
645
|
maxExtent: new OpenLayers.Bounds(0, 0, '.$w.', '.$h.')
|
646
|
};
|
647
|
var mapOptions={
|
648
|
controls:
|
649
|
[
|
650
|
new OpenLayers.Control.PanZoom(),
|
651
|
new OpenLayers.Control.Navigation({zoomWheelEnabled: false, handleRightClicks:true, zoomBoxKeyMask: OpenLayers.Handler.MOD_CTRL})
|
652
|
],
|
653
|
restrictedExtent: new OpenLayers.Bounds(0, 0, '.$w.', '.$h.')
|
654
|
};
|
655
|
|
656
|
var graphic = new OpenLayers.Layer.Image(
|
657
|
\'Image Title\',
|
658
|
\''.$mediaRepresentationPart->uri.'\',
|
659
|
new OpenLayers.Bounds(0, 0, '.$w.', '.$h.'),
|
660
|
new OpenLayers.Size('.$w.', '.$h.'),
|
661
|
imageLayerOptions
|
662
|
);
|
663
|
|
664
|
function init() {
|
665
|
map = new OpenLayers.Map(\'openlayers_image\', mapOptions);
|
666
|
map.addLayers([graphic]);
|
667
|
map.setCenter(new OpenLayers.LonLat(0, 0), 1);
|
668
|
map.zoomToMaxExtent();
|
669
|
}
|
670
|
|
671
|
$(document).ready(function(){
|
672
|
init();
|
673
|
|
674
|
});'
|
675
|
, 'inline');
|
676
|
$out = '<div id="openlayers_image" class="image_viewer" style="width: '.$maxExtend.'px; height:'.($maxExtend).'px"></div>';
|
677
|
return $out;
|
678
|
|
679
|
}
|
680
|
|
681
|
function theme_cdm_media_page($media, $mediarepresentation_uuid = false, $partId = false){
|
682
|
$out = '';
|
683
|
// determine which reprresentation and which part to show
|
684
|
$representationIdx = 0;
|
685
|
if($mediarepresentation_uuid){
|
686
|
$i = 0;
|
687
|
foreach($media->representations as $representation) {
|
688
|
if($representation->uuid == $mediarepresentation_uuid){
|
689
|
$representationIdx = $i;
|
690
|
}
|
691
|
$i++;
|
692
|
}
|
693
|
} else {
|
694
|
$mediarepresentation_uuid = $media->representations[0]->uuid;
|
695
|
}
|
696
|
|
697
|
$partIdx = 0;
|
698
|
if(!is_numeric($partId)){
|
699
|
// assuming it is an uuid
|
700
|
$i = 0;
|
701
|
foreach($media->representations[$representationIdx]->parts as $part) {
|
702
|
if($part->uuid == $partId){
|
703
|
$partIdx = $i;
|
704
|
}
|
705
|
$i++;
|
706
|
}
|
707
|
} else {
|
708
|
// assuming it is an index
|
709
|
$partIdx = $partId;
|
710
|
}
|
711
|
|
712
|
$media_metadata = cdm_read_media_metadata($media);
|
713
|
//$title = $media->titleCache;
|
714
|
$title = $media_metadata['title'];
|
715
|
|
716
|
$imageMaxExtend = variable_get('image-page-maxextend', 400);
|
717
|
|
718
|
if(!$title){
|
719
|
$title = 'Media### '.$media->uuid.'';
|
720
|
}
|
721
|
|
722
|
drupal_set_title($title);
|
723
|
|
724
|
|
725
|
$out .= '<div class="media">';
|
726
|
|
727
|
//$out .= '<div class="viewer">';
|
728
|
$out .= theme(cdm_back_to_image_gallery_button);
|
729
|
$out .= '<div class="viewer">';
|
730
|
//$out .= theme('cdm_media_gallerie_image', $representation->parts[$partIdx], $imageMaxExtend);
|
731
|
$out .= theme('cdm_openlayers_image', $media->representations[$representationIdx]->parts[$partIdx], $imageMaxExtend);
|
732
|
$out .= '</div>';
|
733
|
|
734
|
// general media metadata
|
735
|
//$media_metadata = cdm_ws_get(CDM_WS_MEDIA_METADATA, array($media->uuid));
|
736
|
//vardump("PRINTING MEDIA METADATA");
|
737
|
//vardump($media_metadata);
|
738
|
//vardump("PRINTING MEDIA");
|
739
|
//vardump($media);
|
740
|
$metadataToPrint = theme('cdm_media_caption', $media);
|
741
|
$out .= $metadataToPrint;
|
742
|
|
743
|
|
744
|
//tabs for the different representations
|
745
|
//ul.secondary
|
746
|
$out .= '<ul class="primary">';
|
747
|
foreach($media->representations as $representation){
|
748
|
$out .= '<li>'.l($media->representations[$representationIdx]->mimeType, path_to_media($media->uuid, $mediarepresentation_uuid, $partIdx)).'</li>';
|
749
|
}
|
750
|
$out .= '</ul>';
|
751
|
|
752
|
// representation(-part) specific metadata
|
753
|
$thumbnailMaxExtend = 100;
|
754
|
$out .= '<table>';
|
755
|
//$out .= '<tr><th colspan="3">'.t('MimeType').': '.$media->representations[$representationIdx]->mimeType.'</th></tr>';
|
756
|
$i = 0;
|
757
|
foreach($media->representations[$representationIdx]->parts as $part){
|
758
|
$out .= '<tr><th>'.t('Part').' '.($i + 1).'</th><td>';
|
759
|
switch($part->class){
|
760
|
case 'ImageFile': $out .= $part->width.' x '.$part->height.' - '.$part->size.'k'; break;
|
761
|
case 'AudioFile':
|
762
|
case 'MovieFile': $out .= t('Duration').': '.$part->duration.'s - '.$part->size.'k'; break;
|
763
|
default: $out .= $part->size.'k';
|
764
|
}
|
765
|
$out .= '</td><td><a href="'.url(path_to_media($media->uuid, $mediarepresentation_uuid, $i)).'">'.theme('cdm_media_gallerie_image', $part, $thumbnailMaxExtend, true);'</a></td><tr>';
|
766
|
$i++;
|
767
|
}
|
768
|
$out .= '</table>';
|
769
|
$out .= '</div>';
|
770
|
|
771
|
return $out;
|
772
|
}
|
773
|
|
774
|
/**
|
775
|
* TODO
|
776
|
* Quick-and-dirty solution to show distribution service to exemplar groups
|
777
|
*
|
778
|
* @param unknown_type $featureTo
|
779
|
* @return unknown
|
780
|
*/
|
781
|
function theme_cdm_descriptionElements_distribution($taxon){
|
782
|
|
783
|
$fontStyles = array(0 => "plane", 1 => "italic");
|
784
|
$server = variable_get('cdm_dataportal_geoservice_access_point', false);
|
785
|
|
786
|
if(!server){
|
787
|
return "<p>No geoservice specified</p>";
|
788
|
}else{
|
789
|
$map_data_parameters = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid);
|
790
|
|
791
|
$display_width = variable_get('cdm_dataportal_geoservice_display_width', false);
|
792
|
$bounding_box = variable_get('cdm_dataportal_geoservice_bounding_box', false);
|
793
|
$labels_on = variable_get('cdm_dataportal_geoservice_labels_on', 0);
|
794
|
|
795
|
$query_string = ($display_width ? '&ms=' . $display_width: '')
|
796
|
. ($bounding_box ? '&bbox=' . $bounding_box : '')
|
797
|
. ($labels_on ? '&labels=' . $labels_on : '');
|
798
|
|
799
|
if(variable_get('cdm_dataportal_map_openlayers', 1)){
|
800
|
// embed into openlayers viewer
|
801
|
$server = 'http://edit.csic.es/v1/areas.php';
|
802
|
$query_string .= '&img=false&legend=1&mlp=3';
|
803
|
$map_tdwg_Uri = url($server. '?' .$map_data_parameters->String, $query_string);
|
804
|
$legend_url_font_size = variable_get('cdm_dataportal_geoservice_legend_font_size', 10);
|
805
|
$legend_url_font_style = variable_get('cdm_dataportal_geoservice_legend_font_style', 1);
|
806
|
$legend_url_font_style = $fontStyles[$legend_url_font_style];
|
807
|
$legend_url_icon_width = variable_get('cdm_dataportal_geoservice_legend_icon_width', 35);
|
808
|
$legend_url_icon_height = variable_get('cdm_dataportal_geoservice_legend_icon_height', 15);
|
809
|
|
810
|
//#print($map_tdwg_Uri.'<br>');
|
811
|
|
812
|
//$map_tdwg_Uri ='http://edit.csic.es/v1/areas3_ol.php?l=earth&ad=tdwg4:c:UGAOO,SAROO,NZSOO,SUDOO,SPAAN,BGMBE,SICSI,TANOO,GEROO,SPASP,KENOO,SICMA,CLCBI,YUGMA,GRCOO,ROMOO,NZNOO,CLCMA,YUGSL,CLCLA,ALGOO,SWIOO,CLCSA,MDROO,HUNOO,ETHOO,BGMLU,COROO,BALOO,POROO,BALOO|e:CZESK,GRBOO|g:AUTAU|b:LBSLB,TUEOO|d:IREIR,AUTLI,POLOO,IRENI|f:NETOO,YUGCR|a:TUEOO,BGMBE,LBSLB||tdwg3:c:BGM,MOR,SPA,SIC,ITA,MOR,SPA,FRA|a:YUG,AUT&as=a:8dd3c7,,1|b:fdb462,,1|c:4daf4a,,1|d:ffff33,,1|e:bebada,,1|f:ff7f00,,1|g:377eb8,,1&&ms=610&bbox=-180,-90,180,90';
|
813
|
//$tdwg_sldFile = cdm_http_request($map_tdwg_Uri);
|
814
|
|
815
|
// get the respone from the map service
|
816
|
$responseObj = cdm_ws_get($map_tdwg_Uri, null, null, "GET", TRUE);
|
817
|
$responseObj = $responseObj[0];
|
818
|
|
819
|
// get the sld files from the response object
|
820
|
if(isset($responseObj->layers)){
|
821
|
if(isset($responseObj->legend)){
|
822
|
//$splittedLegendSldUrl = explode("http://edit.csic.es/v1/sld/", $responseObj->legend);
|
823
|
//$tdwg_sldLegend = $splittedLegendSldUrl[1];
|
824
|
$sldLegend=$responseObj->legend;
|
825
|
$legend_url ="http://edit.csic.es/geoserver/wms/GetLegendGraphic?SERVICE=WMS&VERSION=1.1.1&format=image".urlencode('/')."png&TRANSPARENT=TRUE";
|
826
|
$legend_url .= "&WIDTH=".$legend_url_icon_width."&HEIGHT=".$legend_url_icon_height."&";
|
827
|
$legend_url .="layer=topp".urlencode(':')."tdwg_level_4&LEGEND_OPTIONS=forceLabels".urlencode(':')."on;fontStyle".urlencode(':').$legend_url_font_style.";fontSize".urlencode(':').$legend_url_font_size."&SLD=".urlencode($sldLegend);
|
828
|
}
|
829
|
$layerSlds = $responseObj->layers;
|
830
|
foreach($layerSlds as $layer){
|
831
|
$tdwg_sldUris[$layer->tdwg] = "http://edit.csic.es/v1/sld/".$layer->sld;
|
832
|
//#print($tdwg_sldUris[$layer->tdwg].'<br>');
|
833
|
}
|
834
|
}
|
835
|
// get the bbox from the response object
|
836
|
$zoomto_bbox = ($bounding_box ? $bounding_box : ($responseObj->bbox ? $responseObj->bbox :'-180, -90, 180, 90') );
|
837
|
|
838
|
$add_tdwg1 = (isset($tdwg_sldUris['tdwg1']) ? "
|
839
|
tdwg_1.params.SLD = '".$tdwg_sldUris['tdwg1']."';
|
840
|
map.addLayers([tdwg_1]);" : '');
|
841
|
$add_tdwg2 = (isset($tdwg_sldUris['tdwg2']) ? "
|
842
|
tdwg_2.params.SLD = '".$tdwg_sldUris['tdwg2']."';
|
843
|
map.addLayers([tdwg_2]);" : '');
|
844
|
$add_tdwg3 = (isset($tdwg_sldUris['tdwg3']) ? "
|
845
|
tdwg_3.params.SLD = '".$tdwg_sldUris['tdwg3']."';
|
846
|
map.addLayers([tdwg_3]);" : '');
|
847
|
$add_tdwg4 = (isset($tdwg_sldUris['tdwg4']) ? "
|
848
|
tdwg_4.params.SLD = '".$tdwg_sldUris['tdwg4']."';
|
849
|
map.addLayers([tdwg_4]);" : '');
|
850
|
|
851
|
// $googleMapsApiKey_localhost = 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ';
|
852
|
// drupal_set_html_head(' <script src="http://maps.google.com/maps?file=api&v=2&key='.$googleMapsApiKey_localhost.'"></script>');
|
853
|
|
854
|
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
855
|
* OpenLayers.js must be loaded BEFORE jQuery.
|
856
|
* If jQuery loaded before $.something will fail in IE8.
|
857
|
* Therefore we add OpenLayers.js it in the page.tpl.php
|
858
|
* -----------------------------------------------------
|
859
|
* Andreas Kohlbecker [Feb 25th 2010]:
|
860
|
* This problems seems to be solved somehow (a bugfix in IE8?)
|
861
|
* so I am removing this "hack" by uncommenting the line below
|
862
|
*/
|
863
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/OpenLayers/OpenLayers.js', 'core', 'header');
|
864
|
drupal_add_js('
|
865
|
var map;
|
866
|
|
867
|
var layerOptions = {
|
868
|
maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90),
|
869
|
isBaseLayer: false,
|
870
|
displayInLayerSwitcher: false
|
871
|
};
|
872
|
|
873
|
var tdwg_1 = new OpenLayers.Layer.WMS.Untiled(
|
874
|
"tdwg level 1",
|
875
|
"http://edit.csic.es/geoserver/wms",
|
876
|
{layers:"topp:tdwg_level_1",transparent:"true", format:"image/png"},
|
877
|
layerOptions
|
878
|
);
|
879
|
|
880
|
var tdwg_2 = new OpenLayers.Layer.WMS.Untiled(
|
881
|
"tdwg level 2",
|
882
|
"http://edit.csic.es/geoserver/wms",
|
883
|
{layers:"topp:tdwg_level_2",transparent:"true", format:"image/png"},
|
884
|
layerOptions
|
885
|
);
|
886
|
|
887
|
var tdwg_3 = new OpenLayers.Layer.WMS.Untiled(
|
888
|
"tdwg level 3",
|
889
|
"http://edit.csic.es/geoserver/wms",
|
890
|
{layers:"topp:tdwg_level_3", transparent:"true", format:"image/png"},
|
891
|
layerOptions
|
892
|
);
|
893
|
|
894
|
var tdwg_4 = new OpenLayers.Layer.WMS.Untiled(
|
895
|
"tdwg level 4",
|
896
|
"http://edit.csic.es/geoserver/wms",
|
897
|
{layers:"topp:tdwg_level_4",transparent:"true", format:"image/png"},
|
898
|
layerOptions
|
899
|
);
|
900
|
|
901
|
// make baselayer
|
902
|
layerOptions[\'isBaseLayer\'] = true;
|
903
|
|
904
|
var ol_wms = new OpenLayers.Layer.WMS(
|
905
|
"OpenLayers WMS",
|
906
|
"http://labs.metacarta.com/wms/vmap0",
|
907
|
{layers: \'basic\'},
|
908
|
layerOptions
|
909
|
);
|
910
|
|
911
|
|
912
|
// ------------------------------
|
913
|
|
914
|
|
915
|
function init() {
|
916
|
|
917
|
var mapOptions={
|
918
|
controls:
|
919
|
[
|
920
|
new OpenLayers.Control.PanZoom(),
|
921
|
new OpenLayers.Control.Navigation({zoomWheelEnabled: false, handleRightClicks:true, zoomBoxKeyMask: OpenLayers.Handler.MOD_CTRL})
|
922
|
],
|
923
|
maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90),
|
924
|
maxResolution: '.(360 / $display_width).',
|
925
|
restrictedExtent: new OpenLayers.Bounds(-180, -90, 180, 90),
|
926
|
projection: new OpenLayers.Projection("EPSG:4326")
|
927
|
};
|
928
|
|
929
|
map = new OpenLayers.Map(\'openlayers_map\', mapOptions);
|
930
|
map.addLayers([ol_wms]);
|
931
|
'.$add_tdwg1.'
|
932
|
'.$add_tdwg2.'
|
933
|
'.$add_tdwg3.'
|
934
|
'.$add_tdwg4.'
|
935
|
map.zoomToExtent(new OpenLayers.Bounds('.$zoomto_bbox.'), false);
|
936
|
}
|
937
|
|
938
|
$(document).ready(function(){
|
939
|
init();
|
940
|
$(\'#openlayers_legend\').css(\'top\', -$(\'#openlayers_map\').height());
|
941
|
$(\'#openlayers_legend\').css(\'left\', $(\'#openlayers_map\').width()-100);
|
942
|
});'
|
943
|
, 'inline');
|
944
|
// showing openlayers
|
945
|
$out = '<div id="openlayers">';
|
946
|
$out .= '<div id="openlayers_map" class="smallmap" style="width: '.$display_width.'px; height:'.($display_width / 2).'px"></div>';
|
947
|
// showing lengeds
|
948
|
if (variable_get('cdm_dataportal_geoservice_legend_on', TRUE)){
|
949
|
$out .= '<div id="openlayers_legend"><img id="legend" src="'.$legend_url.'"></div>';
|
950
|
}
|
951
|
// showing map caption
|
952
|
$out .= '<div class="distribution_map_caption">' . variable_get('cdm_dataportal_geoservice_map_caption', '') . '</div>' . '<br>';
|
953
|
$out .= '</div>';
|
954
|
|
955
|
} else {
|
956
|
// simple image
|
957
|
$mapStaticCaption = '&mc_s=Georgia,15,blue&mc=' . variable_get('cdm_dataportal_geoservice_map_caption', '');
|
958
|
$query_string .= '&img=true&legend=1&mlp=3' . $mapStaticCaption . '&recalculate=false';
|
959
|
$mapUri = url($server. '?' .$map_data_parameters->String, $query_string);
|
960
|
$out .= '<img class="distribution_map" src="' . $mapUri . '" alt="Distribution Map" />';
|
961
|
}
|
962
|
/*
|
963
|
// add a simple legend
|
964
|
if(variable_get('cdm_dataportal_geoservice_legend_on', TRUE)){
|
965
|
$legenddata = array(
|
966
|
'native' => "4daf4a",
|
967
|
'native_doubtfully_native' => "377eb8",
|
968
|
'cultivated' => "984ea3",
|
969
|
'introduced' => "ff7f00",
|
970
|
'introduced adventitious' => "ffff33",
|
971
|
'introduced cultivated' => "a65628",
|
972
|
'introduced naturalized' => "f781bf"
|
973
|
);
|
974
|
|
975
|
$out .= '<div class="distribution_map_legend">';
|
976
|
foreach($legenddata as $term => $color){
|
977
|
$out .= '<img style="width: 3em; height: 1em; background-color: #'.$color.'" src="'.
|
978
|
drupal_get_path('module', 'cdm_dataportal').'/images/clear.gif" />'.t($term).' ';
|
979
|
}
|
980
|
$out .= '</div>';
|
981
|
|
982
|
}
|
983
|
*/
|
984
|
return $out;
|
985
|
}
|
986
|
}
|
987
|
|
988
|
function theme_cdm_taxonName($taxonName, $nameLink = NULL, $refenceLink = NULL, $renderPath = null){
|
989
|
|
990
|
|
991
|
|
992
|
$renderTemplate = get_nameRenderTemplate($renderPath, $nameLink, $refenceLink);
|
993
|
|
994
|
$partDefinition = get_partDefinition($taxonName->class);
|
995
|
|
996
|
// apply defintions to template
|
997
|
foreach($renderTemplate as $part=>$uri){
|
998
|
if(isset($partDefinition[$part])){
|
999
|
$renderTemplate[$part] = $partDefinition[$part];
|
1000
|
}
|
1001
|
if(is_array($uri)){
|
1002
|
$renderTemplate[$part]['#uri'] = $uri['#uri'];
|
1003
|
}
|
1004
|
}
|
1005
|
|
1006
|
$firstEntryIsValidNamePart = is_array($taxonName->taggedName)
|
1007
|
&& is_string($taxonName->taggedName[1]->text)
|
1008
|
&& $taxonName->taggedName[1]->text != ''
|
1009
|
&& $taxonName->taggedName[1]->type = 'name';
|
1010
|
// got to use second entry as first one, see ToDo comment below ...
|
1011
|
if($firstEntryIsValidNamePart){
|
1012
|
|
1013
|
$taggedName = $taxonName->taggedName;
|
1014
|
//TODO due to a bug in the cdmlib the taggedName alway has a lst empty element, we will remove it:
|
1015
|
array_pop($taggedName);
|
1016
|
|
1017
|
$lastAuthorElementString = false;
|
1018
|
$hasNamePart_with_Authors = isset($renderTemplate['namePart']) && isset($renderTemplate['namePart']['authors']);
|
1019
|
$hasNameAuthorPart_with_Authors = isset($renderTemplate['nameAuthorPart']) && isset($renderTemplate['nameAuthorPart']['authors']);
|
1020
|
|
1021
|
if(!($hasNamePart_with_Authors || $hasNameAuthorPart_with_Authors)){
|
1022
|
// // find author and split off from name
|
1023
|
// // TODO expecting to find the author as the last element
|
1024
|
// if($taggedName[count($taggedName)- 1]->type == 'authors'){
|
1025
|
// $authorTeam = $taggedName[count($taggedName)- 1]->text;
|
1026
|
// unset($taggedName[count($taggedName)- 1]);
|
1027
|
// }
|
1028
|
|
1029
|
// remove all authors
|
1030
|
$taggedNameNew = array();
|
1031
|
foreach($taggedName as $element){
|
1032
|
if($element->type != 'authors'){
|
1033
|
$taggedNameNew[] = $element;
|
1034
|
} else {
|
1035
|
$lastAuthorElementString = $element->text;
|
1036
|
}
|
1037
|
}
|
1038
|
$taggedName = $taggedNameNew;
|
1039
|
|
1040
|
}
|
1041
|
$name = '<span class="'.$taxonName->class.'">'.theme('cdm_taggedtext2html', $taggedName).'</span>';
|
1042
|
} else {
|
1043
|
$name = '<span class="'.$taxonName->class.'_titleCache">'.$taxonName->titleCache.'</span>';
|
1044
|
}
|
1045
|
|
1046
|
// fill name into $renderTemplate
|
1047
|
array_setr('name', $name, $renderTemplate);
|
1048
|
|
1049
|
// // fill with authorTeam
|
1050
|
// if($authorTeam){
|
1051
|
// $authorTeamHtml = ' <span class="authorTeam">'.$authorTeam.'</span>';
|
1052
|
// array_setr('authorTeam', $authorTeamHtml, $renderTemplate);
|
1053
|
// }
|
1054
|
|
1055
|
|
1056
|
// fill with reference
|
1057
|
if(isset($renderTemplate['referencePart'])){
|
1058
|
|
1059
|
// [Eckhard]:"Komma nach dem Taxonnamen ist grunsätzlich falsch,
|
1060
|
// Komma nach dem Autornamen ist überall dort falsch, wo ein "in" folgt."
|
1061
|
if(isset($renderTemplate['referencePart']['reference']) && $taxonName->nomenclaturalReference){
|
1062
|
$microreference = null;
|
1063
|
if(isset($renderTemplate['referencePart']['microreference'])){
|
1064
|
$microreference = $taxonName->nomenclaturalMicroReference;
|
1065
|
}
|
1066
|
$citation = cdm_ws_get(CDM_WS_NOMENCLATURAL_REFERENCE_CITATION, array($taxonName->nomenclaturalReference->uuid, $microreference));
|
1067
|
$citation = $citation->String;
|
1068
|
// find preceding element of the refrence
|
1069
|
$precedingKey = get_preceding_contentElementKey('reference', $renderTemplate);
|
1070
|
if(str_beginsWith($citation, ", in")){
|
1071
|
$citation = substr($citation, 2);
|
1072
|
$separator = ' ';
|
1073
|
} else if(!str_beginsWith($citation, "in") && $precedingKey == 'authors'){
|
1074
|
$separator = ', ';
|
1075
|
} else {
|
1076
|
$separator = ' ';
|
1077
|
}
|
1078
|
|
1079
|
$referenceArray['#separator'] = $separator;
|
1080
|
$referenceArray['#html'] = '<span class="reference">'.$citation.'</span>';
|
1081
|
array_setr('reference', $referenceArray, $renderTemplate);
|
1082
|
}
|
1083
|
|
1084
|
// if authors have been removed from the name part the last named authorteam
|
1085
|
// should be added to the reference citation, otherwise, keep the separator
|
1086
|
// out of the reference
|
1087
|
if(isset($renderTemplate['referencePart']['authors']) && $lastAuthorElementString){
|
1088
|
// if the nomenclaturalReference cintation is not included in the reference part but diplay of the microreference
|
1089
|
// is whanted append the microreference to the authorTeam
|
1090
|
if(!isset($renderTemplate['referencePart']['reference']) && isset($renderTemplate['referencePart']['microreference'])){
|
1091
|
$separator = ": ";
|
1092
|
$citation = $taxonName->nomenclaturalMicroReference;
|
1093
|
}
|
1094
|
$referenceArray['#html'] = ' <span class="reference">'.$lastAuthorElementString.$separator.$citation.'</span>';
|
1095
|
array_setr('authors', $referenceArray, $renderTemplate);
|
1096
|
}
|
1097
|
|
1098
|
}
|
1099
|
|
1100
|
// fill with status
|
1101
|
if(array_setr('status', true, $renderTemplate)){
|
1102
|
if(isset($taxon->name->status[0])){
|
1103
|
foreach($taxon->name->status as $status){
|
1104
|
$statusHtml .= ', '.$status->type->representation_L10n;
|
1105
|
}
|
1106
|
}
|
1107
|
array_setr('status', ' <span class="nomenclatural_status">'.$statusHtml.'</span>', $renderTemplate);
|
1108
|
}
|
1109
|
|
1110
|
// fill with protologues etc...
|
1111
|
if(array_setr('description', true, $renderTemplate)){
|
1112
|
$descriptions = cdm_ws_get(CDM_WS_NAME_DESCRIPTIONS, $taxonName->uuid);
|
1113
|
foreach($descriptions as $description){
|
1114
|
if(!empty($description)){
|
1115
|
foreach($description->elements as $description_element){
|
1116
|
$descriptionHtml .= theme("cdm_media", $description_element, array('application/pdf', 'image/png', 'image/jpeg', 'image/gif', 'text/html'));
|
1117
|
}
|
1118
|
}
|
1119
|
}
|
1120
|
array_setr('description', $descriptionHtml, $renderTemplate);
|
1121
|
}
|
1122
|
|
1123
|
// render
|
1124
|
$out = '<span ref="/name/'.$taxonName->uuid.'">';
|
1125
|
foreach($renderTemplate as $partName=>$part){
|
1126
|
$separator = '';
|
1127
|
$partHtml = '';
|
1128
|
$uri = false;
|
1129
|
if(!is_array($part)){
|
1130
|
continue;
|
1131
|
}
|
1132
|
if(isset($part['#uri']) && is_string($part['#uri'])){
|
1133
|
$uri = $part['#uri'];
|
1134
|
unset($part['#uri']);
|
1135
|
}
|
1136
|
foreach($part as $key=>$content){
|
1137
|
$html = '';
|
1138
|
if(is_array($content)){
|
1139
|
$html = $content['#html'];
|
1140
|
$separator = $content['#separator'];
|
1141
|
} else if(is_string($content)){
|
1142
|
$html = $content;
|
1143
|
}
|
1144
|
$partHtml .= '<span class="'.$key.'">'.$html.'</span>';
|
1145
|
}
|
1146
|
if($uri){
|
1147
|
$out .= $separator.'<a href="'.$uri.'" class="'.$partName.'">'.$partHtml.'</a>';
|
1148
|
} else {
|
1149
|
$out .= $separator.$partHtml;
|
1150
|
}
|
1151
|
}
|
1152
|
|
1153
|
return $out.'</span>';
|
1154
|
}
|
1155
|
|
1156
|
/**
|
1157
|
* Recursively searches the array for the $key and sets the given value
|
1158
|
* @param $key
|
1159
|
* @param $value
|
1160
|
* @param $array
|
1161
|
* @return true if the key has been found
|
1162
|
*/
|
1163
|
function &array_setr($key, $value, array &$array){
|
1164
|
foreach($array as $k=>&$v){
|
1165
|
if($key == $k){
|
1166
|
$v = $value;
|
1167
|
return $array;
|
1168
|
} else if(is_array($v)){
|
1169
|
$innerArray = array_setr($key, $value, $v);
|
1170
|
if($innerArray){
|
1171
|
return $array;
|
1172
|
}
|
1173
|
}
|
1174
|
}
|
1175
|
return null;
|
1176
|
}
|
1177
|
|
1178
|
function &get_preceding_contentElement($contentElementKey, array &$renderTemplate){
|
1179
|
$precedingElement = null;
|
1180
|
foreach($renderTemplate as &$part){
|
1181
|
foreach($part as $key=>&$element){
|
1182
|
if($key == $contentElementKey){
|
1183
|
return $precedingElement;
|
1184
|
}
|
1185
|
$precedingElement = $element;
|
1186
|
}
|
1187
|
}
|
1188
|
return null;
|
1189
|
}
|
1190
|
|
1191
|
function &get_preceding_contentElementKey($contentElementKey, array &$renderTemplate){
|
1192
|
$precedingKey = null;
|
1193
|
foreach($renderTemplate as &$part){
|
1194
|
foreach($part as $key=>&$element){
|
1195
|
if($key == $contentElementKey){
|
1196
|
return $precedingKey;
|
1197
|
}
|
1198
|
if(!str_beginsWith($key, '#')){
|
1199
|
$precedingKey = $key;
|
1200
|
}
|
1201
|
}
|
1202
|
}
|
1203
|
return null;
|
1204
|
}
|
1205
|
|
1206
|
|
1207
|
function theme_cdm_related_taxon($taxon, $reltype_uuid = '', $displayNomRef = true){
|
1208
|
|
1209
|
$relsign = '';
|
1210
|
$name_prefix = '';
|
1211
|
$name_postfix = '';
|
1212
|
switch ($reltype_uuid){
|
1213
|
case UUID_HETEROTYPIC_SYNONYM_OF:
|
1214
|
case UUID_SYNONYM_OF:
|
1215
|
$relsign = '=';
|
1216
|
break;
|
1217
|
case UUID_HOMOTYPIC_SYNONYM_OF:
|
1218
|
$relsign = '≡';
|
1219
|
break;
|
1220
|
case UUID_MISAPPLIED_NAME_FOR:
|
1221
|
case UUID_INVALID_DESIGNATION_FOR:
|
1222
|
$relsign = '–'; // – — −
|
1223
|
$name_prefix = '"';
|
1224
|
$name_postfix = '"';
|
1225
|
break;
|
1226
|
default :
|
1227
|
$relsign = '–';
|
1228
|
}
|
1229
|
|
1230
|
$renderPath = 'related_taxon';
|
1231
|
|
1232
|
//$taxonUri = url(path_to_taxon($taxon->uuid));
|
1233
|
if($taxon->name->nomenclaturalReference){
|
1234
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
1235
|
}
|
1236
|
$nameHtml = theme('cdm_taxonName', $taxon->name, $taxonUri, $referenceUri, $renderPath);
|
1237
|
|
1238
|
$out = '<span class="relation_sign">'.$relsign.'</span>'.$name_prefix . $nameHtml . $name_postfix;
|
1239
|
|
1240
|
return uuid_anchor($taxon->uuid, $out);
|
1241
|
|
1242
|
}
|
1243
|
|
1244
|
/**
|
1245
|
* will theme form elements of type 'select_secuuid'
|
1246
|
* see $form['cdm_dataportal']['secuuid_widget']
|
1247
|
* @param FormElement $element
|
1248
|
*/
|
1249
|
function theme_select_secuuid($element) {
|
1250
|
|
1251
|
$default_uuid = variable_get($element['#varname'], false);
|
1252
|
|
1253
|
$tree = cdm_taxontree_build_tree(null, false); // get root nodes
|
1254
|
$secUuids = array();
|
1255
|
foreach($tree as $node){
|
1256
|
$secUuids[] = $node->secUuid;
|
1257
|
}
|
1258
|
cdm_api_secref_cache_prefetch($secUuids);
|
1259
|
|
1260
|
theme('cdm_taxontree_add_scripts');
|
1261
|
drupal_add_js('$(document).ready(function() {$(\'ul.cdm_taxontree\').cdm_taxontree(
|
1262
|
{
|
1263
|
widget: true,
|
1264
|
element_name: \''.$element['#varname'].'\', //
|
1265
|
multiselect: '.($element['#multiple']?'true':'false').', //
|
1266
|
}
|
1267
|
);});', 'inline');
|
1268
|
|
1269
|
$out = '<div class="cdm_taxontree_widget">';
|
1270
|
$out .= '<div class="taxontree">'.theme('cdm_taxontree', $tree, NULL, FALSE, 'cdm_taxontree_node_reference').'</div>';
|
1271
|
$out .= $element['#children'].'<div style="clear: both;" /></div>';
|
1272
|
|
1273
|
return theme(
|
1274
|
'form_element',
|
1275
|
array(
|
1276
|
'#title' => $element['#title'],
|
1277
|
'#description' => $element['#description'],
|
1278
|
'#id' => $element['#id'],
|
1279
|
'#required' => $element['#required'],
|
1280
|
'#error' => $element['#error'],
|
1281
|
),
|
1282
|
$out
|
1283
|
);
|
1284
|
}
|
1285
|
|
1286
|
function theme_cdm_dynabox($label, $content_url, $theme, $enclosingtag = 'li'){
|
1287
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_dynabox.js');
|
1288
|
|
1289
|
$cdm_proxy_url = url('cdm_api/proxy/'.urlencode($content_url)."/$theme");
|
1290
|
$out .= '<li class="dynabox"><span class="label" alt="'.t('Click for accepted taxon').'">'.$label.'</span>';
|
1291
|
$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>';
|
1292
|
return $out;
|
1293
|
}
|
1294
|
|
1295
|
function theme_cdm_list_of_taxa($records, $showMedia = false){
|
1296
|
|
1297
|
$renderPath = 'list_of_taxa';
|
1298
|
|
1299
|
$showMedia_taxa = variable_get('cdm_dataportal_findtaxa_show_taxon_thumbnails', 1);
|
1300
|
$showMedia_synonyms = variable_get('cdm_dataportal_findtaxa_show_synonym_thumbnails', 0);
|
1301
|
|
1302
|
// .. well, for sure not as performant as before, but better than nothing.
|
1303
|
$synonym_uuids = array();
|
1304
|
foreach($records as $taxon){
|
1305
|
if($taxon->class != "Taxon"){
|
1306
|
if(!array_key_exists($taxon->uuid, $synonym_uuids)){
|
1307
|
$synonym_uuids[$taxon->uuid] = $taxon->uuid;
|
1308
|
}
|
1309
|
}
|
1310
|
}
|
1311
|
// batch service not jet implemented:
|
1312
|
// $table_of_accepted = cdm_ws_property(CDM_WS_TAXON_ACCEPTED, join(',', $synonym_uuids));
|
1313
|
// thus ...
|
1314
|
$table_of_accepted = array();
|
1315
|
foreach($synonym_uuids as $synUuid){
|
1316
|
$table_of_accepted[$synUuid] = cdm_ws_get(CDM_WS_TAXON_ACCEPTED, $synUuid);
|
1317
|
}
|
1318
|
|
1319
|
$out = '<ul class="cdm_names" style="background-image: none;">';
|
1320
|
|
1321
|
foreach($records as $taxon){
|
1322
|
// its a Taxon
|
1323
|
if($taxon->class == "Taxon"){
|
1324
|
$taxonUri = url(path_to_taxon($taxon->uuid));
|
1325
|
if(isset($taxon->name->nomenclaturalReference)){
|
1326
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
1327
|
}
|
1328
|
$out .= '<li class="Taxon">'.theme('cdm_taxonName', $taxon->name, $taxonUri, $referenceUri, $renderPath);
|
1329
|
if($showMedia_taxa){
|
1330
|
$out .= theme('cdm_taxon_list_thumbnails', $taxon);
|
1331
|
}
|
1332
|
$out .= '</li>';
|
1333
|
} else {
|
1334
|
// its a synonym
|
1335
|
$uuid = $taxon->uuid;
|
1336
|
$acceptedTaxa = $table_of_accepted[$uuid];
|
1337
|
if(count($acceptedTaxa) == 1){
|
1338
|
$acceptedTaxon = $acceptedTaxa[0];
|
1339
|
$taxonUri = uri_to_synonym($taxon->uuid, $acceptedTaxon->uuid, 'synonymy');
|
1340
|
if(isset($acceptedTaxon->name->nomenclaturalReference)){
|
1341
|
$referenceUri = url(path_to_reference($acceptedTaxon->name->nomenclaturalReference->uuid));
|
1342
|
}
|
1343
|
$out .= '<li class="Synonym">'.theme('cdm_taxonName', $taxon->name, $taxonUri, $referenceUri, $renderPath);
|
1344
|
if($showMedia_synonyms){
|
1345
|
$out .= theme('cdm_taxon_list_thumbnails', $acceptedTaxon);
|
1346
|
}
|
1347
|
$out .= '</li>';
|
1348
|
} else {
|
1349
|
//TODO avoid using Ajax in the cdm_dynabox
|
1350
|
//TODO add media
|
1351
|
$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');
|
1352
|
}
|
1353
|
}
|
1354
|
}
|
1355
|
$out .= '</ul>';
|
1356
|
return $out;
|
1357
|
}
|
1358
|
|
1359
|
|
1360
|
function theme_cdm_credits(){
|
1361
|
return null;
|
1362
|
$secRef_array = _cdm_dataportal_currentSecRef_array();
|
1363
|
return '<span class="sec_reference_citation">'.$secRef_array['citation'].'</span>'
|
1364
|
.( $secRef_array['period'] ? ' <span class="year">'.partialToYear($secRef_array['period']).'</span>' : '')
|
1365
|
.( $secRef_array['authorTeam'] ? '<div class="author">'.$secRef_array['authorTeam']['titleCache'].'</div>' : '');
|
1366
|
}
|
1367
|
|
1368
|
|
1369
|
function theme_cdm_print_button(){
|
1370
|
|
1371
|
drupal_add_js ('$(document).ready(function() {
|
1372
|
$(\'#print_button\').click(function () {
|
1373
|
window.print();
|
1374
|
});
|
1375
|
});', 'inline');
|
1376
|
|
1377
|
$output = '<div id="print_button"><img src="'
|
1378
|
.drupal_get_path('module', 'cdm_dataportal').'/images/print_icon.gif'
|
1379
|
. ' "alt="' . t('Print this page') . ' "title="'.t('Print this page').'" />'; //.t(' Print this page');
|
1380
|
//$output .= l(' Print this page', '');
|
1381
|
$output .= '<span>Print this page</span>';
|
1382
|
$output .= '</div>';
|
1383
|
|
1384
|
return $output;
|
1385
|
}
|
1386
|
|
1387
|
/**
|
1388
|
* @deprecated ??
|
1389
|
*/
|
1390
|
function theme_cdm_reference($reference, $linkToReference = FALSE, $style = NULL ){
|
1391
|
|
1392
|
if($style == "ZoologicalName"){
|
1393
|
$year = partialToYear($reference->datePublished->start);
|
1394
|
$citation = $reference->authorTeam->titleCache.($year ? ', '.$year : '');
|
1395
|
} else {
|
1396
|
$citation = $reference->titleCache;
|
1397
|
}
|
1398
|
if($linkToReference){
|
1399
|
return l('<span class="reference">'.$citation.'</span>', "/cdm_dataportal/reference/".$reference->uuid, array("class"=>"reference"), NULL, NULL, FALSE ,TRUE);
|
1400
|
} else {
|
1401
|
return '<span class="reference">'.$citation.'</span>';
|
1402
|
}
|
1403
|
}
|
1404
|
|
1405
|
/**
|
1406
|
* Enter description here...
|
1407
|
*
|
1408
|
* @param unknown_type $referenceSTO a referenceSTO or referenceTO instance
|
1409
|
* @param unknown_type $cssClass
|
1410
|
* @param unknown_type $separator
|
1411
|
* @param unknown_type $enclosingTag
|
1412
|
* @return unknown
|
1413
|
*/
|
1414
|
function theme_cdm_nomenclaturalReference($name, $doLink = FALSE, $displayMicroreference = TRUE, $displayPages = FALSE, $enclosingTag = 'span'){
|
1415
|
|
1416
|
if(!$name->nomenclaturalReference){
|
1417
|
return;
|
1418
|
}
|
1419
|
|
1420
|
$reference = $name->nomenclaturalReference;
|
1421
|
|
1422
|
// different display for ZoologicalNames and others
|
1423
|
if($name->class == ZoologicalName){
|
1424
|
$year = partialToYear($reference->datePublished->start);
|
1425
|
$citation = $reference->authorTeam->titleCache.($year ? ', '.$year : '');
|
1426
|
} else {
|
1427
|
// BotanicalName and others
|
1428
|
$citation = $reference->titleCache;
|
1429
|
}
|
1430
|
|
1431
|
if($doLink){
|
1432
|
$citationHtml = l($citation, "/cdm_dataportal/reference/".$reference->uuid, array(), NULL, NULL, FALSE, TRUE);
|
1433
|
} else {
|
1434
|
$citationHtml = $citation;
|
1435
|
}
|
1436
|
|
1437
|
if(!empty($citation)){
|
1438
|
$citationHtml = (str_beginsWith($citation, 'in') ? ' ':', ') . $citationHtml;
|
1439
|
if($displayMicroreference && $name->nomenclaturalMicroReference){
|
1440
|
$microreference = '<span class="pages">: ' . $name->nomenclaturalMicroReference . '</span>';
|
1441
|
}
|
1442
|
if($displayPages){ //TODO substitute for microreference in dipterea? -> check theme.php#L85
|
1443
|
$citation .= ': '.$reference->pages;
|
1444
|
}
|
1445
|
$citationHtml .= $microreference;
|
1446
|
}
|
1447
|
|
1448
|
|
1449
|
return '<'.$enclosingTag.' class="reference">'.$citationHtml.'</'.$enclosingTag.'>'; ;
|
1450
|
}
|
1451
|
|
1452
|
/**
|
1453
|
* Allows theming of the taxon page tabs
|
1454
|
*
|
1455
|
* @param $tabname
|
1456
|
* @return unknown_type
|
1457
|
*/
|
1458
|
function theme_cdm_taxonpage_tab($tabname){
|
1459
|
//TODO replace by using translations or theme the menue tabs itself instead?
|
1460
|
switch($tabname){
|
1461
|
default: return t($tabname);
|
1462
|
}
|
1463
|
}
|
1464
|
|
1465
|
/**
|
1466
|
* default title for a taxon page
|
1467
|
*
|
1468
|
* @param NameTO $nameTO
|
1469
|
* @return the formatted taxon name
|
1470
|
*/
|
1471
|
function theme_cdm_taxon_page_title($taxon){
|
1472
|
|
1473
|
$renderPath = 'taxon_page_title';
|
1474
|
if(isset($taxon->name->nomenclaturalReference)){
|
1475
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
1476
|
}
|
1477
|
return '<span class="'.$taxon->class.'">'.theme('cdm_taxonName', $taxon->name, null, $referenceUri, $renderPath).'</span>';
|
1478
|
}
|
1479
|
|
1480
|
|
1481
|
function theme_cdm_acceptedFor($renderPath = false){
|
1482
|
$out = '';
|
1483
|
if(!$renderPath){
|
1484
|
$renderPath = 'acceptedFor';
|
1485
|
}
|
1486
|
if(isset($_REQUEST['acceptedFor'])){
|
1487
|
|
1488
|
$synonym = cdm_ws_get(CDM_WS_TAXON, $_REQUEST['acceptedFor']);
|
1489
|
|
1490
|
if($synonym){
|
1491
|
$out .= '<span class="acceptedFor">';
|
1492
|
$out .= t('is accepted for ');
|
1493
|
if(isset($synonym->name->nomenclaturalReference)){
|
1494
|
$referenceUri = url(path_to_reference($synonym->name->nomenclaturalReference->uuid));
|
1495
|
}
|
1496
|
$out .= theme('cdm_taxonName', $synonym->name, null, $referenceUri, $renderPath);
|
1497
|
$out .= '</span>';
|
1498
|
}
|
1499
|
}
|
1500
|
|
1501
|
return $out;
|
1502
|
}
|
1503
|
|
1504
|
function theme_cdm_back_to_search_result_button(){
|
1505
|
$out = '';
|
1506
|
if($_SESSION['cdm']['search']){
|
1507
|
/*['cdm']['last_search']*/
|
1508
|
//$out .= '<div id="backButton">'.l(t('Back to search result'), $_SESSION ).'</div>';
|
1509
|
$out .= '<div id="backButton">'.l(t('Back to search result'), "http://" . $_SERVER['SERVER_NAME'] . $_SESSION['cdm']['last_search'] ).'</div>';
|
1510
|
|
1511
|
}
|
1512
|
return $out;
|
1513
|
}
|
1514
|
|
1515
|
function theme_cdm_back_to_image_gallery_button(){
|
1516
|
//$galleryLinkUri = path_to_taxon($taxon->uuid).'/images';
|
1517
|
//$gallery_name = $taxon->uuid;
|
1518
|
//$mediaList = cdm_ws_get(CDM_WS_TAXON_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
|
1519
|
|
1520
|
$out = '<div id="backToGalleryButton">'.l(t('Back to Images'), $_SESSION['cdm']['last_gallery'] ).'</div>';
|
1521
|
|
1522
|
return $out;
|
1523
|
}
|
1524
|
|
1525
|
|
1526
|
/**
|
1527
|
* A wrapper function that groups available information to show by default, when
|
1528
|
* a taxon page is requested by the browser.
|
1529
|
* Individual themeing has to decide what this page should include (see methods beneath)
|
1530
|
* and what information should go into tabs or should not be shown at all.
|
1531
|
*
|
1532
|
* It is headed by the name of the accepted taxon without author and reference.
|
1533
|
* @param $taxonTO the taxon object
|
1534
|
* @param $page_part name of the part to display,
|
1535
|
* valid values are: 'description', 'images', 'synonymy', 'all'
|
1536
|
*/
|
1537
|
function theme_cdm_taxon_page_general($taxon, $page_part = 'description') {
|
1538
|
|
1539
|
global $theme;
|
1540
|
|
1541
|
$page_part = variable_get('cdm_dataportal_taxonpage_tabs', 1) ? $page_part : 'all';
|
1542
|
$hideTabs = array();
|
1543
|
|
1544
|
|
1545
|
// get images
|
1546
|
$prefMimeTypeRegex = 'image:.*';
|
1547
|
$prefMediaQuality = '*';
|
1548
|
//$media = cdm_ws_get(CDM_WS_TAXONOMY_MEDIA, array(variable_get('cdm_taxonomictree_uuid', false),$taxon->uuid));
|
1549
|
|
1550
|
|
1551
|
$selectShowMedia = variable_get('cdm_dataportal_show_media', 0);
|
1552
|
if ($selectShowMedia == 0){
|
1553
|
$media = cdm_ws_get(CDM_WS_TAXON_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
|
1554
|
}else{
|
1555
|
$media = cdm_ws_get(CDM_WS_TAXON_SUBTREE_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
|
1556
|
}
|
1557
|
/*
|
1558
|
if(!isset($mediaList[0])) {
|
1559
|
$hideTabs[] = theme('cdm_taxonpage_tab', 'Images');
|
1560
|
}
|
1561
|
*/
|
1562
|
|
1563
|
if(!isset($media[0])) {
|
1564
|
$hideTabs[] = theme('cdm_taxonpage_tab', 'Images');
|
1565
|
}
|
1566
|
|
1567
|
// hideImage flag depending on administative preset
|
1568
|
$hideImages = false;
|
1569
|
if(variable_get('image_hide_rank', '0') != '0'){
|
1570
|
$rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
|
1571
|
$hideImages = ($rankCompare > -1);
|
1572
|
}
|
1573
|
// $hideTabs[] = theme('cdm_taxonpage_tab', 'General');
|
1574
|
// $hideTabs[] = theme('cdm_taxonpage_tab', 'Synonymy')
|
1575
|
|
1576
|
// hide tabs
|
1577
|
$tabhide_js = '';
|
1578
|
foreach($hideTabs as $tabText) {
|
1579
|
$tabhide_js .= "$('.tabs.primary').children('li').children('a:contains(\"$tabText\")').hide();\n";
|
1580
|
}
|
1581
|
drupal_add_js("
|
1582
|
$(document).ready(function(){
|
1583
|
$tabhide_js
|
1584
|
});", 'inline');
|
1585
|
|
1586
|
$out = '';
|
1587
|
$out .= theme('cdm_back_to_search_result_button');
|
1588
|
if(variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR)){
|
1589
|
$out .= theme('cdm_acceptedFor', 'page_general');
|
1590
|
}
|
1591
|
// --- DESCRIPTION --- //
|
1592
|
if($page_part == 'description' || $page_part == 'all'){
|
1593
|
|
1594
|
$featureTree = cdm_ws_get(CDM_WS_FEATURETREE, variable_get('cdm_dataportal_featuretree_uuid', false));
|
1595
|
$taxonDescriptions = cdm_ws_get(CDM_WS_TAXON_DESCRIPTIONS, $taxon->uuid);
|
1596
|
$mergedTrees = cdm_ws_descriptions_by_featuretree($featureTree, $taxonDescriptions, variable_get('cdm_dataportal_descriptions_separated', FALSE));
|
1597
|
|
1598
|
$out .= '<div id="general">';
|
1599
|
$out .= theme('cdm_taxon_page_description', $taxon, $mergedTrees, $media, $hideImages);
|
1600
|
$out .= '</div>';
|
1601
|
}
|
1602
|
// --- IMAGES --- //
|
1603
|
if(!$hideImages && $page_part == 'images' || $page_part == 'all'){
|
1604
|
$out .= '<div id="images">';
|
1605
|
if($page_part == 'all'){
|
1606
|
$out .= '<h2>'.t('Images').'</h2>';
|
1607
|
}
|
1608
|
$out .= theme('cdm_taxon_page_images', $taxon, $media);
|
1609
|
$out .= '</div>';
|
1610
|
|
1611
|
if($theme == 'garland_cichorieae'){
|
1612
|
$out .= theme('cdm_taxon_page_images_cichorieae_copyright');
|
1613
|
}
|
1614
|
|
1615
|
}
|
1616
|
// --- SYNONYMY --- //
|
1617
|
if($page_part == 'synonymy' || $page_part == 'all'){
|
1618
|
$out .= '<div id="synonymy">';
|
1619
|
if($page_part == 'all'){
|
1620
|
$out .= '<h2>'.t('Synonymy').'</h2>';
|
1621
|
}
|
1622
|
$addAcceptedTaxon = !variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE);
|
1623
|
$out .= theme('cdm_taxon_page_synonymy', $taxon, $addAcceptedTaxon);
|
1624
|
|
1625
|
if(variable_get('cdm_dataportal_display_name_relations', 1)){
|
1626
|
|
1627
|
$nameRelationships = cdm_ws_get(CDM_WS_TAXON_NAMERELATIONS, $taxon->uuid);
|
1628
|
// TODO is it correct to skip relationsFromThisName since all relationships are to be understood as 'is .... of'
|
1629
|
if(variable_get('cdm_dataportal_name_relations_skiptype_basionym', 1)){
|
1630
|
$skip = array(UUID_BASIONYM);
|
1631
|
}
|
1632
|
$out .= theme('cdm_nameRelations', $nameRelationships, $skip);
|
1633
|
}
|
1634
|
$out .= '</div>';
|
1635
|
}
|
1636
|
|
1637
|
return $out;
|
1638
|
}
|
1639
|
|
1640
|
/**
|
1641
|
* Outputs all descriptive data and shows the preferred picture of the
|
1642
|
* accepted taxon.
|
1643
|
*
|
1644
|
*/
|
1645
|
function theme_cdm_taxon_page_description($taxon, $mergedTrees, $media = null, $hideImages = false){
|
1646
|
|
1647
|
// if(!$hideImages){
|
1648
|
// // preferred image
|
1649
|
// // hardcoded for testing;
|
1650
|
// $defaultRepresentationPart = false;
|
1651
|
// $defaultRepresentationPart->width = 184;
|
1652
|
// $defaultRepresentationPart->height = 144;
|
1653
|
// $defaultRepresentationPart->uri = drupal_get_path('theme', 'palmweb_2').'/images/no_picture.png';
|
1654
|
//
|
1655
|
// // preferred image size 184px × 144
|
1656
|
// $imageMaxExtend = 184;
|
1657
|
// $out .= '<div class="preferredImage">'.$defaultRepresentationPart->uri.theme('cdm_preferredImage', $media, $defaultRepresentationPart, $imageMaxExtend).'</div>';
|
1658
|
// }
|
1659
|
|
1660
|
// description TOC
|
1661
|
$out .= theme('cdm_featureTreeTOCs', $mergedTrees);
|
1662
|
// description
|
1663
|
$out .= theme('cdm_featureTrees', $mergedTrees, $taxon);
|
1664
|
return $out;
|
1665
|
}
|
1666
|
|
1667
|
/**
|
1668
|
* Show whole synonymy for the accepted taxon. Synonymy list is headed by the complete scientific name
|
1669
|
* of the accepted taxon with nomenclatural reference.
|
1670
|
*
|
1671
|
*/
|
1672
|
function theme_cdm_taxon_page_synonymy($taxon, $addAcceptedTaxon){
|
1673
|
|
1674
|
$renderPath = 'taxon_page_synonymy';
|
1675
|
$synomymie = cdm_ws_get(CDM_WS_TAXON_SYNONYMY, $taxon->uuid);
|
1676
|
$taxonRelationships = cdm_ws_get(CDM_WS_TAXON_RELATIONS, $taxon->uuid);
|
1677
|
$skip = array(UUID_BASIONYM);
|
1678
|
|
1679
|
if($addAcceptedTaxon){
|
1680
|
if(isset($taxon->name->nomenclaturalReference)){
|
1681
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
1682
|
}
|
1683
|
$out .= theme('cdm_taxonName', $taxon->name, null, $referenceUri, $renderPath);
|
1684
|
}
|
1685
|
|
1686
|
if($addAcceptedTaxon && !isset($synomymie->homotypicSynonymsByHomotypicGroup[0])){
|
1687
|
// display the type information for the added taxon
|
1688
|
$typeDesignations = cdm_ws_get(CDM_WS_TAXON_NAMETYPEDESIGNATIONS, $taxon->uuid);
|
1689
|
if($typeDesignations){
|
1690
|
$out .= theme('cdm_typedesignations', $typeDesignations);
|
1691
|
}
|
1692
|
} else {
|
1693
|
// reder the homotypicSynonymyGroup including the type information
|
1694
|
$out .= theme('cdm_homotypicSynonymyGroup', $synomymie->homotypicSynonymsByHomotypicGroup);
|
1695
|
}
|
1696
|
if($synomymie->heterotypicSynonymyGroups) {
|
1697
|
foreach($synomymie->heterotypicSynonymyGroups as $homotypicalGroup){
|
1698
|
$out .= theme('cdm_heterotypicSynonymyGroup', $homotypicalGroup);
|
1699
|
}
|
1700
|
}
|
1701
|
|
1702
|
$out .= theme('cdm_taxonRelations', $taxonRelationships, $skip);
|
1703
|
|
1704
|
return $out;
|
1705
|
}
|
1706
|
|
1707
|
/**
|
1708
|
* Show the collection of images stored with the accepted taxon
|
1709
|
*
|
1710
|
*/
|
1711
|
function theme_cdm_taxon_page_images($taxon, $media){
|
1712
|
|
1713
|
$hasImages = isset($media[0]);
|
1714
|
|
1715
|
if($hasImages){
|
1716
|
//
|
1717
|
$maxExtend = 150;
|
1718
|
$cols = 3;
|
1719
|
$maxRows = false;
|
1720
|
$alternativeMediaUri = null;
|
1721
|
$captionElements = array('title', 'rights', '#uri'=>t('open Image'));
|
1722
|
$gallery_name = $taxon->uuid;
|
1723
|
$mediaLinkType = 'LIGHTBOX';
|
1724
|
$out = '<div class="image-gallerie">';
|
1725
|
//$out .= theme('cdm_media_gallerie', $media, $gallery_name, $maxExtend, $cols, $maxRows, $captionElements, $mediaLinkType, null);
|
1726
|
$out .= theme('cdm_media_gallery_wrapper', $media, $gallery_name, CDM_DATAPORTAL_MEDIA_GALLERY_FORM_NAME);
|
1727
|
$out .= '</div>';
|
1728
|
}else{
|
1729
|
$out = 'No images available.';
|
1730
|
|
1731
|
}
|
1732
|
return $out;
|
1733
|
|
1734
|
}
|
1735
|
|
1736
|
function theme_cdm_reference_pager($referencePager, $path, $parameters = array()){
|
1737
|
drupal_set_title(t('Bibliographic Index'));
|
1738
|
$out = '';
|
1739
|
if(count($referencePager->records) > 0){
|
1740
|
$out .= '<ul>';
|
1741
|
foreach($referencePager->records as $reference){
|
1742
|
$reference->fullCitation = $reference->titleCache; //FIXME remove hack for matching cdm entity to STO
|
1743
|
$out .= '<li>'.theme('cdm_reference', $reference, TRUE).'</li>';
|
1744
|
}
|
1745
|
$out .= '</ul>';
|
1746
|
$out .= theme('cdm_pager', $referencePager, $path, $parameters);
|
1747
|
} else {
|
1748
|
$out = '<h4 class="error">Sorry, this page contains not entries.</h4>';
|
1749
|
}
|
1750
|
return $out;
|
1751
|
}
|
1752
|
|
1753
|
/**
|
1754
|
* Show a reference in it's atomized form
|
1755
|
*/
|
1756
|
function theme_cdm_reference_page($referenceTO){
|
1757
|
|
1758
|
/*
|
1759
|
if($referenceTO->titleCache) {
|
1760
|
drupal_set_title($referenceTO->titleCache);
|
1761
|
} else {
|
1762
|
drupal_set_title($referenceTO->fullCitation);
|
1763
|
}
|
1764
|
*/
|
1765
|
|
1766
|
$field_order = array(
|
1767
|
"title",
|
1768
|
//"titleCache",
|
1769
|
//"citation",
|
1770
|
"authorTeam",
|
1771
|
"editor",
|
1772
|
"publisher",
|
1773
|
"placePublished",
|
1774
|
"datePublished",
|
1775
|
"year",
|
1776
|
"edition", // class Book
|
1777
|
"volume", // class Article
|
1778
|
"seriesPart",
|
1779
|
"inReference",
|
1780
|
//"inJournal", // class Article
|
1781
|
//"inBook", // class BookSection
|
1782
|
"nomRefBase", // class BookSection, Book, Article
|
1783
|
//"inProceedings", // class InProceedings
|
1784
|
"pages", // class Article
|
1785
|
"series", // class Article, PrintSeries
|
1786
|
"school", // class Thesis
|
1787
|
"institution", // class Report
|
1788
|
"organization", // class Proceedings
|
1789
|
"nextVersion",
|
1790
|
"previousVersion",
|
1791
|
"isbn", // class Book
|
1792
|
"issn", // class Journal
|
1793
|
"uri",
|
1794
|
);
|
1795
|
/*
|
1796
|
$table_rows = array();
|
1797
|
foreach($field_order as $fieldname){
|
1798
|
|
1799
|
if(isset($referenceTO->$fieldname)){
|
1800
|
|
1801
|
if($fieldname == "datePublished") {
|
1802
|
$partial = $referenceTO->$fieldname;
|
1803
|
$datePublished = '';
|
1804
|
if($partial->start){
|
1805
|
//var_dump ($partial->start);
|
1806
|
$datePublishedYear = substr($partial->start, 0, 4);
|
1807
|
$datePublishedMonth = substr($partial->start, 5, 2);
|
1808
|
|
1809
|
if (!(preg_match('#[0-9]#',$datePublishedMonth))){
|
1810
|
$datePublishedMonth = '00';
|
1811
|
}
|
1812
|
|
1813
|
$datePublishedDay = substr($partial->start, 7, 2);
|
1814
|
if (!(preg_match('#[0-9]#',$datePublishedDay))){
|
1815
|
$datePublishedDay = '00';
|
1816
|
}
|
1817
|
$datePublished = $datePublishedYear.'-'.$datePublishedMonth.'-'.$datePublishedDay;
|
1818
|
}
|
1819
|
if($partial->end){
|
1820
|
$datePublished = (strlen($datePublished) > 0 ? ' '.t('to').' ' : '').substr($partial->end, 0, 4).'-'.substr($partial->end, 4, 2).'-'.substr($partial->end, 6, 2);
|
1821
|
}
|
1822
|
$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $datePublished);
|
1823
|
//$datePublished = array(t(ucfirst(strtolower($fieldname))), $datePublished);
|
1824
|
} else if(is_object($referenceTO->$fieldname)){
|
1825
|
if ($fieldname == "authorTeam"){
|
1826
|
$dump = $referenceTO->$fieldname;
|
1827
|
$teammembers = "teamMembers";
|
1828
|
$team = $dump->$teammembers;
|
1829
|
$nameArray = array();
|
1830
|
|
1831
|
foreach($team as $member){
|
1832
|
if (strlen($member->lastname)> 0){
|
1833
|
$nname = $member->lastname;
|
1834
|
$name = $nname;
|
1835
|
if (strlen($member->firstname)> 0){
|
1836
|
$vname = $member->firstname;
|
1837
|
$name =$vname." ". $nname;
|
1838
|
}
|
1839
|
$nameArray[] =$name;
|
1840
|
}else{
|
1841
|
if (strlen($member->titleCache)> 0){
|
1842
|
$nameArray[] = $member->titleCache;
|
1843
|
}
|
1844
|
}
|
1845
|
}
|
1846
|
$names = join($nameArray, ", ");
|
1847
|
}else if ($fieldname == "inReference"){
|
1848
|
$type = $referenceTO ->$fieldname-> type;
|
1849
|
$names = $referenceTO-> $fieldname-> titleCache;
|
1850
|
switch ($type) {
|
1851
|
case "Book":
|
1852
|
$fieldname = "in book";
|
1853
|
break;
|
1854
|
case "Journal":
|
1855
|
$fieldname = "in journal";
|
1856
|
break;
|
1857
|
case "Proceedings":
|
1858
|
$fieldname = "in proceedings";
|
1859
|
break;
|
1860
|
}
|
1861
|
|
1862
|
}else{
|
1863
|
$names = $referenceTO->$fieldname-> titleCache;
|
1864
|
}
|
1865
|
$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $names);
|
1866
|
//$name = array(t(ucfirst(strtolower($fieldname))), $names);
|
1867
|
|
1868
|
} else {
|
1869
|
$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $referenceTO->$fieldname);
|
1870
|
//$name = array(t(ucfirst(strtolower($fieldname))), $referenceTO->$fieldname);
|
1871
|
}
|
1872
|
}
|
1873
|
}
|
1874
|
*/
|
1875
|
|
1876
|
//select the type of the reference and find the in Reference attribute
|
1877
|
|
1878
|
$referenceData = array(
|
1879
|
"title" => NULL,
|
1880
|
//"titleCache",
|
1881
|
//"citation",
|
1882
|
"authorTeam" => NULL,
|
1883
|
"editor" => NULL,
|
1884
|
"publisher" => NULL,
|
1885
|
"placePublished" => NULL,
|
1886
|
"datePublished" => NULL,
|
1887
|
"year" => NULL,
|
1888
|
"edition" => NULL, // class Book
|
1889
|
"volume" => NULL, // class Article
|
1890
|
"seriesPart" => NULL,
|
1891
|
"inReference" => NULL,
|
1892
|
//"inJournal", // class Article
|
1893
|
//"inBook", // class BookSection
|
1894
|
"nomRefBase" => NULL, // class BookSection, Book, Article
|
1895
|
//"inProceedings", // class InProceedings
|
1896
|
"pages" => NULL, // class Article
|
1897
|
"series" => NULL, // class Article, PrintSeries
|
1898
|
"school" => NULL, // class Thesis
|
1899
|
"institution" => NULL, // class Report
|
1900
|
"organization" => NULL, // class Proceedings
|
1901
|
"nextVersion" => NULL,
|
1902
|
"previousVersion" => NULL,
|
1903
|
"isbn" => NULL, // class Book
|
1904
|
"issn" => NULL, // class Journal
|
1905
|
"uri" => NULL,
|
1906
|
);
|
1907
|
|
1908
|
foreach($field_order as $fieldname){
|
1909
|
|
1910
|
if(isset($referenceTO->$fieldname)){
|
1911
|
switch($fieldname){
|
1912
|
case "datePublished":
|
1913
|
$partial = $referenceTO->$fieldname;
|
1914
|
$datePublished = '';
|
1915
|
if($partial->start){
|
1916
|
$datePublishedYear = substr($partial->start, 0, 4);
|
1917
|
$datePublishedMonth = substr($partial->start, 5, 2);
|
1918
|
if (!(preg_match('#[0-9]#',$datePublishedMonth))){
|
1919
|
$datePublishedMonth = '00';
|
1920
|
}
|
1921
|
$datePublishedDay = substr($partial->start, 7, 2);
|
1922
|
if (!(preg_match('#[0-9]#',$datePublishedDay))){
|
1923
|
$datePublishedDay = '00';
|
1924
|
}
|
1925
|
$datePublished = $datePublishedYear.'-'.$datePublishedMonth.'-'.$datePublishedDay;
|
1926
|
}
|
1927
|
if($partial->end){
|
1928
|
$datePublished = (strlen($datePublished) > 0 ? ' '.t('to').' ' : '').substr($partial->end, 0, 4).'-'.substr($partial->end, 4, 2).'-'.substr($partial->end, 6, 2);
|
1929
|
}
|
1930
|
|
1931
|
$referenceData[$fieldname] = $datePublishedYear;
|
1932
|
break;
|
1933
|
|
1934
|
default:
|
1935
|
if(is_object($referenceTO->$fieldname)){
|
1936
|
if ($fieldname == "authorTeam"){
|
1937
|
$dump = $referenceTO->$fieldname;
|
1938
|
$teammembers = "teamMembers";
|
1939
|
$team = $dump->$teammembers;
|
1940
|
$nameArray = array();
|
1941
|
|
1942
|
foreach($team as $member){
|
1943
|
if (strlen($member->lastname)> 0){
|
1944
|
$nname = $member->lastname;
|
1945
|
$name = $nname;
|
1946
|
if (strlen($member->firstname)> 0){
|
1947
|
$vname = $member->firstname;
|
1948
|
$name =$vname." ". $nname;
|
1949
|
}
|
1950
|
$nameArray[] =$name;
|
1951
|
}else{
|
1952
|
if (strlen($member->titleCache)> 0){
|
1953
|
$nameArray[] = $member->titleCache;
|
1954
|
}
|
1955
|
}
|
1956
|
}
|
1957
|
$names = join($nameArray, ", ");
|
1958
|
$referenceData[$fieldname] = $names;
|
1959
|
}else if ($fieldname == "inReference"){
|
1960
|
$names = $referenceTO->$fieldname->titleCache;
|
1961
|
$referenceData[$fieldname] = $names;
|
1962
|
}else{
|
1963
|
$names = $referenceTO->$fieldname->titleCache;
|
1964
|
$referenceData[$fieldname] = $names;
|
1965
|
}
|
1966
|
}else{
|
1967
|
$referenceData[$fieldname] = $referenceTO->$fieldname;
|
1968
|
}
|
1969
|
|
1970
|
}
|
1971
|
}
|
1972
|
}
|
1973
|
|
1974
|
return "" . ((strlen($referenceData["authorTeam"])>0) ? ($referenceData["authorTeam"] . '. ') : '')
|
1975
|
. ((strlen($referenceData["datePublished"])>0) ? ($referenceData["datePublished"] . '. ') : '')
|
1976
|
. ((strlen($referenceData["title"])>0) ? ($referenceData["title"] . '. ') : "")
|
1977
|
. ((strlen($referenceData["placePublished"])>0) ? ($referenceData["placePublished"] . '. ') : '')
|
1978
|
. ((strlen($referenceData["editor"])>0) ? ($referenceData["editor"] . '. ') : '')
|
1979
|
. ((strlen($referenceData["publisher"])>0) ? ($referenceData["publisher"] . '. ') : '')
|
1980
|
. ((strlen($referenceData["inReference"])>0) ? ($referenceData["inReference"] . '. ') : '')
|
1981
|
. ((strlen($referenceData["series"])>0) ? ($referenceData["series"] . '. ') : '')
|
1982
|
. ((strlen($referenceData["volume"])>0) ? ($referenceData["volume"] . '. ') : '')
|
1983
|
. ((strlen($referenceData["pages"])>0) ? ($referenceData["pages"] . '. ') : '')
|
1984
|
. ((strlen($referenceData["isbn"])>0) ? ($referenceData["isbn"] . '. ') : '')
|
1985
|
. ((strlen($referenceData["issn"])>0) ? ($referenceData["issn"] . '. ') : '')
|
1986
|
. ((strlen($referenceData["uri"])>0) ? ($referenceData["uri"] . '. ') : '');
|
1987
|
|
1988
|
}
|
1989
|
|
1990
|
/**
|
1991
|
* Show a synonym page
|
1992
|
*
|
1993
|
* TODO what should show on this page exactly?
|
1994
|
*
|
1995
|
*/
|
1996
|
function theme_cdm_synonym_page(){
|
1997
|
|
1998
|
}
|
1999
|
|
2000
|
function theme_cdm_preferredImage($media, $defaultRepresentationPart, $imageMaxExtend, $parameters = ''){
|
2001
|
|
2002
|
if(isset($media[0])){
|
2003
|
$representationPart = $media[0]->representations[0]->parts[0];
|
2004
|
if($parameters){
|
2005
|
$representationPart->uri.$parameters;
|
2006
|
}
|
2007
|
} else {
|
2008
|
$representationPart = $defaultRepresentationPart;
|
2009
|
}
|
2010
|
|
2011
|
//$widthAndHeight = ($imageWidth ? ' width="'.$imageWidth : '').($imageHeight ? '" height="'.$imageHeight : '');
|
2012
|
// $imageUri = $preferredMedia ? $preferredMedia->representations[0]->parts[0]->uri . $parameters : $defaultImage;
|
2013
|
$attributes = array('alt'=>($preferredMedia ? $preferredMedia->representations[0]->parts[0]->uri : "no image available"));
|
2014
|
$out .= theme('cdm_media_gallerie_image', $representationPart, $imageMaxExtend, false, $attributes);
|
2015
|
// $out = '<img class="left" '.$widthAndHeight.' " src="'.$imageUri.'" alt="'.$altText.'" />';
|
2016
|
return $out;
|
2017
|
}
|
2018
|
|
2019
|
function theme_cdm_homotypicSynonymyGroup($synonymList, $prependedSynonyms = array()){
|
2020
|
|
2021
|
if(! is_array($synonymList) || count($synonymList) == 0){
|
2022
|
return;
|
2023
|
}
|
2024
|
|
2025
|
$out = '<ul class="homotypicSynonyms">';
|
2026
|
|
2027
|
if(!empty($prependedSynonyms)){
|
2028
|
foreach($prependedSynonyms as $taxon){
|
2029
|
$out .= '<li class="synonym">'.theme('cdm_related_taxon', $taxon, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
|
2030
|
}
|
2031
|
}
|
2032
|
|
2033
|
foreach($synonymList as $synonym){
|
2034
|
$out .= '<li class="synonym">'.theme('cdm_related_taxon', $synonym, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
|
2035
|
}
|
2036
|
|
2037
|
$typeDesignations = cdm_ws_get(CDM_WS_TAXON_NAMETYPEDESIGNATIONS, $synonymList[0]->uuid);
|
2038
|
if($typeDesignations){
|
2039
|
$out .= theme('cdm_typedesignations', $typeDesignations);
|
2040
|
}
|
2041
|
|
2042
|
$out .= '</ul>';
|
2043
|
return $out;
|
2044
|
}
|
2045
|
|
2046
|
function theme_cdm_homotypicSynonymLine($taxon){
|
2047
|
$out = '';
|
2048
|
$out .= '<li class="synonym">'.theme('cdm_related_taxon', $taxon, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
|
2049
|
return $out;
|
2050
|
}
|
2051
|
|
2052
|
function theme_cdm_heterotypicSynonymyGroup($homotypicalGroup){
|
2053
|
$out = '';
|
2054
|
$out = '<ul class="heterotypicSynonymyGroup">';
|
2055
|
|
2056
|
$is_first_entry = true;
|
2057
|
$typeDesignations = null;
|
2058
|
foreach($homotypicalGroup as $synonym){
|
2059
|
if($is_first_entry){
|
2060
|
$is_first_entry = false;
|
2061
|
//$typeDesignations = cdm_ws_get(CDM_WS_NAME_TYPEDESIGNATIONS, $synonym->name->uuid);
|
2062
|
$typeDesignations = cdm_ws_get(CDM_WS_TAXON_NAMETYPEDESIGNATIONS, $synonym->uuid);
|
2063
|
// is first list entry
|
2064
|
$out .= '<li class="firstentry synonym">'.theme('cdm_related_taxon',$synonym, UUID_HETEROTYPIC_SYNONYM_OF).'</li>';
|
2065
|
} else {
|
2066
|
$out .= '<li class="synonym">'.theme('cdm_related_taxon',$synonym, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
|
2067
|
}
|
2068
|
}
|
2069
|
|
2070
|
if($typeDesignations){
|
2071
|
$out .= theme('cdm_typedesignations', $typeDesignations);
|
2072
|
}
|
2073
|
|
2074
|
$out .= '</ul>';
|
2075
|
|
2076
|
return $out;
|
2077
|
}
|
2078
|
|
2079
|
/**
|
2080
|
* renders misapplied names and invalid designations.
|
2081
|
* Both relation types are currently treated the same!
|
2082
|
*
|
2083
|
* @param unknown_type $taxonRelationships
|
2084
|
* @return unknown
|
2085
|
*/
|
2086
|
function theme_cdm_taxonRelations($taxonRelationships){
|
2087
|
|
2088
|
if(!$taxonRelationships){
|
2089
|
return;
|
2090
|
}
|
2091
|
|
2092
|
_add_js_cluetip();
|
2093
|
|
2094
|
// aggregate misapplied names having the same fullname:
|
2095
|
$misapplied = array();
|
2096
|
foreach($taxonRelationships as $taxonRelation){
|
2097
|
if(true || $taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR ){
|
2098
|
|
2099
|
$name = $taxonRelation->fromTaxon->name->titleCache;
|
2100
|
$authorteam = $taxonRelation->fromTaxon->sec->authorTeam->titleCache;
|
2101
|
|
2102
|
if(!isset($misapplied[$name])){
|
2103
|
$misapplied[$name]['out'] = '<span class="misapplied">'.theme('cdm_related_taxon',$taxonRelation->fromTaxon, UUID_MISAPPLIED_NAME_FOR, false).'</span>';
|
2104
|
}
|
2105
|
|
2106
|
// collect all authors for this fullname
|
2107
|
if(isset($authorteam)){
|
2108
|
$misapplied[$name]['authorteam'][$authorteam] = ' <span class="sensu cluetip no-print" title="|sensu '.htmlspecialchars(theme('cdm_reference',$taxonRelation->fromTaxon->sec )).'|">sensu '
|
2109
|
.$authorteam.'</span>'
|
2110
|
.'<span class="reference only-print">sensu '.theme('cdm_reference', $taxonRelation->fromTaxon->sec ).'</span>';
|
2111
|
}
|
2112
|
|
2113
|
}
|
2114
|
}
|
2115
|
|
2116
|
// generate output
|
2117
|
$out = '<ul class="misapplied">';
|
2118
|
foreach($misapplied as $misapplied_name){
|
2119
|
$out .= '<li class="synonym">'.$misapplied_name['out'] . " ";
|
2120
|
// sorting authors
|
2121
|
if(isset($misapplied_name['authorteam'])){
|
2122
|
ksort($misapplied_name['authorteam']);
|
2123
|
$out .= join('; ', $misapplied_name['authorteam']);
|
2124
|
}
|
2125
|
$out .= '</li>';
|
2126
|
}
|
2127
|
$out .= '</ul>';
|
2128
|
return $out;
|
2129
|
}
|
2130
|
|
2131
|
function theme_cdm_nameRelations($nameRelationships, $skipTypes = false){
|
2132
|
|
2133
|
// group by relationship type
|
2134
|
$relationshipGroups = array();
|
2135
|
foreach($nameRelationships as $nameRelationship){
|
2136
|
if(!array_key_exists($nameRelationship->type->uuid, $relationshipGroups)){
|
2137
|
$relationshipGroups[$nameRelationship->type->uuid] = array();
|
2138
|
}
|
2139
|
$relationshipGroups[$nameRelationship->type->uuid][] = $nameRelationship;
|
2140
|
}
|
2141
|
|
2142
|
// generate output
|
2143
|
$out = '';
|
2144
|
foreach($relationshipGroups as $group){
|
2145
|
$type = $group[0]->type;
|
2146
|
|
2147
|
if(is_array($skipTypes) && in_array($type->uuid, $skipTypes)){
|
2148
|
continue;
|
2149
|
}
|
2150
|
|
2151
|
$block->module = 'cdm_dataportal';
|
2152
|
$block->subject = t(ucfirst($type->inverseRepresentation_L10n));
|
2153
|
$block->delta = generalizeString(strtolower($type->inverseRepresentation_L10n));
|
2154
|
|
2155
|
foreach($group as $relationship){
|
2156
|
$relatedNames[] = cdm_taggedtext2html($relationship->fromName->taggedName);
|
2157
|
}
|
2158
|
|
2159
|
$block->content .= implode('; ', $relatedNames);
|
2160
|
$out .= theme('block', $block);
|
2161
|
}
|
2162
|
return $out;
|
2163
|
}
|
2164
|
|
2165
|
/**
|
2166
|
* FIXME this definitively has to be in another spot. just didn't know where to put it right now.
|
2167
|
* Compares the status of two SpecimenTypeDesignations
|
2168
|
* @param String $a a SpecimenTypeDesignations
|
2169
|
* @param String $b another SpecimenTypeDesignations
|
2170
|
*/
|
2171
|
function compare_specimenTypeDesignationStatus($a, $b){
|
2172
|
/* this is the desired sort oder as of now:
|
2173
|
* Holotype
|
2174
|
* Isotype
|
2175
|
* Lectotype
|
2176
|
* Isolectotype
|
2177
|
* Syntype
|
2178
|
*
|
2179
|
* TODO
|
2180
|
* Basically, what we are trying to do is, we define an ordered array of TypeDesignation-states
|
2181
|
* and use the index of this array for comparison. This array has to be filled with the cdm-
|
2182
|
* TypeDesignation states and the order should be parameterisable inside the dataportal.
|
2183
|
*/
|
2184
|
// make that static for now
|
2185
|
$typeOrder = array('Holotype', 'Isotype', 'Lectotype', 'Isolectotype', 'Syntype');
|
2186
|
|
2187
|
$aQuantifier = array_search($a->typeStatus->label, $typeOrder);
|
2188
|
$bQuantifier = array_search($b->typeStatus->label, $typeOrder);
|
2189
|
|
2190
|
if ($aQuantifier == $bQuantifier) {
|
2191
|
// sort alphabetically
|
2192
|
return ($a->typeStatus->label < $b->typeStatus->label) ? -1 : 1;
|
2193
|
}
|
2194
|
return ($aQuantifier < $bQuantifier) ? -1 : 1;
|
2195
|
|
2196
|
}
|
2197
|
|
2198
|
function theme_cdm_typedesignations($typeDesignations = array()){
|
2199
|
|
2200
|
_add_js_cluetip();
|
2201
|
$renderPath = 'typedesignations';
|
2202
|
$out = '<ul class="typeDesignations">';
|
2203
|
|
2204
|
$specimenTypeDesignations = array();
|
2205
|
foreach($typeDesignations as $typeDesignation){
|
2206
|
if($typeDesignation->class == 'SpecimenTypeDesignation'){
|
2207
|
// SpecimenTypeDesignations should be ordered. collect theme here only
|
2208
|
$specimenTypeDesignations[] = $typeDesignation;
|
2209
|
}else {
|
2210
|
|
2211
|
// it's a NameTypeDesignation
|
2212
|
if($typeDesignation->notDesignated){
|
2213
|
$out .= '<li class="nameTypeDesignation"><span class="status">Type</span>: '.t('not designated'). '</li>';
|
2214
|
}else if($typeDesignation->typeName){
|
2215
|
|
2216
|
$out .= '<li class="nameTypeDesignation"><span class="status">Type</span>: ';
|
2217
|
|
2218
|
if($typeDesignation->typeName->nomenclaturalReference){
|
2219
|
$referenceUri = url(path_to_reference($typeDesignation->typeName->nomenclaturalReference->uuid));
|
2220
|
}
|
2221
|
$out .= theme('cdm_taxonName', $typeDesignation->typeName, null, $referenceUri, $renderPath);
|
2222
|
|
2223
|
// if($typeDesignation->typeName->class == 'ZoologicalName') {
|
2224
|
// // appending authorTeam which has been skipped in cdm_name
|
2225
|
// $authorTeam = cdm_taggedtext_value($typeDesignation->typeName->taggedName, 'authors');
|
2226
|
// $authorTeamPart = l('<span class="authors">'.$authorTeam.'</span>', "/cdm_dataportal/reference/".$typeDesignation->typeName->nomenclaturalReference->uuid, array(), NULL, NULL, FALSE, TRUE);
|
2227
|
// $out .= (str_endsWith($authorTeam, ')') ? '' : ', ').$authorTeamPart;
|
2228
|
// } else {
|
2229
|
// $out .= ' '.theme('cdm_reference', $typeDesignation->citation, true, $referenceStyle);
|
2230
|
// $out .= '</li>';
|
2231
|
// }
|
2232
|
}
|
2233
|
}
|
2234
|
}
|
2235
|
|
2236
|
if(!empty($specimenTypeDesignations)){
|
2237
|
// sorting might be different for dataportals so this has to be parameterized
|
2238
|
usort($specimenTypeDesignations, "compare_specimenTypeDesignationStatus");
|
2239
|
foreach($specimenTypeDesignations as $std){
|
2240
|
|
2241
|
$typeReference = '';
|
2242
|
//show citation only for Lectotype or Neotype
|
2243
|
$showCitation = isset($std->typeStatus) && ($std->typeStatus->uuid == UUID_NEOTYPE || $std->typeStatus->uuid == UUID_LECTOTYPE);
|
2244
|
if($showCitation && !empty($std->citation)){
|
2245
|
$shortCitation = $std->citation->authorTeam->titleCache;
|
2246
|
$shortCitation .= (strlen($shortCitation) > 0 ? ' ' : '' ). partialToYear($std->citation->datePublished->start);
|
2247
|
if(strlen($shortCitation) == 0){
|
2248
|
$shortCitation = theme('cdm_reference',$std->citation );
|
2249
|
$missingShortCitation = true;
|
2250
|
}
|
2251
|
$typeReference .= ' (' . t('designated by');
|
2252
|
$typeReference .= ' <span class="typeReference '.($missingShortCitation ? '' : 'cluetip').' no-print" title="'. htmlspecialchars('|'.theme('cdm_reference',$std->citation ).'|') .'">';
|
2253
|
$typeReference .= $shortCitation.'</span>';
|
2254
|
$typeReference .= ')';
|
2255
|
//$typeReference .= '<span class="reference only-print">(designated by '.theme('cdm_reference',$std->citation ).')</span>';
|
2256
|
}
|
2257
|
|
2258
|
$out .= '<li class="specimenTypeDesignation">';
|
2259
|
$out .= '<span class="status">'.(($std->typeStatus->representation_L10n) ? $std->typeStatus->representation_L10n : t('Type')) .$typeReference.'</span>: '.$std->typeSpecimen->titleCache;
|
2260
|
$out .= theme('cdm_specimen', $std->typeSpecimen);
|
2261
|
$out .= '</li>';
|
2262
|
}
|
2263
|
}
|
2264
|
|
2265
|
$out .= '</ul>';
|
2266
|
|
2267
|
return $out;
|
2268
|
}
|
2269
|
|
2270
|
function theme_cdm_specimen($specimen){
|
2271
|
|
2272
|
_add_js_thickbox();
|
2273
|
|
2274
|
$out = '';
|
2275
|
if(isset($specimen->media[0])){
|
2276
|
|
2277
|
$image_url = drupal_get_path('module', 'cdm_dataportal').'/images/external_link.gif';
|
2278
|
// thickbox has problems reading the first url parameter, so a litte hack is needed here:
|
2279
|
// adding a meaningless patameter &tb_hack=1& ....
|
2280
|
$out .= ' <a href="#TB_inline?tb_hack=1&width=300&height=330&inlineId=specimen_media_'.$specimen->uuid.'" class="thickbox">'
|
2281
|
.'<img src="'.$image_url.'" title="'.t('Show media').'" /></a>';
|
2282
|
|
2283
|
$out .= '<div id="specimen_media_'.$specimen->uuid.'" class="tickbox_content"><table>';
|
2284
|
|
2285
|
$media_row = '<tr class="media_data">';
|
2286
|
$meta_row = '<tr class="meta_data">';
|
2287
|
|
2288
|
foreach($specimen->media as $media){
|
2289
|
foreach($media->representations as $representation){
|
2290
|
|
2291
|
//TODO this this is PART 2/2 of a HACK - select preferred representation by mimetype and size
|
2292
|
//
|
2293
|
if(true || $representation->mimeType == 'image/jpeg'){
|
2294
|
foreach($representation->parts as $part){
|
2295
|
// get media uri conversion rules if the module is installed and activated
|
2296
|
if(module_exists('cdm_mediauri')){
|
2297
|
$muris = cdm_mediauri_conversion($part->uri);
|
2298
|
}
|
2299
|
// --- handle media preview rules
|
2300
|
if(isset($muris['preview'])){
|
2301
|
|
2302
|
$a_child = '<img src="'.$muris['preview']['uri'].'" class="preview" '
|
2303
|
.($muris['preview']['size_x'] ? 'width="'.$muris['preview']['size_x'].'"' : '')
|
2304
|
.($muris['preview']['size_y'] ? 'width="'.$muris['preview']['size_y'].'"' : '')
|
2305
|
.'/>';
|
2306
|
} else {
|
2307
|
$a_child = '<img src="'.$part->uri.'" />';
|
2308
|
}
|
2309
|
|
2310
|
// --- handle web application rules
|
2311
|
$webapp = '';
|
2312
|
if(isset($muris['webapp'])){
|
2313
|
if($muris['webapp']['embed_html']){
|
2314
|
// embed in same page
|
2315
|
$webapp = $muris['webapp']['embed_html'];
|
2316
|
} else {
|
2317
|
$webapp = l(t('web application'), $muris['webapp']['uri']);
|
2318
|
}
|
2319
|
}
|
2320
|
$media_row .= '<td><a href="'.$part->uri.'" target="'.$part->uuid.'">'.$a_child.'</a></td>';
|
2321
|
$meta_row .= '<td><span class="label">'.check_plain($specimen->titleCache).'</span><div class="webapp">'.$webapp.'</div></td>';
|
2322
|
} // END parts
|
2323
|
//TODO this is PART 2/2 of a hack
|
2324
|
break;
|
2325
|
} // END representations
|
2326
|
} // END media
|
2327
|
}
|
2328
|
$out .= $media_row.'</tr>';
|
2329
|
$out .= $meta_row.'</tr>';
|
2330
|
|
2331
|
$out .= '</div></table>';
|
2332
|
}
|
2333
|
return $out;
|
2334
|
}
|
2335
|
|
2336
|
function theme_cdm_featureTrees($mergedTrees, $taxon){
|
2337
|
|
2338
|
if(!$mergedTrees){
|
2339
|
return;
|
2340
|
}
|
2341
|
|
2342
|
foreach($mergedTrees as &$mTree){
|
2343
|
//TODO diplay title and reference in case of multiple $mergedTrees -> theme
|
2344
|
$out .= theme('cdm_feature_nodes', $mTree->root->children, $taxon);
|
2345
|
}
|
2346
|
return $out;
|
2347
|
}
|
2348
|
|
2349
|
function theme_cdm_featureTreeTOCs($mergedTrees){
|
2350
|
|
2351
|
if(!$mergedTrees){
|
2352
|
return;
|
2353
|
}
|
2354
|
//FIXME
|
2355
|
$out = '<div class="featureTOC">';
|
2356
|
$out .= '<h2>' . t('Content') .'</h2>';
|
2357
|
|
2358
|
//TODO diplay title and reference in case of multiple $mergedTrees -> theme
|
2359
|
|
2360
|
foreach($mergedTrees as &$mTree){
|
2361
|
$out .= theme('cdm_feature_nodesTOC', $mTree->root->children);
|
2362
|
}
|
2363
|
|
2364
|
$out .= '</div>';
|
2365
|
return $out;
|
2366
|
}
|
2367
|
|
2368
|
function theme_cdm_feature_nodes($featureNodes, $taxon){
|
2369
|
|
2370
|
foreach($featureNodes as $node){
|
2371
|
// process $descriptionElements with content only
|
2372
|
if(is_array($node->descriptionElements) && count($node->descriptionElements) > 0){
|
2373
|
|
2374
|
$featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
|
2375
|
|
2376
|
$block->module = 'cdm_dataportal';
|
2377
|
|
2378
|
if($node->feature->uuid != UUID_IMAGE){
|
2379
|
$block->delta = generalizeString($featureRepresentation);
|
2380
|
$block->subject = theme('cdm_feature_name', $featureRepresentation);
|
2381
|
$block->module = "cdm_dataportal-feature";
|
2382
|
|
2383
|
//get the text for the feature block
|
2384
|
$block->content = theme('cdm_descriptionElements', $node->descriptionElements, $node->feature->uuid);
|
2385
|
// get media for the feature block
|
2386
|
$media_list = cdm_dataportal_media_from_descriptionElements($node->descriptionElements);
|
2387
|
$captionElements = array('title', 'rights');
|
2388
|
//$block->content .= theme('cdm_media_gallerie', $media_list, "test", 150, 4, false, $captionElements);
|
2389
|
$block->content .= theme('cdm_media_gallery_wrapper', $media_list, 'test5', 'description_gallery');
|
2390
|
|
2391
|
// set anchor; FIXME put anchor in $block->subject
|
2392
|
$out .= '<a name="'.$block->delta.'"></a>';
|
2393
|
$out .= theme('block', $block);
|
2394
|
|
2395
|
// TODO HACK
|
2396
|
if($node->feature->uuid == UUID_DISTRIBUTION){
|
2397
|
$out .= theme('cdm_descriptionElements_distribution', $taxon);
|
2398
|
}
|
2399
|
}
|
2400
|
}
|
2401
|
// theme
|
2402
|
if(count($node->children) > 0){
|
2403
|
$out .= '<div class="nested_description_elements">';
|
2404
|
$out .= theme('cdm_feature_nodes', $node->children, $taxon);
|
2405
|
$out .= '</div>';
|
2406
|
}
|
2407
|
}
|
2408
|
return $out;
|
2409
|
}
|
2410
|
|
2411
|
|
2412
|
function theme_cdm_feature_nodesTOC($featureNodes){
|
2413
|
|
2414
|
$out .= '<ul>';
|
2415
|
|
2416
|
foreach($featureNodes as $node){
|
2417
|
// process $descriptionElements with content only
|
2418
|
if(is_array($node->descriptionElements) && count($node->descriptionElements) > 0){
|
2419
|
|
2420
|
$featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
|
2421
|
// HACK to implement images for taxa, should be removed
|
2422
|
if($node->feature->uuid != UUID_IMAGE){
|
2423
|
$out .= '<li>'.l(t(theme('cdm_feature_name', $featureRepresentation)), $_GET['q'], array("class"=>"toc"), NULL, generalizeString($featureRepresentation)).'</li>';
|
2424
|
}
|
2425
|
}
|
2426
|
}
|
2427
|
|
2428
|
$out .= '</ul>';
|
2429
|
return $out;
|
2430
|
}
|
2431
|
|
2432
|
function theme_cdm_feature_name($feature_name){
|
2433
|
//TODO replace by using translations ?
|
2434
|
switch($feature_name){
|
2435
|
default: return t(ucfirst($feature_name));
|
2436
|
}
|
2437
|
}
|
2438
|
|
2439
|
/**
|
2440
|
* This function collects all the media from a list of description elements
|
2441
|
* and return them as an Array.
|
2442
|
*
|
2443
|
* @param $descriptionElementes The description elements
|
2444
|
* @return Array The output with all the media
|
2445
|
*/
|
2446
|
function cdm_dataportal_media_from_descriptionElements($descriptionElements){
|
2447
|
//variables
|
2448
|
$outArrayOfMedia = array(); //return value
|
2449
|
//implementation
|
2450
|
foreach($descriptionElements as $descriptionElement){
|
2451
|
foreach($descriptionElement->media as $media){
|
2452
|
if(isset($media)){
|
2453
|
$outArrayOfMedia[] = $media;
|
2454
|
}
|
2455
|
}
|
2456
|
}
|
2457
|
return $outArrayOfMedia;
|
2458
|
}
|
2459
|
|
2460
|
/**
|
2461
|
* Theme a list of description elements, usually of a specific feature type
|
2462
|
* @param $descriptionElements
|
2463
|
* @return unknown_type
|
2464
|
*/
|
2465
|
function theme_cdm_descriptionElements($descriptionElements, $featureUuid){
|
2466
|
$outArray = array();
|
2467
|
$glue = '';
|
2468
|
$sortOutArray = false;
|
2469
|
$enclosingHtml = 'ul';
|
2470
|
$distributionElements = array();
|
2471
|
|
2472
|
foreach($descriptionElements as $descriptionElement){
|
2473
|
|
2474
|
if($descriptionElement->feature->uuid == UUID_DISTRIBUTION){
|
2475
|
if($descriptionElement->class == 'Distribution'){
|
2476
|
$distributionElements[]= $descriptionElement;
|
2477
|
} else if($descriptionElement->class == 'TextData'){
|
2478
|
$asListElement = false;
|
2479
|
$repr = theme ('cdm_descriptionElementTextData', $descriptionElement, $asListElement);
|
2480
|
|
2481
|
if( !array_search($repr, $outArray)){
|
2482
|
$outArray[] = $repr;
|
2483
|
$glue = '<br/> ';
|
2484
|
$sortOutArray = true;
|
2485
|
$enclosingHtml = 'p';
|
2486
|
}
|
2487
|
}
|
2488
|
} else if($descriptionElement->class == 'TextData'){
|
2489
|
$asListElement = true;
|
2490
|
$outArray[] = theme('cdm_descriptionElementTextData', $descriptionElement, $asListElement);
|
2491
|
} else {
|
2492
|
$outArray[] = '<li>No method for rendering unknown description class: '.$descriptionElement->classType.'</li>';
|
2493
|
}
|
2494
|
|
2495
|
}
|
2496
|
|
2497
|
$outArray[] = theme('cdm_descriptionElementDistribution', $distributionElements);
|
2498
|
|
2499
|
|
2500
|
// take the feature of the last $descriptionElement
|
2501
|
$feature = $descriptionElement->feature;
|
2502
|
$out = theme('cdm_descriptionElementArray', $outArray, $feature, $glue, $sortOutArray, $enclosingHtml);
|
2503
|
$out .= '<div class="footnote_list">'. FootnoteManager::renderFootnoteList($featureUuid) . '</div>';
|
2504
|
return $out;
|
2505
|
}
|
2506
|
|
2507
|
function theme_cdm_descriptionElementDistribution($descriptionElements){
|
2508
|
|
2509
|
$out = '';
|
2510
|
$separator = ', ';
|
2511
|
|
2512
|
foreach($descriptionElements as $descriptionElement){
|
2513
|
//$footnoteKey = FootnoteManager::addNewFootnote($descriptionElement->feature->uuid, $descriptionElement->area->representation_L10n);
|
2514
|
$footnoteKeyList = '';
|
2515
|
foreach($descriptionElement->sources as $source){
|
2516
|
$footnoteKey = FootnoteManager::addNewFootnote($descriptionElement->feature->uuid, $source, 'cdm_DescriptionElementSource');
|
2517
|
$footnoteKeyList .= theme('cdm_footnode_key', $footnoteKey) . ' ';
|
2518
|
}
|
2519
|
$out .= $descriptionElement->area->representation_L10n . $footnoteKeyList . $separator;
|
2520
|
}
|
2521
|
$out = substr($out, 0, strlen($out)-strlen($separator) );
|
2522
|
|
2523
|
$taxonTrees = cdm_ws_get(CDM_WS_TAXONOMY);
|
2524
|
foreach($taxonTrees as $taxonTree){
|
2525
|
if ($taxonTree -> uuid == variable_get('cdm_taxonomictree_uuid', FALSE)){
|
2526
|
$reference = $taxonTree-> reference;
|
2527
|
break;
|
2528
|
}
|
2529
|
}
|
2530
|
|
2531
|
// $referenceCitation = l('<span class="reference">('.$reference->title.')</span>', path_to_reference($reference->uuid), array("class"=>"reference"), NULL, NULL, FALSE ,TRUE);
|
2532
|
// if($descriptions && strlen($descriptions) > 0 ){
|
2533
|
// $sourceRefs .= ' '.$referenceCitation;
|
2534
|
// }
|
2535
|
|
2536
|
return $out;
|
2537
|
|
2538
|
}
|
2539
|
|
2540
|
function theme_cdm_DescriptionElementSource($descriptionElementSource, $doLink = TRUE){
|
2541
|
|
2542
|
//ev. delegate to theme_cdm_ReferencedEntityBase
|
2543
|
$out = '';
|
2544
|
if($descriptionElementSource->citation){
|
2545
|
$datePublished = $descriptionElementSource->citation->datePublished;
|
2546
|
if (strlen($datePublished->start) >0){
|
2547
|
$year=substr($datePublished->start,0,strpos($datePublished->start,'-'));
|
2548
|
}
|
2549
|
$author_team_titlecache = $descriptionElementSource->citation->authorTeam->titleCache;
|
2550
|
if (strlen($year)>0){
|
2551
|
$reference = $author_team_titlecache.' '. $year;
|
2552
|
}else {
|
2553
|
$reference = $author_team_titlecache ;
|
2554
|
}
|
2555
|
|
2556
|
if($doLink){
|
2557
|
$out = l('<span class="reference">'.$reference.'</span>'
|
2558
|
, path_to_reference($descriptionElementSource->citation->uuid)
|
2559
|
, array("class"=>"reference")
|
2560
|
, NULL, NULL, FALSE ,TRUE);
|
2561
|
} else {
|
2562
|
$out = $reference;
|
2563
|
}
|
2564
|
if($descriptionElementSource->citationMicroReference){
|
2565
|
$out .= ': '. $descriptionElementSource->citationMicroReference;
|
2566
|
}
|
2567
|
}
|
2568
|
return $out;
|
2569
|
}
|
2570
|
|
2571
|
function theme_cdm_descriptionElementArray($elementArray, $feature, $glue = '', $sortArray = false, $enclosingHtml = 'ul'){
|
2572
|
$out = '<'.$enclosingHtml.' class="description" id="'.$feature->representation_L10n.'">';
|
2573
|
|
2574
|
if($sortArray) sort($elementArray);
|
2575
|
|
2576
|
$out .= join($elementArray, $glue);
|
2577
|
|
2578
|
$out .= '</'.$enclosingHtml.'>';
|
2579
|
return $out;
|
2580
|
}
|
2581
|
|
2582
|
/**
|
2583
|
* TODO: assign a new name to the function? because it is used for the citations
|
2584
|
* textdata elements and not for all text data description elements
|
2585
|
* @param $element The description element which contains the text information
|
2586
|
* @param $asListElement A boolean which determines whether the citations should
|
2587
|
* be renderer as a list or not
|
2588
|
* @return unknown_type Html to be renderized in drupal
|
2589
|
*/
|
2590
|
function theme_cdm_descriptionElementTextData($element, $asListElement){
|
2591
|
|
2592
|
$description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
|
2593
|
$sourceRefs = '';
|
2594
|
$result = array();
|
2595
|
$res_text;
|
2596
|
$res_author;
|
2597
|
$res_date;
|
2598
|
|
2599
|
foreach($element->sources as $source){
|
2600
|
$referenceCitation = theme('cdm_DescriptionElementSource', $source);
|
2601
|
if($description && strlen($description) > 0 && $referenceCitation ){
|
2602
|
$sourceRefs .= ' ('.$referenceCitation.')' ;
|
2603
|
}
|
2604
|
}
|
2605
|
if(strlen($sourceRefs) > 0){
|
2606
|
$sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
|
2607
|
}
|
2608
|
if ($asListElement){
|
2609
|
$res_text = '<li class="descriptionText">' . $description . $sourceRefs. '</li>';
|
2610
|
}else{
|
2611
|
$res_text = $description . $sourceRefs;
|
2612
|
}
|
2613
|
return $res_text;
|
2614
|
}
|
2615
|
|
2616
|
function theme_cdm_search_results($pager, $path, $parameters){
|
2617
|
|
2618
|
|
2619
|
$showThumbnails = $_SESSION['pageoptions']['searchtaxa']['showThumbnails'];
|
2620
|
if( !is_numeric($showThumbnails)){
|
2621
|
$showThumbnails = 1;
|
2622
|
}
|
2623
|
$setSessionUri = url('cdm_api/setvalue/session').'/pageoptions|searchtaxa|showThumbnails/';
|
2624
|
drupal_add_js('$(document).ready(function() {
|
2625
|
|
2626
|
// init
|
2627
|
if('.$showThumbnails.' == 1){
|
2628
|
$(\'.media_gallery\').show(20);
|
2629
|
} else {
|
2630
|
$(\'.media_gallery\').hide(20);
|
2631
|
}
|
2632
|
// add change hander
|
2633
|
$(\'#showThumbnails\').change(
|
2634
|
function(event){
|
2635
|
var state = 0;
|
2636
|
if($(this).is(\':checked\')){
|
2637
|
$(\'.media_gallery\').show(20);
|
2638
|
state = 1;
|
2639
|
} else {
|
2640
|
$(\'.media_gallery\').hide(20);
|
2641
|
}
|
2642
|
// store state in session variable
|
2643
|
var uri = \''.$setSessionUri.'\' + state;
|
2644
|
jQuery.get(uri);
|
2645
|
});
|
2646
|
});', "inline");
|
2647
|
|
2648
|
drupal_set_title(t('Search Results'));
|
2649
|
|
2650
|
$out = ''; //l('Advanced Search', '/cdm_dataportal/search');
|
2651
|
|
2652
|
$out = '<div class="page_options"><form name="pageoptions"><input id="showThumbnails" type="checkbox" name="showThumbnails" '.($showThumbnails == 1? 'checked="checked"': '').'> '.t('Show Thumbnails').'</form></div>';
|
2653
|
if(count($pager->records) > 0){
|
2654
|
$out .= theme('cdm_list_of_taxa', $pager->records);
|
2655
|
$out .= theme('cdm_pager', $pager, $path, $parameters);
|
2656
|
} else {
|
2657
|
$out = '<h4 class="error">Sorry, no matching entries found.</h4>';
|
2658
|
}
|
2659
|
return $out;
|
2660
|
}
|
2661
|
|
2662
|
function theme_cdm_footnode_key($footnoteKey){
|
2663
|
$out = '<a href="#footnote-'.$footnoteKey.'" class="footnote-key">'.$footnoteKey.'</a>';
|
2664
|
return $out;
|
2665
|
}
|
2666
|
|
2667
|
function theme_cdm_footnode($footnoteKey, $footnodeText){
|
2668
|
_add_js_footnotes();
|
2669
|
$out = '<span class="footnote footnote-'.$footnoteKey.'"><a name="footnote-'.$footnoteKey.'"></a><span class="footnote-anchor">'.$footnoteKey.'.</span> '.$footnodeText.'</span>';
|
2670
|
return $out;
|
2671
|
}
|
2672
|
|
2673
|
|
2674
|
|
2675
|
function theme_cdm_pager(&$pager, $path, $parameters){
|
2676
|
$out = '';
|
2677
|
|
2678
|
if ($pager->pagesAvailable > 1) {
|
2679
|
|
2680
|
$out .= '<div class="pager">';
|
2681
|
if($pager->currentIndex > 0){
|
2682
|
$out .= theme('cdm_pager_link', t('« first'), 0, $pager, $path, $parameters, array('class' => 'pager-first'));
|
2683
|
$out .= theme('cdm_pager_link', t('‹ previous'), $pager->currentIndex - 1, $pager, $path, $parameters, array('class' => 'pager-previous'));
|
2684
|
}
|
2685
|
|
2686
|
if($pager->indices[0] > 0){
|
2687
|
$out .= '<div class="pager-list-dots-left">...</div>';
|
2688
|
}
|
2689
|
|
2690
|
foreach($pager->indices as $index){
|
2691
|
$label = $index + 1;
|
2692
|
$out .= theme('cdm_pager_link', $label, $index, $pager, $path, $parameters, array('class' => 'pager-first'));
|
2693
|
}
|
2694
|
if($pager->indices[count($pager->indices) - 1] < $pager->pagesAvailable - 1){
|
2695
|
$out .= '<div class="pager-list-dots-right">...</div>';
|
2696
|
}
|
2697
|
|
2698
|
if($pager->nextIndex){
|
2699
|
$out .= theme('cdm_pager_link', t('next ›'), $pager->nextIndex, $pager, $path, $parameters, array('class' => 'pager-next'));
|
2700
|
$out .= theme('cdm_pager_link', t('last »'), $pager->pagesAvailable - 1, $pager, $path, $parameters, array('class' => 'pager-last'));
|
2701
|
}
|
2702
|
$out .= '</div>';
|
2703
|
|
2704
|
return $out;
|
2705
|
}
|
2706
|
}
|
2707
|
|
2708
|
function theme_cdm_pager_link($text, $linkIndex, &$pager, $path, $parameters = array(), $attributes) {
|
2709
|
|
2710
|
$out = '';
|
2711
|
$parameters['search']['page'] = $linkIndex;
|
2712
|
if ($linkIndex == $pager->currentIndex) {
|
2713
|
$out = '<strong>'.$text.'</strong>';
|
2714
|
} else {
|
2715
|
$queryString = drupal_query_string_encode($parameters);
|
2716
|
$out = l($text, $path, $attributes, $queryString);
|
2717
|
}
|
2718
|
return $out;
|
2719
|
}
|
2720
|
|
2721
|
|
2722
|
function getimagesize_remote($image_url) {
|
2723
|
|
2724
|
$contents = cdm_http_request($image_url);
|
2725
|
if(!$contents){
|
2726
|
return false;
|
2727
|
}
|
2728
|
|
2729
|
$im = ImageCreateFromString($contents);
|
2730
|
if (!$im) {
|
2731
|
return false;
|
2732
|
}
|
2733
|
$gis[0] = ImageSX($im);
|
2734
|
$gis[1] = ImageSY($im);
|
2735
|
// array member 3 is used below to keep with current getimagesize standards
|
2736
|
$gis[3] = "width={$gis[0]} height={$gis[1]}";
|
2737
|
ImageDestroy($im);
|
2738
|
return $gis;
|
2739
|
}
|
2740
|
|
2741
|
function media_content_type_dir($media_representation, $default = false){
|
2742
|
|
2743
|
if($media_representation->mimeType){
|
2744
|
return substr($media_representation->mimeType, 0, stripos($media_representation->mimeType, '/'));
|
2745
|
} else {
|
2746
|
return $default;
|
2747
|
}
|
2748
|
}
|