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
|
RenderHints::pushToRenderStack('taxon_page_title');
|
30
|
$referenceUri = '';
|
31
|
$out = '';
|
32
|
if (isset($taxon->name->nomenclaturalReference)) {
|
33
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
34
|
}
|
35
|
|
36
|
$out .= theme('cdm_taxonName', array(
|
37
|
'taxonName' => $taxon->name,
|
38
|
'nameLink' => NULL,
|
39
|
'refenceLink' => $referenceUri,
|
40
|
'show_annotations' => FALSE,
|
41
|
));
|
42
|
RenderHints::popFromRenderStack();
|
43
|
|
44
|
return '<span class="' . $taxon->class . '">' . $out . '</span>';
|
45
|
}
|
46
|
|
47
|
/**
|
48
|
* Returns HTML for the default title for a name page.
|
49
|
*
|
50
|
* The returned title is a formatted name.
|
51
|
*
|
52
|
* @param array $variables
|
53
|
* An associative array containing:
|
54
|
* - taxon_name: The taxon name object.
|
55
|
*
|
56
|
* @ingroup themeable
|
57
|
*/
|
58
|
function theme_cdm_name_page_title($variables) {
|
59
|
$taxon_name = $variables['taxon_name'];
|
60
|
RenderHints::pushToRenderStack('taxon_page_title');
|
61
|
if (isset($taxon_name->nomenclaturalReference)) {
|
62
|
$referenceUri = url(path_to_reference($taxon_name->nomenclaturalReference->uuid));
|
63
|
}
|
64
|
|
65
|
$out = '<span class="' . $taxon_name->class . '">' . theme('cdm_taxonName', array(
|
66
|
'taxonName' => $taxon_name,
|
67
|
'nameLink' => NULL,
|
68
|
'refenceLink' => $referenceUri,
|
69
|
'show_annotations' => FALSE,
|
70
|
)) . '</span>';
|
71
|
RenderHints::popFromRenderStack();
|
72
|
return $out;
|
73
|
}
|
74
|
|
75
|
/**
|
76
|
* Returns HTML for a taxon page.
|
77
|
*
|
78
|
* A wrapper function that groups available information to show by default,
|
79
|
* when a taxon page is requested by the browser.
|
80
|
* Individual themeing has to decide what this page should include (see methods
|
81
|
* beneath) and what information should go into tabs or should not be shown
|
82
|
* at all.
|
83
|
*
|
84
|
* It is headed by the name of the accepted taxon without author and reference.
|
85
|
*
|
86
|
* @param array $variables
|
87
|
* An associative array containing:
|
88
|
* - taxon: The taxon object for which to theme the page.
|
89
|
* - page_part: Name of the part to display, valid values are:
|
90
|
* 'description', 'images', 'synonymy', 'all'.
|
91
|
*
|
92
|
* @ingroup themeable
|
93
|
*/
|
94
|
function theme_cdm_taxon_page($variables) {
|
95
|
|
96
|
// add all mandatory js sources
|
97
|
_add_js_footnotes();
|
98
|
|
99
|
$taxon = $variables['taxon'];
|
100
|
$page_part = $variables['page_part'];
|
101
|
global $theme;
|
102
|
|
103
|
$render_array = array();
|
104
|
$weight = 0; // the weight for the render array elements
|
105
|
|
106
|
$tabsToDisplay = variable_get('cdm_taxonpage_tabs_visibility', unserialize(TAXONPAGE_VISIBILITY_OPTIONS_DEFAULT));
|
107
|
|
108
|
$page_part = variable_get('cdm_dataportal_taxonpage_tabs', 1) ? $page_part : 'all';
|
109
|
|
110
|
$media = _load_media_for_taxon($taxon);
|
111
|
|
112
|
|
113
|
if (!isset($media[0]) || ($tabsToDisplay["Images"] == '0')) {
|
114
|
taxon_page_tabs_hidden('images');
|
115
|
}
|
116
|
|
117
|
// HideImage flag depending on administative preset.
|
118
|
$hideImages = FALSE;
|
119
|
if (variable_get('image_hide_rank', '0') != '0' && isset($taxon->name->rank->uuid)) {
|
120
|
$rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
|
121
|
$hideImages = ($rankCompare > -1);
|
122
|
}
|
123
|
|
124
|
// --- GET specimensOrObservations --- //
|
125
|
$specimensOrObservations = cdm_ws_get(CDM_WS_TAXON, array( $taxon->uuid, 'specimensOrObservations'));
|
126
|
|
127
|
$specimensOrObservationsCount = is_array($specimensOrObservations) ? count($specimensOrObservations) : 0;
|
128
|
if ($specimensOrObservationsCount == 0 || ($tabsToDisplay["Specimens"] == '0')) {
|
129
|
taxon_page_tabs_hidden('specimens');
|
130
|
}
|
131
|
|
132
|
// --- GET polytomousKeys --- //
|
133
|
$polytomousKeysPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, NULL, "findByTaxonomicScope=$taxon->uuid");
|
134
|
$identificationKeyCount = 0;
|
135
|
if ($polytomousKeysPager) {
|
136
|
$identificationKeyCount += $polytomousKeysPager->count;
|
137
|
}
|
138
|
if ($identificationKeyCount == 0 || ($tabsToDisplay["Keys"] == '0')) {
|
139
|
taxon_page_tabs_hidden('keys');
|
140
|
}
|
141
|
|
142
|
if ($tabsToDisplay["Synonymy"] == '0') {
|
143
|
taxon_page_tabs_hidden('synonymy');
|
144
|
}
|
145
|
|
146
|
// -------------------------------------------- //
|
147
|
|
148
|
$render_array['back_to_search'] = markup_to_render_array(theme('cdm_back_to_search_result_button'), $weight++);
|
149
|
|
150
|
if (variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR) && isset($_REQUEST['acceptedFor'])) {
|
151
|
$render_array['accepted_for'] = markup_to_render_array(theme('cdm_acceptedFor', array('acceptedFor' => $_REQUEST['acceptedFor'])), $weight++);
|
152
|
}
|
153
|
|
154
|
// --- PAGE PART: DESCRIPTION --- //
|
155
|
if ($page_part == 'description' || $page_part == 'all') {
|
156
|
|
157
|
/*
|
158
|
$markerTypesEmpty = array();
|
159
|
$markerTypesEmpty['markerTypes'] = '';
|
160
|
$queryString = $markerTypesEmpty['markerTypes'] ? queryString($markerTypesEmpty) : '';
|
161
|
|
162
|
// Retrieve all descriptions for the taxon.
|
163
|
$taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon->uuid, $queryString);
|
164
|
$nonStructuredDescriptions = array();
|
165
|
if ($taxonDescriptions != NULL) {
|
166
|
foreach ($taxonDescriptions as $taxonDescription) {
|
167
|
// handling of structured data:
|
168
|
// structured data will be transformed in to natural language and is then readded
|
169
|
// to the array of descriptions
|
170
|
$hasStructuredData = cdm_ws_get(CDM_WS_DESCRIPTION_HAS_STRUCTRURED_DATA, $taxonDescription->uuid);
|
171
|
if (isset($hasStructuredData->Boolean)) {
|
172
|
$hasStructuredData = $hasStructuredData->Boolean == 'TRUE';
|
173
|
}
|
174
|
if ($hasStructuredData) {
|
175
|
$structured_description_featuretree_uuid = variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, FALSE);
|
176
|
if($structured_description_featuretree_uuid) {
|
177
|
// if a feature tree for natural language generation has been defined use it,
|
178
|
// otherwise natural language generation is skipped
|
179
|
$naturallanguage_textData = cdm_ws_get(CDM_WS_DESCRIPTION_NATURALLANGUAGE_DESCRIPTION, array(
|
180
|
$taxonDescription->uuid,
|
181
|
$structured_description_featuretree_uuid,
|
182
|
));
|
183
|
|
184
|
if (!isset($naturallanguage_textData)) {
|
185
|
drupal_set_message(
|
186
|
t(
|
187
|
"The 'FeatureTree' for the generation of natural language representations is not configured correctly,"
|
188
|
." please select a 'FeatureTree' in the !settings",
|
189
|
array(
|
190
|
'!settings' => l(t('CDM Dataportal Settings'), 'admin/config/cdm_dataportal/layout/taxon'))
|
191
|
),
|
192
|
'warning');
|
193
|
} else {
|
194
|
$taxonDescription->elements = NULL;
|
195
|
$taxonDescription->elements = array(
|
196
|
$naturallanguage_textData,
|
197
|
);
|
198
|
}
|
199
|
}
|
200
|
}
|
201
|
$nonStructuredDescriptions[] = $taxonDescription;
|
202
|
}
|
203
|
// ...............................................END
|
204
|
// Release memory.
|
205
|
$taxonDescriptions = NULL;
|
206
|
}
|
207
|
*/
|
208
|
|
209
|
$merged_tree = cdm_ws_descriptions_by_featuretree(get_profile_featureTree(), $taxon->uuid);
|
210
|
|
211
|
$profile_html = '<div id="general">';
|
212
|
$profile_html .= theme('cdm_taxon_page_profile', array(
|
213
|
'taxon' => $taxon,
|
214
|
'merged_tree' => $merged_tree,
|
215
|
'media' => $media,
|
216
|
'hideImages' => $hideImages,
|
217
|
));
|
218
|
$profile_html .= '</div>';
|
219
|
$render_array['profile'] = markup_to_render_array($profile_html, $weight++);
|
220
|
}
|
221
|
|
222
|
// --- PAGE PART: IMAGES --- //
|
223
|
if ((!$hideImages && $page_part == 'images' || $page_part == 'all')) {
|
224
|
$images_html = '<div id="images">';
|
225
|
if ($page_part == 'all') {
|
226
|
$images_html .= '<h2>' . t('Images') . '</h2>';
|
227
|
}
|
228
|
// Get the image gallery as configured by the admin.
|
229
|
$taxon_image_gallery = call_user_func_array('taxon_image_gallery_' . variable_get('image_gallery_viewer', 'default'), array(
|
230
|
$taxon,
|
231
|
$media,
|
232
|
));
|
233
|
$images_html .= $taxon_image_gallery;
|
234
|
$images_html .= '</div>';
|
235
|
$render_array['images'] = markup_to_render_array($images_html, $weight++);
|
236
|
}
|
237
|
|
238
|
// --- PAGE PART: SYNONYMY --- //
|
239
|
if (($page_part == 'synonymy' || $page_part == 'all')) {
|
240
|
$synonymy_html = '<div id="synonymy">';
|
241
|
if ($page_part == 'all') {
|
242
|
$synonymy_html .= '<h2>' . t('Synonymy') . '</h2>';
|
243
|
}
|
244
|
$addAcceptedTaxon = variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE);
|
245
|
$synonymy_html .= theme('cdm_taxon_page_synonymy', array('taxon' => $taxon, 'addAcceptedTaxon' => $addAcceptedTaxon));
|
246
|
|
247
|
$synonymy_html .= '</div>';
|
248
|
$render_array['synonymy'] = markup_to_render_array($synonymy_html, $weight++);
|
249
|
}
|
250
|
|
251
|
// --- PAGE PART: SPECIMENS --- //
|
252
|
if ($specimensOrObservationsCount > 0 && ($page_part == 'specimens' || $page_part == 'all')) {
|
253
|
$render_array['specimens'] = array(
|
254
|
'#prefix' => '<div id="specimens">' . ($page_part == 'all' ? '<h2>' . t('Specimens') . '</h2>' : ''),
|
255
|
'content' => cdm_dataportal_taxon_page_specimens($taxon), // returns render array
|
256
|
'#suffix' => '</div>',
|
257
|
);
|
258
|
}
|
259
|
|
260
|
// --- PAGE PART: KEYS --- //
|
261
|
if ($identificationKeyCount == 1 && $page_part == 'keys'){
|
262
|
drupal_goto(path_to_key($polytomousKeysPager->records[0]->class, $polytomousKeysPager->records[0]->uuid));
|
263
|
}
|
264
|
else if ($identificationKeyCount > 0 && ($page_part == 'keys' || $page_part == 'all')) {
|
265
|
$keys_html = '<div id="keys">';
|
266
|
if ($page_part == 'all') {
|
267
|
$keys_html .= '<h2>' . t('Keys') . '</h2>';
|
268
|
}
|
269
|
$keys_html .= theme('cdm_block_IdentificationKeys', array('taxonUuid' => $taxon->uuid));
|
270
|
$keys_html .= '</div>';
|
271
|
$render_array['keys'] = markup_to_render_array($keys_html, $weight++);
|
272
|
}
|
273
|
|
274
|
return $render_array;
|
275
|
}
|
276
|
|
277
|
/**
|
278
|
* Returns HTML containing descriptive data and preferred picture.
|
279
|
*
|
280
|
* Outputs all descriptive data and shows the preferred picture of the
|
281
|
* accepted taxon.
|
282
|
*
|
283
|
* @param array $variables
|
284
|
* An associative array containing:
|
285
|
* - taxon
|
286
|
* - mergedTrees
|
287
|
* - media:
|
288
|
* - hideImages
|
289
|
*
|
290
|
* @ingroup themeable
|
291
|
*/
|
292
|
function theme_cdm_taxon_page_profile($variables) {
|
293
|
$taxon = $variables['taxon'];
|
294
|
$merged_tree = $variables['merged_tree'];
|
295
|
$media = $variables['media'];
|
296
|
$hideImages = $variables['hideImages'];
|
297
|
$out = '';
|
298
|
|
299
|
$taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
|
300
|
if ($taxon_profile_image_settings['show'] && !$hideImages) {
|
301
|
|
302
|
$representationPart = new stdClass();
|
303
|
$attributes = array();
|
304
|
if (isset($media[0]->representations[0]->parts[0])) {
|
305
|
$representationPart = $media[0]->representations[0]->parts[0];
|
306
|
$attributes['alt'] = $representationPart->uri;
|
307
|
|
308
|
if(!empty($taxon_profile_image_settings['media_uri_query'])){
|
309
|
$representationPart->uri = $representationPart->uri
|
310
|
. (strpos($representationPart->uri, '?') !== FALSE ? '&' : '?')
|
311
|
. $taxon_profile_image_settings['media_uri_query'];
|
312
|
}
|
313
|
}
|
314
|
else {
|
315
|
// show placeholder image instead
|
316
|
if(!empty($taxon_profile_image_settings['custom_placeholder_image_on']) && !empty($taxon_profile_image_settings['custom_placeholder_image_fid'])){
|
317
|
// use the user provided image
|
318
|
$profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
|
319
|
$url = file_create_url($profile_image_file->uri);
|
320
|
$image_info = image_get_info($profile_image_file->uri);
|
321
|
$representationPart->width = $image_info['width'];
|
322
|
$representationPart->height = $image_info['height'];
|
323
|
$representationPart->uri = $url;
|
324
|
} else {
|
325
|
// use the hard coded default
|
326
|
$representationPart->width = 184;
|
327
|
$representationPart->height = 144;
|
328
|
$representationPart->uri = base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/no_picture.png';
|
329
|
}
|
330
|
$attributes['alt'] = "no image available";
|
331
|
}
|
332
|
|
333
|
$profile_image = theme('cdm_media_gallerie_image', array(
|
334
|
'mediaRepresentationPart' => $representationPart,
|
335
|
'maxExtend' => $taxon_profile_image_settings['maxextend'],
|
336
|
'addPassePartout' => FALSE,
|
337
|
'attributes' => $attributes,
|
338
|
));
|
339
|
// NOTE: style="width:${maxextend}px' is needed for IE8 !!!
|
340
|
$out .= '<div id="taxonProfileImage" style="width:' . $taxon_profile_image_settings['maxextend'] . 'px">' . $profile_image. '</div>';
|
341
|
}
|
342
|
|
343
|
// Description TOC.
|
344
|
$out = '<div id="featureTOC">';
|
345
|
$out .= '<h2>' . t('Content') . '</h2>';
|
346
|
$out .= theme('cdm_feature_nodesTOC', array('featureNodes' => $merged_tree->root->children));
|
347
|
$out .= '</div>';
|
348
|
|
349
|
// Description.
|
350
|
$out .= theme('cdm_feature_nodes', array('mergedFeatureNodes' => $merged_tree->root->children, 'taxon' => $taxon));
|
351
|
|
352
|
return $out;
|
353
|
}
|
354
|
|
355
|
|
356
|
|
357
|
/**
|
358
|
* Returns HTML containing the synonymy for the accepted taxon.
|
359
|
*
|
360
|
* Shows the whole synonymy for the accepted taxon.
|
361
|
* The synonymy list is headed by the complete scientific name
|
362
|
* of the accepted taxon with nomenclatural reference.
|
363
|
*
|
364
|
* @param array $variables
|
365
|
* An associative array containing:
|
366
|
* - taxon
|
367
|
* - addAcceptedTaxon
|
368
|
*
|
369
|
* @ingroup themeable
|
370
|
*/
|
371
|
function theme_cdm_taxon_page_synonymy($variables) {
|
372
|
$taxon = $variables['taxon'];
|
373
|
$addAcceptedTaxon = $variables['addAcceptedTaxon'];
|
374
|
|
375
|
RenderHints::pushToRenderStack('taxon_page_synonymy');
|
376
|
|
377
|
// footnote key for the homotypic group and accepted taxon,
|
378
|
// both should have the same footnote key
|
379
|
RenderHints::setFootnoteListKey(RenderHints::getRenderPath());
|
380
|
|
381
|
$synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, $taxon->uuid);
|
382
|
$skip = array(
|
383
|
UUID_BASIONYM,
|
384
|
);
|
385
|
$out = '';
|
386
|
|
387
|
// Render accepted taxon.
|
388
|
//
|
389
|
// foonotes of the accepted taxon will be rendered in the homotypic group section
|
390
|
// even if there are not synonyms in the homotypic group
|
391
|
// homotypic group and accepted taxon should have the same footnote key
|
392
|
$referenceUri = '';
|
393
|
if ($addAcceptedTaxon) {
|
394
|
if (isset($taxon->name->nomenclaturalReference)) {
|
395
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
396
|
}
|
397
|
|
398
|
$accepted_name = '<span class="accepted-name">';
|
399
|
$accepted_name .= theme('cdm_taxonName', array(
|
400
|
'taxonName' => $taxon->name,
|
401
|
'nameLink' => NULL,
|
402
|
'refenceLink' => $referenceUri,
|
403
|
));
|
404
|
$accepted_name .= '</span>';
|
405
|
|
406
|
// handle annotations of the name and taxon
|
407
|
$special_annotations_array = array();
|
408
|
$special_annotations_array[] = $taxon->name;
|
409
|
$special_annotations_array[] = $taxon;
|
410
|
$accepted_name .= theme('cdm_annotations_as_footnotekeys', array(
|
411
|
'cdmBase_list' => $special_annotations_array,
|
412
|
'footnote_list_key' => RenderHints::getRenderPath() . '-annotations')
|
413
|
);
|
414
|
}
|
415
|
|
416
|
// --- Render homotypic synonymy group
|
417
|
if (!empty($accepted_name)) {
|
418
|
$out .= $accepted_name;
|
419
|
}
|
420
|
|
421
|
// Render the homotypicSynonymyGroup including the type information.
|
422
|
$out .= theme('cdm_homotypicSynonymyGroup', array('synonymList' => $synomymie->homotypicSynonymsByHomotypicGroup, 'accepted_taxon_uuid' => $taxon->uuid));
|
423
|
|
424
|
|
425
|
// Render accepted taxon heterotypic synonymy groups.
|
426
|
if ($synomymie->heterotypicSynonymyGroups) {
|
427
|
foreach ($synomymie->heterotypicSynonymyGroups as $homotypicalGroup) {
|
428
|
$out .= theme('cdm_heterotypicSynonymyGroup', array('homotypicalGroup' => $homotypicalGroup));
|
429
|
}
|
430
|
}
|
431
|
// Render taxon relationships.
|
432
|
if (variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)) {
|
433
|
$taxonRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, $taxon->uuid);
|
434
|
$out .= theme('cdm_taxonRelationships', array('taxonRelationships' => $taxonRelationships, 'focusedTaxon' => $taxon));
|
435
|
}
|
436
|
// Render name relationships.
|
437
|
$name_rels_to_show = variable_get('name_relationships_to_show', NULL);
|
438
|
$skip = array();
|
439
|
if ($name_rels_to_show) {
|
440
|
foreach ($name_rels_to_show as $key => $value) {
|
441
|
if ($value === 0) {
|
442
|
$skip[] = $key;
|
443
|
}
|
444
|
}
|
445
|
if (sizeof($name_rels_to_show) != sizeof($skip)) {
|
446
|
$nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
|
447
|
$out .= theme('cdm_nameRelationships', array('nameRelationships' => $nameRelationships, 'skipTypes' => $skip));
|
448
|
}
|
449
|
}
|
450
|
|
451
|
RenderHints::popFromRenderStack();
|
452
|
|
453
|
return $out;
|
454
|
}
|
455
|
|
456
|
|
457
|
/**
|
458
|
* Returns HTML for the given result page including a pager.
|
459
|
*
|
460
|
* @param array $variables
|
461
|
* An associative array containing:
|
462
|
* - pager: The cdmlib pager object containing the result set of cdm base
|
463
|
* objects (currently this function can only handle taxon instances =>
|
464
|
* TODO)
|
465
|
* - path: The target path for the pager links, this will usually point to
|
466
|
* 'cdm_dataportal/search/results/taxon'
|
467
|
*
|
468
|
* @ingroup themeable
|
469
|
*/
|
470
|
function theme_cdm_search_results($variables) {
|
471
|
$pager = $variables['pager'];
|
472
|
$path = $variables['path'];
|
473
|
|
474
|
$freetextSearchResults = array();
|
475
|
|
476
|
// If the pager contains records of SearchResults, extract the taxa and use
|
477
|
// them as records instead.
|
478
|
if (isset($pager->records[0]) && $pager->records[0]->class == "SearchResult") {
|
479
|
$freetextSearchResults = $pager->records;
|
480
|
$taxa = array();
|
481
|
// $highlightedFragments = array();
|
482
|
foreach ($pager->records as $searchResult) {
|
483
|
$taxa[] = &$searchResult->entity;
|
484
|
/*
|
485
|
if(!isset($searchResult->fieldHighlightMap)){
|
486
|
$searchResult->fieldHighlightMap = NULL;
|
487
|
}
|
488
|
$fragmentHighlighting[] = $searchResult->fieldHighlightMap;
|
489
|
*/
|
490
|
}
|
491
|
$pager->records = $taxa;
|
492
|
}
|
493
|
|
494
|
$out = '';
|
495
|
// Add thumbnails checkbox and refine search link.
|
496
|
$out = '<div class="page_options">';
|
497
|
if (isset($_REQUEST['ws'])) {
|
498
|
if (cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) {
|
499
|
$out .= '<div id="backButton">' . l(t('Modify search'), cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) . '</div>';
|
500
|
}
|
501
|
}
|
502
|
$out .= '<form name="pageoptions"><input id="showThumbnails" type="checkbox" name="showThumbnails" ' . (do_showThumbnails() == 1 ? 'checked="checked"' : '') . '> ' . t('Show Thumbnails') . '</form>';
|
503
|
$out .= '</div>';
|
504
|
$out .= '<div id="search-summary">' . t('results for') . ' ';
|
505
|
$classification = cdm_dataportal_searched_in_classification();
|
506
|
if ($classification != NULL) {
|
507
|
$out .= $classification->titleCache ;
|
508
|
} else {
|
509
|
$out .= t('any classification');
|
510
|
}
|
511
|
$out .= ':</div>';
|
512
|
|
513
|
// List results.
|
514
|
if (isset($pager->records) && count($pager->records) > 0) {
|
515
|
$out .= '<div id="search_results">';
|
516
|
$out .= theme('cdm_list_of_taxa',
|
517
|
array(
|
518
|
'records' => $pager->records,
|
519
|
'freetextSearchResults' => $freetextSearchResults,
|
520
|
'show_classification' => $classification === NULL
|
521
|
)
|
522
|
);
|
523
|
$out .= '</div>';
|
524
|
$out .= theme('cdm_pager', array(
|
525
|
'pager' => $pager,
|
526
|
'path' => $path,
|
527
|
'parameters' => $_REQUEST,
|
528
|
));
|
529
|
}
|
530
|
else {
|
531
|
$out .= '<h4 class="error">Sorry, no matching entries found.</h4>';
|
532
|
}
|
533
|
return $out;
|
534
|
}
|
535
|
|
536
|
|
537
|
/**
|
538
|
* TODO Implementation of Hook taxon_image_gallery()
|
539
|
*
|
540
|
* @param unknown_type $taxon
|
541
|
* @param unknown_type $media
|
542
|
*
|
543
|
* @return unknown_type
|
544
|
*/
|
545
|
function taxon_image_gallery_default($taxon, $media) {
|
546
|
$hasImages = isset($media[0]);
|
547
|
|
548
|
if ($hasImages) {
|
549
|
|
550
|
$maxExtend = 150;
|
551
|
$cols = 3;
|
552
|
$maxRows = FALSE;
|
553
|
$alternativeMediaUri = NULL;
|
554
|
/* Comment @WA: was in D5:
|
555
|
$captionElements = array(
|
556
|
'title',
|
557
|
'rights',
|
558
|
'#uri' => t('open Image'),
|
559
|
);
|
560
|
*/
|
561
|
$captionElements = array(
|
562
|
'title',
|
563
|
'description',
|
564
|
'artist',
|
565
|
'location',
|
566
|
'rights',
|
567
|
'#uri' => t('open Image'),
|
568
|
);
|
569
|
$gallery_name = $taxon->uuid;
|
570
|
$mediaLinkType = 'LIGHTBOX';
|
571
|
|
572
|
// $gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
|
573
|
|
574
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
|
575
|
|
576
|
$out = '<div class="image-gallerie">';
|
577
|
$out .= theme('cdm_media_gallerie', array(
|
578
|
'mediaList' => $media,
|
579
|
'galleryName' => $gallery_name,
|
580
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
581
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
582
|
'maxRows' => 0, // Ignore maxrows settings.
|
583
|
'captionElements' => $captionElements,
|
584
|
'mediaLinkType' => $mediaLinkType,
|
585
|
'alternativeMediaUri' => NULL,
|
586
|
'galleryLinkUri' => NULL,
|
587
|
'showCaption' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
|
588
|
));
|
589
|
$out .= '</div>';
|
590
|
}
|
591
|
else {
|
592
|
$out = 'No images available.';
|
593
|
}
|
594
|
return $out;
|
595
|
}
|
596
|
|
597
|
/**
|
598
|
* TODO Implementation of Hook taxon_image_gallery()
|
599
|
*
|
600
|
* @param unknown_type $taxon
|
601
|
* @param unknown_type $media
|
602
|
*
|
603
|
* @return unknown_type
|
604
|
*/
|
605
|
function taxon_image_gallery_fsi($taxon, $media) {
|
606
|
$flashLink = isset($media[0]);
|
607
|
|
608
|
if ($flashLink) {
|
609
|
|
610
|
if (module_exists("fsi_gallery")) {
|
611
|
$out = theme("fsi_gallery", array('taxon' => $taxon, 'media' => $media));
|
612
|
}
|
613
|
else {
|
614
|
$message = t('In order to use the FSI gallery you must enable the according ') . l(t("module"), "admin/modules");
|
615
|
drupal_set_message($message, "error");
|
616
|
$out = '<h3>' . $message . '</h3>';
|
617
|
}
|
618
|
}
|
619
|
else {
|
620
|
$out = 'No images available.';
|
621
|
}
|
622
|
return $out;
|
623
|
}
|
624
|
|
625
|
/**
|
626
|
* Returns HTML for a single reference page.
|
627
|
*
|
628
|
* Renders a page with all data on a single reference.
|
629
|
*
|
630
|
* @param array $variables
|
631
|
* An associative array containing:
|
632
|
* - reference: Object.
|
633
|
*
|
634
|
* @ingroup themeable
|
635
|
*/
|
636
|
function theme_cdm_reference_page($variables) {
|
637
|
$reference = $variables['reference'];
|
638
|
|
639
|
$out = '';
|
640
|
|
641
|
if (isset($reference->titleCache)) {
|
642
|
drupal_set_title($reference->titleCache, PASS_THROUGH);
|
643
|
}
|
644
|
|
645
|
$field_order = array(
|
646
|
"title",
|
647
|
// "titleCache",
|
648
|
// "citation",
|
649
|
"authorTeam",
|
650
|
"editor",
|
651
|
"publisher",
|
652
|
"placePublished",
|
653
|
"datePublished",
|
654
|
"year",
|
655
|
"edition",// Class Book.
|
656
|
"volume",// Class Article.
|
657
|
"seriesPart",
|
658
|
"inReference",
|
659
|
"nomRefBase", // Class BookSection, Book, Article.
|
660
|
"pages",// Class Article.
|
661
|
"series",// Class Article, PrintSeries.
|
662
|
"school",// Class Thesis.
|
663
|
"institution",// Class Report.
|
664
|
"organization",// Class Proceedings.
|
665
|
"nextVersion",
|
666
|
"previousVersion",
|
667
|
"isbn",// Class Book.
|
668
|
"issn",// Class Journal.
|
669
|
"uri",
|
670
|
);
|
671
|
|
672
|
$header = array(
|
673
|
t('Field'),
|
674
|
t('Value'),
|
675
|
);
|
676
|
$table_rows = array();
|
677
|
|
678
|
if (!isset($reference->authorTeam)) {
|
679
|
$authorTeam = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
|
680
|
$reference->authorTeam = isset($authorTeam->titleCache) ? $authorTeam->titleCache : '';
|
681
|
}
|
682
|
|
683
|
if (!isset($reference->inReference)) {
|
684
|
$reference->inReference = cdm_ws_get(CDM_WS_REFERENCE, array(
|
685
|
$reference->uuid,
|
686
|
"inReference",
|
687
|
));
|
688
|
}
|
689
|
|
690
|
foreach ($field_order as $fieldname) {
|
691
|
|
692
|
if (isset($reference->$fieldname)) {
|
693
|
|
694
|
if ($fieldname == "datePublished") {
|
695
|
$period = $reference->$fieldname;
|
696
|
$datePublished = timePeriodToString($period);
|
697
|
if (isset($datePublished) && $datePublished != '') {
|
698
|
$table_rows[] = array(
|
699
|
t(ucfirst(strtolower($fieldname))),
|
700
|
$datePublished,
|
701
|
);
|
702
|
}
|
703
|
// $datePublished = array(t(ucfirst(strtolower($fieldname))),
|
704
|
// $datePublished);
|
705
|
}
|
706
|
elseif (is_object($reference->$fieldname)) {
|
707
|
if ($fieldname == "authorTeam") {
|
708
|
$dump = $reference->$fieldname;
|
709
|
$teammembers = "teamMembers";
|
710
|
$team = $dump->$teammembers;
|
711
|
$nameArray = array();
|
712
|
|
713
|
foreach ($team as $member) {
|
714
|
if (strlen($member->lastname) > 0) {
|
715
|
$nname = $member->lastname;
|
716
|
$name = $nname;
|
717
|
if (strlen($member->firstname) > 0) {
|
718
|
$vname = $member->firstname;
|
719
|
$name = $vname . " " . $nname;
|
720
|
}
|
721
|
$nameArray[] = $name;
|
722
|
}
|
723
|
else {
|
724
|
if (strlen($member->titleCache) > 0) {
|
725
|
$nameArray[] = $member->titleCache;
|
726
|
}
|
727
|
}
|
728
|
}
|
729
|
$value = join($nameArray, ", ");
|
730
|
}
|
731
|
elseif ($fieldname == "inReference") {
|
732
|
$type = $reference->$fieldname->type;
|
733
|
$value = l($reference->$fieldname->titleCache, path_to_reference($reference->$fieldname->uuid));
|
734
|
switch ($type) {
|
735
|
case "Book":
|
736
|
$fieldname = "in book";
|
737
|
break;
|
738
|
case "Journal":
|
739
|
$fieldname = "in journal";
|
740
|
break;
|
741
|
case "Proceedings":
|
742
|
$fieldname = "in proceedings";
|
743
|
break;
|
744
|
}
|
745
|
}
|
746
|
else {
|
747
|
$value = $reference->$fieldname->titleCache;
|
748
|
}
|
749
|
if (isset($value) && $value != '') {
|
750
|
$table_rows[] = array(
|
751
|
t(ucfirst(strtolower($fieldname))),
|
752
|
$value,
|
753
|
);
|
754
|
}
|
755
|
}
|
756
|
else {
|
757
|
if (isset($reference->$fieldname) && $reference->$fieldname != '') {
|
758
|
$table_rows[] = array(
|
759
|
t(ucfirst(strtolower($fieldname))),
|
760
|
$reference->$fieldname,
|
761
|
);
|
762
|
}
|
763
|
}
|
764
|
}
|
765
|
}
|
766
|
|
767
|
$out = theme_table(array(
|
768
|
'header' => array(),
|
769
|
'rows' => $table_rows,
|
770
|
'attributes' => array(),
|
771
|
'caption' => NULL,
|
772
|
'colgroups' => NULL,
|
773
|
'sticky' => NULL,
|
774
|
'empty' => NULL,
|
775
|
));
|
776
|
|
777
|
// Annotations below the table.
|
778
|
$annotations = cdm_ws_getAnnotationsFor($reference);
|
779
|
$out .= theme("cdm_annotations", array('annotations' => $annotations));
|
780
|
|
781
|
return $out;
|
782
|
}
|
783
|
|
784
|
/**
|
785
|
* @todo Please document this function.
|
786
|
* @see http://drupal.org/node/1354
|
787
|
*/
|
788
|
function theme_cdm_media_page($variables) {
|
789
|
$media = $variables['media'];
|
790
|
$mediarepresentation_uuid = $variables['mediarepresentation_uuid'];
|
791
|
$partId = $variables['partId'];
|
792
|
$out = '';
|
793
|
// Determine which reprresentation and which part to show.
|
794
|
$representationIdx = 0;
|
795
|
if ($mediarepresentation_uuid) {
|
796
|
$i = 0;
|
797
|
foreach ($media->representations as $representation) {
|
798
|
if ($representation->uuid == $mediarepresentation_uuid) {
|
799
|
$representationIdx = $i;
|
800
|
}
|
801
|
$i++;
|
802
|
}
|
803
|
}
|
804
|
else {
|
805
|
$mediarepresentation_uuid = $media->representations[0]->uuid;
|
806
|
}
|
807
|
|
808
|
$partIdx = 0;
|
809
|
if (!is_numeric($partId)) {
|
810
|
// Assuming it is an uuid.
|
811
|
$i = 0;
|
812
|
foreach ($media->representations[$representationIdx]->parts as $part) {
|
813
|
if ($part->uuid == $partId) {
|
814
|
$partIdx = $i;
|
815
|
}
|
816
|
$i++;
|
817
|
}
|
818
|
}
|
819
|
else {
|
820
|
// Assuming it is an index.
|
821
|
$partIdx = $partId;
|
822
|
}
|
823
|
|
824
|
$media_metadata = cdm_read_media_metadata($media);
|
825
|
// $title = $media->titleCache;
|
826
|
$title = $media_metadata['title'];
|
827
|
|
828
|
$imageMaxExtend = variable_get('image-page-maxextend', 400);
|
829
|
|
830
|
if (!$title) {
|
831
|
$title = 'Media ' . $media->uuid . '';
|
832
|
}
|
833
|
|
834
|
drupal_set_title($title, PASS_THROUGH);
|
835
|
|
836
|
$out .= '<div class="media cdm_media_viewer_image">';
|
837
|
|
838
|
$out .= theme('cdm_back_to_image_gallery_button', array());
|
839
|
$out .= '<div class="viewer">';
|
840
|
$out .= theme('cdm_openlayers_image', array('mediaRepresentationPart' => $media->representations[$representationIdx]->parts[$partIdx], 'maxExtend' => $imageMaxExtend));
|
841
|
$out .= '</div>';
|
842
|
|
843
|
// General media metadata.
|
844
|
/*
|
845
|
$media_metadata = cdm_ws_get(CDM_WS_MEDIA_METADATA, array($media->uuid));
|
846
|
vardump("PRINTING MEDIA METADATA");
|
847
|
vardump($media_metadata);
|
848
|
vardump("PRINTING MEDIA");
|
849
|
vardump($media);
|
850
|
*/
|
851
|
$metadataToPrint = theme('cdm_media_caption', array('media' => $media));
|
852
|
$out .= $metadataToPrint;
|
853
|
|
854
|
// Tabs for the different representations.
|
855
|
// ul.secondary
|
856
|
$out .= '<ul class="primary">';
|
857
|
foreach ($media->representations as $representation) {
|
858
|
$out .= '<li>' . l($media->representations[$representationIdx]->mimeType, path_to_media($media->uuid, $mediarepresentation_uuid, $partIdx)) . '</li>';
|
859
|
}
|
860
|
$out .= '</ul>';
|
861
|
|
862
|
// Representation(-part) specific metadata.
|
863
|
$thumbnailMaxExtend = 100;
|
864
|
$out .= '<table>';
|
865
|
$i = 0;
|
866
|
foreach ($media->representations[$representationIdx]->parts as $part) {
|
867
|
$out .= '<tr><th>' . t('Part') . ' ' . ($i + 1) . '</th><td>';
|
868
|
switch ($part->class) {
|
869
|
case 'ImageFile':
|
870
|
$out .= $part->width . ' x ' . $part->height . ' - ' . $part->size . 'k';
|
871
|
break;
|
872
|
case 'AudioFile':
|
873
|
case 'MovieFile':
|
874
|
$out .= t('Duration') . ': ' . $part->duration . 's - ' . $part->size . 'k';
|
875
|
break;
|
876
|
default:
|
877
|
$out .= $part->size . 'k';
|
878
|
}
|
879
|
|
880
|
$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));
|
881
|
$i++;
|
882
|
}
|
883
|
$out .= '</table>';
|
884
|
$out .= '</div>';
|
885
|
|
886
|
return $out;
|
887
|
}
|
888
|
|
889
|
/**
|
890
|
* @todo Please document this function.
|
891
|
* @see http://drupal.org/node/1354
|
892
|
*/
|
893
|
function theme_cdm_polytomousKey_page($variables) {
|
894
|
$polytomousKey = $variables['polytomousKey'];
|
895
|
drupal_set_title($polytomousKey->titleCache, PASS_THROUGH);
|
896
|
|
897
|
$out = theme("cdm_IdentificationKey", array(
|
898
|
'identificationKey' => $polytomousKey,
|
899
|
'doLinkToKeyPage' => FALSE,
|
900
|
'showIdentificationKeyTitle' => FALSE,
|
901
|
));
|
902
|
|
903
|
// Key nodes in linked style.
|
904
|
$out .= theme('cdm_polytomousKey', array('polytomousKey' => $polytomousKey));
|
905
|
/*
|
906
|
* FIXME implement node type for keys !!!
|
907
|
* (wrapping the content in the cdm_dataportal.node becomes obsolete then).
|
908
|
*/
|
909
|
return '<div id="identificationKey">' . $out . '</div>';
|
910
|
}
|
911
|
|
912
|
/**
|
913
|
* Returns HTML for taxon page tabs.
|
914
|
*
|
915
|
* Allows theming of the taxon page tabs.
|
916
|
*
|
917
|
* @param array $variables
|
918
|
* An associative array containing:
|
919
|
* - tabname
|
920
|
*
|
921
|
* @ingroup themeable
|
922
|
*/
|
923
|
function theme_cdm_taxonpage_tab($variables) {
|
924
|
$tabname = $variables['tabname'];
|
925
|
// TODO replace by using translations or theme the menue tabs itself instead?
|
926
|
switch ($tabname) {
|
927
|
default:
|
928
|
return t($tabname);
|
929
|
}
|
930
|
}
|