Project

General

Profile

Download (23 KB) Statistics
| Branch: | Tag: | Revision:
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
 * @return string
26
 *  Markup for a taxon page title
27
 *
28
 * @ingroup themeable
29
 */
30
function theme_cdm_taxon_page_title($variables) {
31
  $taxon = $variables['taxon'];
32
  RenderHints::pushToRenderStack('taxon_page_title');
33
  $referenceUri = '';
34
  $out = '';
35
  if (isset($taxon->name->nomenclaturalReference)) {
36
    $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
37
  }
38

    
39
  $out .= render_taxon_or_name($taxon, NULL, $referenceUri, FALSE);
40
  RenderHints::popFromRenderStack();
41

    
42
  return '<span class="' . $taxon->class . '">' . $out . '</span>';
43
}
44

    
45
/**
46
 * Returns HTML for the default title of a specimen page.
47
 *  * The returned title is a the identifier of the specimen.
48
 *
49
 * @param array $variables
50
 *   An associative array containing:
51
 *   - specimen: The specimen being formatted for the title.
52
 *
53
 * @return string
54
 *  Markup for the title of a specimen page
55
 *
56
 * @ingroup themeable
57
 */
58
function theme_cdm_specimen_page_title($variables)
59
{
60

    
61
    $specimen = $variables['specimen'];
62
    RenderHints::pushToRenderStack('specimen_page_title');
63
    $referenceUri = '';
64
    $out = '';
65

    
66
    $collection = null;
67
    if ($specimen->collection) {
68
        if ($specimen->collection->code) {
69
            $collection = $specimen->collection->code;
70
        } elseif ($specimen->collection->name) {
71
            $collection = $specimen->collection->name;
72
        }
73
    }
74
    if($specimen->accessionNumber){
75
        $specimenID = $specimen->accessionNumber;
76
    }
77
    elseif($specimen->barcode){
78
      $specimenID = $specimen->barcode;
79
    }
80
    elseif($specimen->catalogNumber) {
81
      $specimenID = $specimen->catalogNumber;
82
    }
83
    elseif($specimen->titleCache) {
84
        $specimenID = $specimen->titleCache;
85
    }
86
    if(!isset($specimenID) and !isset($collection)){
87
      $specimenID = $specimen->uuid;
88
    }
89

    
90

    
91
  $out .= "Specimen ";
92
  if($collection){
93
    $out .= $collection." ";
94
  }
95
  $out .= $specimenID;
96

    
97
  RenderHints::popFromRenderStack();
98

    
99
  return '<span class="' . $specimen->class . '">' . $out . '</span>';
100
}
101

    
102
/**
103
 * Returns HTML for the default title for a name page.
104
 *
105
 * The returned title is a formatted name.
106
 *
107
 * @param array $variables
108
 *   An associative array containing:
109
 *   - taxon_name: The taxon name object.
110
 *
111
 * @return string
112
 *  Markup for the title of a name page
113
 *
114
 * @ingroup themeable
115
 */
116
function theme_cdm_name_page_title($variables) {
117
  $taxon_name = $variables['taxon_name'];
118
  RenderHints::pushToRenderStack('taxon_page_title');
119

    
120
  $referenceUri = NULL;
121
  if (isset($taxon_name->nomenclaturalReference)) {
122
    $referenceUri = url(path_to_reference($taxon_name->nomenclaturalReference->uuid));
123
  }
124

    
125
  $out = '<span class="' . $taxon_name->class . '">'
126
    . render_taxon_or_name($taxon_name, NULL, $referenceUri, FALSE)
127
    . '</span>';
128
  RenderHints::popFromRenderStack();
129
  return $out;
130
}
131

    
132

    
133
/**
134
 * Returns HTML containing the synonymy for the accepted taxon.
135
 *
136
 * Shows the whole synonymy for the accepted taxon.
137
 * The synonymy list is headed by the complete scientific name
138
 * of the accepted taxon with nomenclatural reference.
139
 *
140
 * @param object $taxon
141
 * @param boolean $add_accepted_taxon
142
 *
143
 * @return array
144
 *  Drupal render array for the synonymy
145
 *
146
 * @throws Exception
147
 *
148
 * @ingroup compose
149
 */
150
function compose_cdm_taxon_page_synonymy($taxon, $add_accepted_taxon) {
151

    
152
  RenderHints::pushToRenderStack('taxon_page_synonymy');
153

    
154
  // footnote key for the homotypic group and accepted taxon,
155
  // both should have the same footnote key
156
  RenderHints::setFootnoteListKey(RenderHints::getRenderPath());
157

    
158
  $synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, array($taxon->uuid));
159

    
160
  $out = '';
161

    
162
  // Render accepted taxon.
163
  //
164
  // foonotes of the accepted taxon will be rendered in the homotypic group section
165
  // even if there are not synonyms in the homotypic group
166
  // homotypic group and accepted taxon should have the same footnote key
167
  $referenceUri = '';
168
  if ($add_accepted_taxon) {
169
    // remember the last part of the render path
170
    $synonymy_render_path = RenderHints::getRenderPath();
171
    // set new render path for the accepted taxon so
172
    // it can be styled differently via the name render part definitions
173
    RenderHints::pushToRenderStack('accepted_taxon');
174
    $accepted_name = '';
175
    if (variable_get(CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE, 0)) {
176
      $label = variable_get(CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE_LABEL, CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE_LABEL_DEFAULT);
177
      $accepted_name .= '<div class="secReference"><span class="label">' . t($label) . ':</span> ' . $taxon->sec->titleCache . '</div>';
178
    }
179
    if (isset($taxon->name->nomenclaturalReference)) {
180
      $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
181
    }
182

    
183
    $accepted_name .= '<div class="accepted-name">';
184
    $accepted_name .= render_taxon_or_name($taxon, NULL, $referenceUri);
185

    
186
    $name_relations = cdm_name_relationships_for_taxon($taxon);
187
    $name_relationships = render_name_relationships_of($name_relations, $taxon->name->uuid, $taxon->uuid);
188
    // Render relationships of accepted name.
189
    if($name_relationships){
190

    
191
      $accepted_name .= ' <span class="name_relationships">' . $name_relationships . '</span>';
192
    }
193

    
194
      // handle annotations of the name and taxon
195
    $special_annotations_array = array();
196
    $special_annotations_array[] = $taxon->name;
197
    $special_annotations_array[] = $taxon;
198
    $accepted_name .= theme('cdm_annotations_as_footnotekeys', array(
199
        'cdmBase_list' => $special_annotations_array,
200
        'footnote_list_key' => $synonymy_render_path . '-annotations')
201
      );
202
    $accepted_name .= '</div>';
203
    RenderHints::popFromRenderStack();
204
  }
205

    
206
  // --- Render homotypic synonymy group
207
  if (!empty($accepted_name)) {
208
    $out .= $accepted_name;
209
  }
210

    
211
  // Render the homotypicSynonymyGroup including the type information.
212
  $out .= theme(
213
      'cdm_homotypicSynonymyGroup',
214
      array(
215
          'synonymList' => $synomymie->homotypicSynonymsByHomotypicGroup,
216
          'accepted_taxon_name_uuid' => $taxon->name->uuid
217
      )
218
    );
219

    
220

    
221
  // Render accepted taxon heterotypic synonymy groups.
222
  if ($synomymie->heterotypicSynonymyGroups) {
223
    foreach ($synomymie->heterotypicSynonymyGroups as $homotypicalGroup) {
224
      $out .= theme('cdm_heterotypicSynonymyGroup', array('homotypicalGroup' => $homotypicalGroup));
225
    }
226
  }
227
  // Render taxon relationships.
228
  if (variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)) {
229
    $taxonRelationshipsDTO = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS_DTO, $taxon->uuid);
230
    $out .= cdm_taxonRelationships($taxonRelationshipsDTO, $taxon);
231
  }
232

    
233
  RenderHints::popFromRenderStack();
234

    
235
  return markup_to_render_array($out);
236
}
237

    
238

    
239
/**
240
 * Returns HTML for the given result page including a pager.
241
 *
242
 * @param array $variables
243
 *   An associative array containing:
244
 *   - pager: The cdmlib pager object containing the result set of cdm base
245
 *     objects (currently this function can only handle taxon instances =>
246
 *     TODO)
247
 *   - path: The target path for the pager links, this will usually point to
248
 *     'cdm_dataportal/search/results/taxon'
249
 *
250
 * @return string
251
 *  Markup for the result page
252
 *
253
 * @throws Exception
254
 *
255
 * @ingroup themeable
256
 */
257
function theme_cdm_search_taxa_results($variables)
258
{
259
  $pager = $variables['pager'];
260
  $path = $variables['path'];
261

    
262
  $freetextSearchResults = array();
263

    
264
  // If the pager contains records of SearchResults, extract the taxa and use
265
  // them as records instead.
266
  if (isset($pager->records[0]) && $pager->records[0]->class == "SearchResult") {
267
    $freetextSearchResults = $pager->records;
268
    $taxa = array();
269
    // $highlightedFragments = array();
270
    foreach ($pager->records as $searchResult) {
271
      $taxa[] = &$searchResult->entity;
272
      /*
273
       if(!isset($searchResult->fieldHighlightMap)){
274
      $searchResult->fieldHighlightMap = NULL;
275
      }
276
      $fragmentHighlighting[] = $searchResult->fieldHighlightMap;
277
      */
278
    }
279
    $pager->records = $taxa;
280
  }
281

    
282

    
283
  // Add thumbnails checkbox and refine search link.
284
  $out = '<div class="page_options">';
285
  if (isset($_REQUEST['ws'])) {
286
    if (cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) {
287
      $out .= '<div id="backButton">' . l(t('Modify search'), cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) . '</div>';
288
    }
289
  }
290
  if (variable_get(SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX, SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX_DEFAULT)) {
291
    $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>';
292
  }
293
  $out .= '</div>';
294

    
295
  $classification = cdm_dataportal_searched_in_classification();
296

    
297

    
298
  if (  count(cdm_ws_fetch_all(CDM_WS_PORTAL_TAXONOMY)) > 1 ) { // FIXME use a count REST method for this!!!
299
    $out .= '<div id="search-summary">' . t('results for') . ' ';
300
    if ($classification != NULL) {
301
      $out .=  $classification->titleCache ;
302
    } else {
303
     $out .= t('any classification');
304
    }
305
    $out .= ':</div>';
306
  }
307

    
308
  // List results.
309
  if (isset($pager->records) && count($pager->records) > 0) {
310
    $out .= '<div id="search_results">';
311
    $list_of_taxa = compose_list_of_taxa($pager->records, $freetextSearchResults, $classification === NULL);
312
    $out .= drupal_render($list_of_taxa);
313
    $out .= '</div>';
314
    $out .= theme('cdm_pager', array(
315
        'pager' => $pager,
316
        'path' => $path,
317
        'parameters' => $_REQUEST,
318
    ));
319
  } else {
320
    $out .= '<h4 class="error">' . t('Sorry, no matching entries found.') . '</h4>';
321
  }
322
  return $out;
323
}
324

    
325

    
326
/**
327
 * TODO Implementation of Hook taxon_image_gallery()
328
 *
329
 * @param object $taxon
330
 * @param object $media
331
 *
332
 * @return string
333
 *  Markup for the default media gallery
334
 */
335
function taxon_image_gallery_default($taxon, $media) {
336
  $hasImages = isset($media[0]);
337

    
338
  if ($hasImages) {
339

    
340
    $maxExtend = 150;
341
    $cols = 3;
342
    $maxRows = FALSE;
343
    $alternativeMediaUri = NULL;
344
    /* Comment @WA: was in D5:
345
    $captionElements = array(
346
      'title',
347
      'rights',
348
      '#uri' => t('Open Image'),
349
    );
350
    */
351
    $captionElements = array(
352
      'title',
353
      'description',
354
      'artist',
355
      'location',
356
      'rights',
357
      '#uri' => t('Open image'),
358
    );
359
    $gallery_name = $taxon->uuid;
360
    $mediaLinkType = 'LIGHTBOX';
361

    
362
    // $gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
363

    
364
    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
365

    
366
    $out = '<div class="image-gallerie">';
367
    $out .= compose_cdm_media_gallerie(array(
368
      'mediaList' => $media,
369
      'galleryName' => $gallery_name,
370
      'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
371
      'cols' => $gallery_settings['cdm_dataportal_media_cols'],
372
      'maxRows' => 0, // Ignore maxrows settings.
373
      'captionElements' => $captionElements,
374
      'mediaLinkType' => $mediaLinkType,
375
      'alternativeMediaUri' => NULL,
376
      'galleryLinkUri' => NULL,
377
      'showCaption' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
378
    ));
379
    $out .= '</div>';
380
  }
381
  else {
382
    $out = 'No images available.';
383
  }
384
  return $out;
385
}
386

    
387
/**
388
 * TODO Implementation of Hook taxon_image_gallery()
389
 *
390
 * @param object $taxon
391
 * @param object $media
392
 *
393
 * @return string
394
 *  Markup for the fsi media gallery
395
 *
396
 * @throws Exception
397
 */
398
function taxon_image_gallery_fsi($taxon, $media) {
399
  $flashLink = isset($media[0]);
400

    
401
  if ($flashLink) {
402

    
403
    if (module_exists("fsi_gallery")) {
404
      $out = theme("fsi_gallery", array('taxon' => $taxon, 'media' => $media));
405
    }
406
    else {
407
      $message = t('In order to use the FSI gallery you must enable the according ') . l(t("module"), "admin/modules");
408
      drupal_set_message($message, "error");
409
      $out = '<h3>' . $message . '</h3>';
410
    }
411
  }
412
  else {
413
    $out = 'No images available.';
414
  }
415
  return $out;
416
}
417

    
418
/**
419
 * Returns a drupal render array for a single reference page.
420
 *
421
 * Composes a page with all data on a single reference.
422
 *
423
 * @param string $uuid
424
 *   An uuid for a cdm reference.
425
 *
426
 * @return array
427
 *  A drupal render array
428
 *
429
 * @throws Exception
430
 *
431
 * @ingroup compose
432
 */
433
function compose_cdm_reference_page($uuid) {
434

    
435
  $reference = cdm_ws_get(CDM_WS_REFERENCE, $uuid);
436
  if (isset($reference->titleCache)) {
437
    drupal_set_title($reference->titleCache, PASS_THROUGH);
438
  }
439

    
440
  $field_order = array(
441
    "title",
442
    "abbrevTitle",
443
    // "titleCache" abbrevTitleCache
444
    // "citation",
445
    "authorship",
446
    "editor",
447
    "publisher",
448
    "placePublished",
449
    "datePublished",
450
    "year",
451
    "edition",// Class Book.
452
    "volume",// Class Article.
453
    "seriesPart",
454
    "inReference",
455
    "nomRefBase", // Class BookSection, Book, Article.
456
    "pages",// Class Article.
457
    "series",// Class Article, PrintSeries.
458
    "school",// Class Thesis.
459
    "institution",// Class Report.
460
    "organization",// Class Proceedings.
461
    "nextVersion",
462
    "previousVersion",
463
    "isbn",// Class Book.
464
    "issn",// Class Journal.
465
    "doi",
466
    "uri"
467
  );
468

    
469
  $table_rows = array();
470

    
471
  if (!isset($reference->authorship)) {
472
    $authorship = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
473
    $reference->authorship = isset($authorship->titleCache) ? $authorship->titleCache : '';
474
  }
475

    
476
  if (!isset($reference->inReference)) {
477
    $reference->inReference = cdm_ws_get(CDM_WS_REFERENCE, array(
478
      $reference->uuid,
479
      "inReference",
480
    ));
481
  }
482

    
483
  foreach ($field_order as $fieldname) {
484

    
485
    if (isset($reference->$fieldname)) {
486

    
487
      if ($fieldname == "datePublished") {
488
        $period = $reference->$fieldname;
489
        $datePublished = timePeriodToString($period);
490
        if (isset($datePublished) && $datePublished != '') {
491
          $table_rows[] = array(
492
            t("Date published"),
493
            $datePublished,
494
          );
495
        }
496
        // $datePublished = array(t(ucfirst(strtolower($fieldname))),
497
        // $datePublished);
498
      }
499
      elseif ($fieldname == "doi" && is_object($reference->doi)) {
500
        $table_rows[] = array(
501
          t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
502
          cdm_doi($reference->doi, false)
503
        );
504
      }
505
      elseif ($fieldname == "uri" && isset($reference->uri) && $reference->uri) {
506
        $table_rows[] = array(
507
          t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
508
          cdm_external_uri($reference->uri, false)
509
        );
510
      }
511
      elseif (is_object($reference->$fieldname)) {
512
        if ($fieldname == "authorship") {
513
          $dump = $reference->$fieldname;
514
          $teammembers = "teamMembers";
515
          $team = $dump->$teammembers;
516
          $nameArray = array();
517

    
518
          foreach ($team as $member) {
519
            if (strlen($member->lastname) > 0) {
520
              $nname = $member->lastname;
521
              $name = $nname;
522
              if (strlen($member->firstname) > 0) {
523
                $vname = $member->firstname;
524
                $name = $vname . " " . $nname;
525
              }
526
              $nameArray[] = $name;
527
            }
528
            else {
529
              if (strlen($member->titleCache) > 0) {
530
                $nameArray[] = $member->titleCache;
531
              }
532
            }
533
          }
534
          $value = join($nameArray, ", ");
535
        }
536
        elseif ($fieldname == "inReference") {
537
          $type = $reference->$fieldname->type;
538
          $value = l($reference->$fieldname->titleCache, path_to_reference($reference->$fieldname->uuid));
539
          switch ($type) {
540
            case "Book":
541
              $fieldname = "in book";
542
              break;
543
            case "Journal":
544
              $fieldname = "in journal";
545
              break;
546
            case "Proceedings":
547
              $fieldname = "in proceedings";
548
              break;
549
          }
550
        }
551
        else {
552
          $value = $reference->$fieldname->titleCache;
553
        }
554

    
555

    
556
        if (isset($value) && $value != '') {
557
          $table_rows[] = array(
558
            t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
559
            $value,
560
          );
561
        }
562

    
563
      }
564
      else {
565
        if (isset($reference->$fieldname) && $reference->$fieldname != '') {
566
          $table_rows[] = array(
567
            t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
568
            $reference->$fieldname,
569
          );
570
        }
571
      }
572
    }
573
  }
574

    
575
  $out = theme_table(array(
576
      'header' => array(),
577
      'rows' => $table_rows,
578
      'attributes' => array(
579
        'class' => html_class_attribute_ref($reference)
580
      ),
581
      'caption' => NULL,
582
      'colgroups' => NULL,
583
      'sticky' => NULL,
584
      'empty' => NULL,
585
  ));
586

    
587
  if($reference->referenceAbstract){
588
    $out .= '<h2 class="block-title">Abstract</h2><div class="abstract">' . $reference->referenceAbstract . '</div>';
589
  }
590

    
591

    
592
  // Annotations below the table.
593
  $annotations = cdm_ws_getAnnotationsFor($reference);
594
  $out .= theme("cdm_annotations", array('annotations' => $annotations));
595

    
596
  $registration_working_set = cdm_ws_get("registrationWorkingSetDTO", array($uuid));
597
  if($registration_working_set && count($registration_working_set->registrationDTOs) > 0){
598
    $out .= "<h3>Nomenclatural acts:</h3><div class=\"cdm-item-list\">";
599
    foreach($registration_working_set->registrationDTOs as $registration_dto){
600
      if($registration_dto->status == "PUBLISHED"){
601
        $registration_render_a = compose_registation_dto($registration_dto, false, true);
602
        $registration_render_a["#prefix"] = "<div class=\"item\">";
603
        $registration_render_a["#suffix"] = "</div>";
604
        $out .= drupal_render($registration_render_a);
605
      }
606
    }
607
    $out .= "</div>";
608
  }
609

    
610
  return markup_to_render_array($out);
611
}
612

    
613
/**
614
 * @todo Please document this function.
615
 * @see http://drupal.org/node/1354
616
 */
617
function theme_cdm_media_page($variables) {
618

    
619
  $media = $variables['media'];
620
  $mediarepresentation_uuid = $variables['mediarepresentation_uuid'];
621
  $partId = $variables['partId'];
622
  $out = '';
623

    
624
  // Determine which representation and which part to show
625
  $active_representation_index = 0;
626

    
627
  if (!$mediarepresentation_uuid) {
628
    // no representation requested by the method parameters, find the best one
629
    $representations = cdm_preferred_media_representations($media, array('image/png', 'image/jpeg', 'image/gif'), null, null);
630
    if($representations  && count($representations) > 0){
631
      $preferred_representation = array_shift($representations);
632
      $mediarepresentation_uuid = $preferred_representation->uuid;
633
    }
634
  }
635

    
636
  if($mediarepresentation_uuid){
637
    foreach ($media->representations as $representation) {
638
      if ($representation->uuid == $mediarepresentation_uuid) {
639
        break;
640
      }
641
      $active_representation_index++;
642
    }
643
  }
644

    
645

    
646
  $active_part_index = 0;
647
  if (is_uuid($partId)) {
648
    foreach ($media->representations[$active_representation_index]->parts as $part) {
649
      if ($part->uuid == $partId) {
650
        break;
651
      }
652
      $active_part_index++;
653
    }
654
  }
655
  else if(is_numeric($partId)){
656
    $active_part_index = $partId;
657
  }
658

    
659
  $media_metadata = read_media_metadata($media);
660
  // $title = $media->titleCache;
661
  $title = $media_metadata['title'];
662

    
663
  $imageMaxExtend = variable_get('image-page-maxextend', 400);
664

    
665
  if (!$title) {
666
    $title = 'Media ' . $media->uuid . '';
667
  }
668

    
669
  drupal_set_title($title, PASS_THROUGH);
670

    
671
  $out .= '<div class="media cdm_media_viewer_image">';
672

    
673
  if(preg_match('/cdm_dataportal\/taxon\//', $_SERVER['HTTP_REFERER']) ){
674
    if(variable_get('cdm_dataportal_taxonpage_tabs', 1)){
675
      // taxon page with tabs
676
      $out .= '<div id="backToGalleryButton">' . l(t('Back to images'), $_SESSION['cdm']['last_gallery']) . '</div>';
677
    } else {
678
      // tabless mode
679
      $out .= '<div id="backToGalleryButton">' . l(t('Back to taxon page'), $_SESSION['cdm']['last_gallery']) . '</div>';
680
    }
681
  }
682
  $out .= '<div class="viewer">';
683
  $out .= cdm_openlayers_image($media->representations[$active_representation_index]->parts[$active_part_index], $imageMaxExtend);
684
  $out .= '</div>';
685

    
686
  // General media metadata.
687
  $metadataToPrint = theme('cdm_media_caption', array('media' => $media, 'sources_as_content' => true));
688
  $out .= $metadataToPrint;
689

    
690
  $cdm_standard_image_viewer_settings = get_array_variable_merged(CDM_STANDARD_IMAGE_VIEWER, CDM_STANDARD_IMAGE_VIEWER_DEFAULT);
691
  if ($cdm_standard_image_viewer_settings['media_representation_details_enabled'] == 1){
692
    // Tabs for the different representations.
693
    // Representation(-part) specific metadata.
694
    $thumbnailMaxExtend = 100;
695
    $out .= '<h3>' .t('Media representations') .'</h3><ul id="media-representations">';
696
    $r_i = 0;
697
    foreach ($media->representations as $representation) {
698
      $out .= '<li><strong>'. t('Representation') . ' ' . $r_i . "</strong> ($representation->mimeType)" ;
699
      // parts
700
      $active_part_index = 0;
701
      $table_class_attribute = '';
702
      if($partIdx == $active_part_index && $active_representation_index == $r_i ){
703
        $table_class_attribute = 'class="active"';
704
      }
705
      $out .= "<table $table_class_attribute>";
706
      foreach ($representation->parts as $part) {
707
        $out .= '<tr><th>' . t('Part') . ' ' . ($active_part_index + 1) . '</th></tr><tr><td>';
708
        switch ($part->class) {
709
          case 'ImageFile':
710
            $out .= $part->width . 'x' . $part->height . ' px - ' . $part->size . ' kB';
711
            break;
712
          case 'AudioFile':
713
          case 'MovieFile':
714
            $out .= t('Duration') . ': ' . $part->duration . 's - ' . $part->size . ' kB';
715
            break;
716
          default:
717
            $out .= $part->size . 'k';
718
        }
719

    
720
        $out .= '</td><td><a href="' . url(path_to_media($media->uuid, $representation->uuid, $active_part_index)) . '">'
721
          . cdm_media_gallerie_image($part, $thumbnailMaxExtend, TRUE);
722
        $active_part_index++;
723
      }
724
      $out .= '</table>';
725
      $out .=  '</li>';
726
      $r_i++;
727
    }
728
    $out .= '</ul>';
729
  }
730

    
731
  $out .= '</div>';
732
  return $out;
733
}
734

    
735
/**
736
 * @todo Please document this function.
737
 * @see http://drupal.org/node/1354
738
 */
739
function theme_cdm_polytomousKey_page($variables) {
740
  $polytomousKey = $variables['polytomousKey'];
741
  drupal_set_title($polytomousKey->titleCache, PASS_THROUGH);
742

    
743
  $out = theme("cdm_IdentificationKey", array(
744
    'identificationKey' => $polytomousKey,
745
    'doLinkToKeyPage' => FALSE,
746
    'showIdentificationKeyTitle' => FALSE,
747
    ));
748

    
749
  // Key nodes in linked style.
750
  $out .= theme('cdm_polytomousKey', array('polytomousKey' => $polytomousKey));
751
  /*
752
   * FIXME implement node type for keys !!!
753
   * (wrapping the content in the cdm_dataportal.node becomes obsolete then).
754
   */
755
  return '<div id="identificationKey">' . $out . '</div>';
756
}
(6-6/9)