Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / theme / cdm_dataportal.page.theme @ 87bf25dd

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
    $specimen = $variables['specimen'];
61
    RenderHints::pushToRenderStack('specimen_page_title');
62
    $referenceUri = '';
63
    $out = '';
64

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

    
88

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

    
95
  RenderHints::popFromRenderStack();
96

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

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

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

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

    
130

    
131
/**
132
 * Returns HTML containing the synonymy for the accepted taxon.
133
 *
134
 * Shows the whole synonymy for the accepted taxon.
135
 * The synonymy list is headed by the complete scientific name
136
 * of the accepted taxon with nomenclatural reference.
137
 *
138
 * @param array $variables
139
 *   An associative array containing:
140
 *   - taxon
141
 *   - addAcceptedTaxon
142
 *
143
 * @return string
144
 *  Markup for the synonymy
145
 *
146
 * @throws Exception
147
 *
148
 * @ingroup themeable
149
 */
150
function theme_cdm_taxon_page_synonymy($variables) {
151
  $taxon = $variables['taxon'];
152
  $addAcceptedTaxon = $variables['addAcceptedTaxon'];
153

    
154
  RenderHints::pushToRenderStack('taxon_page_synonymy');
155

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

    
160
  $synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, array($taxon->uuid));
161

    
162
  $out = '';
163

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

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

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

    
187
      $accepted_name .= ' <span class="name_relationships">' . $name_relationships . '</span>';
188
    }
189

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

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

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

    
216

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

    
229
  RenderHints::popFromRenderStack();
230

    
231
  return $out;
232
}
233

    
234

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

    
258
  $freetextSearchResults = array();
259

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

    
278

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

    
291
  $classification = cdm_dataportal_searched_in_classification();
292

    
293

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

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

    
321

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

    
334
  if ($hasImages) {
335

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

    
358
    // $gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
359

    
360
    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
361

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

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

    
397
  if ($flashLink) {
398

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

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

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

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

    
466
  $table_rows = array();
467

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

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

    
480
  foreach ($field_order as $fieldname) {
481

    
482
    if (isset($reference->$fieldname)) {
483

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

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

    
552

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

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

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

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

    
588

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

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

    
605
  return markup_to_render_array($out);
606
}
607

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

    
614
  $media = $variables['media'];
615
  $mediarepresentation_uuid = $variables['mediarepresentation_uuid'];
616
  $partId = $variables['partId'];
617
  $out = '';
618

    
619
  // Determine which representation and which part to show
620
  $active_representation_index = 0;
621

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

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

    
640

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

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

    
658
  $imageMaxExtend = variable_get('image-page-maxextend', 400);
659

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

    
664
  drupal_set_title($title, PASS_THROUGH);
665

    
666
  $out .= '<div class="media cdm_media_viewer_image">';
667

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

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

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

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

    
726
  $out .= '</div>';
727
  return $out;
728
}
729

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

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

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