Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / theme / cdm_dataportal.page.theme @ 26b8a1bc

History | View | Annotate | Download (23.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->class == 'FieldUnit')) {
68
        if ($specimen->collection) {
69
            if ($specimen->collection->code) {
70
                $collection = $specimen->collection->code;
71
            } elseif ($specimen->collection->name) {
72
                $collection = $specimen->collection->name;
73
            }
74
        }
75
        if ($specimen->accessionNumber) {
76
            $specimenID = $specimen->accessionNumber;
77
        } elseif ($specimen->barcode) {
78
            $specimenID = $specimen->barcode;
79
        } elseif ($specimen->catalogNumber) {
80
            $specimenID = $specimen->catalogNumber;
81
        } elseif ($specimen->titleCache) {
82
            $specimenID = $specimen->titleCache;
83
        }
84
        if (!isset($specimenID) and !isset($collection)) {
85
            $specimenID = $specimen->uuid;
86
        }
87
    }else{
88
        if ($specimen->titleCache) {
89
            $specimenID = $specimen->titleCache;
90
        }
91
        if (!isset($specimenID) and !isset($collection)) {
92
            $specimenID = $specimen->uuid;
93
        }
94
    }
95

    
96
    if ($specimen ->class == 'FieldUnit'){
97
        $out .= "FieldUnit ";
98
    }else{
99
        $out .= "Specimen ";
100
    }
101

    
102
  if($collection){
103
    $out .= $collection." ";
104
  }
105
  $out .= $specimenID;
106

    
107
  RenderHints::popFromRenderStack();
108

    
109
  return '<span class="' . $specimen->class . '">' . $out . '</span>';
110
}
111

    
112
/**
113
 * Returns HTML for the default title for a name page.
114
 *
115
 * The returned title is a formatted name.
116
 *
117
 * @param array $variables
118
 *   An associative array containing:
119
 *   - taxon_name: The taxon name object.
120
 *
121
 * @return string
122
 *  Markup for the title of a name page
123
 *
124
 * @ingroup themeable
125
 */
126
function theme_cdm_name_page_title($variables) {
127
  $taxon_name = $variables['taxon_name'];
128
  RenderHints::pushToRenderStack('taxon_page_title');
129

    
130
  $referenceUri = NULL;
131
  if (isset($taxon_name->nomenclaturalReference)) {
132
    $referenceUri = url(path_to_reference($taxon_name->nomenclaturalReference->uuid));
133
  }
134

    
135
  $out = '<span class="' . $taxon_name->class . '">'
136
    . render_taxon_or_name($taxon_name, NULL, $referenceUri, FALSE)
137
    . '</span>';
138
  RenderHints::popFromRenderStack();
139
  return $out;
140
}
141

    
142

    
143
/**
144
 * Returns HTML containing the synonymy for the accepted taxon.
145
 *
146
 * Shows the whole synonymy for the accepted taxon.
147
 * The synonymy list is headed by the complete scientific name
148
 * of the accepted taxon with nomenclatural reference.
149
 *
150
 * @param object $taxon
151
 * @param boolean $add_accepted_taxon
152
 *
153
 * @return array
154
 *  Drupal render array for the synonymy
155
 *
156
 * @throws Exception
157
 *
158
 * @ingroup compose
159
 */
160
function compose_cdm_taxon_page_synonymy($taxon, $add_accepted_taxon) {
161

    
162
  RenderHints::pushToRenderStack('taxon_page_synonymy');
163

    
164
  // footnote key for the homotypic group and accepted taxon,
165
  // both should have the same footnote key
166
  RenderHints::setFootnoteListKey(RenderHints::getRenderPath());
167

    
168
  $synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, array($taxon->uuid));
169

    
170
  $out = '';
171

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

    
193
    $accepted_name .= '<div class="accepted-name">';
194
    $accepted_name .= render_taxon_or_name($taxon, NULL, $referenceUri);
195

    
196
    $name_relations = cdm_name_relationships_for_taxon($taxon);
197
    $name_relationships = render_name_relationships_of($name_relations, $taxon->name->uuid, $taxon->uuid);
198
    // Render relationships of accepted name.
199
    if($name_relationships){
200

    
201
      $accepted_name .= ' <span class="name_relationships">' . $name_relationships . '</span>';
202
    }
203

    
204
      // handle annotations of the name and taxon
205
    $special_annotations_array = array();
206
    $special_annotations_array[] = $taxon->name;
207
    $special_annotations_array[] = $taxon;
208
    $accepted_name .= theme('cdm_annotations_as_footnotekeys', array(
209
        'cdmBase_list' => $special_annotations_array,
210
        'footnote_list_key' => $synonymy_render_path . '-annotations')
211
      );
212
    $accepted_name .= '</div>';
213
    RenderHints::popFromRenderStack();
214
  }
215

    
216
  // --- Render homotypic synonymy group
217
  if (!empty($accepted_name)) {
218
    $out .= $accepted_name;
219
  }
220

    
221
  // Render the homotypicSynonymyGroup including the type information.
222
  $out .= theme(
223
      'cdm_homotypicSynonymyGroup',
224
      array(
225
          'synonymList' => $synomymie->homotypicSynonymsByHomotypicGroup,
226
          'accepted_taxon_name_uuid' => $taxon->name->uuid
227
      )
228
    );
229

    
230

    
231
  // Render accepted taxon heterotypic synonymy groups.
232
  if ($synomymie->heterotypicSynonymyGroups) {
233
    foreach ($synomymie->heterotypicSynonymyGroups as $homotypicalGroup) {
234
      $out .= theme('cdm_heterotypicSynonymyGroup', array('homotypicalGroup' => $homotypicalGroup));
235
    }
236
  }
237
  // Render taxon relationships.
238
  if (variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)) {
239
    $taxonRelationshipsDTO = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS_DTO, $taxon->uuid);
240
    $out .= cdm_taxonRelationships($taxonRelationshipsDTO, $taxon);
241
  }
242

    
243
  RenderHints::popFromRenderStack();
244

    
245
  return markup_to_render_array($out);
246
}
247

    
248

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

    
272
  $freetextSearchResults = array();
273

    
274
  // If the pager contains records of SearchResults, extract the taxa and use
275
  // them as records instead.
276
  if (isset($pager->records[0]) && $pager->records[0]->class == "SearchResult") {
277
    $freetextSearchResults = $pager->records;
278
    $taxa = array();
279
    // $highlightedFragments = array();
280
    foreach ($pager->records as $searchResult) {
281
      $taxa[] = &$searchResult->entity;
282
      /*
283
       if(!isset($searchResult->fieldHighlightMap)){
284
      $searchResult->fieldHighlightMap = NULL;
285
      }
286
      $fragmentHighlighting[] = $searchResult->fieldHighlightMap;
287
      */
288
    }
289
    $pager->records = $taxa;
290
  }
291

    
292

    
293
  // Add thumbnails checkbox and refine search link.
294
  $out = '<div class="page_options">';
295
  if (isset($_REQUEST['ws'])) {
296
    if (cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) {
297
      $out .= '<div id="backButton">' . l(t('Modify search'), cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) . '</div>';
298
    }
299
  }
300
  if (variable_get(SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX, SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX_DEFAULT)) {
301
    $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>';
302
  }
303
  $out .= '</div>';
304

    
305
  $classification = cdm_dataportal_searched_in_classification();
306

    
307

    
308
  if (  count(cdm_ws_fetch_all(CDM_WS_PORTAL_TAXONOMY)) > 1 ) { // FIXME use a count REST method for this!!!
309
    $out .= '<div id="search-summary">' . t('results for') . ' ';
310
    if ($classification != NULL) {
311
      $out .=  $classification->titleCache ;
312
    } else {
313
     $out .= t('any classification');
314
    }
315
    $out .= ':</div>';
316
  }
317

    
318
  // List results.
319
  if (isset($pager->records) && count($pager->records) > 0) {
320
    $out .= '<div id="search_results">';
321
    $list_of_taxa = compose_list_of_taxa($pager->records, $freetextSearchResults, $classification === NULL);
322
    $out .= drupal_render($list_of_taxa);
323
    $out .= '</div>';
324
    $out .= theme('cdm_pager', array(
325
        'pager' => $pager,
326
        'path' => $path,
327
        'parameters' => $_REQUEST,
328
    ));
329
  } else {
330
    $out .= '<h4 class="error">' . t('Sorry, no matching entries found.') . '</h4>';
331
  }
332
  return $out;
333
}
334

    
335

    
336
/**
337
 * TODO Implementation of Hook taxon_image_gallery()
338
 *
339
 * @param object $taxon
340
 * @param object $media
341
 *
342
 * @return string
343
 *  Markup for the default media gallery
344
 */
345
function taxon_image_gallery_default($taxon, $media) {
346
  $hasImages = isset($media[0]);
347

    
348
  if ($hasImages) {
349

    
350
    $maxExtend = 150;
351
    $cols = 3;
352
    $maxRows = FALSE;
353
    $alternativeMediaUri = NULL;
354
    /* Comment @WA: was in D5:
355
    $captionElements = array(
356
      'title',
357
      'rights',
358
      '#uri' => t('Open Image'),
359
    );
360
    */
361
    $captionElements = array(
362
      'title',
363
      'description',
364
      'artist',
365
      'location',
366
      'rights',
367
      '#uri' => t('Open image'),
368
    );
369
    $gallery_name = $taxon->uuid;
370
    $mediaLinkType = 'LIGHTBOX';
371

    
372
    // $gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
373

    
374
    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
375

    
376
    $out = '<div class="image-gallerie">';
377
    $out .= compose_cdm_media_gallerie(array(
378
      'mediaList' => $media,
379
      'galleryName' => $gallery_name,
380
      'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
381
      'cols' => $gallery_settings['cdm_dataportal_media_cols'],
382
      'maxRows' => 0, // Ignore maxrows settings.
383
      'captionElements' => $captionElements,
384
      'mediaLinkType' => $mediaLinkType,
385
      'alternativeMediaUri' => NULL,
386
      'galleryLinkUri' => NULL,
387
      'showCaption' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
388
    ));
389
    $out .= '</div>';
390
  }
391
  else {
392
    $out = 'No images available.';
393
  }
394
  return $out;
395
}
396

    
397
/**
398
 * TODO Implementation of Hook taxon_image_gallery()
399
 *
400
 * @param object $taxon
401
 * @param object $media
402
 *
403
 * @return string
404
 *  Markup for the fsi media gallery
405
 *
406
 * @throws Exception
407
 */
408
function taxon_image_gallery_fsi($taxon, $media) {
409
  $flashLink = isset($media[0]);
410

    
411
  if ($flashLink) {
412

    
413
    if (module_exists("fsi_gallery")) {
414
      $out = theme("fsi_gallery", array('taxon' => $taxon, 'media' => $media));
415
    }
416
    else {
417
      $message = t('In order to use the FSI gallery you must enable the according ') . l(t("module"), "admin/modules");
418
      drupal_set_message($message, "error");
419
      $out = '<h3>' . $message . '</h3>';
420
    }
421
  }
422
  else {
423
    $out = 'No images available.';
424
  }
425
  return $out;
426
}
427

    
428
/**
429
 * Returns a drupal render array for a single reference page.
430
 *
431
 * Composes a page with all data on a single reference.
432
 *
433
 * @param string $uuid
434
 *   An uuid for a cdm reference.
435
 *
436
 * @return array
437
 *  A drupal render array
438
 *
439
 * @throws Exception
440
 *
441
 * @ingroup compose
442
 */
443
function compose_cdm_reference_page($uuid) {
444

    
445
  $pathelement = "reference_page";
446
  RenderHints::pushToRenderStack($pathelement);
447
  $reference = cdm_ws_get(CDM_WS_REFERENCE, $uuid);
448
  if (isset($reference->titleCache)) {
449
    drupal_set_title($reference->titleCache, PASS_THROUGH);
450
  }
451

    
452
  $field_order = array(
453
    "title",
454
    "abbrevTitle",
455
    // "titleCache" abbrevTitleCache
456
    // "citation",
457
    "authorship",
458
    "editor",
459
    "publisher",
460
    "placePublished",
461
    "datePublished",
462
    "year",
463
    "edition",// Class Book.
464
    "volume",// Class Article.
465
    "seriesPart",
466
    "inReference",
467
    "nomRefBase", // Class BookSection, Book, Article.
468
    "pages",// Class Article.
469
    "series",// Class Article, PrintSeries.
470
    "school",// Class Thesis.
471
    "institution",// Class Report.
472
    "organization",// Class Proceedings.
473
    "nextVersion",
474
    "previousVersion",
475
    "isbn",// Class Book.
476
    "issn",// Class Journal.
477
    "doi",
478
    "uri"
479
  );
480

    
481
  $table_rows = array();
482

    
483
  if (!isset($reference->authorship)) {
484
    $authorship = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
485
    $reference->authorship = isset($authorship->titleCache) ? $authorship->titleCache : '';
486
  }
487

    
488
  if (!isset($reference->inReference)) {
489
    $reference->inReference = cdm_ws_get(CDM_WS_REFERENCE, array(
490
      $reference->uuid,
491
      "inReference",
492
    ));
493
  }
494

    
495
  foreach ($field_order as $fieldname) {
496

    
497
    if (isset($reference->$fieldname)) {
498

    
499
      if ($fieldname == "datePublished") {
500
        $period = $reference->$fieldname;
501
        $datePublished = timePeriodToString($period);
502
        if (isset($datePublished) && $datePublished != '') {
503
          $table_rows[] = array(
504
            t("Date published"),
505
            $datePublished,
506
          );
507
        }
508
      }
509
      elseif ($fieldname == "doi" && is_object($reference->doi)) {
510
        $table_rows[] = array(
511
          t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
512
          cdm_doi($reference->doi, false)
513
        );
514
      }
515
      elseif ($fieldname == "uri" && isset($reference->uri) && $reference->uri) {
516
        $table_rows[] = array(
517
          t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
518
          cdm_external_uri($reference->uri, false)
519
        );
520
      }
521
      elseif (is_object($reference->$fieldname)) {
522
        if ($fieldname == "authorship") {
523
          $dump = $reference->$fieldname;
524
          $teammembers = "teamMembers";
525
          $team = $dump->$teammembers;
526
          $nameArray = array();
527

    
528
          foreach ($team as $member) {
529
            if (strlen($member->lastname) > 0) {
530
              $nname = $member->lastname;
531
              $name = $nname;
532
              if (strlen($member->firstname) > 0) {
533
                $vname = $member->firstname;
534
                $name = $vname . " " . $nname;
535
              }
536
              $nameArray[] = $name;
537
            }
538
            else {
539
              if (strlen($member->titleCache) > 0) {
540
                $nameArray[] = $member->titleCache;
541
              }
542
            }
543
          }
544
          $value = join($nameArray, ", ");
545
        }
546
        elseif ($fieldname == "inReference") {
547
          $type = $reference->$fieldname->type;
548
          $value = l($reference->$fieldname->titleCache, path_to_reference($reference->$fieldname->uuid));
549
          switch ($type) {
550
            case "Book":
551
              $fieldname = "in book";
552
              break;
553
            case "Journal":
554
              $fieldname = "in journal";
555
              break;
556
            case "Proceedings":
557
              $fieldname = "in proceedings";
558
              break;
559
          }
560
        }
561
        else {
562
          $value = $reference->$fieldname->titleCache;
563
        }
564

    
565

    
566
        if (isset($value) && $value != '') {
567
          $table_rows[] = array(
568
            t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
569
            $value,
570
          );
571
        }
572

    
573
      }
574
      else {
575
        if (isset($reference->$fieldname) && $reference->$fieldname != '') {
576
          $table_rows[] = array(
577
            t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
578
            $reference->$fieldname,
579
          );
580
        }
581
      }
582
    }
583
  }
584

    
585
  $out = theme_table(array(
586
      'header' => array(),
587
      'rows' => $table_rows,
588
      'attributes' => array(
589
        'class' => html_class_attribute_ref($reference)
590
      ),
591
      'caption' => NULL,
592
      'colgroups' => NULL,
593
      'sticky' => NULL,
594
      'empty' => NULL,
595
  ));
596

    
597
  if(isset($reference->referenceAbstract)){
598
    $out .= '<h2 class="block-title">Abstract</h2><div class="abstract">' . $reference->referenceAbstract . '</div>';
599
  }
600

    
601

    
602
  // Annotations below the table
603
  $annotations = cdm_fetch_visible_annotations($reference);
604
  $out .= theme("cdm_annotations", array('annotations' => $annotations));
605

    
606
  $registration_working_set = cdm_ws_get("registrationWorkingSetDTO", array($uuid));
607
  if($registration_working_set && count($registration_working_set->registrationDTOs) > 0){
608
    $out .= "<h3>Nomenclatural acts:</h3><div class=\"cdm-item-list registration-item-list\">";
609
    foreach($registration_working_set->registrationDTOs as $registration_dto){
610
      if($registration_dto->status == "PUBLISHED"){
611
        $registration_render_a = compose_registration_dto_compact($registration_dto, 'citation');
612
        $registration_render_a["#prefix"] = "<div class=\"item item-registration\">";
613
        $registration_render_a["#suffix"] = "</div>";
614
        $out .= drupal_render($registration_render_a);
615
      }
616
    }
617
    $out .= "</div>";
618
  }
619

    
620
  RenderHints::popFromRenderStack();
621

    
622
  return markup_to_render_array($out);
623
}
624

    
625
/**
626
 * @todo Please document this function.
627
 * @see http://drupal.org/node/1354
628
 */
629
function theme_cdm_media_page($variables) {
630

    
631
  $media = $variables['media'];
632
  $mediarepresentation_uuid = $variables['mediarepresentation_uuid'];
633
  $partId = $variables['partId'];
634
  $out = '';
635

    
636
  // Determine which representation and which part to show
637
  $active_representation_index = 0;
638

    
639
  if (!$mediarepresentation_uuid) {
640
    // no representation requested by the method parameters, find the best one
641
    $representations = cdm_preferred_media_representations($media, array('image/png', 'image/jpeg', 'image/gif'), null, null);
642
    if($representations  && count($representations) > 0){
643
      $preferred_representation = array_shift($representations);
644
      $mediarepresentation_uuid = $preferred_representation->uuid;
645
    }
646
  }
647

    
648
  if($mediarepresentation_uuid){
649
    foreach ($media->representations as $representation) {
650
      if ($representation->uuid == $mediarepresentation_uuid) {
651
        break;
652
      }
653
      $active_representation_index++;
654
    }
655
  }
656

    
657

    
658
  $active_part_index = 0;
659
  if (is_uuid($partId)) {
660
    foreach ($media->representations[$active_representation_index]->parts as $part) {
661
      if ($part->uuid == $partId) {
662
        break;
663
      }
664
      $active_part_index++;
665
    }
666
  }
667
  else if(is_numeric($partId)){
668
    $active_part_index = $partId;
669
  }
670

    
671
  $media_metadata = read_media_metadata($media);
672
  // $title = $media->titleCache;
673
  $title = $media_metadata['title'];
674

    
675
  $imageMaxExtend = variable_get('image-page-maxextend', 400);
676

    
677
  if (!$title) {
678
    $title = 'Media ' . $media->uuid . '';
679
  }
680

    
681
  drupal_set_title($title, PASS_THROUGH);
682

    
683
  $out .= '<div class="media cdm_media_viewer_image">';
684

    
685
  if(preg_match('/cdm_dataportal\/taxon\//', $_SERVER['HTTP_REFERER']) ){
686
    if(variable_get('cdm_dataportal_taxonpage_tabs', 1)){
687
      // taxon page with tabs
688
      $out .= '<div id="backToGalleryButton">' . l(t('Back to images'), $_SESSION['cdm']['last_gallery']) . '</div>';
689
    } else {
690
      // tabless mode
691
      $out .= '<div id="backToGalleryButton">' . l(t('Back to taxon page'), $_SESSION['cdm']['last_gallery']) . '</div>';
692
    }
693
  }
694
  $out .= '<div class="viewer">';
695
  $out .= cdm_openlayers_image($media->representations[$active_representation_index]->parts[$active_part_index], $imageMaxExtend);
696
  $out .= '</div>';
697

    
698
  // General media metadata.
699
  $metadataToPrint = theme('cdm_media_caption', array('media' => $media, 'sources_as_content' => true));
700
  $out .= $metadataToPrint;
701

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

    
732
        $out .= '</td><td><a href="' . url(path_to_media($media->uuid, $representation->uuid, $active_part_index)) . '">'
733
          . cdm_media_gallerie_image($part, $thumbnailMaxExtend, TRUE);
734
        $active_part_index++;
735
      }
736
      $out .= '</table>';
737
      $out .=  '</li>';
738
      $r_i++;
739
    }
740
    $out .= '</ul>';
741
  }
742

    
743
  $out .= '</div>';
744
  return $out;
745
}
746

    
747
/**
748
 * @todo Please document this function.
749
 * @see http://drupal.org/node/1354
750
 */
751
function theme_cdm_polytomousKey_page($variables) {
752
  $polytomousKey = $variables['polytomousKey'];
753
  drupal_set_title($polytomousKey->titleCache, PASS_THROUGH);
754

    
755
  $out = theme("cdm_IdentificationKey", array(
756
    'identificationKey' => $polytomousKey,
757
    'doLinkToKeyPage' => FALSE,
758
    'showIdentificationKeyTitle' => FALSE,
759
    ));
760

    
761
  // Key nodes in linked style.
762
  $out .= theme('cdm_polytomousKey', array('polytomousKey' => $polytomousKey));
763
  /*
764
   * FIXME implement node type for keys !!!
765
   * (wrapping the content in the cdm_dataportal.node becomes obsolete then).
766
   */
767
  return '<div id="identificationKey">' . $out . '</div>';
768
}
Add picture from clipboard (Maximum size: 40 MB)