Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / theme / cdm_dataportal.page.theme @ 6eaec849

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

    
357

    
358

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

    
371

    
372

    
373

    
374

    
375

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

    
394

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

    
407
  if ($hasImages) {
408

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

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

    
433
    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
434

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

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

    
470
  if ($flashLink) {
471

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

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

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

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

    
540
  $table_rows = array();
541

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

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

    
554
  foreach ($field_order as $fieldname) {
555

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

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

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

    
624

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

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

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

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

    
660

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

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

    
679
  RenderHints::popFromRenderStack();
680

    
681
  return markup_to_render_array($out);
682
}
683

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

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

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

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

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

    
716

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

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

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

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

    
740
  drupal_set_title($title, PASS_THROUGH);
741

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

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

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

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

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

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

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

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

    
820
  // Key nodes in linked style.
821
  $out .= theme('cdm_polytomousKey', array('polytomousKey' => $polytomousKey));
822
  /*
823
   * FIXME implement node type for keys !!!
824
   * (wrapping the content in the cdm_dataportal.node becomes obsolete then).
825
   */
826
  return '<div id="identificationKey">' . $out . '</div>';
827
}
Add picture from clipboard (Maximum size: 40 MB)