Project

General

Profile

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