Project

General

Profile

Revision 7370f4f7

ID7370f4f72901075e33e80a29d6d079561332b2b3
Parent 471192e3
Child e35d5a7c

Added by Andreas Kohlbecker almost 3 years ago

fix #7907 centalizing annotation filtering:
- annotation type filter settings are general
- render hint for reference page
- cdm_fetch_visible_annotations() implemented

View differences:

modules/cdm_dataportal/cdm_api/cdm_api.module
1530 1530
}
1531 1531

  
1532 1532
/**
1533
 * Provides the list of visible annotations for the $cdmBase.
1534
 *
1535
 * @param $cdmBase
1536
 *     The annotatable CDM entity
1537
 *
1538
 * @return array of the annotations which are visible according to the settings as stored in ANNOTATION_TYPES_VISIBLE
1539
 */
1540
function cdm_fetch_visible_annotations($cdmBase){
1541

  
1542
  static $annotations_types_filter = null;
1543
  if(!$annotations_types_filter) {
1544
    $annotations_types_filter = unserialize(ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT);
1545
  }
1546
  return cdm_ws_getAnnotationsFor($cdmBase, variable_get(ANNOTATION_TYPES_VISIBLE, $annotations_types_filter));
1547
}
1548

  
1549
/**
1533 1550
 * Loads the annotations from the REST service an adds them as field to the given $annotatable_entity.
1534 1551
 *
1552
 * NOTE: The annotations are not filtered by the ANNOTATION_TYPES_VISIBLE settings since this method is meant to act
1553
 * like the annotations have been fetched in the ORM-framework in the service.
1554
 *
1535 1555
 * @param object $annotatable_entity
1536 1556
 *   The CDM AnnotatableEntity to load annotations for
1537 1557
 */
modules/cdm_dataportal/cdm_dataportal.module
2593 2593
}
2594 2594

  
2595 2595
/**
2596
 * @todo Please document this function.
2597
 * @see http://drupal.org/node/1354
2596
 * Fetches the list of visible annotations for each of the cdm entities and returns the footnote keys for them.
2597
 *
2598
 * The footnotes are passed to the FootnoteManager in order to store the annotations and to create the footnote keys.
2599
 *
2600
 * @see cdm_fetch_visible_annotations()
2598 2601
 *
2599 2602
 * @param array $cdm_entities
2600 2603
 *   An array of CdmBase instances or a single instance.
2601 2604
 * @param string $footnote_list_key_suggestion
2602 2605
 *
2603
 * @return unknown
2606
 * @return array of footnote keys
2604 2607
 */
2605 2608
function cdm_annotations_as_footnotekeys($cdm_entities, $footnote_list_key_suggestion = NULL) {
2606 2609

  
2607
   static $annotations_types_filter = null;
2608
   if(!$annotations_types_filter) {
2609
     $annotations_types_filter = unserialize(ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT);
2610
   }
2611

  
2612 2610
  $footNoteKeys = array();
2613 2611

  
2614 2612
  // Is argument cdmBase an array?
......
2630 2628

  
2631 2629
  // Adding the footnotes keys.
2632 2630
  foreach ($cdmBase_array as $cdmBase_element) {
2633
    $annotations = cdm_ws_getAnnotationsFor($cdmBase_element, variable_get('annotations_types_as_footnotes', $annotations_types_filter));
2631
    $annotations = cdm_fetch_visible_annotations($cdmBase_element);
2634 2632
    if (is_array($annotations)) {
2635 2633
      foreach ($annotations as $annotation) {
2636 2634
        $footNoteKeys[] = FootnoteManager::addNewFootnote($footnote_list_key, $annotation->text);
modules/cdm_dataportal/settings.php
46 46
    // Additional value for the NULL case.
47 47
    $annotationTypeKeys[] = 'NULL_VALUE';
48 48
  }
49

  
50
  define('ANNOTATION_TYPES_VISIBLE', 'annotations_types_as_footnotes');
49 51
  define('ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT', serialize($annotationTypeKeys));
50 52

  
51 53
  define('BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE', 'bibliography_for_original_source');
......
1542 1544
    '#description' => t('Check this if you do not want to show annotation footnotes'),
1543 1545
  );
1544 1546

  
1547
  $form['annotations'] = array(
1548
    '#type' => 'fieldset',
1549
    '#title' => t('Annotations'),
1550
    '#collapsible' => FALSE,
1551
    '#collapsed' => FALSE,
1552
    '#description' => t('This sections allows configuring global settings regarding annotations and thus will affect annotations dispayed as footnote and others.'),
1553
  );
1554

  
1545 1555
  $annotationTypeOptions = cdm_terms_by_type_as_option('AnnotationType');
1546 1556
  // Additional option for the NULL case.
1547 1557
  $annotationTypeOptions['NULL_VALUE'] = t('untyped');
1548
  $form['footnotes']['annotations_types_as_footnotes'] = array(
1558
  $annotationsTypesAsFootnotes = variable_get(ANNOTATION_TYPES_VISIBLE, unserialize(ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT));
1559
  $form['annotations'][ANNOTATION_TYPES_VISIBLE] = array(
1549 1560
    '#type' => 'checkboxes',
1550
    '#title' => t('Annotation types as footnotes'),
1551
    '#description' => t("Only annotations of the selected type will be displayed
1552
       as footnotes. You may want to turn 'technical annotations' off."),
1561
    '#title' => t('Visbility of annotation types'),
1562
    '#description' => t("Only annotations of the selected type will be displayed. You may want to turn 'technical annotations' off."),
1553 1563
    '#options' => $annotationTypeOptions,
1564
    '#default_value' => $annotationsTypesAsFootnotes
1554 1565
  );
1555
  $annotationsTypesAsFootnotes = variable_get('annotations_types_as_footnotes', unserialize(ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT));
1556
  if (!empty($annotationsTypesAsFootnotes)) {
1557
    $form['footnotes']['annotations_types_as_footnotes']['#default_value'] = $annotationsTypesAsFootnotes;
1558
  }
1566

  
1559 1567

  
1560 1568
  // ---- original source --- //
1561 1569
  $form[BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE] = array(
modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
112 112
    $out .= '</div>';
113 113
  }
114 114
  // Display annotations.
115
  $out .= theme('cdm_annotations', array('annotations' => cdm_ws_getAnnotationsFor($identificationKey), 'enclosingTag' => 'div'));
115
  $out .= theme('cdm_annotations', array('annotations' => cdm_fetch_visible_annotations($identificationKey), 'enclosingTag' => 'div'));
116 116
  RenderHints::popFromRenderStack();
117 117
  return $out;
118 118
}
modules/cdm_dataportal/theme/cdm_dataportal.page.theme
442 442
 */
443 443
function compose_cdm_reference_page($uuid) {
444 444

  
445
  $pathelement = "reference_page";
446
  RenderHints::pushToRenderStack($pathelement);
445 447
  $reference = cdm_ws_get(CDM_WS_REFERENCE, $uuid);
446 448
  if (isset($reference->titleCache)) {
447 449
    drupal_set_title($reference->titleCache, PASS_THROUGH);
......
594 596
      'empty' => NULL,
595 597
  ));
596 598

  
597
  if($reference->referenceAbstract){
599
  if(isset($reference->referenceAbstract)){
598 600
    $out .= '<h2 class="block-title">Abstract</h2><div class="abstract">' . $reference->referenceAbstract . '</div>';
599 601
  }
600 602

  
601 603

  
602
  // Annotations below the table.
603
  $annotations = cdm_ws_getAnnotationsFor($reference);
604
  // Annotations below the table
605
  $annotations = cdm_fetch_visible_annotations($reference);
604 606
  $out .= theme("cdm_annotations", array('annotations' => $annotations));
605 607

  
606 608
  $registration_working_set = cdm_ws_get("registrationWorkingSetDTO", array($uuid));
......
617 619
    $out .= "</div>";
618 620
  }
619 621

  
622
  RenderHints::popFromRenderStack();
623

  
620 624
  return markup_to_render_array($out);
621 625
}
622 626

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)