Revision 0e617798
Added by Andreas Kohlbecker over 2 years ago
modules/cdm_dataportal/cdm_api/cdm_api.module | ||
---|---|---|
891 | 891 |
* |
892 | 892 |
* NOTE: Not all CDM Base types are yet supported. |
893 | 893 |
* |
894 |
* @param $cdmBase
|
|
894 |
* @param $cdm_entity
|
|
895 | 895 |
* The CDM entity to construct the annotations pager uri for |
896 | 896 |
*/ |
897 |
function cdm_compose_annotations_uri($cdmBase) { |
|
897 |
function cdm_compose_annotations_uri($cdm_entity) { |
|
898 |
|
|
899 |
$cdm_entity_type = $cdm_entity->class; |
|
900 |
|
|
901 |
if($cdm_entity_type == 'DerivedUnitFacade'){ |
|
902 |
// TODO we may want to implement a derivedUnitFacade/{uuid}/annotations service and use that instead |
|
903 |
$cdm_entity_type = $cdm_entity->fieldUnitEntityReference->type; |
|
904 |
$cdm_entity_uuid = $cdm_entity->fieldUnitEntityReference->uuid; |
|
905 |
} else { |
|
906 |
if (isset($cdm_entity->uuid)) { |
|
907 |
$cdm_entity_uuid = $cdm_entity->uuid; |
|
908 |
} |
|
909 |
} |
|
898 | 910 |
|
899 |
if (!$cdmBase->uuid) { |
|
911 |
if(!$cdm_entity_uuid){ |
|
912 |
// silently give up |
|
900 | 913 |
return; |
901 | 914 |
} |
902 | 915 |
|
903 |
$ws_base_uri = cdm_ws_base_uri($cdmBase->class);
|
|
916 |
$ws_base_uri = cdm_ws_base_uri($cdm_entity_type);
|
|
904 | 917 |
|
905 | 918 |
if($ws_base_uri === null){ |
906 |
trigger_error(check_plain('Unsupported CDM Class - no annotations available for ' . $cdmBase->class), E_USER_ERROR);
|
|
919 |
trigger_error(check_plain('Unsupported CDM Class - no annotations available for ' . $cdm_entity_type), E_USER_ERROR);
|
|
907 | 920 |
} |
908 | 921 |
return cdm_compose_url($ws_base_uri, array( |
909 |
$cdmBase->uuid,
|
|
922 |
$cdm_entity_uuid,
|
|
910 | 923 |
'annotations', |
911 | 924 |
)); |
912 | 925 |
} |
... | ... | |
1777 | 1790 |
* @return array |
1778 | 1791 |
* An array of Annotation objects or an empty array. |
1779 | 1792 |
*/ |
1780 |
function cdm_ws_getAnnotationsFor(&$cdm_entity, $include_types = FALSE) {
|
|
1793 |
function cdm_ws_fetch_annotations(&$cdm_entity, $include_types = FALSE) {
|
|
1781 | 1794 |
|
1782 | 1795 |
if(!isset($cdm_entity->annotations)){ |
1783 | 1796 |
$annotation_url = cdm_compose_annotations_uri($cdm_entity); |
... | ... | |
1816 | 1829 |
if(!$annotations_types_filter) { |
1817 | 1830 |
$annotations_types_filter = unserialize(EXTENSION_TYPES_VISIBLE_DEFAULT); |
1818 | 1831 |
} |
1819 |
return cdm_ws_getAnnotationsFor($cdm_entity, variable_get(ANNOTATION_TYPES_VISIBLE, $annotations_types_filter));
|
|
1832 |
return cdm_ws_fetch_annotations($cdm_entity, variable_get(ANNOTATION_TYPES_VISIBLE, $annotations_types_filter));
|
|
1820 | 1833 |
} |
1821 | 1834 |
|
1822 | 1835 |
/** |
... | ... | |
1830 | 1843 |
*/ |
1831 | 1844 |
function cdm_load_annotations(&$annotatable_entity) { |
1832 | 1845 |
if (isset($annotatable_entity) && !isset($annotatable_entity->annotations)) { |
1833 |
$annotations = cdm_ws_getAnnotationsFor($annotatable_entity);
|
|
1846 |
$annotations = cdm_ws_fetch_annotations($annotatable_entity);
|
|
1834 | 1847 |
if (is_array($annotations)) { |
1835 | 1848 |
$annotatable_entity->annotations = $annotations; |
1836 | 1849 |
} |
... | ... | |
2699 | 2712 |
return $query; |
2700 | 2713 |
} |
2701 | 2714 |
|
2702 |
/** |
|
2703 |
* Implementation of the magic method __clone to allow deep cloning of objects |
|
2704 |
* and arrays. |
|
2705 |
*/ |
|
2706 |
function __clone() { |
|
2707 |
foreach ($this as $name => $value) { |
|
2708 |
if (gettype($value) == 'object' || gettype($value) == 'array') { |
|
2709 |
$this->$name = clone($this->$name); |
|
2710 |
} |
|
2711 |
} |
|
2712 |
} |
|
2713 |
|
|
2714 | 2715 |
/** |
2715 | 2716 |
* Compares the given CDM Term instances by the representationL10n. |
2716 | 2717 |
* |
modules/cdm_dataportal/includes/descriptions.inc | ||
---|---|---|
345 | 345 |
* @param $footnote_list_key_suggestion string |
346 | 346 |
* Optional parameter. If this parameter is left empty (null, 0, "") the footnote key will be determined by the nested |
347 | 347 |
* method calls by calling RenderHints::getFootnoteListKey(). NOTE: the footnote key for annotations will be set to |
348 |
* RenderHints::getFootnoteListKey().'-annotations'. @return String |
|
348 |
* RenderHints::getFootnoteListKey().'-annotations'. |
|
349 |
* |
|
350 |
* @return String |
|
349 | 351 |
* The foot note keys |
350 | 352 |
* |
351 | 353 |
* @see cdm_entities_annotations_as_footnotekeys() |
... | ... | |
367 | 369 |
$sources = cdm_entity_sources_sorted($description_element); |
368 | 370 |
|
369 | 371 |
// Annotations as footnotes. |
370 |
$footNoteKeys = cdm_entity_annotations_as_footnotekeys($description_element, $footnote_list_key_suggestion);
|
|
372 |
$footnote_keys = cdm_entity_annotations_as_footnotekeys($description_element, $footnote_list_key_suggestion);
|
|
371 | 373 |
|
372 | 374 |
// Source references as footnotes. |
373 | 375 |
if($is_bibliography_aware){ |
... | ... | |
394 | 396 |
$original_source_footnote_tag |
395 | 397 |
); |
396 | 398 |
// Ensure uniqueness of the footnote keys. |
397 |
cdm_add_footnote_to_array($footNoteKeys, $fn_key);
|
|
399 |
cdm_add_footnote_to_array($footnote_keys, $fn_key);
|
|
398 | 400 |
} |
399 | 401 |
} |
400 | 402 |
// Sort and render footnote keys. |
401 |
$footnoteKeyListStr = ''; |
|
402 |
asort($footNoteKeys); |
|
403 |
foreach ($footNoteKeys as $footNoteKey) { |
|
404 |
try{ |
|
405 |
$footnoteKeyListStr .= theme('cdm_footnote_key', |
|
403 |
asort($footnote_keys); |
|
404 |
$footnotes_markup = footnote_keys_to_markup($footnote_keys, $separator); |
|
405 |
return $footnotes_markup; |
|
406 |
} |
|
407 |
|
|
408 |
/** |
|
409 |
* Creates markup for an array of foot note keys |
|
410 |
* |
|
411 |
* @param array $footnote_keys |
|
412 |
* @param string $separator |
|
413 |
* |
|
414 |
* @return string |
|
415 |
*/ |
|
416 |
function footnote_keys_to_markup(array $footnote_keys, string $separator): string { |
|
417 |
|
|
418 |
$footnotes_markup = ''; |
|
419 |
foreach ($footnote_keys as $foot_note_key) { |
|
420 |
try { |
|
421 |
$footnotes_markup .= theme('cdm_footnote_key', |
|
406 | 422 |
array( |
407 |
'footnoteKey' => $footNoteKey, |
|
408 |
'separator' => ($footnoteKeyListStr ? $separator : ''))); |
|
423 |
'footnoteKey' => $foot_note_key, |
|
424 |
'separator' => ($footnotes_markup ? $separator : '') |
|
425 |
)); |
|
409 | 426 |
} catch (Exception $e) { |
410 |
drupal_set_message("Exception: " . $e->getMessage(), 'error');
|
|
427 |
drupal_set_message("Exception: " . $e->getMessage(), 'error'); |
|
411 | 428 |
} |
412 | 429 |
} |
413 |
return $footnoteKeyListStr;
|
|
430 |
return $footnotes_markup;
|
|
414 | 431 |
} |
415 | 432 |
|
416 | 433 |
|
... | ... | |
559 | 576 |
|
560 | 577 |
$annotations_and_sources = array( |
561 | 578 |
'foot_note_keys' => NULL, |
562 |
'source_references' => array(),
|
|
563 |
'names_used_in_source' => array()
|
|
579 |
'source_references' => [],
|
|
580 |
'names_used_in_source' => []
|
|
564 | 581 |
); |
565 | 582 |
|
566 | 583 |
// some entity types only have single sources: |
... | ... | |
596 | 613 |
} |
597 | 614 |
} // END of loop over sources |
598 | 615 |
|
599 |
// annotations footnotes separate. |
|
600 |
$annotations_and_sources['foot_note_keys'] = theme('cdm_entities_annotations_as_footnotekeys', |
|
601 |
array( |
|
602 |
'cdmBase_list' => $entity, |
|
603 |
'footnote_list_key' => $footnote_list_key_suggestion, |
|
604 |
) |
|
616 |
// annotations footnotes separate from sources |
|
617 |
$annotations_and_sources['foot_note_keys'] = footnote_keys_to_markup( |
|
618 |
cdm_entity_annotations_as_footnotekeys($entity, $footnote_list_key_suggestion), ', ' |
|
605 | 619 |
); |
606 | 620 |
|
607 | 621 |
} // END of references inline |
modules/cdm_dataportal/includes/name.inc | ||
---|---|---|
694 | 694 |
$render_array['nomenclatural_act']['#weight'] + 10 ); |
695 | 695 |
} |
696 | 696 |
|
697 |
$render_array['footnotes'] = markup_to_render_array( |
|
698 |
theme('cdm_annotation_footnotes', ['footnoteListKey' => RenderHints::getFootnoteListKey() ]), |
|
699 |
12 |
|
700 |
); |
|
701 |
|
|
697 | 702 |
// registration date and office |
698 | 703 |
$registration_date_insitute_markup = render_registration_date_and_institute($registration_dto); |
699 | 704 |
if($registration_date_insitute_markup){ |
... | ... | |
702 | 707 |
100); |
703 | 708 |
} |
704 | 709 |
|
710 |
|
|
705 | 711 |
return $render_array; |
706 | 712 |
} |
707 | 713 |
|
... | ... | |
864 | 870 |
/** |
865 | 871 |
* Renders and array of CDM TypeDesignations |
866 | 872 |
* |
873 |
* - NameTypeDesignation |
|
874 |
* - SpecimenTypeDesignation |
|
875 |
* - TextualTypeDesignation |
|
876 |
* |
|
867 | 877 |
* @param object $type_designations an array of cdm TypeDesignation entities |
868 | 878 |
* to render |
869 | 879 |
* @param string $enclosing_tag the tag element type to enclose the whole list |
... | ... | |
1084 | 1094 |
/** |
1085 | 1095 |
* Composes the TypedEntityReference to name type designations passed as associatve array. |
1086 | 1096 |
* |
1087 |
* @param $$type_entity_refs array
|
|
1097 |
* @param $type_entity_refs array |
|
1088 | 1098 |
* an associative array of name type type => TypedEntityReference for name type designations as |
1089 | 1099 |
* produced by the eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager |
1090 | 1100 |
* |
... | ... | |
1128 | 1138 |
|
1129 | 1139 |
$render_array = array(); |
1130 | 1140 |
|
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 |
|
|
1131 | 1149 |
$type_designation_list = array(); |
1132 | 1150 |
uksort($type_entity_refs, "compare_type_designation_status_labels"); |
1133 |
foreach($type_entity_refs as $type_status => $specimen_types){
|
|
1134 |
foreach($specimen_types as $specimen_type){
|
|
1151 |
foreach($type_entity_refs as $type_status => $type_designation_entity_refs){
|
|
1152 |
foreach($type_designation_entity_refs as $type_designation_entity_ref){
|
|
1135 | 1153 |
|
1136 |
$type_designation = cdm_ws_get(CDM_WS_PORTAL_TYPEDESIGNATION, array($specimen_type->uuid));
|
|
1154 |
$type_designation = cdm_ws_get(CDM_WS_PORTAL_TYPEDESIGNATION, array($type_designation_entity_ref->uuid));
|
|
1137 | 1155 |
$type_designation_list[] = $type_designation; // collect for the map |
1138 | 1156 |
|
1139 |
$derivedUnitFacadeInstance = cdm_ws_get(CDM_WS_PORTAL_DERIVEDUNIT_FACADE, $type_designation->typeSpecimen->uuid);
|
|
1157 |
$derived_unit_facade_dto = cdm_ws_get(CDM_WS_PORTAL_DERIVEDUNIT_FACADE, $type_designation->typeSpecimen->uuid);
|
|
1140 | 1158 |
// the media specimen is not contained in the $type_designation returned by CDM_PORTAL_TYPEDESIGNATION, so we need to fetch it separately |
1141 | 1159 |
$mediaSpecimen = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($type_designation->typeSpecimen->uuid, 'mediaSpecimen')); |
1142 | 1160 |
|
... | ... | |
1145 | 1163 |
$citation_markup = ''; |
1146 | 1164 |
$media = ''; |
1147 | 1165 |
|
1166 |
// annotations and sources for the $derived_unit_facade_dto |
|
1167 |
$annotations_and_sources = handle_annotations_and_sources( |
|
1168 |
$derived_unit_facade_dto, |
|
1169 |
$annotations_and_sources_config, |
|
1170 |
'', |
|
1171 |
null |
|
1172 |
); |
|
1173 |
$source_citations = $annotations_and_sources['source_references']; |
|
1174 |
$foot_note_keys = $annotations_and_sources['foot_note_keys']; |
|
1175 |
|
|
1148 | 1176 |
// preferredStableUri |
1149 | 1177 |
if(isset($type_designation->typeSpecimen->preferredStableUri) && $type_designation->typeSpecimen->preferredStableUri){ |
1150 | 1178 |
$preferredStableUri = $type_designation->typeSpecimen->preferredStableUri; |
... | ... | |
1162 | 1190 |
); |
1163 | 1191 |
$media = compose_cdm_media_gallerie(array( |
1164 | 1192 |
'mediaList' => array($mediaSpecimen), |
1165 |
'galleryName' => CDM_DATAPORTAL_TYPE_SPECIMEN_GALLERY_NAME . '_' . $specimen_type->uuid,
|
|
1193 |
'galleryName' => CDM_DATAPORTAL_TYPE_SPECIMEN_GALLERY_NAME . '_' . $type_designation_entity_ref->uuid,
|
|
1166 | 1194 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'], |
1167 | 1195 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'], |
1168 | 1196 |
'captionElements' => $captionElements, |
1169 | 1197 |
)); |
1170 | 1198 |
} |
1171 |
// citation and detail |
|
1199 |
// citation and detail for the media specimen
|
|
1172 | 1200 |
$annotations_and_sources = handle_annotations_and_sources( |
1173 |
$mediaSpecimen, |
|
1174 |
array( |
|
1175 |
'sources_as_content' => true, |
|
1176 |
'link_to_name_used_in_source' => false, |
|
1177 |
'link_to_reference' => true, |
|
1178 |
'add_footnote_keys' => false, |
|
1179 |
'bibliography_aware' => false), |
|
1180 |
'', |
|
1181 |
null |
|
1201 |
$mediaSpecimen, |
|
1202 |
$annotations_and_sources_config, |
|
1203 |
'', |
|
1204 |
null |
|
1182 | 1205 |
); |
1183 | 1206 |
if(is_array( $annotations_and_sources['source_references'])){ |
1184 |
$citation_markup = join(', ', $annotations_and_sources['source_references']); |
|
1207 |
$source_citations = array_merge($source_citations, $annotations_and_sources['source_references']); |
|
1208 |
} |
|
1209 |
if($annotations_and_sources['foot_note_keys']){ |
|
1210 |
$foot_note_keys .= ', ' . $annotations_and_sources['foot_note_keys']; |
|
1185 | 1211 |
} |
1186 | 1212 |
} |
1187 | 1213 |
|
1188 |
$specimen_markup = $derivedUnitFacadeInstance->titleCache; |
|
1189 |
if(isset($derivedUnitFacadeInstance->specimenLabel) && $derivedUnitFacadeInstance->specimenLabel){ |
|
1190 |
$specimen_markup = str_replace($derivedUnitFacadeInstance->specimenLabel, l($derivedUnitFacadeInstance->specimenLabel, path_to_specimen($type_designation->typeSpecimen->uuid)), $specimen_markup); |
|
1214 |
$citation_markup = join(', ', $source_citations); |
|
1215 |
|
|
1216 |
$specimen_markup = $derived_unit_facade_dto->titleCache; |
|
1217 |
if(isset($derived_unit_facade_dto->specimenLabel) && $derived_unit_facade_dto->specimenLabel){ |
|
1218 |
$specimen_markup = str_replace( |
|
1219 |
$derived_unit_facade_dto->specimenLabel, |
|
1220 |
l($derived_unit_facade_dto->specimenLabel, path_to_specimen($type_designation->typeSpecimen->uuid)), $specimen_markup); |
|
1191 | 1221 |
} |
1192 | 1222 |
|
1193 |
$type_designation_render_array = markup_to_render_array('<div class="specimen_type_designation ' . html_class_attribute_ref($specimen_type) . '"> |
|
1223 |
$type_designation_render_array = markup_to_render_array( |
|
1224 |
'<div class="type_designation_entity_ref ' . html_class_attribute_ref($type_designation_entity_ref) . '"> |
|
1194 | 1225 |
<span class="type-status">' . ucfirst($type_status) . "</span>: " |
1195 |
. $specimen_markup |
|
1226 |
. $specimen_markup . $foot_note_keys
|
|
1196 | 1227 |
. ($citation_markup ? ' '. $citation_markup : '') |
1197 | 1228 |
. ($preferredStableUri ? " ". l($preferredStableUri, $preferredStableUri) : '') |
1198 | 1229 |
. $media |
Also available in: Unified diff
ref #8850 showing fieldunit annotations in registration page