Project

General

Profile

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