Project

General

Profile

« Previous | Next » 

Revision 991ae630

Added by Andreas Kohlbecker over 2 years ago

ref #8850 annotations for FieldUnits and nameTypeDesignations in registration and name page

View differences:

modules/cdm_dataportal/includes/name.inc
626 626
  );
627 627

  
628 628
  // name
629
  $name_relations = null;
629 630
  if($registration_dto->nameRef){
630 631
    $name = cdm_ws_get(CDM_WS_PORTAL_NAME, $registration_dto->nameRef->uuid);
631 632
    cdm_load_tagged_full_title($name);
632 633
    $render_array['nomenclatural_act']['published_name'] = markup_to_render_array('<div class="published-name">' . render_taxon_or_name($name, url(path_to_name($name->uuid))) . '</div>', 0);
633 634
    $name_relations = cdm_ws_fetch_all(str_replace("$0", $registration_dto->nameRef->uuid, CDM_WS_PORTAL_NAME_NAME_RELATIONS));
634
    $render_array['nomenclatural_act']['name_relations'] = compose_name_relationships_list($name_relations, $registration_dto->nameRef->uuid, null);
635
    $render_array['nomenclatural_act']['name_relations']['#weight'] = 10;
635
    // need to create the name relationships later, so that the foot notes are in correct order, see section // name relations
636 636
  } else {
637 637
    // in this case the registration must have a
638 638
    $name = cdm_ws_get(CDM_WS_PORTAL_NAME, $registration_dto->typifiedNameRef->uuid);
639 639
    $render_array['typified_name'] = markup_to_render_array('<p class="typified-name">for ' . render_taxon_or_name($name, url(path_to_name($name->uuid))) . '</p>', 40);
640 640
  }
641

  
641 642
  // typedesignation in detail
642 643
  if(is_object($registration_dto->orderdTypeDesignationWorkingSets)) {
643 644
    $field_unit_uuids = array();
......
668 669
        drupal_set_message("Unimplemented type: " . $tokens[0], 'error');
669 670
      }
670 671
    }
671
    // type designations wich are in this nomenclatural act.
672
    // type designations which are in this nomenclatural act.
672 673
    if (count($name_type_designation_refs) > 0) {
673 674
      $render_array['nomenclatural_act']['name_type_designations'] = compose_name_type_designations($name_type_designation_refs);
674 675
      $render_array['nomenclatural_act']['name_type_designations']['#prefix'] = '<p class="name_type_designations">';
......
683 684
    }
684 685
  }
685 686

  
687
  // name relations
688
  if($name_relations){
689
    $render_array['nomenclatural_act']['name_relations'] = compose_name_relationships_list($name_relations, $registration_dto->nameRef->uuid, null);
690
    $render_array['nomenclatural_act']['name_relations']['#weight'] = 10;
691
  }
692

  
686 693
  // citation
687 694
  if ($with_citation) {
688 695
    $render_array['citation'] = markup_to_render_array(
......
694 701
      $render_array['nomenclatural_act']['#weight'] + 10 );
695 702
  }
696 703

  
697
  $render_array['footnotes'] = markup_to_render_array(
698
    theme('cdm_annotation_footnotes', ['footnoteListKey' => RenderHints::getFootnoteListKey() ]),
699
    12
704
  $render_array['nomenclatural_act']['footnotes'] = markup_to_render_array(render_cdm_footnotes(),
705
    100
700 706
  );
701 707

  
702 708
  // registration date and office
......
936 942
        }
937 943
        $out .= ': ' . render_taxon_or_name($name_type_designation->typeName, $link_to_name_page, $referenceUri, TRUE, TRUE);
938 944
      }
945
      $annotations_and_sources = handle_annotations_and_sources(
946
        $name_type_designation,
947
        typedesignations_annotations_and_sources_config(),
948
        '',
949
        RenderHints::getFootnoteListKey());
950
      $out .= $annotations_and_sources['foot_note_keys'];
939 951
    }
940 952
  } // END NameTypeDesignation
941 953

  
......
989 1001

  
990 1002
      }
991 1003

  
1004

  
992 1005
      $out .= '<'. $element_tag .' class="' . html_class_attribute_ref($specimen_type_designation) . '">';
993 1006
      $out .= type_designation_status_label_markup($specimen_type_designation) . $type_citation_markup;
994 1007

  
......
1003 1016
        if($link_to_specimen_page && isset($derivedUnitFacadeInstance->specimenLabel) && $derivedUnitFacadeInstance->specimenLabel){
1004 1017
          $specimen_markup = str_replace($derivedUnitFacadeInstance->specimenLabel, l($derivedUnitFacadeInstance->specimenLabel, path_to_specimen($specimen_type_designation->typeSpecimen->uuid)), $specimen_markup);
1005 1018
        }
1019
        $annotations_and_sources = handle_annotations_and_sources(
1020
          $derivedUnitFacadeInstance,
1021
          typedesignations_annotations_and_sources_config(),
1022
          '',
1023
          RenderHints::getFootnoteListKey()
1024
        );
1006 1025
        $out .= ': <span class="' . html_class_attribute_ref($specimen_type_designation->typeSpecimen) . '">'
1007 1026
          . $specimen_markup
1008 1027
          . '</span>'; // . ': ' . theme('cdm_specimen', array('specimenTypeDesignation' => $derivedUnitFacadeInstance));
1009 1028
        if(!empty($derivedUnitFacadeInstance->preferredStableUri)){
1010 1029
          $out .= ' ' . l($derivedUnitFacadeInstance->preferredStableUri, $derivedUnitFacadeInstance->preferredStableUri, array('absolute' => true));
1011 1030
        }
1031
        $out .= $annotations_and_sources['foot_note_keys'];
1012 1032
      }
1013 1033

  
1014 1034

  
......
1031 1051
          'bibliography_aware' => false
1032 1052
        ),
1033 1053
        '',
1034
        RenderHints::getFootnoteListKey() // passing a defined key to avoid separate annotation footnote key see https://dev.e-taxonomy.eu/redmine/issues/8543
1054
        RenderHints::getFootnoteListKey() // passing a defined key to avoid a separate annotation footnote key see https://dev.e-taxonomy.eu/redmine/issues/8543
1035 1055
      );
1036 1056
      $encasement =  $textual_type_designation->verbatim ? '"' : '';
1037 1057
      $out .= '<' . $element_tag . ' class="' . html_class_attribute_ref($textual_type_designation) . '">' . type_designation_status_label_markup(null)
......
1043 1063
    }
1044 1064
  }
1045 1065

  
1046
  // Footnotes for citations, collection acronym?s.
1066
  // Footnotes for citations, collection acronyms.
1047 1067
  // footnotes should be rendered in the parent element so we
1048 1068
  // are relying on the FootnoteListKey set there
1049 1069
  $_fkey = FootnoteManager::addNewFootnote(
......
1094 1114
/**
1095 1115
 * Composes the TypedEntityReference to name type designations passed as associatve array.
1096 1116
 *
1097
 * @param $type_entity_refs array
1117
 * @param $type_entity_refs_by_status array
1098 1118
 *   an associative array of name type type => TypedEntityReference for name type designations as
1099 1119
 *   produced by the eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager
1100 1120
 *
1101 1121
 * @ingroup compose
1102 1122
 */
1103
function compose_name_type_designations($type_entity_refs){
1123
function compose_name_type_designations($type_entity_refs_by_status){
1104 1124
  $render_array = array();
1105 1125
  $preferredStableUri = '';
1106
  foreach($type_entity_refs as $type_status => $name_types){
1107
    foreach ($name_types as $name_type){
1108
      $type_designation = cdm_ws_get(CDM_WS_TYPEDESIGNATION, array($name_type->uuid, 'preferredUri'));
1126
  foreach($type_entity_refs_by_status as $type_status => $name_type_entityRefs){
1127
    foreach ($name_type_entityRefs as $name_type_entity_ref){
1128
      $type_designation = cdm_ws_get(CDM_WS_TYPEDESIGNATION, array($name_type_entity_ref->uuid, 'preferredUri'));
1129
      $footnote_keys = '';
1130

  
1109 1131
      if(isset($type_designation->typeSpecimen->preferredStableUri) && $type_designation->typeSpecimen->preferredStableUri){
1110 1132
        $preferredStableUri = $type_designation->typeSpecimen->preferredStableUri;
1111 1133
      }
1112
      $render_array[] = markup_to_render_array('<div class="name_type_designation ' . html_class_attribute_ref($name_type)  . '"><span class="type-status">'. ucfirst($type_status) . "</span>: "
1113
        . $name_type->label
1134
      // annotations and sources for the $derived_unit_facade_dto
1135
      $annotations_and_sources = handle_annotations_and_sources(
1136
        $name_type_entity_ref,
1137
        typedesignations_annotations_and_sources_config(),
1138
        '',
1139
        RenderHints::getFootnoteListKey()
1140
      );
1141

  
1142
      $render_array[] = markup_to_render_array('<div class="name_type_designation ' . html_class_attribute_ref($name_type_entity_ref)  . '"><span class="type-status">'. ucfirst($type_status) . "</span>: "
1143
        . $name_type_entity_ref->label
1114 1144
        . ($preferredStableUri ? " ". l($preferredStableUri,  $preferredStableUri) : '')
1145
        . $annotations_and_sources['foot_note_keys']
1115 1146
        . '</div>');
1116 1147
      }
1117 1148
  }
......
1138 1169

  
1139 1170
  $render_array = array();
1140 1171

  
1141
  static $annotations_and_sources_config = [
1142
    'sources_as_content' => TRUE,
1143
    'link_to_name_used_in_source' => FALSE,
1144
    'link_to_reference' => TRUE,
1145
    'add_footnote_keys' => FALSE,
1146
    'bibliography_aware' => FALSE
1147
  ];
1148

  
1149 1172
  $type_designation_list = array();
1150 1173
  uksort($type_entity_refs, "compare_type_designation_status_labels");
1151 1174
  foreach($type_entity_refs as $type_status => $type_designation_entity_refs){
......
1166 1189
      // annotations and sources for the $derived_unit_facade_dto
1167 1190
      $annotations_and_sources = handle_annotations_and_sources(
1168 1191
        $derived_unit_facade_dto,
1169
        $annotations_and_sources_config,
1192
        typedesignations_annotations_and_sources_config(),
1170 1193
        '',
1171
        null
1194
        RenderHints::getFootnoteListKey()
1172 1195
      );
1173 1196
      $source_citations = $annotations_and_sources['source_references'];
1174 1197
      $foot_note_keys = $annotations_and_sources['foot_note_keys'];
......
1240 1263
  return $render_array;
1241 1264
}
1242 1265

  
1266
/**
1267
 * Provides the default configuration for typedesignations which
1268
 * are passed to the handle_annotations_and_sources()
1269
 * function:
1270
 * - 'sources_as_content' => TRUE,
1271
 * - 'link_to_name_used_in_source' => FALSE,
1272
 * - 'link_to_reference' => TRUE,
1273
 * - 'add_footnote_keys' => FALSE,
1274
 * - 'bibliography_aware' => FALSE
1275
 *
1276
 * @return array
1277
 */
1278
function typedesignations_annotations_and_sources_config() {
1279
  static $annotations_and_sources_config = [
1280
    'sources_as_content' => TRUE,
1281
    'link_to_name_used_in_source' => FALSE,
1282
    'link_to_reference' => TRUE,
1283
    'add_footnote_keys' => FALSE,
1284
    'bibliography_aware' => FALSE
1285
  ];
1286
  return $annotations_and_sources_config;
1287
}
1288

  
1243 1289
/**
1244 1290
 * @param $name_rel
1245 1291
 * @param $current_name_uuid
......
1393 1439
  $render_array = compose_name_relationships($name_relations, $name_rel_type_filter, $current_name_uuid, $current_taxon_uuid, $list_prefix, $list_suffix, $item_prefix, $item_suffix);
1394 1440

  
1395 1441
  RenderHints::popFromRenderStack();
1396
  $render_array['footnotes'] = markup_to_render_array(theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey())));
1397 1442
  if(RenderHints::getFootnoteListKey() == $key) {
1443
    $render_array['footnotes'] = markup_to_render_array(theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey())));
1398 1444
    RenderHints::clearFootnoteListKey();
1399 1445
  }
1400 1446
  return $render_array;

Also available in: Unified diff