Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / theme / cdm_dataportal.page.theme @ 2a14e5d9

History | View | Annotate | Download (22.1 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
    if(!isset($specimenID) and !isset($collection)){
82
      $specimenID = $specimen->uuid;
83
    }
84

    
85

    
86
  $out .= "Specimen ";
87
  if($collection){
88
    $out .= $collection." ";
89
  }
90
  $out .= $specimenID;
91

    
92
  RenderHints::popFromRenderStack();
93

    
94
  return '<span class="' . $specimen->class . '">' . $out . '</span>';
95
}
96

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

    
115
  $referenceUri = NULL;
116
  if (isset($taxon_name->nomenclaturalReference)) {
117
    $referenceUri = url(path_to_reference($taxon_name->nomenclaturalReference->uuid));
118
  }
119

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

    
127

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

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

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

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

    
159
  $out = '';
160

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

    
177
    $accepted_name = '<div class="accepted-name">';
178
    $accepted_name .= render_taxon_or_name($taxon, NULL, $referenceUri);
179

    
180
    $name_relationships = cdm_name_relationships_of($taxon);
181
    // Render relationships of accepted name.
182
    if($name_relationships){
183

    
184
      $accepted_name .= ' <span class="name_relationships">' . $name_relationships . '</span>';
185
    }
186

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

    
199
  // --- Render homotypic synonymy group
200
  if (!empty($accepted_name)) {
201
    $out .= $accepted_name;
202
  }
203

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

    
213

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

    
226
  RenderHints::popFromRenderStack();
227

    
228
  return $out;
229
}
230

    
231

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

    
255
  $freetextSearchResults = array();
256

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

    
275

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

    
288
  $classification = cdm_dataportal_searched_in_classification();
289

    
290

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

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

    
318

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

    
331
  if ($hasImages) {
332

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

    
355
    // $gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
356

    
357
    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
358

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

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

    
394
  if ($flashLink) {
395

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

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

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

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

    
463
  $table_rows = array();
464

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

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

    
477
  foreach ($field_order as $fieldname) {
478

    
479
    if (isset($reference->$fieldname)) {
480

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

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

    
549

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

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

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

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

    
585

    
586
  // Annotations below the table.
587
  $annotations = cdm_ws_getAnnotationsFor($reference);
588
  $out .= theme("cdm_annotations", array('annotations' => $annotations));
589

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

    
602
  return markup_to_render_array($out);
603
}
604

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

    
611
  $media = $variables['media'];
612
  $mediarepresentation_uuid = $variables['mediarepresentation_uuid'];
613
  $partId = $variables['partId'];
614
  $out = '';
615

    
616
  // Determine which representation and which part to show
617
  $active_representation_index = 0;
618

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

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

    
637

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

    
651
  $media_metadata = read_media_metadata($media);
652
  // $title = $media->titleCache;
653
  $title = $media_metadata['title'];
654

    
655
  $imageMaxExtend = variable_get('image-page-maxextend', 400);
656

    
657
  if (!$title) {
658
    $title = 'Media ' . $media->uuid . '';
659
  }
660

    
661
  drupal_set_title($title, PASS_THROUGH);
662

    
663
  $out .= '<div class="media cdm_media_viewer_image">';
664

    
665
  if(preg_match('/cdm_dataportal\/taxon\//', $_SERVER['HTTP_REFERER']) ){
666
    $out .= '<div id="backToGalleryButton">' . l(t('Back to Images'), $_SESSION['cdm']['last_gallery']) . '</div>';
667
  }
668
  $out .= '<div class="viewer">';
669
  $out .= cdm_openlayers_image($media->representations[$active_representation_index]->parts[$active_part_index], $imageMaxExtend);
670
  $out .= '</div>';
671

    
672
  // General media metadata.
673
  $metadataToPrint = theme('cdm_media_caption', array('media' => $media, 'sources_as_content' => true));
674
  $out .= $metadataToPrint;
675

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

    
706
        $out .= '</td><td><a href="' . url(path_to_media($media->uuid, $representation->uuid, $active_part_index)) . '">'
707
          . cdm_media_gallerie_image($part, $thumbnailMaxExtend, TRUE);
708
        $active_part_index++;
709
      }
710
      $out .= '</table>';
711
      $out .=  '</li>';
712
      $r_i++;
713
    }
714
    $out .= '</ul>';
715
  }
716

    
717
  $out .= '</div>';
718
  return $out;
719
}
720

    
721
/**
722
 * @todo Please document this function.
723
 * @see http://drupal.org/node/1354
724
 */
725
function theme_cdm_polytomousKey_page($variables) {
726
  $polytomousKey = $variables['polytomousKey'];
727
  drupal_set_title($polytomousKey->titleCache, PASS_THROUGH);
728

    
729
  $out = theme("cdm_IdentificationKey", array(
730
    'identificationKey' => $polytomousKey,
731
    'doLinkToKeyPage' => FALSE,
732
    'showIdentificationKeyTitle' => FALSE,
733
    ));
734

    
735
  // Key nodes in linked style.
736
  $out .= theme('cdm_polytomousKey', array('polytomousKey' => $polytomousKey));
737
  /*
738
   * FIXME implement node type for keys !!!
739
   * (wrapping the content in the cdm_dataportal.node becomes obsolete then).
740
   */
741
  return '<div id="identificationKey">' . $out . '</div>';
742
}
Add picture from clipboard (Maximum size: 40 MB)