Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / theme / cdm_dataportal.page.theme @ 0b4ac33b

History | View | Annotate | Download (22.5 KB)

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 array $variables
141
 *   An associative array containing:
142
 *   - taxon
143
 *   - addAcceptedTaxon
144
 *
145
 * @return string
146
 *  Markup for the synonymy
147
 *
148
 * @throws Exception
149
 *
150
 * @ingroup themeable
151
 */
152
function theme_cdm_taxon_page_synonymy($variables) {
153
  $taxon = $variables['taxon'];
154
  $addAcceptedTaxon = $variables['addAcceptedTaxon'];
155

    
156
  RenderHints::pushToRenderStack('taxon_page_synonymy');
157

    
158
  // footnote key for the homotypic group and accepted taxon,
159
  // both should have the same footnote key
160
  RenderHints::setFootnoteListKey(RenderHints::getRenderPath());
161

    
162
  $synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, array($taxon->uuid));
163

    
164
  $out = '';
165

    
166
  // Render accepted taxon.
167
  //
168
  // foonotes of the accepted taxon will be rendered in the homotypic group section
169
  // even if there are not synonyms in the homotypic group
170
  // homotypic group and accepted taxon should have the same footnote key
171
  $referenceUri = '';
172
  if ($addAcceptedTaxon) {
173
    // remember the last part of the render path
174
    $synonymy_render_path = RenderHints::getRenderPath();
175
    // set new render path for the accepted taxon so
176
    // it can be styled differently via the name render part definitions
177
    RenderHints::pushToRenderStack('accepted_taxon');
178
    if (isset($taxon->name->nomenclaturalReference)) {
179
      $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
180
    }
181

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

    
185
    $name_relationships = cdm_name_relationships_of($taxon);
186
    // Render relationships of accepted name.
187
    if($name_relationships){
188

    
189
      $accepted_name .= ' <span class="name_relationships">' . $name_relationships . '</span>';
190
    }
191

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

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

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

    
218

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

    
231
  RenderHints::popFromRenderStack();
232

    
233
  return $out;
234
}
235

    
236

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

    
260
  $freetextSearchResults = array();
261

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

    
280

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

    
293
  $classification = cdm_dataportal_searched_in_classification();
294

    
295

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

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

    
323

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

    
336
  if ($hasImages) {
337

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

    
360
    // $gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
361

    
362
    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
363

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

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

    
399
  if ($flashLink) {
400

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

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

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

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

    
468
  $table_rows = array();
469

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

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

    
482
  foreach ($field_order as $fieldname) {
483

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

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

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

    
554

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

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

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

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

    
590

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

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

    
607
  return markup_to_render_array($out);
608
}
609

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

    
616
  $media = $variables['media'];
617
  $mediarepresentation_uuid = $variables['mediarepresentation_uuid'];
618
  $partId = $variables['partId'];
619
  $out = '';
620

    
621
  // Determine which representation and which part to show
622
  $active_representation_index = 0;
623

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

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

    
642

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

    
656
  $media_metadata = read_media_metadata($media);
657
  // $title = $media->titleCache;
658
  $title = $media_metadata['title'];
659

    
660
  $imageMaxExtend = variable_get('image-page-maxextend', 400);
661

    
662
  if (!$title) {
663
    $title = 'Media ' . $media->uuid . '';
664
  }
665

    
666
  drupal_set_title($title, PASS_THROUGH);
667

    
668
  $out .= '<div class="media cdm_media_viewer_image">';
669

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

    
683
  // General media metadata.
684
  $metadataToPrint = theme('cdm_media_caption', array('media' => $media, 'sources_as_content' => true));
685
  $out .= $metadataToPrint;
686

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

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

    
728
  $out .= '</div>';
729
  return $out;
730
}
731

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

    
740
  $out = theme("cdm_IdentificationKey", array(
741
    'identificationKey' => $polytomousKey,
742
    'doLinkToKeyPage' => FALSE,
743
    'showIdentificationKeyTitle' => FALSE,
744
    ));
745

    
746
  // Key nodes in linked style.
747
  $out .= theme('cdm_polytomousKey', array('polytomousKey' => $polytomousKey));
748
  /*
749
   * FIXME implement node type for keys !!!
750
   * (wrapping the content in the cdm_dataportal.node becomes obsolete then).
751
   */
752
  return '<div id="identificationKey">' . $out . '</div>';
753
}
Add picture from clipboard (Maximum size: 40 MB)