Project

General

Profile

Download (20.4 KB) Statistics
| Branch: | Tag: | Revision:
1 6657531f Andreas Kohlbecker
<?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
 * @ingroup themeable
26
 */
27
function theme_cdm_taxon_page_title($variables) {
28
  $taxon = $variables['taxon'];
29
  RenderHints::pushToRenderStack('taxon_page_title');
30
  $referenceUri = '';
31
  $out = '';
32
  if (isset($taxon->name->nomenclaturalReference)) {
33
    $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
34
  }
35
36 63c3ac73 Andreas Kohlbecker
  $out .= render_taxon_or_name($taxon, NULL, $referenceUri, FALSE);
37 6657531f Andreas Kohlbecker
  RenderHints::popFromRenderStack();
38
39
  return '<span class="' . $taxon->class . '">' . $out . '</span>';
40
}
41
42 216abf0b Patric Plitzner
/**
43
 * Returns HTML for the default title of a specimen page.
44
 *  * The returned title is a the identifier of the specimen.
45
 *
46
 * @param array $variables
47
 *   An associative array containing:
48
 *   - specimen: The specimen being formatted for the title.
49
 *
50
 * @ingroup themeable
51
 */
52
function theme_cdm_specimen_page_title($variables) {
53
    $specimen = $variables['specimen'];
54
    RenderHints::pushToRenderStack('specimen_page_title');
55
    $referenceUri = '';
56
    $out = '';
57
58
    $title = "";
59
    if($specimen->accessionNumber){
60
        $title = $specimen->accessionNumber;
61
    }
62
    elseif($specimen->barcode){
63
        $title = $specimen->barcode;
64
    }
65
    elseif($specimen->catalogNumber) {
66
        $title = $specimen->catalogNumber;
67
    }
68
69
70
  $out .= $title;
71
  RenderHints::popFromRenderStack();
72
73
  return '<span class="' . $specimen->class . '">' . $out . '</span>';
74
}
75
76 6657531f Andreas Kohlbecker
/**
77
 * Returns HTML for the default title for a name page.
78
 *
79
 * The returned title is a formatted name.
80
 *
81
 * @param array $variables
82
 *   An associative array containing:
83
 *   - taxon_name: The taxon name object.
84
 *
85
 * @ingroup themeable
86
 */
87
function theme_cdm_name_page_title($variables) {
88
  $taxon_name = $variables['taxon_name'];
89
  RenderHints::pushToRenderStack('taxon_page_title');
90 d0d068e9 Andreas Kohlbecker
91
  $referenceUri = NULL;
92 6657531f Andreas Kohlbecker
  if (isset($taxon_name->nomenclaturalReference)) {
93
    $referenceUri = url(path_to_reference($taxon_name->nomenclaturalReference->uuid));
94
  }
95
96 c8c879d8 Andreas Kohlbecker
  $out = '<span class="' . $taxon_name->class . '">'
97
    . render_taxon_or_name($taxon_name, NULL, $referenceUri, FALSE)
98
    . '</span>';
99 6657531f Andreas Kohlbecker
  RenderHints::popFromRenderStack();
100
  return $out;
101
}
102
103
104
105 0a1151a4 Andreas Kohlbecker
106
107 6657531f Andreas Kohlbecker
/**
108
 * Returns HTML containing the synonymy for the accepted taxon.
109
 *
110
 * Shows the whole synonymy for the accepted taxon.
111
 * The synonymy list is headed by the complete scientific name
112
 * of the accepted taxon with nomenclatural reference.
113
 *
114
 * @param array $variables
115
 *   An associative array containing:
116
 *   - taxon
117
 *   - addAcceptedTaxon
118
 *
119
 * @ingroup themeable
120
 */
121
function theme_cdm_taxon_page_synonymy($variables) {
122
  $taxon = $variables['taxon'];
123
  $addAcceptedTaxon = $variables['addAcceptedTaxon'];
124 15b7c460 Andreas Kohlbecker
125 6657531f Andreas Kohlbecker
  RenderHints::pushToRenderStack('taxon_page_synonymy');
126 15b7c460 Andreas Kohlbecker
127
  // footnote key for the homotypic group and accepted taxon,
128
  // both should have the same footnote key
129
  RenderHints::setFootnoteListKey(RenderHints::getRenderPath());
130
131 6657531f Andreas Kohlbecker
  $synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, $taxon->uuid);
132
  $skip = array(
133 6421984d Andreas Kohlbecker
    UUID_NAMERELATIONSHIPTYPE_BASIONYM,
134 6657531f Andreas Kohlbecker
  );
135
  $out = '';
136
137
  // Render accepted taxon.
138 15b7c460 Andreas Kohlbecker
  //
139
  // foonotes of the accepted taxon will be rendered in the homotypic group section
140
  // even if there are not synonyms in the homotypic group
141
  // homotypic group and accepted taxon should have the same footnote key
142 6657531f Andreas Kohlbecker
  $referenceUri = '';
143
  if ($addAcceptedTaxon) {
144 b3a806e8 Andreas Kohlbecker
    // remember the last part of the render path
145
    $synonymy_render_path = RenderHints::getRenderPath();
146
    // set new render path for the accepted taxon so
147
    // it can be styled differently via the name render part definitions
148
    RenderHints::pushToRenderStack('accepted_taxon');
149 6657531f Andreas Kohlbecker
    if (isset($taxon->name->nomenclaturalReference)) {
150
      $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
151
    }
152
153 0e0c8c01 Andreas Kohlbecker
    $accepted_name = '<div class="accepted-name">';
154 63c3ac73 Andreas Kohlbecker
    $accepted_name .= render_taxon_or_name($taxon, NULL, $referenceUri);
155 6657531f Andreas Kohlbecker
156 510d3be7 Andreas Kohlbecker
    $name_relationships = cdm_name_relationships_of($taxon);
157
    // Render relationships of accepted name.
158
    if($name_relationships){
159
160
      $accepted_name .= ' <span class="name_relationships">' . $name_relationships . '</span>';
161
    }
162
163
      // handle annotations of the name and taxon
164 6657531f Andreas Kohlbecker
    $special_annotations_array = array();
165
    $special_annotations_array[] = $taxon->name;
166
    $special_annotations_array[] = $taxon;
167 15b7c460 Andreas Kohlbecker
    $accepted_name .= theme('cdm_annotations_as_footnotekeys', array(
168 34dd7be9 Andreas Kohlbecker
        'cdmBase_list' => $special_annotations_array,
169 b3a806e8 Andreas Kohlbecker
        'footnote_list_key' => $synonymy_render_path . '-annotations')
170 34dd7be9 Andreas Kohlbecker
      );
171 0e0c8c01 Andreas Kohlbecker
    $accepted_name .= '</div>';
172 b3a806e8 Andreas Kohlbecker
    RenderHints::popFromRenderStack();
173 6657531f Andreas Kohlbecker
  }
174
175 bdcb2628 Andreas Kohlbecker
  // --- Render homotypic synonymy group
176 6657531f Andreas Kohlbecker
  if (!empty($accepted_name)) {
177
    $out .= $accepted_name;
178
  }
179
180 bdcb2628 Andreas Kohlbecker
  // Render the homotypicSynonymyGroup including the type information.
181 2b7cd6c2 Andreas Kohlbecker
  $out .= theme(
182
      'cdm_homotypicSynonymyGroup',
183
      array(
184
          'synonymList' => $synomymie->homotypicSynonymsByHomotypicGroup,
185
          'accepted_taxon_name_uuid' => $taxon->name->uuid
186
      )
187
    );
188 c9d996cd Andreas Kohlbecker
189 6657531f Andreas Kohlbecker
190
  // Render accepted taxon heterotypic synonymy groups.
191
  if ($synomymie->heterotypicSynonymyGroups) {
192
    foreach ($synomymie->heterotypicSynonymyGroups as $homotypicalGroup) {
193
      $out .= theme('cdm_heterotypicSynonymyGroup', array('homotypicalGroup' => $homotypicalGroup));
194
    }
195
  }
196
  // Render taxon relationships.
197
  if (variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)) {
198
    $taxonRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, $taxon->uuid);
199 b7a20282 Andreas Kohlbecker
    $out .= cdm_taxonRelationships($taxonRelationships, $taxon);
200 6657531f Andreas Kohlbecker
  }
201 51b04faf Andreas Kohlbecker
202 6657531f Andreas Kohlbecker
  RenderHints::popFromRenderStack();
203
204
  return $out;
205
}
206
207 0e0c8c01 Andreas Kohlbecker
208
/**
209
 * Returns HTML for the given result page including a pager.
210
 *
211
 * @param array $variables
212
 *   An associative array containing:
213
 *   - pager: The cdmlib pager object containing the result set of cdm base
214
 *     objects (currently this function can only handle taxon instances =>
215
 *     TODO)
216
 *   - path: The target path for the pager links, this will usually point to
217
 *     'cdm_dataportal/search/results/taxon'
218
 *
219
 * @ingroup themeable
220
 */
221 1d69a96c Andreas Kohlbecker
function theme_cdm_search_results($variables)
222
{
223 0e0c8c01 Andreas Kohlbecker
  $pager = $variables['pager'];
224 34dd7be9 Andreas Kohlbecker
  $path = $variables['path'];
225 0e0c8c01 Andreas Kohlbecker
226 34dd7be9 Andreas Kohlbecker
  $freetextSearchResults = array();
227 0e0c8c01 Andreas Kohlbecker
228
  // If the pager contains records of SearchResults, extract the taxa and use
229
  // them as records instead.
230
  if (isset($pager->records[0]) && $pager->records[0]->class == "SearchResult") {
231
    $freetextSearchResults = $pager->records;
232
    $taxa = array();
233
    // $highlightedFragments = array();
234
    foreach ($pager->records as $searchResult) {
235
      $taxa[] = &$searchResult->entity;
236
      /*
237
       if(!isset($searchResult->fieldHighlightMap)){
238
      $searchResult->fieldHighlightMap = NULL;
239
      }
240
      $fragmentHighlighting[] = $searchResult->fieldHighlightMap;
241
      */
242
    }
243
    $pager->records = $taxa;
244
  }
245
246 1d69a96c Andreas Kohlbecker
247 0e0c8c01 Andreas Kohlbecker
  // Add thumbnails checkbox and refine search link.
248
  $out = '<div class="page_options">';
249
  if (isset($_REQUEST['ws'])) {
250
    if (cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) {
251
      $out .= '<div id="backButton">' . l(t('Modify search'), cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) . '</div>';
252
    }
253
  }
254 1d69a96c Andreas Kohlbecker
  if (variable_get(SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX, SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX_DEFAULT)) {
255
    $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>';
256
  }
257 61b6ee11 Andreas Kohlbecker
  $out .= '</div>';
258 f56b1626 Andreas Kohlbecker
259 61b6ee11 Andreas Kohlbecker
  $classification = cdm_dataportal_searched_in_classification();
260 f56b1626 Andreas Kohlbecker
261 a488aeb6 Andreas Kohlbecker
262
  if (  count(cdm_ws_fetch_all(CDM_WS_PORTAL_TAXONOMY)) > 1 ) { // FIXME use a count REST method for this!!!
263 f56b1626 Andreas Kohlbecker
    $out .= '<div id="search-summary">' . t('results for') . ' ';
264
    if ($classification != NULL) {
265
      $out .=  $classification->titleCache ;
266
    } else {
267
     $out .= t('any classification');
268
    }
269 0e0c8c01 Andreas Kohlbecker
    $out .= ':</div>';
270 61b6ee11 Andreas Kohlbecker
  }
271 0e0c8c01 Andreas Kohlbecker
272
  // List results.
273
  if (isset($pager->records) && count($pager->records) > 0) {
274
    $out .= '<div id="search_results">';
275 01fff74a Andreas Kohlbecker
    $list_of_taxa = compose_list_of_taxa($pager->records, $freetextSearchResults, $classification === NULL);
276
    $out .= drupal_render($list_of_taxa);
277 0e0c8c01 Andreas Kohlbecker
    $out .= '</div>';
278
    $out .= theme('cdm_pager', array(
279
        'pager' => $pager,
280
        'path' => $path,
281
        'parameters' => $_REQUEST,
282
    ));
283
  } else {
284 04f74f8d Andreas Kohlbecker
    $out .= '<h4 class="error">' . t('Sorry, no matching entries found.') . '</h4>';
285 0e0c8c01 Andreas Kohlbecker
  }
286
  return $out;
287
}
288 308b5f90 Andreas Kohlbecker
289
290 6657531f Andreas Kohlbecker
/**
291
 * TODO Implementation of Hook taxon_image_gallery()
292
 *
293
 * @param unknown_type $taxon
294
 * @param unknown_type $media
295
 *
296
 * @return unknown_type
297
 */
298
function taxon_image_gallery_default($taxon, $media) {
299
  $hasImages = isset($media[0]);
300
301
  if ($hasImages) {
302
303
    $maxExtend = 150;
304
    $cols = 3;
305
    $maxRows = FALSE;
306
    $alternativeMediaUri = NULL;
307
    /* Comment @WA: was in D5:
308
    $captionElements = array(
309
      'title',
310
      'rights',
311
      '#uri' => t('open Image'),
312
    );
313
    */
314
    $captionElements = array(
315
      'title',
316
      'description',
317
      'artist',
318
      'location',
319
      'rights',
320
      '#uri' => t('open Image'),
321
    );
322
    $gallery_name = $taxon->uuid;
323
    $mediaLinkType = 'LIGHTBOX';
324
325
    // $gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
326
327
    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
328
329
    $out = '<div class="image-gallerie">';
330
    $out .= theme('cdm_media_gallerie', array(
331
      'mediaList' => $media,
332
      'galleryName' => $gallery_name,
333
      'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
334
      'cols' => $gallery_settings['cdm_dataportal_media_cols'],
335
      'maxRows' => 0, // Ignore maxrows settings.
336
      'captionElements' => $captionElements,
337
      'mediaLinkType' => $mediaLinkType,
338
      'alternativeMediaUri' => NULL,
339
      'galleryLinkUri' => NULL,
340
      'showCaption' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
341
    ));
342
    $out .= '</div>';
343
  }
344
  else {
345
    $out = 'No images available.';
346
  }
347
  return $out;
348
}
349
350
/**
351
 * TODO Implementation of Hook taxon_image_gallery()
352
 *
353
 * @param unknown_type $taxon
354
 * @param unknown_type $media
355
 *
356
 * @return unknown_type
357
 */
358
function taxon_image_gallery_fsi($taxon, $media) {
359
  $flashLink = isset($media[0]);
360
361
  if ($flashLink) {
362
363
    if (module_exists("fsi_gallery")) {
364
      $out = theme("fsi_gallery", array('taxon' => $taxon, 'media' => $media));
365
    }
366
    else {
367
      $message = t('In order to use the FSI gallery you must enable the according ') . l(t("module"), "admin/modules");
368
      drupal_set_message($message, "error");
369
      $out = '<h3>' . $message . '</h3>';
370
    }
371
  }
372
  else {
373
    $out = 'No images available.';
374
  }
375
  return $out;
376
}
377
378
/**
379
 * Returns HTML for a single reference page.
380
 *
381
 * Renders a page with all data on a single reference.
382
 *
383
 * @param array $variables
384
 *   An associative array containing:
385
 *   - reference: Object.
386
 *
387
 * @ingroup themeable
388
 */
389
function theme_cdm_reference_page($variables) {
390
  $reference = $variables['reference'];
391
392
  $out = '';
393
394
  if (isset($reference->titleCache)) {
395
    drupal_set_title($reference->titleCache, PASS_THROUGH);
396
  }
397
398
  $field_order = array(
399
    "title",
400 0a288588 Andreas Kohlbecker
    "abbrevTitle",
401
    // "titleCache" abbrevTitleCache
402 6657531f Andreas Kohlbecker
    // "citation",
403 1ce9afb7 Patric Plitzner
    "authorship",
404 6657531f Andreas Kohlbecker
    "editor",
405
    "publisher",
406
    "placePublished",
407
    "datePublished",
408
    "year",
409
    "edition",// Class Book.
410
    "volume",// Class Article.
411
    "seriesPart",
412
    "inReference",
413
    "nomRefBase", // Class BookSection, Book, Article.
414
    "pages",// Class Article.
415
    "series",// Class Article, PrintSeries.
416
    "school",// Class Thesis.
417
    "institution",// Class Report.
418
    "organization",// Class Proceedings.
419
    "nextVersion",
420
    "previousVersion",
421
    "isbn",// Class Book.
422
    "issn",// Class Journal.
423 0a288588 Andreas Kohlbecker
    "doi",
424
    "uri"
425 6657531f Andreas Kohlbecker
  );
426
427
  $table_rows = array();
428
429 1ce9afb7 Patric Plitzner
  if (!isset($reference->authorship)) {
430
    $authorship = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
431
    $reference->authorship = isset($authorship->titleCache) ? $authorship->titleCache : '';
432 6657531f Andreas Kohlbecker
  }
433
434
  if (!isset($reference->inReference)) {
435
    $reference->inReference = cdm_ws_get(CDM_WS_REFERENCE, array(
436
      $reference->uuid,
437
      "inReference",
438
    ));
439
  }
440
441
  foreach ($field_order as $fieldname) {
442
443
    if (isset($reference->$fieldname)) {
444
445
      if ($fieldname == "datePublished") {
446
        $period = $reference->$fieldname;
447
        $datePublished = timePeriodToString($period);
448
        if (isset($datePublished) && $datePublished != '') {
449
          $table_rows[] = array(
450 0a288588 Andreas Kohlbecker
            t("Date published"),
451 6657531f Andreas Kohlbecker
            $datePublished,
452
          );
453
        }
454
        // $datePublished = array(t(ucfirst(strtolower($fieldname))),
455
        // $datePublished);
456
      }
457 0a288588 Andreas Kohlbecker
      elseif ($fieldname == "doi" && is_object($reference->doi)) {
458
        $table_rows[] = array(
459 7cc085da Andreas Kohlbecker
          t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
460 0a288588 Andreas Kohlbecker
          cdm_doi($reference->doi, false)
461
        );
462
      }
463
      elseif ($fieldname == "uri" && isset($reference->uri) && $reference->uri) {
464
        $table_rows[] = array(
465 7cc085da Andreas Kohlbecker
          t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
466 0a288588 Andreas Kohlbecker
          cdm_external_uri($reference->uri, false)
467
        );
468
      }
469 6657531f Andreas Kohlbecker
      elseif (is_object($reference->$fieldname)) {
470 1ce9afb7 Patric Plitzner
        if ($fieldname == "authorship") {
471 6657531f Andreas Kohlbecker
          $dump = $reference->$fieldname;
472
          $teammembers = "teamMembers";
473
          $team = $dump->$teammembers;
474
          $nameArray = array();
475
476
          foreach ($team as $member) {
477
            if (strlen($member->lastname) > 0) {
478
              $nname = $member->lastname;
479
              $name = $nname;
480
              if (strlen($member->firstname) > 0) {
481
                $vname = $member->firstname;
482
                $name = $vname . " " . $nname;
483
              }
484
              $nameArray[] = $name;
485
            }
486
            else {
487
              if (strlen($member->titleCache) > 0) {
488
                $nameArray[] = $member->titleCache;
489
              }
490
            }
491
          }
492
          $value = join($nameArray, ", ");
493
        }
494
        elseif ($fieldname == "inReference") {
495
          $type = $reference->$fieldname->type;
496
          $value = l($reference->$fieldname->titleCache, path_to_reference($reference->$fieldname->uuid));
497
          switch ($type) {
498
            case "Book":
499
              $fieldname = "in book";
500
              break;
501
            case "Journal":
502
              $fieldname = "in journal";
503
              break;
504
            case "Proceedings":
505
              $fieldname = "in proceedings";
506
              break;
507
          }
508
        }
509
        else {
510
          $value = $reference->$fieldname->titleCache;
511
        }
512 0a288588 Andreas Kohlbecker
513
514 6657531f Andreas Kohlbecker
        if (isset($value) && $value != '') {
515
          $table_rows[] = array(
516 7cc085da Andreas Kohlbecker
            t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
517 6657531f Andreas Kohlbecker
            $value,
518
          );
519
        }
520 0a288588 Andreas Kohlbecker
521 6657531f Andreas Kohlbecker
      }
522
      else {
523
        if (isset($reference->$fieldname) && $reference->$fieldname != '') {
524
          $table_rows[] = array(
525 7cc085da Andreas Kohlbecker
            t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
526 6657531f Andreas Kohlbecker
            $reference->$fieldname,
527
          );
528
        }
529
      }
530
    }
531
  }
532
533
  $out = theme_table(array(
534
      'header' => array(),
535
      'rows' => $table_rows,
536 0a288588 Andreas Kohlbecker
      'attributes' => array(
537
        'class' => html_class_attribute_ref($reference)
538
      ),
539 6657531f Andreas Kohlbecker
      'caption' => NULL,
540
      'colgroups' => NULL,
541
      'sticky' => NULL,
542 0a288588 Andreas Kohlbecker
      'empty' => NULL,
543 6657531f Andreas Kohlbecker
  ));
544
545 0a288588 Andreas Kohlbecker
  if($reference->referenceAbstract){
546 11af03f3 Andreas Kohlbecker
    $out .= '<h2 class="block-title">Abstract</h2><div class="abstract">' . $reference->referenceAbstract . '</div>';
547 0a288588 Andreas Kohlbecker
  }
548
549 6657531f Andreas Kohlbecker
  // Annotations below the table.
550
  $annotations = cdm_ws_getAnnotationsFor($reference);
551
  $out .= theme("cdm_annotations", array('annotations' => $annotations));
552
553
  return $out;
554
}
555
556
/**
557
 * @todo Please document this function.
558
 * @see http://drupal.org/node/1354
559
 */
560
function theme_cdm_media_page($variables) {
561
  $media = $variables['media'];
562
  $mediarepresentation_uuid = $variables['mediarepresentation_uuid'];
563
  $partId = $variables['partId'];
564
  $out = '';
565 8f4eb9ce Andreas Kohlbecker
  // Determine which representation and which part to show.
566 6657531f Andreas Kohlbecker
  $representationIdx = 0;
567
  if ($mediarepresentation_uuid) {
568
    $i = 0;
569
    foreach ($media->representations as $representation) {
570
      if ($representation->uuid == $mediarepresentation_uuid) {
571
        $representationIdx = $i;
572
      }
573
      $i++;
574
    }
575
  }
576
  else {
577
    $mediarepresentation_uuid = $media->representations[0]->uuid;
578
  }
579
580
  $partIdx = 0;
581
  if (!is_numeric($partId)) {
582
    // Assuming it is an uuid.
583
    $i = 0;
584
    foreach ($media->representations[$representationIdx]->parts as $part) {
585
      if ($part->uuid == $partId) {
586
        $partIdx = $i;
587
      }
588
      $i++;
589
    }
590
  }
591
  else {
592
    // Assuming it is an index.
593
    $partIdx = $partId;
594
  }
595
596 97ff635c Andreas Kohlbecker
  $media_metadata = read_media_metadata($media);
597 6657531f Andreas Kohlbecker
  // $title = $media->titleCache;
598
  $title = $media_metadata['title'];
599
600
  $imageMaxExtend = variable_get('image-page-maxextend', 400);
601
602
  if (!$title) {
603
    $title = 'Media ' . $media->uuid . '';
604
  }
605
606
  drupal_set_title($title, PASS_THROUGH);
607
608
  $out .= '<div class="media cdm_media_viewer_image">';
609
610
  $out .= theme('cdm_back_to_image_gallery_button', array());
611
  $out .= '<div class="viewer">';
612
  $out .= theme('cdm_openlayers_image', array('mediaRepresentationPart' => $media->representations[$representationIdx]->parts[$partIdx], 'maxExtend' => $imageMaxExtend));
613
  $out .= '</div>';
614
615
  // General media metadata.
616
  /*
617
  $media_metadata = cdm_ws_get(CDM_WS_MEDIA_METADATA, array($media->uuid));
618
  vardump("PRINTING MEDIA METADATA");
619
  vardump($media_metadata);
620
  vardump("PRINTING MEDIA");
621
  vardump($media);
622
  */
623
  $metadataToPrint = theme('cdm_media_caption', array('media' => $media));
624
  $out .= $metadataToPrint;
625
626
  // Tabs for the different representations.
627
  // ul.secondary
628
  $out .= '<ul class="primary">';
629
  foreach ($media->representations as $representation) {
630
    $out .= '<li>' . l($media->representations[$representationIdx]->mimeType, path_to_media($media->uuid, $mediarepresentation_uuid, $partIdx)) . '</li>';
631
  }
632
  $out .= '</ul>';
633
634
  // Representation(-part) specific metadata.
635
  $thumbnailMaxExtend = 100;
636
  $out .= '<table>';
637
  $i = 0;
638
  foreach ($media->representations[$representationIdx]->parts as $part) {
639
    $out .= '<tr><th>' . t('Part') . ' ' . ($i + 1) . '</th><td>';
640
    switch ($part->class) {
641
      case 'ImageFile':
642
        $out .= $part->width . ' x ' . $part->height . ' - ' . $part->size . 'k';
643
        break;
644
      case 'AudioFile':
645
      case 'MovieFile':
646
        $out .= t('Duration') . ': ' . $part->duration . 's - ' . $part->size . 'k';
647
        break;
648
      default:
649
        $out .= $part->size . 'k';
650
    }
651
652
    $out .= '</td><td><a href="' . url(path_to_media($media->uuid, $mediarepresentation_uuid, $i)) . '">' . theme('cdm_media_gallerie_image', array('mediaRepresentationPart' => $part, 'maxExtend' => $thumbnailMaxExtend, 'addPassePartout' => TRUE));
653
    $i++;
654
  }
655
  $out .= '</table>';
656
  $out .= '</div>';
657
658
  return $out;
659
}
660
661
/**
662
 * @todo Please document this function.
663
 * @see http://drupal.org/node/1354
664
 */
665
function theme_cdm_polytomousKey_page($variables) {
666
  $polytomousKey = $variables['polytomousKey'];
667
  drupal_set_title($polytomousKey->titleCache, PASS_THROUGH);
668
669
  $out = theme("cdm_IdentificationKey", array(
670
    'identificationKey' => $polytomousKey,
671
    'doLinkToKeyPage' => FALSE,
672
    'showIdentificationKeyTitle' => FALSE,
673
    ));
674
675
  // Key nodes in linked style.
676
  $out .= theme('cdm_polytomousKey', array('polytomousKey' => $polytomousKey));
677
  /*
678 29809fe3 Andreas Kohlbecker
   * FIXME implement node type for keys !!!
679
   * (wrapping the content in the cdm_dataportal.node becomes obsolete then).
680
   */
681
  return '<div id="identificationKey">' . $out . '</div>';
682 6657531f Andreas Kohlbecker
}
683
684
/**
685
 * Returns HTML for taxon page tabs.
686
 *
687
 * Allows theming of the taxon page tabs.
688
 *
689
 * @param array $variables
690
 *   An associative array containing:
691
 *   - tabname
692
 *
693
 * @ingroup themeable
694
 */
695
function theme_cdm_taxonpage_tab($variables) {
696
  $tabname = $variables['tabname'];
697
  // TODO replace by using translations or theme the menue tabs itself instead?
698
  switch ($tabname) {
699
    default:
700 7cc085da Andreas Kohlbecker
      return t('@tabname', array('@tabname' => $tabname));
701 6657531f Andreas Kohlbecker
  }
702
}