Project

General

Profile

« Previous | Next » 

Revision db9c6559

Added by Andreas Kohlbecker almost 4 years ago

ref #7770, ref #9034 fix settings to choose visible extension types, filter method for chosen extensions

View differences:

modules/cdm_dataportal/includes/common.inc
756 756

  
757 757
}
758 758

  
759
function visible_extensions_sorted($cdm_entity) {
760

  
761
  $visible_extensions_sorted = [];
762
  $extension_types_visible = variable_get(EXTENSION_TYPES_VISIBLE, unserialize(EXTENSION_TYPES_VISIBLE_DEFAULT));
763
  if (isset($cdm_entity->extensions)) {
764
    foreach ($cdm_entity->extensions as $ext) {
765
      if (array_search($ext->type->uuid, $extension_types_visible)) {
766
        if (!array_key_exists($ext->type->uuid, $visible_extensions_sorted)) {
767
          $visible_extensions_sorted[$ext->type->uuid] = [];
768
        }
769
        $visible_extensions_sorted[$ext->type->uuid][] = $ext;
770
      }
771
    }
772
  }
773
  return $visible_extensions_sorted;
774
}
775

  
759 776
/**
760 777
 * Compose an render array from a CDM Extension objects.
761 778
 *
modules/cdm_dataportal/includes/occurrences.inc
737 737
        } // END of loop over $derivedUnitFacade fields
738 738

  
739 739
        // Extensions
740
        // TODO: filter by using visible_extensions_sorted()
740 741
        $extensions = cdm_ws_fetch_all(CDM_WS_PORTAL_OCCURRENCE . '/'  . $specimen_or_observation->uuid . '/extensions', array($specimen_or_observation->uuid));
741 742
        if ($extensions && count($extensions)) {
742 743

  
modules/cdm_dataportal/settings.php
72 72
  // Additional value for the NULL case.
73 73
  $extensionTypeKeys[] = 'NULL_VALUE';
74 74
}
75
const EXTENSION_TYPES_VISIBLE = 'annotations_types_as_footnotes';
76
define('EXTENSION_TYPES_VISIBLE_DEFAULT', serialize($annotationTypeKeys));
75
const EXTENSION_TYPES_VISIBLE = 'extension_types_visible';
76
define('EXTENSION_TYPES_VISIBLE_DEFAULT', serialize([]));
77 77

  
78 78
  define('BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE', 'bibliography_for_original_source');
79 79
  define('BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE_DEFAULT', serialize(array(
......
1577 1577
    '#description' => t('This sections allows configuring global settings regarding annotations and thus will affect annotations dispayed as footnote and others.'),
1578 1578
  );
1579 1579

  
1580
  $annotationTypeOptions = cdm_terms_by_type_as_option('AnnotationType');
1580
  $annotation_type_options = cdm_terms_by_type_as_option('AnnotationType');
1581 1581
  // Additional option for the NULL case.
1582
  $annotationTypeOptions['NULL_VALUE'] = t('untyped');
1583
  $annotationsTypesVisible = variable_get(ANNOTATION_TYPES_VISIBLE, unserialize(EXTENSION_TYPES_VISIBLE_DEFAULT));
1582
  $annotation_type_options['NULL_VALUE'] = t('untyped');
1583
  $annotations_types_visible = variable_get(ANNOTATION_TYPES_VISIBLE, unserialize(EXTENSION_TYPES_VISIBLE_DEFAULT));
1584 1584
  $form['annotations'][ANNOTATION_TYPES_VISIBLE] = array(
1585 1585
    '#type' => 'checkboxes',
1586 1586
    '#title' => t('Visbility of annotation types'),
1587 1587
    '#description' => t("Only annotations of the selected type will be displayed. You may want to turn 'technical annotations' off."),
1588
    '#options' => $annotationTypeOptions,
1589
    '#default_value' => $annotationsTypesVisible
1588
    '#options' => $annotation_type_options,
1589
    '#default_value' => $annotations_types_visible
1590 1590
  );
1591 1591

  
1592 1592
  $form['extensions'] = array(
......
1597 1597
    '#description' => t('This sections allows configuring global settings regarding the data type extensions.'),
1598 1598
  );
1599 1599

  
1600
  $extensionTypeOptions = cdm_terms_by_type_as_option('ExtensionType');
1601
  $extensionTypesVisible = variable_get(EXTENSION_TYPES_VISIBLE, unserialize(EXTENSION_TYPES_VISIBLE_DEFAULT));
1600
  $extension_type_options = cdm_terms_by_type_as_option('ExtensionType');
1601
  $extension_types_visible = variable_get(EXTENSION_TYPES_VISIBLE, unserialize(EXTENSION_TYPES_VISIBLE_DEFAULT));
1602 1602
  $form['extensions'][EXTENSION_TYPES_VISIBLE] = array(
1603 1603
    '#type' => 'checkboxes',
1604 1604
    '#title' => t('Visbility of extension types'),
1605 1605
    '#description' => t("Only extensions of the selected type will be displayed."),
1606
    '#options' => $extensionTypeOptions,
1607
    '#default_value' => $extensionTypesVisible
1606
    '#options' => $extension_type_options,
1607
    '#default_value' => $extension_types_visible
1608 1608
  );
1609 1609

  
1610 1610

  

Also available in: Unified diff