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
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
10
|
* See http://www.mozilla.org/MPL/MPL-1.1.html for the full license terms.
|
11
|
*/
|
12
|
|
13
|
/**
|
14
|
* default title for a taxon page
|
15
|
*
|
16
|
* @param NameTO $nameTO
|
17
|
* @return the formatted taxon name
|
18
|
*/
|
19
|
function theme_cdm_taxon_page_title($taxon, $uuid){
|
20
|
RenderHints::pushToRenderStack('taxon_page_title');
|
21
|
if(isset($taxon->name->nomenclaturalReference)){
|
22
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
23
|
}
|
24
|
$out = theme('cdm_taxonName', $taxon->name, null, $referenceUri, false);
|
25
|
RenderHints::popFromRenderStack();
|
26
|
|
27
|
return '<span class="'.$taxon->class.'">'.$out.'</span>';
|
28
|
}
|
29
|
|
30
|
/**
|
31
|
* Default title for a name page
|
32
|
* @param string $taxon_name The taxon name object
|
33
|
* @return the formatted name title
|
34
|
*/
|
35
|
function theme_cdm_name_page_title($taxon_name){
|
36
|
RenderHints::pushToRenderStack('taxon_page_title');
|
37
|
if(isset($taxon_name->nomenclaturalReference)){
|
38
|
$referenceUri = url(path_to_reference($taxon_name->nomenclaturalReference->uuid));
|
39
|
}
|
40
|
|
41
|
$out = '<span class="'.$taxon_name->class.'">'.theme('cdm_taxonName', $taxon_name, null, $referenceUri, false).'</span>';
|
42
|
RenderHints::popFromRenderStack();
|
43
|
return $out;
|
44
|
}
|
45
|
|
46
|
/**
|
47
|
* A wrapper function that groups available information to show by default, when
|
48
|
* a taxon page is requested by the browser.
|
49
|
* Individual themeing has to decide what this page should include (see methods beneath)
|
50
|
* and what information should go into tabs or should not be shown at all.
|
51
|
*
|
52
|
* It is headed by the name of the accepted taxon without author and reference.
|
53
|
* @param $taxonTO the taxon object
|
54
|
* @param $page_part name of the part to display,
|
55
|
* valid values are: 'description', 'images', 'synonymy', 'all'
|
56
|
*/
|
57
|
function theme_cdm_taxon_page($taxon, $page_part = 'description') {
|
58
|
|
59
|
global $theme;
|
60
|
|
61
|
$page_part = variable_get('cdm_dataportal_taxonpage_tabs', 1) ? $page_part : 'all';
|
62
|
$hideTabs = array();
|
63
|
|
64
|
|
65
|
// --- GET Images --- //
|
66
|
|
67
|
$mediaQueryParameters = array("type"=>"ImageFile");
|
68
|
|
69
|
$selectShowMedia = variable_get('cdm_dataportal_show_media', 0);
|
70
|
if ($selectShowMedia == 0){
|
71
|
$media = cdm_ws_get(CDM_WS_PORTAL_TAXON_MEDIA, array($taxon->uuid), queryString($mediaQueryParameters));
|
72
|
}else{
|
73
|
$media = cdm_ws_get(CDM_WS_PORTAL_TAXON_SUBTREE_MEDIA, array($taxon->uuid), queryString($mediaQueryParameters));
|
74
|
}
|
75
|
if(!isset($media[0])) {
|
76
|
$hideTabs[] = theme('cdm_taxonpage_tab', 'Images');
|
77
|
}
|
78
|
// hideImage flag depending on administative preset
|
79
|
$hideImages = false;
|
80
|
if(variable_get('image_hide_rank', '0') != '0'){
|
81
|
$rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
|
82
|
$hideImages = ($rankCompare > -1);
|
83
|
}
|
84
|
|
85
|
// --- GET specimensOrObersvations --- //
|
86
|
$specimensOrObersvations = cdm_ws_get(CDM_WS_TAXON, array($taxon->uuid, 'specimensOrObersvations') );
|
87
|
$specimensOrObersvationsCount = is_array($specimensOrObersvations) ? count($specimensOrObersvations) : 0;
|
88
|
if($specimensOrObersvationsCount == 0) {
|
89
|
$hideTabs[] = theme('cdm_taxonpage_tab', 'Specimens');
|
90
|
}
|
91
|
|
92
|
// --- GET polytomousKeys --- //
|
93
|
$polytomousKeysPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, null, "findByTaxonomicScope=$taxon->uuid");
|
94
|
$identificationKeyCount = 0;
|
95
|
if($polytomousKeysPager){
|
96
|
$identificationKeyCount += $polytomousKeysPager->count;
|
97
|
}
|
98
|
if($identificationKeyCount == 0){
|
99
|
$hideTabs[] = theme('cdm_taxonpage_tab', 'Keys');
|
100
|
}
|
101
|
// -------------------------------------------- //
|
102
|
|
103
|
// hide tabs
|
104
|
$tabhide_js = '';
|
105
|
foreach($hideTabs as $tabText) {
|
106
|
$tabhide_js .= "$('.tabs.primary').children('li').children('a:contains(\"$tabText\")').hide();\n";
|
107
|
}
|
108
|
drupal_add_js("
|
109
|
$(document).ready(function(){
|
110
|
$tabhide_js
|
111
|
});", 'inline');
|
112
|
|
113
|
$out = '';
|
114
|
$out .= theme('cdm_back_to_search_result_button');
|
115
|
//var_dump(variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR));
|
116
|
if(variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR)){
|
117
|
$out .= theme('cdm_acceptedFor', 'page_general');
|
118
|
}
|
119
|
|
120
|
// --- PAGE PART: DESCRIPTION --- //
|
121
|
if($page_part == 'description' || $page_part == 'all'){
|
122
|
|
123
|
$featureTree = cdm_ws_get(CDM_WS_FEATURETREE, variable_get(CDM_DATAPORTAL_DEFAULT_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE));
|
124
|
$markerTypesEmpty = array();
|
125
|
$markerTypesEmpty['markerTypes'] = '';
|
126
|
$taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon->uuid, queryString($markerTypesEmpty)); //retrieve all description for the taxon
|
127
|
$nonStructuredDescriptions = array();
|
128
|
if($taxonDescriptions != null){
|
129
|
foreach ($taxonDescriptions as $taxonDescription) {
|
130
|
// check if structured description
|
131
|
$hasStructuredData = cdm_ws_get(CDM_WS_DESCRIPTION_HAS_STRUCTRURED_DATA, $taxonDescription->uuid);
|
132
|
|
133
|
$hasStructuredData = $hasStructuredData->Boolean == 'true';
|
134
|
if($hasStructuredData){
|
135
|
$structured_description_featuretree_uuid = variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, false);
|
136
|
$naturallanguage_textData = cdm_ws_get(CDM_WS_DESCRIPTION_NATURALLANGUAGE_DESCRIPTION, array($taxonDescription->uuid, $structured_description_featuretree_uuid));
|
137
|
//$out .= print_r($naturallanguage_textData);
|
138
|
if(!$naturallanguage_textData){
|
139
|
drupal_set_message('The \'FeatureTree\' for the generation of natural language representations is not configured correctly, please select a \'FeatureTree\' in the '.l('CDM Dataportal Settings', 'admin/settings/cdm_dataportal/layout/taxon'), 'warning');
|
140
|
}
|
141
|
$taxonDescription->elements = null;
|
142
|
$taxonDescription->elements = array($naturallanguage_textData);
|
143
|
}
|
144
|
$nonStructuredDescriptions[] = $taxonDescription;
|
145
|
}
|
146
|
$taxonDescriptions = null; // release memory
|
147
|
}
|
148
|
|
149
|
$mergedTrees = cdm_ws_descriptions_by_featuretree($featureTree, $nonStructuredDescriptions, variable_get('cdm_dataportal_descriptions_separated', FALSE));
|
150
|
|
151
|
$out .= '<div id="general">';
|
152
|
$out .= theme('cdm_taxon_page_profile', $taxon, $mergedTrees, $media, $hideImages);
|
153
|
$out .= '</div>';
|
154
|
}
|
155
|
|
156
|
// --- PAGE PART: IMAGES --- //
|
157
|
if(!$hideImages && $page_part == 'images' || $page_part == 'all'){
|
158
|
$out .= '<div id="images">';
|
159
|
if($page_part == 'all'){
|
160
|
$out .= '<h2>'.t('Images').'</h2>';
|
161
|
}
|
162
|
|
163
|
// get the image gallery as configured by the admin
|
164
|
$taxon_image_gallery = call_user_func_array( 'taxon_image_gallery_' . variable_get('image_gallery_viewer', 'default'),
|
165
|
array($taxon, $media));
|
166
|
$out .= $taxon_image_gallery;
|
167
|
|
168
|
$out .= '</div>';
|
169
|
}
|
170
|
|
171
|
// --- PAGE PART: SYNONYMY --- //
|
172
|
if($page_part == 'synonymy' || $page_part == 'all'){
|
173
|
$out .= '<div id="synonymy">';
|
174
|
if($page_part == 'all'){
|
175
|
$out .= '<h2>'.t('Synonymy').'</h2>';
|
176
|
}
|
177
|
$addAcceptedTaxon = variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE);
|
178
|
$out .= theme('cdm_taxon_page_synonymy', $taxon, $addAcceptedTaxon);
|
179
|
|
180
|
$out .= '</div>';
|
181
|
}
|
182
|
|
183
|
// --- PAGE PART: SPECIMENS --- //
|
184
|
if($specimensOrObersvationsCount > 0 && ($page_part == 'specimens' || $page_part == 'all') ){
|
185
|
$out .= '<div id="specimens">';
|
186
|
if($page_part == 'all'){
|
187
|
$out .= '<h2>'.t('Specimens').'</h2>';
|
188
|
}
|
189
|
$out .= theme('cdm_taxon_page_specimens', $taxon);
|
190
|
$out .= '</div>';
|
191
|
}
|
192
|
|
193
|
// --- PAGE PART: KEYS --- //
|
194
|
if($identificationKeyCount > 0 && ($page_part == 'keys' || $page_part == 'all') ){
|
195
|
$out .= '<div id="keys">';
|
196
|
if($page_part == 'all'){
|
197
|
$out .= '<h2>'.t('Keys').'</h2>';
|
198
|
}
|
199
|
$out .= theme('cdm_block_IdentificationKeys', $taxon->uuid);
|
200
|
$out .= '</div>';
|
201
|
}
|
202
|
return $out;
|
203
|
}
|
204
|
|
205
|
|
206
|
/**
|
207
|
* Outputs all descriptive data and shows the preferred picture of the
|
208
|
* accepted taxon.
|
209
|
*
|
210
|
*/
|
211
|
function theme_cdm_taxon_page_profile($taxon, $mergedTrees, $media = null, $hideImages = false){
|
212
|
|
213
|
if( variable_get('cdm_dataportal_show_default_image', false) && !$hideImages){
|
214
|
// preferred image
|
215
|
// hardcoded for testing;
|
216
|
$defaultRepresentationPart = false;
|
217
|
$defaultRepresentationPart->width = 184;
|
218
|
$defaultRepresentationPart->height = 144;
|
219
|
$defaultRepresentationPart->uri = drupal_get_path('theme', 'palmweb_2').'/images/no_picture.png';
|
220
|
|
221
|
// preferred image size 184px × 144
|
222
|
$imageMaxExtend = 184;
|
223
|
$out .= '<div id="taxonProfileImage">'.$defaultRepresentationPart->uri.theme('cdm_preferredImage', $media, $defaultRepresentationPart, $imageMaxExtend).'</div>';
|
224
|
}
|
225
|
// description TOC
|
226
|
$out .= theme('cdm_featureTreeTOCs', $mergedTrees);
|
227
|
// description
|
228
|
$out .= theme('cdm_featureTrees', $mergedTrees, $taxon);
|
229
|
return $out;
|
230
|
}
|
231
|
|
232
|
|
233
|
function theme_cdm_taxon_page_specimens($taxon){
|
234
|
|
235
|
RenderHints::pushToRenderStack('taxon_page_specimens');
|
236
|
|
237
|
$specimensOrObersvations = cdm_ws_get(CDM_WS_TAXON, array($taxon->uuid, 'specimensOrObersvations') );
|
238
|
|
239
|
//collect media (fieldObjectMedia, derivedUnitMedia) and add as fields
|
240
|
foreach($specimensOrObersvations as &$occurrence) {
|
241
|
$occurrence->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($occurrence->uuid, 'fieldObjectMedia') );
|
242
|
$occurrence->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($occurrence->uuid, 'derivedUnitMedia') );
|
243
|
// $derivedUnitFacde = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($descriptionElement->associatedSpecimenOrObservation->uuid) );
|
244
|
// $descriptionElement->_titleCache = $derivedUnitFacde->titleCache;
|
245
|
}
|
246
|
|
247
|
if(count($specimensOrObersvations) > 0){
|
248
|
|
249
|
$occurrenceQuery = cdm_ws_get(CDM_WS_GEOSERVICE_OCCURRENCEMAP, $taxon->uuid);
|
250
|
$occurrenceQuery = $occurrenceQuery->String;
|
251
|
|
252
|
if(variable_get('cdm_dataportal_map_openlayers', 1)){
|
253
|
$out .= get_openlayers_map(
|
254
|
variable_get('cdm_dataportal_geoservice_display_width', false),
|
255
|
variable_get('cdm_dataportal_geoservice_bounding_box', false),
|
256
|
$occurrenceQuery,
|
257
|
null,
|
258
|
$legendFormatQueryStr,
|
259
|
variable_get('cdm_dataportal_geoservice_map_caption', '')
|
260
|
);
|
261
|
} else {
|
262
|
//get_image_map($width, $occurrenceQuery = false, $distributionQuery = false, $legendFormatQuery = false, $map_caption = false )
|
263
|
$out .= get_image_map(
|
264
|
variable_get('cdm_dataportal_geoservice_display_width', false),
|
265
|
variable_get('cdm_dataportal_geoservice_bounding_box', false),
|
266
|
$occurrenceQuery,
|
267
|
null,
|
268
|
$legendFormatQueryStr,
|
269
|
variable_get('cdm_dataportal_geoservice_map_caption', '')
|
270
|
);
|
271
|
}
|
272
|
|
273
|
}
|
274
|
|
275
|
|
276
|
|
277
|
if($specimensOrObersvations){
|
278
|
$out_specimenList = '<table class="specimens">';
|
279
|
$i = 1;
|
280
|
foreach($specimensOrObersvations as $specimensOrObersvation) {
|
281
|
$i++;
|
282
|
|
283
|
$mediaList = array();
|
284
|
if(is_array($specimensOrObersvation->_fieldObjectMedia)){
|
285
|
$mediaList = array_merge($mediaList, $specimensOrObersvation->_fieldObjectMedia);
|
286
|
}
|
287
|
if(is_array($specimensOrObersvation->_derivedUnitMedia)){
|
288
|
$mediaList = array_merge($mediaList, $specimensOrObersvation->_derivedUnitMedia);
|
289
|
}
|
290
|
|
291
|
// --- render the title cache
|
292
|
$out_row = '<tr class="descriptionElement descriptionElement_IndividualsAssociation '.($i%2?'odd':'even').'">';
|
293
|
if($specimensOrObersvation->class != 'FieldObservation'){
|
294
|
$label_html = cdm_dynabox($specimensOrObersvation->titleCache,
|
295
|
cdm_compose_url('portal/'.CDM_WS_DERIVEDUNIT_FACADE, array($specimensOrObersvation->uuid)),
|
296
|
'cdm_derivedUnitFacade',
|
297
|
'Click for details',
|
298
|
array('div', 'div'));
|
299
|
} else {
|
300
|
$label_html = $specimensOrObersvation->titleCache;
|
301
|
}
|
302
|
$out_row .= '<td>' . $label_html . '</td>';
|
303
|
|
304
|
// --- render associated media
|
305
|
if(count($mediaList) > 0){
|
306
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
307
|
$gallery_name = $specimensOrObersvation->uuid;
|
308
|
$captionElements = array('#uri'=>t('open media'));
|
309
|
$gallery_html = theme(
|
310
|
'cdm_media_gallerie',
|
311
|
$mediaList,
|
312
|
$gallery_name ,
|
313
|
$gallery_settings['cdm_dataportal_media_maxextend'],
|
314
|
$gallery_settings['cdm_dataportal_media_cols'],
|
315
|
$gallery_settings['cdm_dataportal_media_maxRows'],
|
316
|
$captionElements, 'LIGHTBOX', null, null);
|
317
|
} else {
|
318
|
$gallery_html = '';
|
319
|
}
|
320
|
$out_row .= '<td>'.$gallery_html.'</td></tr>';
|
321
|
$out_specimenList .= $out_row;
|
322
|
}
|
323
|
$out_specimenList .= '</table>';
|
324
|
}
|
325
|
|
326
|
$out .= $out_specimenList;
|
327
|
|
328
|
|
329
|
RenderHints::popFromRenderStack();
|
330
|
return $out;
|
331
|
}
|
332
|
|
333
|
function specimens_search_form() {
|
334
|
|
335
|
//form select options
|
336
|
$form['specimens_search_options'] = array(
|
337
|
'#type' => 'value',
|
338
|
'#value' => array(t('No sort'), t('Name'), t('CatalogNumber'), t('Gallery'))
|
339
|
);
|
340
|
|
341
|
//the form
|
342
|
$form['specimens_search'] = array(
|
343
|
'#title' => t('Speciments sort'),
|
344
|
'#type' => 'fieldset',
|
345
|
'#description' => t('Select your sort criteria.'),
|
346
|
'#collapsible' => TRUE,
|
347
|
'#collapsed' => FALSE
|
348
|
);
|
349
|
|
350
|
//criteria
|
351
|
$form['specimens_search']['first_criteria'] = array(
|
352
|
'#title' => t('First criteria'),
|
353
|
'#type' => 'select',
|
354
|
'#options' => $form['specimens_search_options']['#value']
|
355
|
);
|
356
|
$form['specimens_search']['second_criteria'] = array(
|
357
|
'#title' => t('Second criteria'),
|
358
|
'#type' => 'select',
|
359
|
'#options' => $form['specimens_search_options']['#value']
|
360
|
);
|
361
|
$form['specimens_search']['third_criteria'] = array(
|
362
|
'#title' => t('Third criteria'),
|
363
|
'#type' => 'select',
|
364
|
'#options' => $form['specimens_search_options']['#value']
|
365
|
);
|
366
|
|
367
|
//submit button
|
368
|
$form['specimens_search']['submit'] = array(
|
369
|
'#type' => 'submit',
|
370
|
'#value' => t('Sort')
|
371
|
);
|
372
|
|
373
|
/*
|
374
|
//from properties
|
375
|
$form['#method'] = 'post';
|
376
|
$form['#action'] = 'http://example.com/?q=foo/bar';
|
377
|
$form['#attributes'] = array(
|
378
|
'enctype' => 'multipart/form-data',
|
379
|
'target' => 'name_of_target_frame'
|
380
|
);
|
381
|
$form['#prefix'] = '<div class="my-form-class">';
|
382
|
$form['#suffix'] = '</div>';
|
383
|
*/
|
384
|
|
385
|
//returning value
|
386
|
return $form;
|
387
|
}
|
388
|
|
389
|
/**
|
390
|
* Show whole synonymy for the accepted taxon. Synonymy list is headed by the complete scientific name
|
391
|
* of the accepted taxon with nomenclatural reference.
|
392
|
*
|
393
|
*/
|
394
|
function theme_cdm_taxon_page_synonymy($taxon, $addAcceptedTaxon){
|
395
|
|
396
|
RenderHints::pushToRenderStack('taxon_page_synonymy');
|
397
|
$synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, $taxon->uuid);
|
398
|
$skip = array(UUID_BASIONYM);
|
399
|
|
400
|
//render accepted taxon
|
401
|
if($addAcceptedTaxon){
|
402
|
if(isset($taxon->name->nomenclaturalReference)){
|
403
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
404
|
}
|
405
|
|
406
|
$accepted_name = '<span class="accepted-name">';
|
407
|
$accepted_name .= theme('cdm_taxonName', $taxon->name, null, $referenceUri);
|
408
|
$accepted_name .= '</span>';
|
409
|
|
410
|
$special_annotations_array = array();
|
411
|
$special_annotations_array[] = $taxon->name;
|
412
|
$special_annotations_array[] = $taxon;
|
413
|
$accepted_name .= theme('cdm_annotations_as_footnotekeys',
|
414
|
$special_annotations_array,
|
415
|
RenderHints::getRenderPath() . '-annotations');
|
416
|
RenderHints::setFootnoteListKey(RenderHints::getRenderPath() . '-annotations');
|
417
|
}
|
418
|
|
419
|
|
420
|
//render homotypic synonymy group
|
421
|
$hasHomotypicSynonyms = isset($synomymie->homotypicSynonymsByHomotypicGroup[0]->name->uuid);
|
422
|
|
423
|
if($accepted_name){
|
424
|
$out .= $accepted_name;
|
425
|
}
|
426
|
|
427
|
if (!$hasHomotypicSynonyms){
|
428
|
//show typeDesignations even if the homotypic synonymy group is empty
|
429
|
$typeDesignations = cdm_ws_get(CDM_WS_PORTAL_TAXON_NAMETYPEDESIGNATIONS, $taxon->uuid);
|
430
|
if($typeDesignations){
|
431
|
$out .= theme('cdm_typedesignations', $typeDesignations);
|
432
|
}
|
433
|
if($typeDesignations || $accepted_name){
|
434
|
// add empty list for coherent layout
|
435
|
$out .= '<ul class="homotypicSynonyms">' . '</ul>';
|
436
|
}
|
437
|
} else {
|
438
|
// render the homotypicSynonymyGroup including the type information
|
439
|
$out .= theme('cdm_homotypicSynonymyGroup', $synomymie->homotypicSynonymsByHomotypicGroup, $taxon->uuid);
|
440
|
}
|
441
|
|
442
|
//render accepted taxon heterotypic synonymy groups
|
443
|
if($synomymie->heterotypicSynonymyGroups) {
|
444
|
foreach($synomymie->heterotypicSynonymyGroups as $homotypicalGroup){
|
445
|
$out .= theme('cdm_heterotypicSynonymyGroup', $homotypicalGroup);
|
446
|
}
|
447
|
}
|
448
|
//render taxon relationships
|
449
|
if(variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)){
|
450
|
$taxonRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, $taxon->uuid);
|
451
|
$out .= theme('cdm_taxonRelationships', $taxonRelationships, $taxon);
|
452
|
}
|
453
|
//render name relationships
|
454
|
$name_rels_to_show = variable_get('name_relationships_to_show', null);
|
455
|
$skip = array();
|
456
|
if($name_rels_to_show){
|
457
|
foreach ($name_rels_to_show as $key => $value){
|
458
|
if ($value === 0){
|
459
|
$skip[] = $key;
|
460
|
}
|
461
|
}
|
462
|
if (sizeof($name_rels_to_show) != sizeof($skip)){
|
463
|
$nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
|
464
|
$out .= theme('cdm_nameRelationships', $nameRelationships, $skip);
|
465
|
}
|
466
|
}
|
467
|
|
468
|
|
469
|
//render the annontations text for the accepted taxa
|
470
|
if ($addAcceptedTaxon){
|
471
|
$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-annotations', 'li');
|
472
|
}
|
473
|
RenderHints::popFromRenderStack();
|
474
|
|
475
|
return $out;
|
476
|
}
|
477
|
|
478
|
/**
|
479
|
* TODO Implementation of Hook taxon_image_gallery()
|
480
|
*
|
481
|
* @param unknown_type $taxon
|
482
|
* @param unknown_type $media
|
483
|
* @return unknown_type
|
484
|
*/
|
485
|
function taxon_image_gallery_default($taxon, $media){
|
486
|
|
487
|
$hasImages = isset($media[0]);
|
488
|
|
489
|
if($hasImages){
|
490
|
//
|
491
|
$maxExtend = 150;
|
492
|
$cols = 3;
|
493
|
$maxRows = false;
|
494
|
$alternativeMediaUri = null;
|
495
|
$captionElements = array('title', 'rights', '#uri'=>t('open Image'));
|
496
|
$gallery_name = $taxon->uuid;
|
497
|
$mediaLinkType = 'LIGHTBOX';
|
498
|
|
499
|
//$gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
|
500
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
|
501
|
$out = '<div class="image-gallerie">';
|
502
|
$out .= theme('cdm_media_gallerie',
|
503
|
$media,
|
504
|
$gallery_name,
|
505
|
$gallery_settings['cdm_dataportal_media_maxextend'],
|
506
|
$gallery_settings['cdm_dataportal_media_cols'],
|
507
|
0, // ignore maxrows settings
|
508
|
$captionElements,
|
509
|
$mediaLinkType,
|
510
|
null,
|
511
|
null,
|
512
|
$gallery_settings['cdm_dataportal_show_thumbnail_captions']);
|
513
|
$out .= '</div>';
|
514
|
}else{
|
515
|
$out = 'No images available.';
|
516
|
|
517
|
}
|
518
|
return $out;
|
519
|
|
520
|
}
|
521
|
|
522
|
/**
|
523
|
* TODO Implementation of Hook taxon_image_gallery()
|
524
|
*
|
525
|
* @param unknown_type $taxon
|
526
|
* @param unknown_type $media
|
527
|
* @return unknown_type
|
528
|
*/
|
529
|
function taxon_image_gallery_fsi($taxon, $media){
|
530
|
|
531
|
$flashLink = isset($media[0]);
|
532
|
|
533
|
if($flashLink){
|
534
|
|
535
|
if(module_exists("fsi_gallery")){
|
536
|
$out = theme("fsi_gallery", $taxon, $media );
|
537
|
} else {
|
538
|
$message = t('In order to use the FSI gallery you must enable the according ') . l(t("module"), "admin/build/modules");
|
539
|
drupal_set_message($message, "error");
|
540
|
$out = '<h3>' . $message . '</h3>';
|
541
|
}
|
542
|
|
543
|
}else{
|
544
|
$out = 'No images available.';
|
545
|
|
546
|
}
|
547
|
return $out;
|
548
|
|
549
|
}
|
550
|
/**
|
551
|
* Show a reference in it's atomized form
|
552
|
*/
|
553
|
function theme_cdm_reference_page($referenceTO){
|
554
|
|
555
|
/*
|
556
|
if($referenceTO->titleCache) {
|
557
|
drupal_set_title($referenceTO->titleCache);
|
558
|
} else {
|
559
|
drupal_set_title($referenceTO->fullCitation);
|
560
|
}
|
561
|
*/
|
562
|
|
563
|
$field_order = array(
|
564
|
"title",
|
565
|
//"titleCache",
|
566
|
//"citation",
|
567
|
"authorTeam",
|
568
|
"editor",
|
569
|
"publisher",
|
570
|
"placePublished",
|
571
|
"datePublished",
|
572
|
"year",
|
573
|
"edition", // class Book
|
574
|
"volume", // class Article
|
575
|
"seriesPart",
|
576
|
"inReference",
|
577
|
//"inJournal", // class Article
|
578
|
//"inBook", // class BookSection
|
579
|
"nomRefBase", // class BookSection, Book, Article
|
580
|
//"inProceedings", // class InProceedings
|
581
|
"pages", // class Article
|
582
|
"series", // class Article, PrintSeries
|
583
|
"school", // class Thesis
|
584
|
"institution", // class Report
|
585
|
"organization", // class Proceedings
|
586
|
"nextVersion",
|
587
|
"previousVersion",
|
588
|
"isbn", // class Book
|
589
|
"issn", // class Journal
|
590
|
"uri",
|
591
|
);
|
592
|
/*
|
593
|
$table_rows = array();
|
594
|
foreach($field_order as $fieldname){
|
595
|
|
596
|
if(isset($referenceTO->$fieldname)){
|
597
|
|
598
|
if($fieldname == "datePublished") {
|
599
|
$partial = $referenceTO->$fieldname;
|
600
|
$datePublished = '';
|
601
|
if($partial->start){
|
602
|
//var_dump ($partial->start);
|
603
|
$datePublishedYear = substr($partial->start, 0, 4);
|
604
|
$datePublishedMonth = substr($partial->start, 5, 2);
|
605
|
|
606
|
if (!(preg_match('#[0-9]#',$datePublishedMonth))){
|
607
|
$datePublishedMonth = '00';
|
608
|
}
|
609
|
|
610
|
$datePublishedDay = substr($partial->start, 7, 2);
|
611
|
if (!(preg_match('#[0-9]#',$datePublishedDay))){
|
612
|
$datePublishedDay = '00';
|
613
|
}
|
614
|
$datePublished = $datePublishedYear.'-'.$datePublishedMonth.'-'.$datePublishedDay;
|
615
|
}
|
616
|
if($partial->end){
|
617
|
$datePublished = (strlen($datePublished) > 0 ? ' '.t('to').' ' : '').substr($partial->end, 0, 4).'-'.substr($partial->end, 4, 2).'-'.substr($partial->end, 6, 2);
|
618
|
}
|
619
|
$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $datePublished);
|
620
|
//$datePublished = array(t(ucfirst(strtolower($fieldname))), $datePublished);
|
621
|
} else if(is_object($referenceTO->$fieldname)){
|
622
|
if ($fieldname == "authorTeam"){
|
623
|
$dump = $referenceTO->$fieldname;
|
624
|
$teammembers = "teamMembers";
|
625
|
$team = $dump->$teammembers;
|
626
|
$nameArray = array();
|
627
|
|
628
|
foreach($team as $member){
|
629
|
if (strlen($member->lastname)> 0){
|
630
|
$nname = $member->lastname;
|
631
|
$name = $nname;
|
632
|
if (strlen($member->firstname)> 0){
|
633
|
$vname = $member->firstname;
|
634
|
$name =$vname." ". $nname;
|
635
|
}
|
636
|
$nameArray[] =$name;
|
637
|
}else{
|
638
|
if (strlen($member->titleCache)> 0){
|
639
|
$nameArray[] = $member->titleCache;
|
640
|
}
|
641
|
}
|
642
|
}
|
643
|
$names = join($nameArray, ", ");
|
644
|
}else if ($fieldname == "inReference"){
|
645
|
$type = $referenceTO ->$fieldname-> type;
|
646
|
$names = $referenceTO-> $fieldname-> titleCache;
|
647
|
switch ($type) {
|
648
|
case "Book":
|
649
|
$fieldname = "in book";
|
650
|
break;
|
651
|
case "Journal":
|
652
|
$fieldname = "in journal";
|
653
|
break;
|
654
|
case "Proceedings":
|
655
|
$fieldname = "in proceedings";
|
656
|
break;
|
657
|
}
|
658
|
|
659
|
}else{
|
660
|
$names = $referenceTO->$fieldname-> titleCache;
|
661
|
}
|
662
|
$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $names);
|
663
|
//$name = array(t(ucfirst(strtolower($fieldname))), $names);
|
664
|
|
665
|
} else {
|
666
|
$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $referenceTO->$fieldname);
|
667
|
//$name = array(t(ucfirst(strtolower($fieldname))), $referenceTO->$fieldname);
|
668
|
}
|
669
|
}
|
670
|
}
|
671
|
*/
|
672
|
|
673
|
//select the type of the reference and find the in Reference attribute
|
674
|
|
675
|
$referenceData = array(
|
676
|
"title" => NULL,
|
677
|
//"titleCache",
|
678
|
//"citation",
|
679
|
"authorTeam" => NULL,
|
680
|
"editor" => NULL,
|
681
|
"publisher" => NULL,
|
682
|
"placePublished" => NULL,
|
683
|
"datePublished" => NULL,
|
684
|
"year" => NULL,
|
685
|
"edition" => NULL, // class Book
|
686
|
"volume" => NULL, // class Article
|
687
|
"seriesPart" => NULL,
|
688
|
"inReference" => NULL,
|
689
|
//"inJournal", // class Article
|
690
|
//"inBook", // class BookSection
|
691
|
"nomRefBase" => NULL, // class BookSection, Book, Article
|
692
|
//"inProceedings", // class InProceedings
|
693
|
"pages" => NULL, // class Article
|
694
|
"series" => NULL, // class Article, PrintSeries
|
695
|
"school" => NULL, // class Thesis
|
696
|
"institution" => NULL, // class Report
|
697
|
"organization" => NULL, // class Proceedings
|
698
|
"nextVersion" => NULL,
|
699
|
"previousVersion" => NULL,
|
700
|
"isbn" => NULL, // class Book
|
701
|
"issn" => NULL, // class Journal
|
702
|
"uri" => NULL,
|
703
|
);
|
704
|
|
705
|
foreach($field_order as $fieldname){
|
706
|
|
707
|
if(isset($referenceTO->$fieldname)){
|
708
|
switch($fieldname){
|
709
|
case "datePublished":
|
710
|
$partial = $referenceTO->$fieldname;
|
711
|
$datePublished = '';
|
712
|
if($partial->start){
|
713
|
$datePublishedYear = substr($partial->start, 0, 4);
|
714
|
$datePublishedMonth = substr($partial->start, 5, 2);
|
715
|
if (!(preg_match('#[0-9]#',$datePublishedMonth))){
|
716
|
$datePublishedMonth = '00';
|
717
|
}
|
718
|
$datePublishedDay = substr($partial->start, 7, 2);
|
719
|
if (!(preg_match('#[0-9]#',$datePublishedDay))){
|
720
|
$datePublishedDay = '00';
|
721
|
}
|
722
|
$datePublished = $datePublishedYear.'-'.$datePublishedMonth.'-'.$datePublishedDay;
|
723
|
}
|
724
|
if($partial->end){
|
725
|
$datePublished = (strlen($datePublished) > 0 ? ' '.t('to').' ' : '').substr($partial->end, 0, 4).'-'.substr($partial->end, 4, 2).'-'.substr($partial->end, 6, 2);
|
726
|
}
|
727
|
|
728
|
$referenceData[$fieldname] = $datePublishedYear;
|
729
|
break;
|
730
|
|
731
|
default:
|
732
|
if(is_object($referenceTO->$fieldname)){
|
733
|
if ($fieldname == "authorTeam"){
|
734
|
$dump = $referenceTO->$fieldname;
|
735
|
$teammembers = "teamMembers";
|
736
|
$team = $dump->$teammembers;
|
737
|
$nameArray = array();
|
738
|
|
739
|
foreach($team as $member){
|
740
|
if (strlen($member->lastname)> 0){
|
741
|
$nname = $member->lastname;
|
742
|
$name = $nname;
|
743
|
if (strlen($member->firstname)> 0){
|
744
|
$vname = $member->firstname;
|
745
|
$name =$vname." ". $nname;
|
746
|
}
|
747
|
$nameArray[] =$name;
|
748
|
}else{
|
749
|
if (strlen($member->titleCache)> 0){
|
750
|
$nameArray[] = $member->titleCache;
|
751
|
}
|
752
|
}
|
753
|
}
|
754
|
$names = join($nameArray, ", ");
|
755
|
$referenceData[$fieldname] = $names;
|
756
|
}else if ($fieldname == "inReference"){
|
757
|
$names = $referenceTO->$fieldname->titleCache;
|
758
|
$referenceData[$fieldname] = $names;
|
759
|
}else{
|
760
|
$names = $referenceTO->$fieldname->titleCache;
|
761
|
$referenceData[$fieldname] = $names;
|
762
|
}
|
763
|
}else{
|
764
|
$referenceData[$fieldname] = $referenceTO->$fieldname;
|
765
|
}
|
766
|
|
767
|
}
|
768
|
}
|
769
|
}
|
770
|
$author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $referenceTO->uuid);
|
771
|
//return "" . ((strlen($referenceData["authorTeam"])>0) ? ($referenceData["authorTeam"] . '. ') : '')
|
772
|
return "" . ((strlen($author_team->titleCache)>0) ? ($author_team->titleCache . '. ') : '')
|
773
|
. ((strlen($referenceData["datePublished"])>0) ? ($referenceData["datePublished"] . '. ') : '')
|
774
|
. ((strlen($referenceData["title"])>0) ? ($referenceData["title"] . '. ') : "")
|
775
|
. ((strlen($referenceData["placePublished"])>0) ? ($referenceData["placePublished"] . '. ') : '')
|
776
|
. ((strlen($referenceData["editor"])>0) ? ($referenceData["editor"] . '. ') : '')
|
777
|
. ((strlen($referenceData["publisher"])>0) ? ($referenceData["publisher"] . '. ') : '')
|
778
|
. ((strlen($referenceData["inReference"])>0) ? ($referenceData["inReference"] . '. ') : '')
|
779
|
. ((strlen($referenceData["series"])>0) ? ($referenceData["series"] . '. ') : '')
|
780
|
. ((strlen($referenceData["volume"])>0) ? ($referenceData["volume"] . '. ') : '')
|
781
|
. ((strlen($referenceData["pages"])>0) ? ($referenceData["pages"] . '. ') : '')
|
782
|
. ((strlen($referenceData["isbn"])>0) ? ($referenceData["isbn"] . '. ') : '')
|
783
|
. ((strlen($referenceData["issn"])>0) ? ($referenceData["issn"] . '. ') : '')
|
784
|
. ((strlen($referenceData["uri"])>0) ? ($referenceData["uri"] . '. ') : '');
|
785
|
|
786
|
}
|
787
|
|
788
|
|
789
|
function theme_cdm_media_page($media, $mediarepresentation_uuid = false, $partId = false){
|
790
|
$out = '';
|
791
|
// determine which reprresentation and which part to show
|
792
|
$representationIdx = 0;
|
793
|
if($mediarepresentation_uuid){
|
794
|
$i = 0;
|
795
|
foreach($media->representations as $representation) {
|
796
|
if($representation->uuid == $mediarepresentation_uuid){
|
797
|
$representationIdx = $i;
|
798
|
}
|
799
|
$i++;
|
800
|
}
|
801
|
} else {
|
802
|
$mediarepresentation_uuid = $media->representations[0]->uuid;
|
803
|
}
|
804
|
|
805
|
$partIdx = 0;
|
806
|
if(!is_numeric($partId)){
|
807
|
// assuming it is an uuid
|
808
|
$i = 0;
|
809
|
foreach($media->representations[$representationIdx]->parts as $part) {
|
810
|
if($part->uuid == $partId){
|
811
|
$partIdx = $i;
|
812
|
}
|
813
|
$i++;
|
814
|
}
|
815
|
} else {
|
816
|
// assuming it is an index
|
817
|
$partIdx = $partId;
|
818
|
}
|
819
|
|
820
|
$media_metadata = cdm_read_media_metadata($media);
|
821
|
//$title = $media->titleCache;
|
822
|
$title = $media_metadata['title'];
|
823
|
|
824
|
$imageMaxExtend = variable_get('image-page-maxextend', 400);
|
825
|
|
826
|
if(!$title){
|
827
|
$title = 'Media '.$media->uuid.'';
|
828
|
}
|
829
|
|
830
|
drupal_set_title($title);
|
831
|
|
832
|
|
833
|
$out .= '<div class="media">';
|
834
|
|
835
|
//$out .= '<div class="viewer">';
|
836
|
$out .= theme(cdm_back_to_image_gallery_button);
|
837
|
$out .= '<div class="viewer">';
|
838
|
//$out .= theme('cdm_media_gallerie_image', $representation->parts[$partIdx], $imageMaxExtend);
|
839
|
$out .= theme('cdm_openlayers_image', $media->representations[$representationIdx]->parts[$partIdx], $imageMaxExtend);
|
840
|
$out .= '</div>';
|
841
|
|
842
|
// general media metadata
|
843
|
//$media_metadata = cdm_ws_get(CDM_WS_MEDIA_METADATA, array($media->uuid));
|
844
|
//vardump("PRINTING MEDIA METADATA");
|
845
|
//vardump($media_metadata);
|
846
|
//vardump("PRINTING MEDIA");
|
847
|
//vardump($media);
|
848
|
$metadataToPrint = theme('cdm_media_caption', $media);
|
849
|
$out .= $metadataToPrint;
|
850
|
|
851
|
|
852
|
//tabs for the different representations
|
853
|
//ul.secondary
|
854
|
$out .= '<ul class="primary">';
|
855
|
foreach($media->representations as $representation){
|
856
|
$out .= '<li>'.l($media->representations[$representationIdx]->mimeType, path_to_media($media->uuid, $mediarepresentation_uuid, $partIdx)).'</li>';
|
857
|
}
|
858
|
$out .= '</ul>';
|
859
|
|
860
|
// representation(-part) specific metadata
|
861
|
$thumbnailMaxExtend = 100;
|
862
|
$out .= '<table>';
|
863
|
//$out .= '<tr><th colspan="3">'.t('MimeType').': '.$media->representations[$representationIdx]->mimeType.'</th></tr>';
|
864
|
$i = 0;
|
865
|
foreach($media->representations[$representationIdx]->parts as $part){
|
866
|
$out .= '<tr><th>'.t('Part').' '.($i + 1).'</th><td>';
|
867
|
switch($part->class){
|
868
|
case 'ImageFile': $out .= $part->width.' x '.$part->height.' - '.$part->size.'k'; break;
|
869
|
case 'AudioFile':
|
870
|
case 'MovieFile': $out .= t('Duration').': '.$part->duration.'s - '.$part->size.'k'; break;
|
871
|
default: $out .= $part->size.'k';
|
872
|
}
|
873
|
$out .= '</td><td><a href="'.url(path_to_media($media->uuid, $mediarepresentation_uuid, $i)).'">'
|
874
|
.theme('cdm_media_gallerie_image', $part, $thumbnailMaxExtend, true);'</a></td><tr>';
|
875
|
$i++;
|
876
|
}
|
877
|
$out .= '</table>';
|
878
|
$out .= '</div>';
|
879
|
|
880
|
return $out;
|
881
|
}
|
882
|
|
883
|
|
884
|
|
885
|
|
886
|
function theme_cdm_polytomousKey_page($polytomousKey){
|
887
|
|
888
|
drupal_set_title($polytomousKey->titleCache);
|
889
|
|
890
|
$out = theme("cdm_IdentificationKey", $polytomousKey, false, false);
|
891
|
|
892
|
// key nodes in linked style
|
893
|
$out .= theme('cdm_polytomousKey', $polytomousKey);
|
894
|
/* FIXME implement node type for keys !!!
|
895
|
* (wrapping the content in the cdm_dataportal.node becomes obsolete then)
|
896
|
*/
|
897
|
return '<div id="cdm_dataportal.node">' . $out . '</div>';
|
898
|
}
|
899
|
|
900
|
/**
|
901
|
* Allows theming of the taxon page tabs
|
902
|
*
|
903
|
* @param $tabname
|
904
|
* @return unknown_type
|
905
|
*/
|
906
|
function theme_cdm_taxonpage_tab($tabname){
|
907
|
//TODO replace by using translations or theme the menue tabs itself instead?
|
908
|
switch($tabname){
|
909
|
default: return t($tabname);
|
910
|
}
|
911
|
}
|
912
|
|