Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / theme / cdm_dataportal.page.theme @ 621f2ae0

History | View | Annotate | Download (22.6 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
  $reference = cdm_ws_get(CDM_WS_REFERENCE, $uuid);
434
  if (isset($reference->titleCache)) {
435
    drupal_set_title($reference->titleCache, PASS_THROUGH);
436
  }
437

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

    
467
  $table_rows = array();
468

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

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

    
481
  foreach ($field_order as $fieldname) {
482

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

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

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

    
553

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

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

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

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

    
589

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

    
594
  $registration_working_set = cdm_ws_get("registrationWorkingSetDTO", array($uuid));
595
  if($registration_working_set && count($registration_working_set->registrationDTOs) > 0){
596
    $out .= "<h3>Nomenclatural acts:</h3><div class=\"cdm-item-list\">";
597
    foreach($registration_working_set->registrationDTOs as $registration_dto){
598
      if($registration_dto->status == "PUBLISHED"){
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
    }
605
    $out .= "</div>";
606
  }
607

    
608
  return markup_to_render_array($out);
609
}
610

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

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

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

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

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

    
643

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

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

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

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

    
667
  drupal_set_title($title, PASS_THROUGH);
668

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

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

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

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

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

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

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

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

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