Project

General

Profile

« Previous | Next » 

Revision c1bf88ee

Added by Andreas Kohlbecker about 3 years ago

ref #6866 display of sources

View differences:

modules/cdm_dataportal/cdm_api/cdm_api.module
1005 1005
    case 'DerivedUnit':
1006 1006
    case 'DnaSample':
1007 1007
    case 'MediaSpecimen':
1008
    case 'DerivedUnitDTO':
1009
    case 'FieldUnitDTO':
1010
    case 'DNASampleDTO':
1008 1011
      $ws_base_uri = CDM_WS_OCCURRENCE;
1009 1012
      break;
1010 1013

  
modules/cdm_dataportal/includes/footnotes.inc
555 555
    $sources = $entity->sources;
556 556
  }
557 557
  else {
558
    $sources = [];
558
    // try to load the sources
559
    $sources = cdm_ws_fetch_all('portal/' . cdm_ws_base_uri($entity->class) . '/' . $entity->uuid .  '/sources');
559 560
  }
560 561
  usort($sources, 'compare_original_sources');
561 562
  return $sources;
modules/cdm_dataportal/includes/occurrences_new.inc
34 34
 * @param object $sob_dto
35 35
 *   the CDM FieldUnitDTO or DerivedUnitDTO to compose
36 36
 *   the render array for.
37
 * @param bool $compact_mode
38
 *   Currently unused, but added for compatibility with
39
 *   compose_cdm_specimen_or_observation($specimen_or_observation,
40
 *   $isSpecimen_page = false, &$derivatives = null)
37
 * @param bool $full_details
38
 *  Activates the display of additional data like: annotations, markers, ...
41 39
 *
42 40
 * @return array
43 41
 *  The render array for the SpecimenOrObservationDTO
44 42
 *
45 43
 * @ingroup compose
46 44
 */
47
function compose_cdm_specimen_or_observation_dto_details_grid($sob_dto, $compact_mode = FALSE) {
45
function compose_cdm_specimen_or_observation_dto_details_grid($sob_dto, $full_details = FALSE) {
48 46
  $render_array = [];
49 47
  if (!$sob_dto) {
50 48
    return $render_array;
51 49
  }
52 50
  if ($sob_dto->type == 'FieldUnit') {
53
    $render_array['field-unit'] = compose_cdm_field_unit_dto_details($sob_dto, $compact_mode);
51
    $render_array['field-unit'] = compose_cdm_field_unit_dto_details($sob_dto, $full_details);
54 52
    if (isset($sob_dto->gatheringEvent)) {
55
      $render_array['gathering'] = compose_cdm_gathering_dto_details($sob_dto->gatheringEvent, $compact_mode);
53
      $render_array['gathering'] = compose_cdm_gathering_dto_details($sob_dto->gatheringEvent, $full_details);
56 54
    }
57 55
  } else {
58 56
    if(isset($sob_dto->derivationEvent)){
59 57
      $render_array['derivation-event'] = compose_cdm_derivation_event($sob_dto->derivationEvent);
60 58
    }
61
    $render_array['storage'] = compose_cdm_derived_unit_dto_storage_details($sob_dto, $compact_mode);
62
    $render_array['type-designations'] = compose_cdm_unit_dto_type_designations($sob_dto, $compact_mode);
59
    $render_array['storage'] = compose_cdm_derived_unit_dto_storage_details($sob_dto, $full_details);
60
    $render_array['type-designations'] = compose_cdm_unit_dto_type_designations($sob_dto, $full_details);
63 61
    if($sob_dto->type == 'DnaSample'){
64 62
      // FIXME:
65
      $render_array['dna-sample'] = compose_cdm_derived_unit_dto_sequences($sob_dto, $compact_mode);
63
      $render_array['dna-sample'] = compose_cdm_derived_unit_dto_sequences($sob_dto, $full_details);
66 64
    } else if($sob_dto->type == 'MediaSpecimen' && isset_not_empty($sob_dto->mediaSpecimen)) {
67 65
      $render_array['media-specimens'] = cdm_sob_dto_media_table($sob_dto->mediaSpecimen, $sob_dto, 'Media Specimens');
68 66
    }
69 67
  }
70 68
  if(isset_not_empty($sob_dto->determinedNames)){
71
    $render_array['determinations'] = compose_cdm_sob_dto_determinations($sob_dto, $compact_mode);
69
    $render_array['determinations'] = compose_cdm_sob_dto_determinations($sob_dto, $full_details);
72 70
  }
73 71
  if(isset_not_empty($sob_dto->listOfMedia)){
74 72
    $render_array['media'] = cdm_sob_dto_media_table($sob_dto->listOfMedia, $sob_dto, 'Media');;
75 73
  }
76 74

  
75
  if($full_details){
76
      RenderHints::setAnnotationsAndSourceConfig([
77
        'sources_as_content' => TRUE,
78
        'link_to_name_used_in_source' => TRUE,
79
        'link_to_reference' => FALSE,
80
        'add_footnote_keys' => FALSE,
81
        'bibliography_aware' => FALSE
82
      ]);
83
      $annotations_and_sources = handle_annotations_and_sources($sob_dto);
84
      if ($annotations_and_sources->hasSourceReferences()) {
85
        $render_array['sources'] = compose_cdm_sob_dto_sources($sob_dto, $annotations_and_sources);
86
      }
87
  }
88

  
77 89
  return $render_array;
78 90
}
79 91
/**
80 92
 * Data rows with details for a SpecimenOrObservationDTO to be used in a table
81 93
 * @param object $sob_dto
82 94
 *   the CDM SpecimenOrObservationDTO
83
 * @param bool $compact_mode
95
 * @param bool $full_details
84 96
 *   Currently unused,
85 97
 *
86 98
 * @return array
87 99
 *  The data rows
88 100
 */
89
function sob_dto_details_rows($sob_dto, $compact_mode = FALSE) {
101
function sob_dto_details_rows($sob_dto, $full_details = FALSE) {
90 102

  
91 103
  $table_row_data = [];
92 104

  
......
130 142
 *
131 143
 * @param object $derivation_event_dto
132 144
 *   the CDM DerivationEventDTO
133
 * @param bool $compact_mode
145
 * @param bool $full_details
134 146
 *   Currently unused,
135 147
 *
136 148
 * @return array
......
138 150
 *
139 151
 * @ingroup compose
140 152
 */
141
function compose_cdm_derivation_event($derivation_event_dto, $compact_mode = FALSE){
153
function compose_cdm_derivation_event($derivation_event_dto, $full_details = FALSE){
142 154

  
143 155
  $details_array = [];
144 156
  // $markup = t("Derivation") . ': ';
......
181 193
 *
182 194
 * @param object $fu_dto
183 195
 *   the CDM FieldUnitDTO
184
 * @param bool $compact_mode
196
 * @param bool $full_details
185 197
 *   Currently unused,
186 198
 *
187 199
 * @return array
......
189 201
 *
190 202
 * @ingroup compose
191 203
 */
192
function compose_cdm_field_unit_dto_details($fu_dto, $compact_mode = FALSE) {
204
function compose_cdm_field_unit_dto_details($fu_dto, $full_details = FALSE) {
193 205

  
194
  $table_row_data = sob_dto_details_rows($fu_dto, $compact_mode);
206
  $table_row_data = sob_dto_details_rows($fu_dto, $full_details);
195 207

  
196 208
  if (isset_not_empty($fu_dto->individualCount)) {
197 209
    $table_row_data[] = cdm_sob_dto_table_row(cdm_occurrence_field_name_label('individualCount'), $fu_dto->individualCount);
......
223 235
 *
224 236
 * @param object $du_dto
225 237
 *   the CDM DerivedUnitDTO
226
 * @param bool $compact_mode
238
 * @param bool $full_details
227 239
 *   Currently unused,
228 240
 *
229 241
 * @return array
......
231 243
 *
232 244
 * @ingroup compose
233 245
 */
234
function  compose_cdm_derived_unit_dto_storage_details($du_dto, $compact_mode = FALSE) {
246
function  compose_cdm_derived_unit_dto_storage_details($du_dto, $full_details = FALSE) {
235 247

  
236
  $table_row_data = sob_dto_details_rows($du_dto, $compact_mode);
248
  $table_row_data = sob_dto_details_rows($du_dto, $full_details);
237 249

  
238 250
  if (isset($du_dto->accessionNumber)) {
239 251
    $table_row_data[] = cdm_sob_dto_table_row(
......
299 311
 *
300 312
 * @param object $gathering_dto
301 313
 *   the CDM GatheringDTO object
302
 * @param bool $compact_mode
314
 * @param bool $full_details
303 315
 *   Currently unused,
304 316
 *
305 317
 * @return array
......
307 319
 *
308 320
 * @ingroup compose
309 321
 */
310
function compose_cdm_gathering_dto_details($gathering_dto, $compact_mode = FALSE) {
322
function compose_cdm_gathering_dto_details($gathering_dto, $full_details = FALSE) {
311 323

  
312 324
  $table_row_data = [];
313 325
  if (isset_not_empty($gathering_dto->date)) {
......
375 387
 *
376 388
 * @param object $sob_dto
377 389
 *   the CDM SpecimenOrObservationDTO
378
 * @param bool $compact_mode
390
 * @param bool $full_details
379 391
 *   Currently unused,
380 392
 *
381 393
 * @return array
......
383 395
 *
384 396
 * @ingroup compose
385 397
 */
386
function compose_cdm_sob_dto_determinations($sob_dto, $compact_mode = FALSE) {
398
function compose_cdm_sob_dto_determinations($sob_dto, $full_details = FALSE) {
387 399

  
388 400
  $table_row_data = [];
389 401

  
......
396 408
  return cdm_sob_dto_table($label, $table_row_data, $sob_dto, 1);
397 409
}
398 410

  
411
/**
412
 * Compose an render array from the SpecimenOrObservationDTO.determinedNames.
413
 *
414
 * The resulting DOM block level element will have a header line and details.
415
 *
416
 * compose_hook() implementation
417
 *
418
 * @param \AnnotationsAndSources $annotations_and_sources
419
 *   see
420
 *
421
 * @return array
422
 *  The render array for the SpecimenOrObservationDTO.determinedNames
423
 *
424
 * @ingroup compose
425
 */
426
function compose_cdm_sob_dto_sources($sob_dto, $annotations_and_sources) {
427

  
428
  $table_row_data = [];
429

  
430
  foreach ($annotations_and_sources->getSourceReferences() as $source_ref) {
431
    $table_row_data[] = cdm_sob_dto_table_row(NULL, $source_ref);
432
  }
433

  
434
  $label = count($table_row_data) > 1 ? t("Sources") : t("Source");
435
  return cdm_sob_dto_table($label, $table_row_data, $sob_dto, 1);
436
}
437

  
399 438
/**
400 439
 * Compose an render array from the DerivedUnitDTO.specimenTypeDesignations.
401 440
 *
......
405 444
 *
406 445
 * @param object $unit_dto
407 446
 *   the CDM DerivedUnitDTO
408
 * @param bool $compact_mode
447
 * @param bool $full_details
409 448
 *   Currently unused,
410 449
 *
411 450
 * @return array
......
413 452
 *
414 453
 * @ingroup compose
415 454
 */
416
function compose_cdm_unit_dto_type_designations($unit_dto, $compact_mode = FALSE) {
455
function compose_cdm_unit_dto_type_designations($unit_dto, $full_details = FALSE) {
417 456

  
418 457
  $table_row_data = [];
419 458

  
......
466 505
 *
467 506
 * @param object $unit_dto
468 507
 *   the CDM DerivedUnitDTO
469
 * @param bool $compact_mode
508
 * @param bool $full_details
470 509
 *   Currently unused,
471 510
 *
472 511
 * @return array
......
476 515
 *
477 516
 * TODO see  #3347 (services and REST service controller for molecular classes implemented)
478 517
 */
479
function compose_cdm_derived_unit_dto_sequences($unit_dto, $compact_mode = FALSE) {
518
function compose_cdm_derived_unit_dto_sequences($unit_dto, $full_details = FALSE) {
480 519

  
481 520
  $table_row_data = [];
482 521
  if(isset_not_empty($unit_dto->sequences)){
......
605 644
 * @param object $sob_dto
606 645
 *   the CDM FieldUnit or DerivedUnit to compose
607 646
 *   the render array for.
608
 * @param bool $isSpecimen_page
609
 * @param array $derivatives
610
 *   the render array which contains the compositions of the derivatives
611
 *   of the supplied $specimenOrObservation
612 647
 *
613 648
 * @return array
614 649
 *   the supplied render array $derivatives to which the composition of the supplied
615 650
 *   $specimenOrObservation has been added to
616 651
 *
617
 * @throws \Exception
618 652
 * @ingroup compose
619 653
 */
620

  
621 654
function compose_cdm_specimen_or_observation_new($sob_dto)
622 655
{
623 656

  
......
649 682
      '#attributes' => [
650 683
        'class' => 'derived-unit-details-grid'
651 684
      ],
652
      'children' => compose_cdm_specimen_or_observation_dto_details_grid($sob_dto)
685
      'children' => compose_cdm_specimen_or_observation_dto_details_grid($sob_dto, true)
653 686
    ];;
654 687

  
655 688
    $derivation_tree_roots = cdm_ws_get(CDM_WS_OCCURRENCE_FIELD_UNIT_DTOS, [$sob_dto->uuid]);
......
662 695
      /* TODO
663 696
      case 'definition':
664 697

  
665
                case 'annotations':
698
      case 'annotations':
666 699
      $dd_elements = array();
667 700
      foreach ($value as $annotation) {
668 701
        // TODO respect annotation type filter settings
......
670 703
      }
671 704
      break;
672 705

  
673
    case 'markers':
706
      case 'markers':
674 707
      $dd_elements = array();
675 708
      foreach ($value as $marker) {
676 709
        $dd_elements[] = compose_cdm_marker($marker);
......
679 712
      break;
680 713

  
681 714
      @_description_list_group_add($groups, t('Notes:'), $dd_elements);
682
       *
683
       */
715

  
684 716

  
685 717

  
686 718

  
......
736 768
      break;
737 769
     */
738 770

  
739
      /* TODO
740

  
741
    case 'sources':
742
      RenderHints::setAnnotationsAndSourceConfig([
743
        'sources_as_content' => TRUE,
744
        'link_to_name_used_in_source' => TRUE,
745
        'link_to_reference' => FALSE,
746
        'add_footnote_keys' => FALSE,
747
        'bibliography_aware' => FALSE
748
      ]);
749
      $annotations_and_sources = handle_annotations_and_sources($sob_dto);
750
      if ($annotations_and_sources->hasSourceReferences()) {
751
        @_description_list_group_add($groups, t('Sources') . ':', join(', ', $annotations_and_sources->getSourceReferences()), '', 12);
752
      }
753
      break;
754
       */
755

  
756

  
757

  
758 771
    /*   TODO Extensions
759 772
    // TODO: filter by using visible_extensions_sorted()
760 773
    // TODO: treat as top level element, see https://dev.e-taxonomy.eu/redmine/issues/2985#note-23
......
768 781
    }
769 782
    */
770 783

  
771

  
772

  
773 784
    $render_array['footnotes'] = markup_to_render_array(render_footnotes($footnote_list_key));
774 785

  
775 786

  

Also available in: Unified diff