Project

General

Profile

Download (25.3 KB) Statistics
| Branch: | Tag: | Revision:
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 = compose_name_relationships_inline($name_relations, $taxon->name->uuid, $taxon->uuid);
198
    // Render relationships of accepted name.
199
    if(isset($name_relationships['list']['items'][0])){
200
      $accepted_name .= ' <span class="name_relationships">' . drupal_render($name_relationships) . '</span>';
201
    }
202

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

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

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

    
229

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

    
242
  RenderHints::popFromRenderStack();
243

    
244
  return markup_to_render_array($out);
245
}
246

    
247

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

    
271
  $freetextSearchResults = array();
272

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

    
291

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

    
304
  $classification = cdm_dataportal_searched_in_classification();
305

    
306

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

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

    
334

    
335
/**
336
 * Returns HTML for the given result page including a pager.
337
 *
338
 * @param array $variables
339
 *   An associative array containing:
340
 *   - pager: TODO
341
 *   - path: The target path for the pager links, this will usually point to
342
 *     'cdm_dataportal/search/results/taxon'
343
 *
344
 * @return string
345
 *  Markup for the result page
346
 *
347
 * @throws Exception
348
 *
349
 * @ingroup themeable
350
 */
351
function theme_cdm_search_specimen_results($variables)
352
{
353
    $pager = $variables['pager'];
354
    $path = $variables['path'];
355

    
356

    
357

    
358
    // Add thumbnails checkbox and refine search link.
359
    $out = '<div class="page_options">';
360
    //if (isset($_REQUEST['ws'])) {
361
     //   if (cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) {
362
     //       $out .= '<div id="backButton">' . l(t('Modify search'), cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) . '</div>';
363
     //   }
364
    //}
365
    if (variable_get(SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX, SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX_DEFAULT)) {
366
        $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>';
367
    }
368
    $out .= '</div>';
369

    
370

    
371

    
372

    
373

    
374

    
375
    // List results.
376
    if (isset($pager->data) ) {
377
        $data = json_decode($pager->data, true);
378
        $out .= '<div id="search_results">';
379
        $list_of_result = compose_table_of_blast_result($data);
380
        $out .= $list_of_result;
381
        $out .= '</div>';
382
       // $out .= theme('cdm_pager', array(
383
       //     'pager' => $pager,
384
       //     'path' => $path,
385
       //     'parameters' => $_REQUEST,
386
        //));
387
    } else {
388
        $out .= '<h4 class="error">' . t('Sorry, no matching entries found.') . '</h4>';
389
    }
390
    return $out;
391
}
392

    
393

    
394
/**
395
 * TODO Implementation of Hook taxon_image_gallery()
396
 *
397
 * @param object $taxon
398
 * @param object $media
399
 *
400
 * @return string
401
 *  Markup for the default media gallery
402
 */
403
function taxon_image_gallery_default($taxon, $media) {
404
  $hasImages = isset($media[0]);
405

    
406
  if ($hasImages) {
407

    
408
    $maxExtend = 150;
409
    $cols = 3;
410
    $maxRows = FALSE;
411
    $alternativeMediaUri = NULL;
412
    /* Comment @WA: was in D5:
413
    $captionElements = array(
414
      'title',
415
      'rights',
416
      '#uri' => t('Open Image'),
417
    );
418
    */
419
    $captionElements = array(
420
      'title',
421
      'description',
422
      'artist',
423
      'location',
424
      'rights',
425
      '#uri' => t('Open image'),
426
    );
427
    $gallery_name = $taxon->uuid;
428
    $mediaLinkType = 'LIGHTBOX';
429

    
430
    // $gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
431

    
432
    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
433

    
434
    $out = '<div class="image-gallerie">';
435
    $out .= compose_cdm_media_gallerie(array(
436
      'mediaList' => $media,
437
      'galleryName' => $gallery_name,
438
      'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
439
      'cols' => $gallery_settings['cdm_dataportal_media_cols'],
440
      'maxRows' => 0, // Ignore maxrows settings.
441
      'captionElements' => $captionElements,
442
      'mediaLinkType' => $mediaLinkType,
443
      'alternativeMediaUri' => NULL,
444
      'galleryLinkUri' => NULL,
445
      'showCaption' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
446
    ));
447
    $out .= '</div>';
448
  }
449
  else {
450
    $out = 'No images available.';
451
  }
452
  return $out;
453
}
454

    
455
/**
456
 * TODO Implementation of Hook taxon_image_gallery()
457
 *
458
 * @param object $taxon
459
 * @param object $media
460
 *
461
 * @return string
462
 *  Markup for the fsi media gallery
463
 *
464
 * @throws Exception
465
 */
466
function taxon_image_gallery_fsi($taxon, $media) {
467
  $flashLink = isset($media[0]);
468

    
469
  if ($flashLink) {
470

    
471
    if (module_exists("fsi_gallery")) {
472
      $out = theme("fsi_gallery", array('taxon' => $taxon, 'media' => $media));
473
    }
474
    else {
475
      $message = t('In order to use the FSI gallery you must enable the according ') . l(t("module"), "admin/modules");
476
      drupal_set_message($message, "error");
477
      $out = '<h3>' . $message . '</h3>';
478
    }
479
  }
480
  else {
481
    $out = 'No images available.';
482
  }
483
  return $out;
484
}
485

    
486
/**
487
 * Returns a drupal render array for a single reference page.
488
 *
489
 * Composes a page with all data on a single reference.
490
 *
491
 * @param string $uuid
492
 *   An uuid for a cdm reference.
493
 *
494
 * @return array
495
 *  A drupal render array
496
 *
497
 * @throws Exception
498
 *
499
 * @ingroup compose
500
 */
501
function compose_cdm_reference_page($uuid) {
502

    
503
  $pathelement = "reference_page";
504
  RenderHints::pushToRenderStack($pathelement);
505
  $reference = cdm_ws_get(CDM_WS_REFERENCE, $uuid);
506
  if (isset($reference->titleCache)) {
507
    drupal_set_title($reference->titleCache, PASS_THROUGH);
508
  }
509

    
510
  $field_order = array(
511
    "title",
512
    "abbrevTitle",
513
    // "titleCache" abbrevTitleCache
514
    // "citation",
515
    "authorship",
516
    "editor",
517
    "publisher",
518
    "placePublished",
519
    "datePublished",
520
    "year",
521
    "edition",// Class Book.
522
    "volume",// Class Article.
523
    "seriesPart",
524
    "inReference",
525
    "nomRefBase", // Class BookSection, Book, Article.
526
    "pages",// Class Article.
527
    "series",// Class Article, PrintSeries.
528
    "school",// Class Thesis.
529
    "institution",// Class Report.
530
    "organization",// Class Proceedings.
531
    "nextVersion",
532
    "previousVersion",
533
    "isbn",// Class Book.
534
    "issn",// Class Journal.
535
    "doi",
536
    "uri"
537
  );
538

    
539
  $table_rows = array();
540

    
541
  if (!isset($reference->authorship)) {
542
    $authorship = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
543
    $reference->authorship = isset($authorship->titleCache) ? $authorship->titleCache : '';
544
  }
545

    
546
  if (!isset($reference->inReference)) {
547
    $reference->inReference = cdm_ws_get(CDM_WS_REFERENCE, array(
548
      $reference->uuid,
549
      "inReference",
550
    ));
551
  }
552

    
553
  foreach ($field_order as $fieldname) {
554

    
555
    if (isset($reference->$fieldname)) {
556

    
557
      if ($fieldname == "datePublished") {
558
        $period = $reference->$fieldname;
559
        $datePublished = timePeriodToString($period);
560
        if (isset($datePublished) && $datePublished != '') {
561
          $table_rows[] = array(
562
            t("Date published"),
563
            $datePublished,
564
          );
565
        }
566
      }
567
      elseif ($fieldname == "doi" && is_object($reference->doi)) {
568
        $table_rows[] = array(
569
          t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
570
          cdm_doi($reference->doi, false)
571
        );
572
      }
573
      elseif ($fieldname == "uri" && isset($reference->uri) && $reference->uri) {
574
        $table_rows[] = array(
575
          t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
576
          cdm_external_uri($reference->uri, false)
577
        );
578
      }
579
      elseif (is_object($reference->$fieldname)) {
580
        if ($fieldname == "authorship") {
581
          $dump = $reference->$fieldname;
582
          $teammembers = "teamMembers";
583
          $team = $dump->$teammembers;
584
          $nameArray = array();
585

    
586
          foreach ($team as $member) {
587
            if (strlen($member->lastname) > 0) {
588
              $nname = $member->lastname;
589
              $name = $nname;
590
              if (strlen($member->firstname) > 0) {
591
                $vname = $member->firstname;
592
                $name = $vname . " " . $nname;
593
              }
594
              $nameArray[] = $name;
595
            }
596
            else {
597
              if (strlen($member->titleCache) > 0) {
598
                $nameArray[] = $member->titleCache;
599
              }
600
            }
601
          }
602
          $value = join($nameArray, ", ");
603
        }
604
        elseif ($fieldname == "inReference") {
605
          $type = $reference->$fieldname->type;
606
          $value = l($reference->$fieldname->titleCache, path_to_reference($reference->$fieldname->uuid));
607
          switch ($type) {
608
            case "Book":
609
              $fieldname = "in book";
610
              break;
611
            case "Journal":
612
              $fieldname = "in journal";
613
              break;
614
            case "Proceedings":
615
              $fieldname = "in proceedings";
616
              break;
617
          }
618
        }
619
        else {
620
          $value = $reference->$fieldname->titleCache;
621
        }
622

    
623

    
624
        if (isset($value) && $value != '') {
625
          $table_rows[] = array(
626
            t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
627
            $value,
628
          );
629
        }
630

    
631
      }
632
      else {
633
        if (isset($reference->$fieldname) && $reference->$fieldname != '') {
634
          $table_rows[] = array(
635
            t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
636
            $reference->$fieldname,
637
          );
638
        }
639
      }
640
    }
641
  }
642

    
643
  $out = theme_table(array(
644
      'header' => array(),
645
      'rows' => $table_rows,
646
      'attributes' => array(
647
        'class' => html_class_attribute_ref($reference)
648
      ),
649
      'caption' => NULL,
650
      'colgroups' => NULL,
651
      'sticky' => NULL,
652
      'empty' => NULL,
653
  ));
654

    
655
  if(isset($reference->referenceAbstract)){
656
    $out .= '<h2 class="block-title">Abstract</h2><div class="abstract">' . $reference->referenceAbstract . '</div>';
657
  }
658

    
659

    
660
  // Annotations below the table
661
  $annotations = cdm_fetch_visible_annotations($reference);
662
  $out .= theme("cdm_annotations", array('annotations' => $annotations));
663

    
664
  $registration_working_set = cdm_ws_get("registrationWorkingSetDTO", array($uuid));
665
  if($registration_working_set && count($registration_working_set->registrationDTOs) > 0){
666
    $out .= "<h3>Nomenclatural acts:</h3><div class=\"cdm-item-list registration-item-list\">";
667
    foreach($registration_working_set->registrationDTOs as $registration_dto){
668
      if($registration_dto->status == "PUBLISHED"){
669
        $registration_render_a = compose_registration_dto_compact($registration_dto, 'citation');
670
        $registration_render_a["#prefix"] = "<div class=\"item item-registration\">";
671
        $registration_render_a["#suffix"] = "</div>";
672
        $out .= drupal_render($registration_render_a);
673
      }
674
    }
675
    $out .= "</div>";
676
  }
677

    
678
  RenderHints::popFromRenderStack();
679

    
680
  return markup_to_render_array($out);
681
}
682

    
683
/**
684
 * @todo Please document this function.
685
 * @see http://drupal.org/node/1354
686
 */
687
function theme_cdm_media_page($variables) {
688

    
689
  $media = $variables['media'];
690
  $mediarepresentation_uuid = $variables['mediarepresentation_uuid'];
691
  $partId = $variables['partId'];
692
  $out = '';
693

    
694
  // Determine which representation and which part to show
695
  $active_representation_index = 0;
696

    
697
  if (!$mediarepresentation_uuid) {
698
    // no representation requested by the method parameters, find the best one
699
    $representations = cdm_preferred_media_representations($media, array('image/png', 'image/jpeg', 'image/gif'), null, null);
700
    if($representations  && count($representations) > 0){
701
      $preferred_representation = array_shift($representations);
702
      $mediarepresentation_uuid = $preferred_representation->uuid;
703
    }
704
  }
705

    
706
  if($mediarepresentation_uuid){
707
    foreach ($media->representations as $representation) {
708
      if ($representation->uuid == $mediarepresentation_uuid) {
709
        break;
710
      }
711
      $active_representation_index++;
712
    }
713
  }
714

    
715

    
716
  $active_part_index = 0;
717
  if (is_uuid($partId)) {
718
    foreach ($media->representations[$active_representation_index]->parts as $part) {
719
      if ($part->uuid == $partId) {
720
        break;
721
      }
722
      $active_part_index++;
723
    }
724
  }
725
  else if(is_numeric($partId)){
726
    $active_part_index = $partId;
727
  }
728

    
729
  $media_metadata = read_media_metadata($media);
730
  // $title = $media->titleCache;
731
  $title = $media_metadata['title'];
732

    
733
  $imageMaxExtend = variable_get('image-page-maxextend', 400);
734

    
735
  if (!$title) {
736
    $title = 'Media ' . $media->uuid . '';
737
  }
738

    
739
  drupal_set_title($title, PASS_THROUGH);
740

    
741
  $out .= '<div class="media cdm_media_viewer_image">';
742

    
743
  if(preg_match('/cdm_dataportal\/taxon\//', $_SERVER['HTTP_REFERER']) ){
744
    if(variable_get('cdm_dataportal_taxonpage_tabs', 1)){
745
      // taxon page with tabs
746
      $out .= '<div id="backToGalleryButton">' . l(t('Back to images'), $_SESSION['cdm']['last_gallery']) . '</div>';
747
    } else {
748
      // tabless mode
749
      $out .= '<div id="backToGalleryButton">' . l(t('Back to taxon page'), $_SESSION['cdm']['last_gallery']) . '</div>';
750
    }
751
  }
752
  $out .= '<div class="viewer">';
753
  $out .= cdm_openlayers_image($media->representations[$active_representation_index]->parts[$active_part_index], $imageMaxExtend);
754
  $out .= '</div>';
755

    
756
  // General media metadata.
757
  $metadataToPrint = theme('cdm_media_caption', array('media' => $media, 'sources_as_content' => true));
758
  $out .= $metadataToPrint;
759

    
760
  $cdm_standard_image_viewer_settings = get_array_variable_merged(CDM_STANDARD_IMAGE_VIEWER, CDM_STANDARD_IMAGE_VIEWER_DEFAULT);
761
  if ($cdm_standard_image_viewer_settings['media_representation_details_enabled'] == 1){
762
    // Tabs for the different representations.
763
    // Representation(-part) specific metadata.
764
    $thumbnailMaxExtend = 100;
765
    $out .= '<h3>' .t('Media representations') .'</h3><ul id="media-representations">';
766
    $r_i = 0;
767
    foreach ($media->representations as $representation) {
768
      $out .= '<li><strong>'. t('Representation') . ' ' . $r_i . "</strong> ($representation->mimeType)" ;
769
      // parts
770
      $active_part_index = 0;
771
      $table_class_attribute = '';
772
      if($partIdx == $active_part_index && $active_representation_index == $r_i ){
773
        $table_class_attribute = 'class="active"';
774
      }
775
      $out .= "<table $table_class_attribute>";
776
      foreach ($representation->parts as $part) {
777
        $out .= '<tr><th>' . t('Part') . ' ' . ($active_part_index + 1) . '</th></tr><tr><td>';
778
        switch ($part->class) {
779
          case 'ImageFile':
780
            $out .= $part->width . 'x' . $part->height . ' px - ' . $part->size . ' kB';
781
            break;
782
          case 'AudioFile':
783
          case 'MovieFile':
784
            $out .= t('Duration') . ': ' . $part->duration . 's - ' . $part->size . ' kB';
785
            break;
786
          default:
787
            $out .= $part->size . 'k';
788
        }
789

    
790
        $out .= '</td><td><a href="' . url(path_to_media($media->uuid, $representation->uuid, $active_part_index)) . '">'
791
          . cdm_media_gallerie_image($part, $thumbnailMaxExtend, TRUE);
792
        $active_part_index++;
793
      }
794
      $out .= '</table>';
795
      $out .=  '</li>';
796
      $r_i++;
797
    }
798
    $out .= '</ul>';
799
  }
800

    
801
  $out .= '</div>';
802
  return $out;
803
}
804

    
805
/**
806
 * @todo Please document this function.
807
 * @see http://drupal.org/node/1354
808
 */
809
function theme_cdm_polytomousKey_page($variables) {
810
  $polytomousKey = $variables['polytomousKey'];
811
  drupal_set_title($polytomousKey->titleCache, PASS_THROUGH);
812

    
813
  $out = theme("cdm_IdentificationKey", array(
814
    'identificationKey' => $polytomousKey,
815
    'doLinkToKeyPage' => FALSE,
816
    'showIdentificationKeyTitle' => FALSE,
817
    ));
818

    
819
  // Key nodes in linked style.
820
  $out .= theme('cdm_polytomousKey', array('polytomousKey' => $polytomousKey));
821
  /*
822
   * FIXME implement node type for keys !!!
823
   * (wrapping the content in the cdm_dataportal.node becomes obsolete then).
824
   */
825
  return '<div id="identificationKey">' . $out . '</div>';
826
}
(6-6/9)