1
|
<?php
|
2
|
/**
|
3
|
* @file
|
4
|
* Page theming functions.
|
5
|
*
|
6
|
* @copyright
|
7
|
* (C) 2007-2012 EDIT
|
8
|
* European Distributed Institute of Taxonomy
|
9
|
* http://www.e-taxonomy.eu
|
10
|
*
|
11
|
* The contents of this module are subject to the Mozilla
|
12
|
* Public License Version 1.1.
|
13
|
* @see http://www.mozilla.org/MPL/MPL-1.1.html
|
14
|
*/
|
15
|
|
16
|
/**
|
17
|
* Returns HTML for the default title of a taxon page.
|
18
|
* * The returned title is a formatted taxon name.
|
19
|
*
|
20
|
* @param array $variables
|
21
|
* An associative array containing:
|
22
|
* - taxon: The taxon name being formatted for the title.
|
23
|
* - uuid: UUID for the taxon.
|
24
|
*
|
25
|
* @ingroup themeable
|
26
|
*/
|
27
|
function theme_cdm_taxon_page_title($variables) {
|
28
|
$taxon = $variables['taxon'];
|
29
|
$uuid = $variables['uuid'];
|
30
|
RenderHints::pushToRenderStack('taxon_page_title');
|
31
|
$referenceUri = '';
|
32
|
$out = '';
|
33
|
if (isset($taxon->name->nomenclaturalReference)) {
|
34
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
35
|
}
|
36
|
|
37
|
$out .= theme('cdm_taxonName', array(
|
38
|
'taxonName' => $taxon->name,
|
39
|
'nameLink' => NULL,
|
40
|
'refenceLink' => $referenceUri,
|
41
|
'show_annotations' => FALSE,
|
42
|
));
|
43
|
RenderHints::popFromRenderStack();
|
44
|
|
45
|
return '<span class="' . $taxon->class . '">' . $out . '</span>';
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
* Returns HTML for the default title for a name page.
|
50
|
*
|
51
|
* The returned title is a formatted name.
|
52
|
*
|
53
|
* @param array $variables
|
54
|
* An associative array containing:
|
55
|
* - taxon_name: The taxon name object.
|
56
|
*
|
57
|
* @ingroup themeable
|
58
|
*/
|
59
|
function theme_cdm_name_page_title($variables) {
|
60
|
$taxon_name = $variables['taxon_name'];
|
61
|
RenderHints::pushToRenderStack('taxon_page_title');
|
62
|
if (isset($taxon_name->nomenclaturalReference)) {
|
63
|
$referenceUri = url(path_to_reference($taxon_name->nomenclaturalReference->uuid));
|
64
|
}
|
65
|
|
66
|
$out = '<span class="' . $taxon_name->class . '">' . theme('cdm_taxonName', array(
|
67
|
'taxonName' => $taxon_name,
|
68
|
'nameLink' => NULL,
|
69
|
'refenceLink' => $referenceUri,
|
70
|
'show_annotations' => FALSE,
|
71
|
)) . '</span>';
|
72
|
RenderHints::popFromRenderStack();
|
73
|
return $out;
|
74
|
}
|
75
|
|
76
|
/**
|
77
|
* Returns HTML for a taxon page.
|
78
|
*
|
79
|
* A wrapper function that groups available information to show by default,
|
80
|
* when a taxon page is requested by the browser.
|
81
|
* Individual themeing has to decide what this page should include (see methods
|
82
|
* beneath) and what information should go into tabs or should not be shown
|
83
|
* at all.
|
84
|
*
|
85
|
* It is headed by the name of the accepted taxon without author and reference.
|
86
|
*
|
87
|
* @param array $variables
|
88
|
* An associative array containing:
|
89
|
* - taxon: The taxon object for which to theme the page.
|
90
|
* - page_part: Name of the part to display, valid values are:
|
91
|
* 'description', 'images', 'synonymy', 'all'.
|
92
|
*
|
93
|
* @ingroup themeable
|
94
|
*/
|
95
|
function theme_cdm_taxon_page($variables) {
|
96
|
|
97
|
$taxon = $variables['taxon'];
|
98
|
$page_part = $variables['page_part'];
|
99
|
global $theme;
|
100
|
|
101
|
$render_array = array();
|
102
|
$weight = 0; // the weight for the render array elements
|
103
|
|
104
|
$tabsToDisplay = variable_get('cdm_taxonpage_tabs_visibility', unserialize(TAXONPAGE_VISIBILITY_OPTIONS_DEFAULT));
|
105
|
|
106
|
$page_part = variable_get('cdm_dataportal_taxonpage_tabs', 1) ? $page_part : 'all';
|
107
|
|
108
|
$media = _load_media_for_taxon($taxon);
|
109
|
|
110
|
|
111
|
if (!isset($media[0]) || ($tabsToDisplay["Images"] == '0')) {
|
112
|
taxon_page_tabs_hidden('images');
|
113
|
}
|
114
|
|
115
|
// HideImage flag depending on administative preset.
|
116
|
$hideImages = FALSE;
|
117
|
if (variable_get('image_hide_rank', '0') != '0' && isset($taxon->name->rank->uuid)) {
|
118
|
$rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
|
119
|
$hideImages = ($rankCompare > -1);
|
120
|
}
|
121
|
|
122
|
// --- GET specimensOrObservations --- //
|
123
|
$specimensOrObservations = cdm_ws_get(CDM_WS_TAXON, array( $taxon->uuid, 'specimensOrObservations'));
|
124
|
|
125
|
$specimensOrObservationsCount = is_array($specimensOrObservations) ? count($specimensOrObservations) : 0;
|
126
|
if ($specimensOrObservationsCount == 0 || ($tabsToDisplay["Specimens"] == '0')) {
|
127
|
taxon_page_tabs_hidden('specimens');
|
128
|
}
|
129
|
|
130
|
// --- GET polytomousKeys --- //
|
131
|
$polytomousKeysPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, NULL, "findByTaxonomicScope=$taxon->uuid");
|
132
|
$identificationKeyCount = 0;
|
133
|
if ($polytomousKeysPager) {
|
134
|
$identificationKeyCount += $polytomousKeysPager->count;
|
135
|
}
|
136
|
if ($identificationKeyCount == 0 || ($tabsToDisplay["Keys"] == '0')) {
|
137
|
taxon_page_tabs_hidden('keys');
|
138
|
}
|
139
|
|
140
|
if ($tabsToDisplay["Synonymy"] == '0') {
|
141
|
taxon_page_tabs_hidden('synonymy');
|
142
|
}
|
143
|
|
144
|
// -------------------------------------------- //
|
145
|
|
146
|
$render_array['back_to_search'] = markup_to_render_array(theme('cdm_back_to_search_result_button'), $weight++);
|
147
|
|
148
|
if (variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR)) {
|
149
|
$render_array['accepted_for'] = theme('cdm_acceptedFor', 'page_general');
|
150
|
}
|
151
|
|
152
|
// --- PAGE PART: DESCRIPTION --- //
|
153
|
if ($page_part == 'description' || $page_part == 'all') {
|
154
|
|
155
|
$markerTypesEmpty = array();
|
156
|
$markerTypesEmpty['markerTypes'] = '';
|
157
|
$queryString = $markerTypesEmpty['markerTypes'] ? queryString($markerTypesEmpty) : '';
|
158
|
// Retrieve all descriptions for the taxon.
|
159
|
$taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon->uuid, $queryString);
|
160
|
|
161
|
$nonStructuredDescriptions = array();
|
162
|
if ($taxonDescriptions != NULL) {
|
163
|
foreach ($taxonDescriptions as $taxonDescription) {
|
164
|
// Check if structured description.
|
165
|
$hasStructuredData = cdm_ws_get(CDM_WS_DESCRIPTION_HAS_STRUCTRURED_DATA, $taxonDescription->uuid);
|
166
|
if (isset($hasStructuredData->Boolean)) {
|
167
|
$hasStructuredData = $hasStructuredData->Boolean == 'TRUE';
|
168
|
}
|
169
|
if ($hasStructuredData) {
|
170
|
$structured_description_featuretree_uuid = variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, FALSE);
|
171
|
if($structured_description_featuretree_uuid) {
|
172
|
// if a feature tree for natural language generation has been defined use it,
|
173
|
// otherwise natural language generation is skipped
|
174
|
$naturallanguage_textData = cdm_ws_get(CDM_WS_DESCRIPTION_NATURALLANGUAGE_DESCRIPTION, array(
|
175
|
$taxonDescription->uuid,
|
176
|
$structured_description_featuretree_uuid,
|
177
|
));
|
178
|
|
179
|
if (!isset($naturallanguage_textData)) {
|
180
|
drupal_set_message(
|
181
|
t(
|
182
|
"The 'FeatureTree' for the generation of natural language representations is not configured correctly,"
|
183
|
." please select a 'FeatureTree' in the !settings",
|
184
|
array(
|
185
|
'!settings' => l(t('CDM Dataportal Settings'), 'admin/config/cdm_dataportal/layout/taxon'))
|
186
|
),
|
187
|
'warning');
|
188
|
} else {
|
189
|
$taxonDescription->elements = NULL;
|
190
|
$taxonDescription->elements = array(
|
191
|
$naturallanguage_textData,
|
192
|
);
|
193
|
}
|
194
|
}
|
195
|
}
|
196
|
$nonStructuredDescriptions[] = $taxonDescription;
|
197
|
}
|
198
|
// Release memory.
|
199
|
$taxonDescriptions = NULL;
|
200
|
}
|
201
|
|
202
|
$mergedTrees = cdm_ws_descriptions_by_featuretree(get_profile_featureTree(), $nonStructuredDescriptions, variable_get('cdm_dataportal_descriptions_separated', FALSE));
|
203
|
|
204
|
$profile_html = '<div id="general">';
|
205
|
$profile_html .= theme('cdm_taxon_page_profile', array(
|
206
|
'taxon' => $taxon,
|
207
|
'mergedTrees' => $mergedTrees,
|
208
|
'media' => $media,
|
209
|
'hideImages' => $hideImages,
|
210
|
));
|
211
|
$profile_html .= '</div>';
|
212
|
$render_array['profile'] = markup_to_render_array($profile_html, $weight++);
|
213
|
}
|
214
|
|
215
|
// --- PAGE PART: IMAGES --- //
|
216
|
if ((!$hideImages && $page_part == 'images' || $page_part == 'all')) {
|
217
|
$images_html = '<div id="images">';
|
218
|
if ($page_part == 'all') {
|
219
|
$images_html .= '<h2>' . t('Images') . '</h2>';
|
220
|
}
|
221
|
// Get the image gallery as configured by the admin.
|
222
|
$taxon_image_gallery = call_user_func_array('taxon_image_gallery_' . variable_get('image_gallery_viewer', 'default'), array(
|
223
|
$taxon,
|
224
|
$media,
|
225
|
));
|
226
|
$images_html .= $taxon_image_gallery;
|
227
|
$images_html .= '</div>';
|
228
|
$render_array['images'] = markup_to_render_array($images_html, $weight++);
|
229
|
}
|
230
|
|
231
|
// --- PAGE PART: SYNONYMY --- //
|
232
|
if (($page_part == 'synonymy' || $page_part == 'all')) {
|
233
|
$synonymy_html = '<div id="synonymy">';
|
234
|
if ($page_part == 'all') {
|
235
|
$synonymy_html .= '<h2>' . t('Synonymy') . '</h2>';
|
236
|
}
|
237
|
$addAcceptedTaxon = variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE);
|
238
|
$synonymy_html .= theme('cdm_taxon_page_synonymy', array('taxon' => $taxon, 'addAcceptedTaxon' => $addAcceptedTaxon));
|
239
|
|
240
|
$synonymy_html .= '</div>';
|
241
|
$render_array['synonymy'] = markup_to_render_array($synonymy_html, $weight++);
|
242
|
}
|
243
|
|
244
|
// --- PAGE PART: SPECIMENS --- //
|
245
|
if ($specimensOrObservationsCount > 0 && ($page_part == 'specimens' || $page_part == 'all')) {
|
246
|
$render_array['specimens'] = array(
|
247
|
'#prefix' => '<div id="specimens">' . ($page_part == 'all' ? '<h2>' . t('Specimens') . '</h2>' : ''),
|
248
|
'content' => cdm_dataportal_taxon_page_specimens($taxon), // returns render array
|
249
|
'#suffix' => '</div>',
|
250
|
);
|
251
|
}
|
252
|
|
253
|
// --- PAGE PART: KEYS --- //
|
254
|
if ($identificationKeyCount > 0 && ($page_part == 'keys' || $page_part == 'all')) {
|
255
|
$keys_html = '<div id="keys">';
|
256
|
if ($page_part == 'all') {
|
257
|
$keys_html .= '<h2>' . t('Keys') . '</h2>';
|
258
|
}
|
259
|
$keys_html .= theme('cdm_block_IdentificationKeys', array('taxonUuid' => $taxon->uuid));
|
260
|
$keys_html .= '</div>';
|
261
|
$render_array['keys'] = markup_to_render_array($keys_html, $weight++);
|
262
|
}
|
263
|
|
264
|
return $render_array;
|
265
|
}
|
266
|
|
267
|
/**
|
268
|
* Returns HTML containing descriptive data and preferred picture.
|
269
|
*
|
270
|
* Outputs all descriptive data and shows the preferred picture of the
|
271
|
* accepted taxon.
|
272
|
*
|
273
|
* @param array $variables
|
274
|
* An associative array containing:
|
275
|
* - taxon
|
276
|
* - mergedTrees
|
277
|
* - media:
|
278
|
* - hideImages
|
279
|
*
|
280
|
* @ingroup themeable
|
281
|
*/
|
282
|
function theme_cdm_taxon_page_profile($variables) {
|
283
|
$taxon = $variables['taxon'];
|
284
|
$mergedTrees = $variables['mergedTrees'];
|
285
|
$media = $variables['media'];
|
286
|
$hideImages = $variables['hideImages'];
|
287
|
$out = '';
|
288
|
if (variable_get('cdm_dataportal_show_default_image', FALSE) && !$hideImages) {
|
289
|
|
290
|
// Preferred image hardcoded for testing.
|
291
|
$defaultRepresentationPart = new stdClass();
|
292
|
$defaultRepresentationPart->width = 184;
|
293
|
$defaultRepresentationPart->height = 144;
|
294
|
$defaultRepresentationPart->uri = drupal_get_path('theme', 'palmweb_2') . '/images/no_picture.png';
|
295
|
|
296
|
// Preferred image size 184px × 144.
|
297
|
$imageMaxExtend = 184;
|
298
|
$out .= '<div id="taxonProfileImage">' . theme('cdm_preferredImage', array(
|
299
|
'media' => $media,
|
300
|
'defaultRepresentationPart' => $defaultRepresentationPart,
|
301
|
'imageMaxExtend' => $imageMaxExtend,
|
302
|
)) . '</div>';
|
303
|
}
|
304
|
|
305
|
// Description TOC.
|
306
|
$out .= theme('cdm_featureTreeTOCs', array('mergedTrees' => $mergedTrees));
|
307
|
|
308
|
// Description.
|
309
|
$out .= theme('cdm_featureTrees', array('mergedTrees' => $mergedTrees, 'taxon' => $taxon));
|
310
|
|
311
|
return $out;
|
312
|
}
|
313
|
|
314
|
|
315
|
|
316
|
/**
|
317
|
* Returns HTML containing the synonymy for the accepted taxon.
|
318
|
*
|
319
|
* Shows the whole synonymy for the accepted taxon.
|
320
|
* The synonymy list is headed by the complete scientific name
|
321
|
* of the accepted taxon with nomenclatural reference.
|
322
|
*
|
323
|
* @param array $variables
|
324
|
* An associative array containing:
|
325
|
* - taxon
|
326
|
* - addAcceptedTaxon
|
327
|
*
|
328
|
* @ingroup themeable
|
329
|
*/
|
330
|
function theme_cdm_taxon_page_synonymy($variables) {
|
331
|
$taxon = $variables['taxon'];
|
332
|
$addAcceptedTaxon = $variables['addAcceptedTaxon'];
|
333
|
RenderHints::pushToRenderStack('taxon_page_synonymy');
|
334
|
$synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, $taxon->uuid);
|
335
|
$skip = array(
|
336
|
UUID_BASIONYM,
|
337
|
);
|
338
|
$out = '';
|
339
|
|
340
|
// Render accepted taxon.
|
341
|
$referenceUri = '';
|
342
|
if ($addAcceptedTaxon) {
|
343
|
if (isset($taxon->name->nomenclaturalReference)) {
|
344
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
345
|
}
|
346
|
|
347
|
$accepted_name = '<span class="accepted-name">';
|
348
|
$accepted_name .= theme('cdm_taxonName', array(
|
349
|
'taxonName' => $taxon->name,
|
350
|
'nameLink' => NULL,
|
351
|
'refenceLink' => $referenceUri,
|
352
|
));
|
353
|
$accepted_name .= '</span>';
|
354
|
|
355
|
$special_annotations_array = array();
|
356
|
$special_annotations_array[] = $taxon->name;
|
357
|
$special_annotations_array[] = $taxon;
|
358
|
$accepted_name .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $special_annotations_array, 'footnote_list_key' => RenderHints::getRenderPath() . '-annotations'));
|
359
|
RenderHints::setFootnoteListKey(RenderHints::getRenderPath() . '-annotations');
|
360
|
}
|
361
|
|
362
|
// Render homotypic synonymy group.
|
363
|
$hasHomotypicSynonyms = isset($synomymie->homotypicSynonymsByHomotypicGroup[0]->name->uuid);
|
364
|
|
365
|
if (!empty($accepted_name)) {
|
366
|
$out .= $accepted_name;
|
367
|
}
|
368
|
|
369
|
if (!$hasHomotypicSynonyms) {
|
370
|
// Show typeDesignations even if the homotypic synonymy group is empty.
|
371
|
$typeDesignations = cdm_ws_get(CDM_WS_PORTAL_TAXON_NAMETYPEDESIGNATIONS, $taxon->uuid);
|
372
|
if ($typeDesignations) {
|
373
|
$out .= theme('cdm_typedesignations', array('typeDesignations' => $typeDesignations));
|
374
|
}
|
375
|
if (!empty($typeDesignations) || !empty($accepted_name)) {
|
376
|
// Add empty list for coherent layout.
|
377
|
$out .= '<ul class="homotypicSynonyms"></ul>';
|
378
|
}
|
379
|
}
|
380
|
else {
|
381
|
// Render the homotypicSynonymyGroup including the type information.
|
382
|
$out .= theme('cdm_homotypicSynonymyGroup', array('synonymList' => $synomymie->homotypicSynonymsByHomotypicGroup, 'accepted_taxon_uuid' => $taxon->uuid));
|
383
|
}
|
384
|
// all footnotes which has been assembled so far (e.g. from typeDesignations) to here
|
385
|
$out .= '<ul class="footnotes">';
|
386
|
$out .= theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getRenderPath(), 'enclosingTag' => 'li'));
|
387
|
$out .= '</ul>';
|
388
|
|
389
|
|
390
|
// Render accepted taxon heterotypic synonymy groups.
|
391
|
if ($synomymie->heterotypicSynonymyGroups) {
|
392
|
foreach ($synomymie->heterotypicSynonymyGroups as $homotypicalGroup) {
|
393
|
$out .= theme('cdm_heterotypicSynonymyGroup', array('homotypicalGroup' => $homotypicalGroup));
|
394
|
}
|
395
|
}
|
396
|
// Render taxon relationships.
|
397
|
if (variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)) {
|
398
|
$taxonRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, $taxon->uuid);
|
399
|
$out .= theme('cdm_taxonRelationships', array('taxonRelationships' => $taxonRelationships, 'focusedTaxon' => $taxon));
|
400
|
}
|
401
|
// Render name relationships.
|
402
|
$name_rels_to_show = variable_get('name_relationships_to_show', NULL);
|
403
|
$skip = array();
|
404
|
if ($name_rels_to_show) {
|
405
|
foreach ($name_rels_to_show as $key => $value) {
|
406
|
if ($value === 0) {
|
407
|
$skip[] = $key;
|
408
|
}
|
409
|
}
|
410
|
if (sizeof($name_rels_to_show) != sizeof($skip)) {
|
411
|
$nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
|
412
|
$out .= theme('cdm_nameRelationships', array('nameRelationships' => $nameRelationships, 'skipTypes' => $skip));
|
413
|
}
|
414
|
}
|
415
|
|
416
|
// Render the annontations text for the accepted taxa.
|
417
|
if ($addAcceptedTaxon) {
|
418
|
$out .= theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getRenderPath() . '-annotations', 'enclosingTag' => 'li'));
|
419
|
}
|
420
|
RenderHints::popFromRenderStack();
|
421
|
|
422
|
return $out;
|
423
|
}
|
424
|
|
425
|
/**
|
426
|
* TODO Implementation of Hook taxon_image_gallery()
|
427
|
*
|
428
|
* @param unknown_type $taxon
|
429
|
* @param unknown_type $media
|
430
|
*
|
431
|
* @return unknown_type
|
432
|
*/
|
433
|
function taxon_image_gallery_default($taxon, $media) {
|
434
|
$hasImages = isset($media[0]);
|
435
|
|
436
|
if ($hasImages) {
|
437
|
|
438
|
$maxExtend = 150;
|
439
|
$cols = 3;
|
440
|
$maxRows = FALSE;
|
441
|
$alternativeMediaUri = NULL;
|
442
|
/* Comment @WA: was in D5:
|
443
|
$captionElements = array(
|
444
|
'title',
|
445
|
'rights',
|
446
|
'#uri' => t('open Image'),
|
447
|
);
|
448
|
*/
|
449
|
$captionElements = array(
|
450
|
'title',
|
451
|
'description',
|
452
|
'artist',
|
453
|
'location',
|
454
|
'rights',
|
455
|
'#uri' => t('open Image'),
|
456
|
);
|
457
|
$gallery_name = $taxon->uuid;
|
458
|
$mediaLinkType = 'LIGHTBOX';
|
459
|
|
460
|
// $gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
|
461
|
|
462
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
|
463
|
|
464
|
$out = '<div class="image-gallerie">';
|
465
|
$out .= theme('cdm_media_gallerie', array(
|
466
|
'mediaList' => $media,
|
467
|
'galleryName' => $gallery_name,
|
468
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
469
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
470
|
'maxRows' => 0, // Ignore maxrows settings.
|
471
|
'captionElements' => $captionElements,
|
472
|
'mediaLinkType' => $mediaLinkType,
|
473
|
'alternativeMediaUri' => NULL,
|
474
|
'galleryLinkUri' => NULL,
|
475
|
'showCaption' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
|
476
|
));
|
477
|
$out .= '</div>';
|
478
|
}
|
479
|
else {
|
480
|
$out = 'No images available.';
|
481
|
}
|
482
|
return $out;
|
483
|
}
|
484
|
|
485
|
/**
|
486
|
* TODO Implementation of Hook taxon_image_gallery()
|
487
|
*
|
488
|
* @param unknown_type $taxon
|
489
|
* @param unknown_type $media
|
490
|
*
|
491
|
* @return unknown_type
|
492
|
*/
|
493
|
function taxon_image_gallery_fsi($taxon, $media) {
|
494
|
$flashLink = isset($media[0]);
|
495
|
|
496
|
if ($flashLink) {
|
497
|
|
498
|
if (module_exists("fsi_gallery")) {
|
499
|
$out = theme("fsi_gallery", array('taxon' => $taxon, 'media' => $media));
|
500
|
}
|
501
|
else {
|
502
|
$message = t('In order to use the FSI gallery you must enable the according ') . l(t("module"), "admin/modules");
|
503
|
drupal_set_message($message, "error");
|
504
|
$out = '<h3>' . $message . '</h3>';
|
505
|
}
|
506
|
}
|
507
|
else {
|
508
|
$out = 'No images available.';
|
509
|
}
|
510
|
return $out;
|
511
|
}
|
512
|
|
513
|
/**
|
514
|
* Returns HTML for a single reference page.
|
515
|
*
|
516
|
* Renders a page with all data on a single reference.
|
517
|
*
|
518
|
* @param array $variables
|
519
|
* An associative array containing:
|
520
|
* - reference: Object.
|
521
|
*
|
522
|
* @ingroup themeable
|
523
|
*/
|
524
|
function theme_cdm_reference_page($variables) {
|
525
|
$reference = $variables['reference'];
|
526
|
|
527
|
$out = '';
|
528
|
|
529
|
if (isset($reference->titleCache)) {
|
530
|
drupal_set_title($reference->titleCache, PASS_THROUGH);
|
531
|
}
|
532
|
|
533
|
$field_order = array(
|
534
|
"title",
|
535
|
// "titleCache",
|
536
|
// "citation",
|
537
|
"authorTeam",
|
538
|
"editor",
|
539
|
"publisher",
|
540
|
"placePublished",
|
541
|
"datePublished",
|
542
|
"year",
|
543
|
"edition",// Class Book.
|
544
|
"volume",// Class Article.
|
545
|
"seriesPart",
|
546
|
"inReference",
|
547
|
"nomRefBase", // Class BookSection, Book, Article.
|
548
|
"pages",// Class Article.
|
549
|
"series",// Class Article, PrintSeries.
|
550
|
"school",// Class Thesis.
|
551
|
"institution",// Class Report.
|
552
|
"organization",// Class Proceedings.
|
553
|
"nextVersion",
|
554
|
"previousVersion",
|
555
|
"isbn",// Class Book.
|
556
|
"issn",// Class Journal.
|
557
|
"uri",
|
558
|
);
|
559
|
|
560
|
$header = array(
|
561
|
t('Field'),
|
562
|
t('Value'),
|
563
|
);
|
564
|
$table_rows = array();
|
565
|
|
566
|
if (!isset($reference->authorTeam)) {
|
567
|
$authorTeam = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
|
568
|
$reference->authorTeam = isset($authorTeam->titleCache) ? $authorTeam->titleCache : '';
|
569
|
}
|
570
|
|
571
|
if (!isset($reference->inReference)) {
|
572
|
$reference->inReference = cdm_ws_get(CDM_WS_REFERENCE, array(
|
573
|
$reference->uuid,
|
574
|
"inReference",
|
575
|
));
|
576
|
}
|
577
|
|
578
|
foreach ($field_order as $fieldname) {
|
579
|
|
580
|
if (isset($reference->$fieldname)) {
|
581
|
|
582
|
if ($fieldname == "datePublished") {
|
583
|
$period = $reference->$fieldname;
|
584
|
$datePublished = timePeriodToString($period);
|
585
|
if (isset($datePublished) && $datePublished != '') {
|
586
|
$table_rows[] = array(
|
587
|
t(ucfirst(strtolower($fieldname))),
|
588
|
$datePublished,
|
589
|
);
|
590
|
}
|
591
|
// $datePublished = array(t(ucfirst(strtolower($fieldname))),
|
592
|
// $datePublished);
|
593
|
}
|
594
|
elseif (is_object($reference->$fieldname)) {
|
595
|
if ($fieldname == "authorTeam") {
|
596
|
$dump = $reference->$fieldname;
|
597
|
$teammembers = "teamMembers";
|
598
|
$team = $dump->$teammembers;
|
599
|
$nameArray = array();
|
600
|
|
601
|
foreach ($team as $member) {
|
602
|
if (strlen($member->lastname) > 0) {
|
603
|
$nname = $member->lastname;
|
604
|
$name = $nname;
|
605
|
if (strlen($member->firstname) > 0) {
|
606
|
$vname = $member->firstname;
|
607
|
$name = $vname . " " . $nname;
|
608
|
}
|
609
|
$nameArray[] = $name;
|
610
|
}
|
611
|
else {
|
612
|
if (strlen($member->titleCache) > 0) {
|
613
|
$nameArray[] = $member->titleCache;
|
614
|
}
|
615
|
}
|
616
|
}
|
617
|
$value = join($nameArray, ", ");
|
618
|
}
|
619
|
elseif ($fieldname == "inReference") {
|
620
|
$type = $reference->$fieldname->type;
|
621
|
$value = l($reference->$fieldname->titleCache, path_to_reference($reference->$fieldname->uuid));
|
622
|
switch ($type) {
|
623
|
case "Book":
|
624
|
$fieldname = "in book";
|
625
|
break;
|
626
|
case "Journal":
|
627
|
$fieldname = "in journal";
|
628
|
break;
|
629
|
case "Proceedings":
|
630
|
$fieldname = "in proceedings";
|
631
|
break;
|
632
|
}
|
633
|
}
|
634
|
else {
|
635
|
$value = $reference->$fieldname->titleCache;
|
636
|
}
|
637
|
if (isset($value) && $value != '') {
|
638
|
$table_rows[] = array(
|
639
|
t(ucfirst(strtolower($fieldname))),
|
640
|
$value,
|
641
|
);
|
642
|
}
|
643
|
}
|
644
|
else {
|
645
|
if (isset($reference->$fieldname) && $reference->$fieldname != '') {
|
646
|
$table_rows[] = array(
|
647
|
t(ucfirst(strtolower($fieldname))),
|
648
|
$reference->$fieldname,
|
649
|
);
|
650
|
}
|
651
|
}
|
652
|
}
|
653
|
}
|
654
|
|
655
|
$out = theme_table(array(
|
656
|
'header' => array(),
|
657
|
'rows' => $table_rows,
|
658
|
'attributes' => array(),
|
659
|
'caption' => NULL,
|
660
|
'colgroups' => NULL,
|
661
|
'sticky' => NULL,
|
662
|
'empty' => NULL,
|
663
|
));
|
664
|
|
665
|
// Annotations below the table.
|
666
|
$annotations = cdm_ws_getAnnotationsFor($reference);
|
667
|
$out .= theme("cdm_annotations", array('annotations' => $annotations));
|
668
|
|
669
|
return $out;
|
670
|
}
|
671
|
|
672
|
/**
|
673
|
* @todo Please document this function.
|
674
|
* @see http://drupal.org/node/1354
|
675
|
*/
|
676
|
function theme_cdm_media_page($variables) {
|
677
|
$media = $variables['media'];
|
678
|
$mediarepresentation_uuid = $variables['mediarepresentation_uuid'];
|
679
|
$partId = $variables['partId'];
|
680
|
$out = '';
|
681
|
// Determine which reprresentation and which part to show.
|
682
|
$representationIdx = 0;
|
683
|
if ($mediarepresentation_uuid) {
|
684
|
$i = 0;
|
685
|
foreach ($media->representations as $representation) {
|
686
|
if ($representation->uuid == $mediarepresentation_uuid) {
|
687
|
$representationIdx = $i;
|
688
|
}
|
689
|
$i++;
|
690
|
}
|
691
|
}
|
692
|
else {
|
693
|
$mediarepresentation_uuid = $media->representations[0]->uuid;
|
694
|
}
|
695
|
|
696
|
$partIdx = 0;
|
697
|
if (!is_numeric($partId)) {
|
698
|
// Assuming it is an uuid.
|
699
|
$i = 0;
|
700
|
foreach ($media->representations[$representationIdx]->parts as $part) {
|
701
|
if ($part->uuid == $partId) {
|
702
|
$partIdx = $i;
|
703
|
}
|
704
|
$i++;
|
705
|
}
|
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, PASS_THROUGH);
|
723
|
|
724
|
$out .= '<div class="media cdm_media_viewer_image">';
|
725
|
|
726
|
$out .= theme('cdm_back_to_image_gallery_button', array());
|
727
|
$out .= '<div class="viewer">';
|
728
|
$out .= theme('cdm_openlayers_image', array('mediaRepresentationPart' => $media->representations[$representationIdx]->parts[$partIdx], 'maxExtend' => $imageMaxExtend));
|
729
|
$out .= '</div>';
|
730
|
|
731
|
// General media metadata.
|
732
|
/*
|
733
|
$media_metadata = cdm_ws_get(CDM_WS_MEDIA_METADATA, array($media->uuid));
|
734
|
vardump("PRINTING MEDIA METADATA");
|
735
|
vardump($media_metadata);
|
736
|
vardump("PRINTING MEDIA");
|
737
|
vardump($media);
|
738
|
*/
|
739
|
$metadataToPrint = theme('cdm_media_caption', array('media' => $media));
|
740
|
$out .= $metadataToPrint;
|
741
|
|
742
|
// Tabs for the different representations.
|
743
|
// ul.secondary
|
744
|
$out .= '<ul class="primary">';
|
745
|
foreach ($media->representations as $representation) {
|
746
|
$out .= '<li>' . l($media->representations[$representationIdx]->mimeType, path_to_media($media->uuid, $mediarepresentation_uuid, $partIdx)) . '</li>';
|
747
|
}
|
748
|
$out .= '</ul>';
|
749
|
|
750
|
// Representation(-part) specific metadata.
|
751
|
$thumbnailMaxExtend = 100;
|
752
|
$out .= '<table>';
|
753
|
$i = 0;
|
754
|
foreach ($media->representations[$representationIdx]->parts as $part) {
|
755
|
$out .= '<tr><th>' . t('Part') . ' ' . ($i + 1) . '</th><td>';
|
756
|
switch ($part->class) {
|
757
|
case 'ImageFile':
|
758
|
$out .= $part->width . ' x ' . $part->height . ' - ' . $part->size . 'k';
|
759
|
break;
|
760
|
case 'AudioFile':
|
761
|
case 'MovieFile':
|
762
|
$out .= t('Duration') . ': ' . $part->duration . 's - ' . $part->size . 'k';
|
763
|
break;
|
764
|
default:
|
765
|
$out .= $part->size . 'k';
|
766
|
}
|
767
|
|
768
|
$out .= '</td><td><a href="' . url(path_to_media($media->uuid, $mediarepresentation_uuid, $i)) . '">' . theme('cdm_media_gallerie_image', array('mediaRepresentationPart' => $part, 'maxExtend' => $thumbnailMaxExtend, 'addPassePartout' => TRUE));
|
769
|
$i++;
|
770
|
}
|
771
|
$out .= '</table>';
|
772
|
$out .= '</div>';
|
773
|
|
774
|
return $out;
|
775
|
}
|
776
|
|
777
|
/**
|
778
|
* @todo Please document this function.
|
779
|
* @see http://drupal.org/node/1354
|
780
|
*/
|
781
|
function theme_cdm_polytomousKey_page($variables) {
|
782
|
$polytomousKey = $variables['polytomousKey'];
|
783
|
drupal_set_title($polytomousKey->titleCache, PASS_THROUGH);
|
784
|
|
785
|
$out = theme("cdm_IdentificationKey", array(
|
786
|
'identificationKey' => $polytomousKey,
|
787
|
'doLinkToKeyPage' => FALSE,
|
788
|
'showIdentificationKeyTitle' => FALSE,
|
789
|
));
|
790
|
|
791
|
// Key nodes in linked style.
|
792
|
$out .= theme('cdm_polytomousKey', array('polytomousKey' => $polytomousKey));
|
793
|
/*
|
794
|
FIXME implement node type for keys !!! (wrapping the content in the
|
795
|
cdm_dataportal.node becomes obsolete then).
|
796
|
*/
|
797
|
return '<div id="cdm_dataportal.node">' . $out . '</div>';
|
798
|
}
|
799
|
|
800
|
/**
|
801
|
* Returns HTML for taxon page tabs.
|
802
|
*
|
803
|
* Allows theming of the taxon page tabs.
|
804
|
*
|
805
|
* @param array $variables
|
806
|
* An associative array containing:
|
807
|
* - tabname
|
808
|
*
|
809
|
* @ingroup themeable
|
810
|
*/
|
811
|
function theme_cdm_taxonpage_tab($variables) {
|
812
|
$tabname = $variables['tabname'];
|
813
|
// TODO replace by using translations or theme the menue tabs itself instead?
|
814
|
switch ($tabname) {
|
815
|
default:
|
816
|
return t($tabname);
|
817
|
}
|
818
|
}
|