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