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 .= render_taxon_or_name($taxon, NULL, $referenceUri, FALSE);
|
37
|
RenderHints::popFromRenderStack();
|
38
|
|
39
|
return '<span class="' . $taxon->class . '">' . $out . '</span>';
|
40
|
}
|
41
|
|
42
|
/**
|
43
|
* Returns HTML for the default title of a specimen page.
|
44
|
* * The returned title is a the identifier of the specimen.
|
45
|
*
|
46
|
* @param array $variables
|
47
|
* An associative array containing:
|
48
|
* - specimen: The specimen being formatted for the title.
|
49
|
*
|
50
|
* @ingroup themeable
|
51
|
*/
|
52
|
function theme_cdm_specimen_page_title($variables) {
|
53
|
$specimen = $variables['specimen'];
|
54
|
RenderHints::pushToRenderStack('specimen_page_title');
|
55
|
$referenceUri = '';
|
56
|
$out = '';
|
57
|
|
58
|
$title = "";
|
59
|
if($specimen->accessionNumber){
|
60
|
$title = $specimen->accessionNumber;
|
61
|
}
|
62
|
elseif($specimen->barcode){
|
63
|
$title = $specimen->barcode;
|
64
|
}
|
65
|
elseif($specimen->catalogNumber) {
|
66
|
$title = $specimen->catalogNumber;
|
67
|
}
|
68
|
|
69
|
|
70
|
$out .= $title;
|
71
|
RenderHints::popFromRenderStack();
|
72
|
|
73
|
return '<span class="' . $specimen->class . '">' . $out . '</span>';
|
74
|
}
|
75
|
|
76
|
/**
|
77
|
* Returns HTML for the default title for a name page.
|
78
|
*
|
79
|
* The returned title is a formatted name.
|
80
|
*
|
81
|
* @param array $variables
|
82
|
* An associative array containing:
|
83
|
* - taxon_name: The taxon name object.
|
84
|
*
|
85
|
* @ingroup themeable
|
86
|
*/
|
87
|
function theme_cdm_name_page_title($variables) {
|
88
|
$taxon_name = $variables['taxon_name'];
|
89
|
RenderHints::pushToRenderStack('taxon_page_title');
|
90
|
|
91
|
$referenceUri = NULL;
|
92
|
if (isset($taxon_name->nomenclaturalReference)) {
|
93
|
$referenceUri = url(path_to_reference($taxon_name->nomenclaturalReference->uuid));
|
94
|
}
|
95
|
|
96
|
$out = '<span class="' . $taxon_name->class . '">'
|
97
|
. render_taxon_or_name($taxon_name, NULL, $referenceUri, FALSE)
|
98
|
. '</span>';
|
99
|
RenderHints::popFromRenderStack();
|
100
|
return $out;
|
101
|
}
|
102
|
|
103
|
|
104
|
|
105
|
|
106
|
|
107
|
/**
|
108
|
* Returns HTML containing the synonymy for the accepted taxon.
|
109
|
*
|
110
|
* Shows the whole synonymy for the accepted taxon.
|
111
|
* The synonymy list is headed by the complete scientific name
|
112
|
* of the accepted taxon with nomenclatural reference.
|
113
|
*
|
114
|
* @param array $variables
|
115
|
* An associative array containing:
|
116
|
* - taxon
|
117
|
* - addAcceptedTaxon
|
118
|
*
|
119
|
* @ingroup themeable
|
120
|
*/
|
121
|
function theme_cdm_taxon_page_synonymy($variables) {
|
122
|
$taxon = $variables['taxon'];
|
123
|
$addAcceptedTaxon = $variables['addAcceptedTaxon'];
|
124
|
|
125
|
RenderHints::pushToRenderStack('taxon_page_synonymy');
|
126
|
|
127
|
// footnote key for the homotypic group and accepted taxon,
|
128
|
// both should have the same footnote key
|
129
|
RenderHints::setFootnoteListKey(RenderHints::getRenderPath());
|
130
|
|
131
|
$synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, array($taxon->uuid));
|
132
|
|
133
|
$out = '';
|
134
|
|
135
|
// Render accepted taxon.
|
136
|
//
|
137
|
// foonotes of the accepted taxon will be rendered in the homotypic group section
|
138
|
// even if there are not synonyms in the homotypic group
|
139
|
// homotypic group and accepted taxon should have the same footnote key
|
140
|
$referenceUri = '';
|
141
|
if ($addAcceptedTaxon) {
|
142
|
// remember the last part of the render path
|
143
|
$synonymy_render_path = RenderHints::getRenderPath();
|
144
|
// set new render path for the accepted taxon so
|
145
|
// it can be styled differently via the name render part definitions
|
146
|
RenderHints::pushToRenderStack('accepted_taxon');
|
147
|
if (isset($taxon->name->nomenclaturalReference)) {
|
148
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
149
|
}
|
150
|
|
151
|
$accepted_name = '<div class="accepted-name">';
|
152
|
$accepted_name .= render_taxon_or_name($taxon, NULL, $referenceUri);
|
153
|
|
154
|
$name_relationships = cdm_name_relationships_of($taxon);
|
155
|
// Render relationships of accepted name.
|
156
|
if($name_relationships){
|
157
|
|
158
|
$accepted_name .= ' <span class="name_relationships">' . $name_relationships . '</span>';
|
159
|
}
|
160
|
|
161
|
// handle annotations of the name and taxon
|
162
|
$special_annotations_array = array();
|
163
|
$special_annotations_array[] = $taxon->name;
|
164
|
$special_annotations_array[] = $taxon;
|
165
|
$accepted_name .= theme('cdm_annotations_as_footnotekeys', array(
|
166
|
'cdmBase_list' => $special_annotations_array,
|
167
|
'footnote_list_key' => $synonymy_render_path . '-annotations')
|
168
|
);
|
169
|
$accepted_name .= '</div>';
|
170
|
RenderHints::popFromRenderStack();
|
171
|
}
|
172
|
|
173
|
// --- Render homotypic synonymy group
|
174
|
if (!empty($accepted_name)) {
|
175
|
$out .= $accepted_name;
|
176
|
}
|
177
|
|
178
|
// Render the homotypicSynonymyGroup including the type information.
|
179
|
$out .= theme(
|
180
|
'cdm_homotypicSynonymyGroup',
|
181
|
array(
|
182
|
'synonymList' => $synomymie->homotypicSynonymsByHomotypicGroup,
|
183
|
'accepted_taxon_name_uuid' => $taxon->name->uuid
|
184
|
)
|
185
|
);
|
186
|
|
187
|
|
188
|
// Render accepted taxon heterotypic synonymy groups.
|
189
|
if ($synomymie->heterotypicSynonymyGroups) {
|
190
|
foreach ($synomymie->heterotypicSynonymyGroups as $homotypicalGroup) {
|
191
|
$out .= theme('cdm_heterotypicSynonymyGroup', array('homotypicalGroup' => $homotypicalGroup));
|
192
|
}
|
193
|
}
|
194
|
// Render taxon relationships.
|
195
|
if (variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)) {
|
196
|
$taxonRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, $taxon->uuid);
|
197
|
$out .= cdm_taxonRelationships($taxonRelationships, $taxon);
|
198
|
}
|
199
|
|
200
|
RenderHints::popFromRenderStack();
|
201
|
|
202
|
return $out;
|
203
|
}
|
204
|
|
205
|
|
206
|
/**
|
207
|
* Returns HTML for the given result page including a pager.
|
208
|
*
|
209
|
* @param array $variables
|
210
|
* An associative array containing:
|
211
|
* - pager: The cdmlib pager object containing the result set of cdm base
|
212
|
* objects (currently this function can only handle taxon instances =>
|
213
|
* TODO)
|
214
|
* - path: The target path for the pager links, this will usually point to
|
215
|
* 'cdm_dataportal/search/results/taxon'
|
216
|
*
|
217
|
* @ingroup themeable
|
218
|
*/
|
219
|
function theme_cdm_search_results($variables)
|
220
|
{
|
221
|
$pager = $variables['pager'];
|
222
|
$path = $variables['path'];
|
223
|
|
224
|
$freetextSearchResults = array();
|
225
|
|
226
|
// If the pager contains records of SearchResults, extract the taxa and use
|
227
|
// them as records instead.
|
228
|
if (isset($pager->records[0]) && $pager->records[0]->class == "SearchResult") {
|
229
|
$freetextSearchResults = $pager->records;
|
230
|
$taxa = array();
|
231
|
// $highlightedFragments = array();
|
232
|
foreach ($pager->records as $searchResult) {
|
233
|
$taxa[] = &$searchResult->entity;
|
234
|
/*
|
235
|
if(!isset($searchResult->fieldHighlightMap)){
|
236
|
$searchResult->fieldHighlightMap = NULL;
|
237
|
}
|
238
|
$fragmentHighlighting[] = $searchResult->fieldHighlightMap;
|
239
|
*/
|
240
|
}
|
241
|
$pager->records = $taxa;
|
242
|
}
|
243
|
|
244
|
|
245
|
// Add thumbnails checkbox and refine search link.
|
246
|
$out = '<div class="page_options">';
|
247
|
if (isset($_REQUEST['ws'])) {
|
248
|
if (cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) {
|
249
|
$out .= '<div id="backButton">' . l(t('Modify search'), cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) . '</div>';
|
250
|
}
|
251
|
}
|
252
|
if (variable_get(SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX, SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX_DEFAULT)) {
|
253
|
$out .= '<form name="pageoptions"><div id="showThumbnails"><input class="showThumbnails" type="checkbox" name="showThumbnails" ' . (do_showThumbnails() == 1 ? 'checked="checked"' : '') . '> ' . t('Display image thumbnails') . '</div></form>';
|
254
|
}
|
255
|
$out .= '</div>';
|
256
|
|
257
|
$classification = cdm_dataportal_searched_in_classification();
|
258
|
|
259
|
|
260
|
if ( count(cdm_ws_fetch_all(CDM_WS_PORTAL_TAXONOMY)) > 1 ) { // FIXME use a count REST method for this!!!
|
261
|
$out .= '<div id="search-summary">' . t('results for') . ' ';
|
262
|
if ($classification != NULL) {
|
263
|
$out .= $classification->titleCache ;
|
264
|
} else {
|
265
|
$out .= t('any classification');
|
266
|
}
|
267
|
$out .= ':</div>';
|
268
|
}
|
269
|
|
270
|
// List results.
|
271
|
if (isset($pager->records) && count($pager->records) > 0) {
|
272
|
$out .= '<div id="search_results">';
|
273
|
$list_of_taxa = compose_list_of_taxa($pager->records, $freetextSearchResults, $classification === NULL);
|
274
|
$out .= drupal_render($list_of_taxa);
|
275
|
$out .= '</div>';
|
276
|
$out .= theme('cdm_pager', array(
|
277
|
'pager' => $pager,
|
278
|
'path' => $path,
|
279
|
'parameters' => $_REQUEST,
|
280
|
));
|
281
|
} else {
|
282
|
$out .= '<h4 class="error">' . t('Sorry, no matching entries found.') . '</h4>';
|
283
|
}
|
284
|
return $out;
|
285
|
}
|
286
|
|
287
|
|
288
|
/**
|
289
|
* TODO Implementation of Hook taxon_image_gallery()
|
290
|
*
|
291
|
* @param unknown_type $taxon
|
292
|
* @param unknown_type $media
|
293
|
*
|
294
|
* @return unknown_type
|
295
|
*/
|
296
|
function taxon_image_gallery_default($taxon, $media) {
|
297
|
$hasImages = isset($media[0]);
|
298
|
|
299
|
if ($hasImages) {
|
300
|
|
301
|
$maxExtend = 150;
|
302
|
$cols = 3;
|
303
|
$maxRows = FALSE;
|
304
|
$alternativeMediaUri = NULL;
|
305
|
/* Comment @WA: was in D5:
|
306
|
$captionElements = array(
|
307
|
'title',
|
308
|
'rights',
|
309
|
'#uri' => t('Open Image'),
|
310
|
);
|
311
|
*/
|
312
|
$captionElements = array(
|
313
|
'title',
|
314
|
'description',
|
315
|
'artist',
|
316
|
'location',
|
317
|
'rights',
|
318
|
'#uri' => t('Open image'),
|
319
|
);
|
320
|
$gallery_name = $taxon->uuid;
|
321
|
$mediaLinkType = 'LIGHTBOX';
|
322
|
|
323
|
// $gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
|
324
|
|
325
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
|
326
|
|
327
|
$out = '<div class="image-gallerie">';
|
328
|
$out .= compose_cdm_media_gallerie(array(
|
329
|
'mediaList' => $media,
|
330
|
'galleryName' => $gallery_name,
|
331
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
332
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
333
|
'maxRows' => 0, // Ignore maxrows settings.
|
334
|
'captionElements' => $captionElements,
|
335
|
'mediaLinkType' => $mediaLinkType,
|
336
|
'alternativeMediaUri' => NULL,
|
337
|
'galleryLinkUri' => NULL,
|
338
|
'showCaption' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
|
339
|
));
|
340
|
$out .= '</div>';
|
341
|
}
|
342
|
else {
|
343
|
$out = 'No images available.';
|
344
|
}
|
345
|
return $out;
|
346
|
}
|
347
|
|
348
|
/**
|
349
|
* TODO Implementation of Hook taxon_image_gallery()
|
350
|
*
|
351
|
* @param unknown_type $taxon
|
352
|
* @param unknown_type $media
|
353
|
*
|
354
|
* @return unknown_type
|
355
|
*/
|
356
|
function taxon_image_gallery_fsi($taxon, $media) {
|
357
|
$flashLink = isset($media[0]);
|
358
|
|
359
|
if ($flashLink) {
|
360
|
|
361
|
if (module_exists("fsi_gallery")) {
|
362
|
$out = theme("fsi_gallery", array('taxon' => $taxon, 'media' => $media));
|
363
|
}
|
364
|
else {
|
365
|
$message = t('In order to use the FSI gallery you must enable the according ') . l(t("module"), "admin/modules");
|
366
|
drupal_set_message($message, "error");
|
367
|
$out = '<h3>' . $message . '</h3>';
|
368
|
}
|
369
|
}
|
370
|
else {
|
371
|
$out = 'No images available.';
|
372
|
}
|
373
|
return $out;
|
374
|
}
|
375
|
|
376
|
/**
|
377
|
* Returns HTML for a single reference page.
|
378
|
*
|
379
|
* Renders a page with all data on a single reference.
|
380
|
*
|
381
|
* @param array $variables
|
382
|
* An associative array containing:
|
383
|
* - reference: Object.
|
384
|
*
|
385
|
* @ingroup themeable
|
386
|
*/
|
387
|
function theme_cdm_reference_page($variables) {
|
388
|
$reference = $variables['reference'];
|
389
|
|
390
|
$out = '';
|
391
|
|
392
|
if (isset($reference->titleCache)) {
|
393
|
drupal_set_title($reference->titleCache, PASS_THROUGH);
|
394
|
}
|
395
|
|
396
|
$field_order = array(
|
397
|
"title",
|
398
|
"abbrevTitle",
|
399
|
// "titleCache" abbrevTitleCache
|
400
|
// "citation",
|
401
|
"authorship",
|
402
|
"editor",
|
403
|
"publisher",
|
404
|
"placePublished",
|
405
|
"datePublished",
|
406
|
"year",
|
407
|
"edition",// Class Book.
|
408
|
"volume",// Class Article.
|
409
|
"seriesPart",
|
410
|
"inReference",
|
411
|
"nomRefBase", // Class BookSection, Book, Article.
|
412
|
"pages",// Class Article.
|
413
|
"series",// Class Article, PrintSeries.
|
414
|
"school",// Class Thesis.
|
415
|
"institution",// Class Report.
|
416
|
"organization",// Class Proceedings.
|
417
|
"nextVersion",
|
418
|
"previousVersion",
|
419
|
"isbn",// Class Book.
|
420
|
"issn",// Class Journal.
|
421
|
"doi",
|
422
|
"uri"
|
423
|
);
|
424
|
|
425
|
$table_rows = array();
|
426
|
|
427
|
if (!isset($reference->authorship)) {
|
428
|
$authorship = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
|
429
|
$reference->authorship = isset($authorship->titleCache) ? $authorship->titleCache : '';
|
430
|
}
|
431
|
|
432
|
if (!isset($reference->inReference)) {
|
433
|
$reference->inReference = cdm_ws_get(CDM_WS_REFERENCE, array(
|
434
|
$reference->uuid,
|
435
|
"inReference",
|
436
|
));
|
437
|
}
|
438
|
|
439
|
foreach ($field_order as $fieldname) {
|
440
|
|
441
|
if (isset($reference->$fieldname)) {
|
442
|
|
443
|
if ($fieldname == "datePublished") {
|
444
|
$period = $reference->$fieldname;
|
445
|
$datePublished = timePeriodToString($period);
|
446
|
if (isset($datePublished) && $datePublished != '') {
|
447
|
$table_rows[] = array(
|
448
|
t("Date published"),
|
449
|
$datePublished,
|
450
|
);
|
451
|
}
|
452
|
// $datePublished = array(t(ucfirst(strtolower($fieldname))),
|
453
|
// $datePublished);
|
454
|
}
|
455
|
elseif ($fieldname == "doi" && is_object($reference->doi)) {
|
456
|
$table_rows[] = array(
|
457
|
t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
|
458
|
cdm_doi($reference->doi, false)
|
459
|
);
|
460
|
}
|
461
|
elseif ($fieldname == "uri" && isset($reference->uri) && $reference->uri) {
|
462
|
$table_rows[] = array(
|
463
|
t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
|
464
|
cdm_external_uri($reference->uri, false)
|
465
|
);
|
466
|
}
|
467
|
elseif (is_object($reference->$fieldname)) {
|
468
|
if ($fieldname == "authorship") {
|
469
|
$dump = $reference->$fieldname;
|
470
|
$teammembers = "teamMembers";
|
471
|
$team = $dump->$teammembers;
|
472
|
$nameArray = array();
|
473
|
|
474
|
foreach ($team as $member) {
|
475
|
if (strlen($member->lastname) > 0) {
|
476
|
$nname = $member->lastname;
|
477
|
$name = $nname;
|
478
|
if (strlen($member->firstname) > 0) {
|
479
|
$vname = $member->firstname;
|
480
|
$name = $vname . " " . $nname;
|
481
|
}
|
482
|
$nameArray[] = $name;
|
483
|
}
|
484
|
else {
|
485
|
if (strlen($member->titleCache) > 0) {
|
486
|
$nameArray[] = $member->titleCache;
|
487
|
}
|
488
|
}
|
489
|
}
|
490
|
$value = join($nameArray, ", ");
|
491
|
}
|
492
|
elseif ($fieldname == "inReference") {
|
493
|
$type = $reference->$fieldname->type;
|
494
|
$value = l($reference->$fieldname->titleCache, path_to_reference($reference->$fieldname->uuid));
|
495
|
switch ($type) {
|
496
|
case "Book":
|
497
|
$fieldname = "in book";
|
498
|
break;
|
499
|
case "Journal":
|
500
|
$fieldname = "in journal";
|
501
|
break;
|
502
|
case "Proceedings":
|
503
|
$fieldname = "in proceedings";
|
504
|
break;
|
505
|
}
|
506
|
}
|
507
|
else {
|
508
|
$value = $reference->$fieldname->titleCache;
|
509
|
}
|
510
|
|
511
|
|
512
|
if (isset($value) && $value != '') {
|
513
|
$table_rows[] = array(
|
514
|
t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
|
515
|
$value,
|
516
|
);
|
517
|
}
|
518
|
|
519
|
}
|
520
|
else {
|
521
|
if (isset($reference->$fieldname) && $reference->$fieldname != '') {
|
522
|
$table_rows[] = array(
|
523
|
t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
|
524
|
$reference->$fieldname,
|
525
|
);
|
526
|
}
|
527
|
}
|
528
|
}
|
529
|
}
|
530
|
|
531
|
$out = theme_table(array(
|
532
|
'header' => array(),
|
533
|
'rows' => $table_rows,
|
534
|
'attributes' => array(
|
535
|
'class' => html_class_attribute_ref($reference)
|
536
|
),
|
537
|
'caption' => NULL,
|
538
|
'colgroups' => NULL,
|
539
|
'sticky' => NULL,
|
540
|
'empty' => NULL,
|
541
|
));
|
542
|
|
543
|
if($reference->referenceAbstract){
|
544
|
$out .= '<h2 class="block-title">Abstract</h2><div class="abstract">' . $reference->referenceAbstract . '</div>';
|
545
|
}
|
546
|
|
547
|
// Annotations below the table.
|
548
|
$annotations = cdm_ws_getAnnotationsFor($reference);
|
549
|
$out .= theme("cdm_annotations", array('annotations' => $annotations));
|
550
|
|
551
|
return $out;
|
552
|
}
|
553
|
|
554
|
/**
|
555
|
* @todo Please document this function.
|
556
|
* @see http://drupal.org/node/1354
|
557
|
*/
|
558
|
function theme_cdm_media_page($variables) {
|
559
|
|
560
|
$media = $variables['media'];
|
561
|
$mediarepresentation_uuid = $variables['mediarepresentation_uuid'];
|
562
|
$partId = $variables['partId'];
|
563
|
$out = '';
|
564
|
// Determine which representation and which part to show.
|
565
|
$representationIdx = 0;
|
566
|
if ($mediarepresentation_uuid) {
|
567
|
$p_i = 0;
|
568
|
foreach ($media->representations as $representation) {
|
569
|
if ($representation->uuid == $mediarepresentation_uuid) {
|
570
|
$representationIdx = $p_i;
|
571
|
}
|
572
|
$p_i++;
|
573
|
}
|
574
|
}
|
575
|
|
576
|
$partIdx = 0;
|
577
|
if (!is_numeric($partId)) {
|
578
|
// Assuming it is an uuid.
|
579
|
$p_i = 0;
|
580
|
foreach ($media->representations[$representationIdx]->parts as $part) {
|
581
|
if ($part->uuid == $partId) {
|
582
|
$partIdx = $p_i;
|
583
|
}
|
584
|
$p_i++;
|
585
|
}
|
586
|
}
|
587
|
else {
|
588
|
// Assuming it is an index.
|
589
|
$partIdx = $partId;
|
590
|
}
|
591
|
|
592
|
$media_metadata = read_media_metadata($media);
|
593
|
// $title = $media->titleCache;
|
594
|
$title = $media_metadata['title'];
|
595
|
|
596
|
$imageMaxExtend = variable_get('image-page-maxextend', 400);
|
597
|
|
598
|
if (!$title) {
|
599
|
$title = 'Media ' . $media->uuid . '';
|
600
|
}
|
601
|
|
602
|
drupal_set_title($title, PASS_THROUGH);
|
603
|
|
604
|
$out .= '<div class="media cdm_media_viewer_image">';
|
605
|
|
606
|
$out .= theme('cdm_back_to_image_gallery_button', array());
|
607
|
$out .= '<div class="viewer">';
|
608
|
$out .= cdm_openlayers_image($media->representations[$representationIdx]->parts[$partIdx], $imageMaxExtend);
|
609
|
$out .= '</div>';
|
610
|
|
611
|
// General media metadata.
|
612
|
$metadataToPrint = theme('cdm_media_caption', array('media' => $media, 'sources_as_content' => true));
|
613
|
$out .= $metadataToPrint;
|
614
|
|
615
|
// Tabs for the different representations.
|
616
|
// Representation(-part) specific metadata.
|
617
|
$thumbnailMaxExtend = 100;
|
618
|
$out .= '<h3>' .t('Media representations') .'</h3><ul id="media-representations">';
|
619
|
$r_i = 0;
|
620
|
foreach ($media->representations as $representation) {
|
621
|
$out .= '<li><strong>'. t('Representation') . ' ' . $r_i . "</strong> ($representation->mimeType)" ;
|
622
|
// parts
|
623
|
$p_i = 0;
|
624
|
$table_class_attribute = '';
|
625
|
if($partIdx == $p_i && $representationIdx == $r_i ){
|
626
|
$table_class_attribute = 'class="active"';
|
627
|
}
|
628
|
$out .= "<table $table_class_attribute>";
|
629
|
foreach ($representation->parts as $part) {
|
630
|
$out .= '<tr><th>' . t('Part') . ' ' . ($p_i + 1) . '</th></tr><tr><td>';
|
631
|
switch ($part->class) {
|
632
|
case 'ImageFile':
|
633
|
$out .= $part->width . 'x' . $part->height . ' px - ' . $part->size . ' kB';
|
634
|
break;
|
635
|
case 'AudioFile':
|
636
|
case 'MovieFile':
|
637
|
$out .= t('Duration') . ': ' . $part->duration . 's - ' . $part->size . ' kB';
|
638
|
break;
|
639
|
default:
|
640
|
$out .= $part->size . 'k';
|
641
|
}
|
642
|
|
643
|
$out .= '</td><td><a href="' . url(path_to_media($media->uuid, $representation->uuid, $p_i)) . '">'
|
644
|
. cdm_media_gallerie_image($part, $thumbnailMaxExtend, TRUE);
|
645
|
$p_i++;
|
646
|
}
|
647
|
$out .= '</table>';
|
648
|
$out .= '</li>';
|
649
|
$r_i++;
|
650
|
}
|
651
|
$out .= '</ul>';
|
652
|
|
653
|
|
654
|
$out .= '</div>';
|
655
|
return $out;
|
656
|
}
|
657
|
|
658
|
/**
|
659
|
* @todo Please document this function.
|
660
|
* @see http://drupal.org/node/1354
|
661
|
*/
|
662
|
function theme_cdm_polytomousKey_page($variables) {
|
663
|
$polytomousKey = $variables['polytomousKey'];
|
664
|
drupal_set_title($polytomousKey->titleCache, PASS_THROUGH);
|
665
|
|
666
|
$out = theme("cdm_IdentificationKey", array(
|
667
|
'identificationKey' => $polytomousKey,
|
668
|
'doLinkToKeyPage' => FALSE,
|
669
|
'showIdentificationKeyTitle' => FALSE,
|
670
|
));
|
671
|
|
672
|
// Key nodes in linked style.
|
673
|
$out .= theme('cdm_polytomousKey', array('polytomousKey' => $polytomousKey));
|
674
|
/*
|
675
|
* FIXME implement node type for keys !!!
|
676
|
* (wrapping the content in the cdm_dataportal.node becomes obsolete then).
|
677
|
*/
|
678
|
return '<div id="identificationKey">' . $out . '</div>';
|
679
|
}
|