Revision 95ef7468
Added by Andreas Kohlbecker over 3 years ago
modules/cdm_dataportal/cdm_dataportal.info | ||
---|---|---|
13 | 13 |
files[] = classes/ItemComposeHandler.php |
14 | 14 |
files[] = classes/RegistrationDtoComposeHandler.php |
15 | 15 |
files[] = classes/AgentComposeHandler.php |
16 |
files[] = classes/AnnotationsAndSources.php |
|
16 | 17 |
|
17 | 18 |
configure = admin/config/cdm_dataportal/settings |
modules/cdm_dataportal/includes/descriptions.inc | ||
---|---|---|
384 | 384 |
|
385 | 385 |
RenderHints::setAnnotationsAndSourceConfig(handle_annotations_and_sources_config($feature_block_settings)); |
386 | 386 |
$annotations_and_sources = handle_annotations_and_sources( |
387 |
$element, |
|
388 |
$element_markup, |
|
389 |
$footnote_list_key_suggestion |
|
387 |
$element, $element_markup, $footnote_list_key_suggestion |
|
390 | 388 |
); |
391 | 389 |
|
392 | 390 |
$timescope_markup = ''; |
... | ... | |
397 | 395 |
// handle the special case were the TextData is used as container for original source with name |
398 | 396 |
// used in source information without any text stored in it. |
399 | 397 |
$names_used_in_source_markup = ''; |
400 |
if (!empty($annotations_and_sources['names_used_in_source']) && empty($element_markup)) {
|
|
401 |
$names_used_in_source_markup = join(', ', $annotations_and_sources['names_used_in_source']) . ': ';
|
|
398 |
if ($annotations_and_sources->hasNameUsedInSource() && empty($element_markup)) {
|
|
399 |
$names_used_in_source_markup = join(', ', $annotations_and_sources->getNameUsedInSource()) . ': ';
|
|
402 | 400 |
// remove all <span class="nameUsedInSource">...</span> from all source_references |
403 | 401 |
// these are expected to be at the end of the strings |
404 | 402 |
$pattern = '/ <span class="nameUsedInSource">.*$/'; |
405 |
foreach( $annotations_and_sources['source_references'] as &$source_reference){
|
|
403 |
foreach( $annotations_and_sources->getSourceReferences() as &$source_reference){
|
|
406 | 404 |
$source_reference = preg_replace($pattern , '', $source_reference); |
407 | 405 |
} |
408 | 406 |
} |
409 | 407 |
|
410 | 408 |
$source_references_markup = ''; |
411 |
if (!empty($annotations_and_sources['source_references'])) {
|
|
412 |
$source_references_markup = '<span class="sources">' . join(' ', $annotations_and_sources['source_references']) . '<span>';
|
|
409 |
if ($annotations_and_sources->hasSourceReferences()) {
|
|
410 |
$source_references_markup = '<span class="sources">' . join(' ', $annotations_and_sources->getSourceReferences()) . '<span>';
|
|
413 | 411 |
} |
414 | 412 |
|
415 | 413 |
$feature_label = ''; |
... | ... | |
425 | 423 |
} |
426 | 424 |
|
427 | 425 |
$render_array['#value'] = $feature_label . $content_markup; |
428 |
$render_array['#value_suffix'] = $annotations_and_sources['foot_note_keys'];
|
|
426 |
$render_array['#value_suffix'] = $annotations_and_sources->footNoteKeysMarkup();
|
|
429 | 427 |
return $render_array; |
430 | 428 |
} |
431 | 429 |
|
... | ... | |
1557 | 1555 |
foreach ($description_elements as $description_element) { |
1558 | 1556 |
RenderHints::setAnnotationsAndSourceConfig(handle_annotations_and_sources_config($feature_block_settings)); |
1559 | 1557 |
$annotations_and_sources = handle_annotations_and_sources( |
1560 |
$description_element, |
|
1561 |
$description_element->area->representation_L10n, |
|
1562 |
UUID_DISTRIBUTION |
|
1558 |
$description_element, $description_element->area->representation_L10n, UUID_DISTRIBUTION |
|
1563 | 1559 |
); |
1564 | 1560 |
|
1565 | 1561 |
$status = distribution_status_label_and_markup([$description_element->status]); |
... | ... | |
1569 | 1565 |
. ' " title="' . $status['label']. '">' |
1570 | 1566 |
. $description_element->area->representation_L10n |
1571 | 1567 |
. $status['markup']; |
1572 |
if(!empty($annotations_and_sources['source_references'])){
|
|
1573 |
$out .= ' ' . join(' ', $annotations_and_sources['source_references'] );
|
|
1568 |
if($annotations_and_sources->hasSourceReferences()){
|
|
1569 |
$out .= ' ' . join(' ', $annotations_and_sources->getSourceReferences());
|
|
1574 | 1570 |
} |
1575 |
$out .= $annotations_and_sources['foot_note_keys'] . '</' . $enclosingTag . '>';
|
|
1571 |
$out .= $annotations_and_sources->footNoteKeysMarkup() . '</' . $enclosingTag . '>';
|
|
1576 | 1572 |
$markup_array[] = $out; |
1577 | 1573 |
} |
1578 | 1574 |
|
... | ... | |
1824 | 1820 |
if($distribution_aggregate) { |
1825 | 1821 |
RenderHints::setAnnotationsAndSourceConfig(handle_annotations_and_sources_config($feature_block_settings)); |
1826 | 1822 |
$annotations_and_sources = handle_annotations_and_sources( |
1827 |
$distribution_aggregate, |
|
1828 |
$label, |
|
1829 |
UUID_DISTRIBUTION |
|
1823 |
$distribution_aggregate, $label, UUID_DISTRIBUTION |
|
1830 | 1824 |
); |
1831 | 1825 |
$status = distribution_status_label_and_markup($distribution_aggregate->status, $level_style['status_glue']); |
1832 | 1826 |
} |
... | ... | |
1841 | 1835 |
; |
1842 | 1836 |
|
1843 | 1837 |
if(isset($annotations_and_sources)){ |
1844 |
if(!empty($annotations_and_sources['source_references'])){
|
|
1845 |
$per_node_markup[$node_index] .= ' ' . join(', ' , $annotations_and_sources['source_references']);
|
|
1838 |
if($annotations_and_sources->hasSourceReferences()){
|
|
1839 |
$per_node_markup[$node_index] .= ' ' . join(', ' , $annotations_and_sources->getSourceReferences());
|
|
1846 | 1840 |
} |
1847 |
if($annotations_and_sources['foot_note_keys']) {
|
|
1848 |
$per_node_markup[$node_index] .= $annotations_and_sources['foot_note_keys'];
|
|
1841 |
if($annotations_and_sources->hasFootnoteKeys()) {
|
|
1842 |
$per_node_markup[$node_index] .= $annotations_and_sources->footNoteKeysMarkup();
|
|
1849 | 1843 |
} |
1850 | 1844 |
} |
1851 | 1845 |
|
modules/cdm_dataportal/includes/footnotes.inc | ||
---|---|---|
35 | 35 |
* |
36 | 36 |
* @param $cdm_entity |
37 | 37 |
* A CDM entity |
38 |
* @param string $separator |
|
39 |
* Optional parameter. The separator string to concatenate the footnote ids, default is ',' |
|
40 | 38 |
* @param $footnote_list_key string |
41 | 39 |
* Optional parameter. If this parameter is left empty (null, 0, "") the footnote key will be determined by the nested |
42 | 40 |
* method calls by calling RenderHints::getFootnoteListKey(). |
... | ... | |
51 | 49 |
* For original sources the $footnote_list_key will be overwritten |
52 | 50 |
* by bibliography_footnote_list_key() when |
53 | 51 |
* $is_bibliography_aware is set TRUE. |
54 |
* @return String
|
|
55 |
* The foot note keys as markup
|
|
52 |
* @return array
|
|
53 |
* An array of the footnote keys for the supplied cdm entity
|
|
56 | 54 |
* |
57 | 55 |
* NOTE: Only used in @see handle_annotations_and_sources() |
58 | 56 |
*/ |
59 |
function render_entity_footnotes(
|
|
57 |
function cdm_entity_footnotes(
|
|
60 | 58 |
$cdm_entity, |
61 |
$separator = ',', |
|
62 | 59 |
$footnote_list_key = NULL, |
63 | 60 |
$do_link_to_reference = FALSE, |
64 | 61 |
$do_link_to_name_used_in_source = FALSE, |
... | ... | |
103 | 100 |
} |
104 | 101 |
// Sort and render footnote keys. |
105 | 102 |
asort($footnote_keys); |
106 |
return render_footnote_keys($footnote_keys, $separator);
|
|
103 |
return $footnote_keys;
|
|
107 | 104 |
} |
108 | 105 |
|
109 | 106 |
/** |
... | ... | |
280 | 277 |
* |
281 | 278 |
* @param $name_rel |
282 | 279 |
* The cdm name relationship |
283 |
* @return string
|
|
284 |
* The markup for the footnote key
|
|
280 |
* @return \FootnoteKey
|
|
281 |
* The FootnoteKey
|
|
285 | 282 |
*/ |
286 | 283 |
function handle_name_relationship_as_footnote($name_rel) |
287 | 284 |
{ |
288 | 285 |
$footnote_markup = ''; |
289 |
$footnote_key_markup = '';
|
|
286 |
$fnkey = null;
|
|
290 | 287 |
if (isset($name_rel->ruleConsidered) && $name_rel->ruleConsidered) { |
291 | 288 |
$footnote_markup = '<span class="rule_considered">' . $name_rel->ruleConsidered . '</span> '; |
292 | 289 |
} |
... | ... | |
298 | 295 |
} |
299 | 296 |
if ($footnote_markup) { |
300 | 297 |
$fnkey = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $footnote_markup); |
301 |
$footnote_key_markup = render_footnote_key($fnkey,',',TRUE); |
|
302 | 298 |
} |
303 |
return $footnote_key_markup;
|
|
299 |
return $fnkey;
|
|
304 | 300 |
} |
305 | 301 |
|
306 | 302 |
/** |
... | ... | |
309 | 305 |
* key is returned as markup. |
310 | 306 |
* |
311 | 307 |
* @param $nom_status |
312 |
* @return string
|
|
313 |
* The markup for the footnote key
|
|
308 |
* @return \FootnoteKey
|
|
309 |
* The FootnoteKey
|
|
314 | 310 |
*/ |
315 | 311 |
function handle_nomenclatural_status_as_footnote($nom_status) |
316 | 312 |
{ |
... | ... | |
326 | 322 |
* |
327 | 323 |
* @param $name |
328 | 324 |
* The name whose nomenclatural reference is to be shown as footnote |
329 |
* @return string
|
|
330 |
* The markup for the footnote key
|
|
325 |
* @return \FootnoteKey
|
|
326 |
* The FootnoteKey
|
|
331 | 327 |
*/ |
332 | 328 |
function handle_nomenclatural_reference_as_footnote($name) |
333 | 329 |
{ |
... | ... | |
339 | 335 |
if (isset($name->nomenclaturalSource->citationMicroReference)) { |
340 | 336 |
$footnote_markup .= ($footnote_key_markup ? ':' : '') . '<span class="reference_detail">' . $name->nomenclaturalSource->citationMicroReference . '</span>'; |
341 | 337 |
} |
338 |
$fnkey = null; |
|
342 | 339 |
if ($footnote_markup) { |
343 | 340 |
$fnkey = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $footnote_markup); |
344 |
$footnote_key_markup = render_footnote_key($fnkey, ',',TRUE); |
|
345 | 341 |
} |
346 |
return $footnote_key_markup;
|
|
342 |
return $fnkey;
|
|
347 | 343 |
} |
348 | 344 |
|
349 | 345 |
/* ============ annotations_and_sources handling =================== */ |
... | ... | |
475 | 471 |
* Optional parameter. If this parameter is left empty (null, 0, "") the |
476 | 472 |
* footnote key will be determined by the nested method calls by calling |
477 | 473 |
* RenderHints::getFootnoteListKey(). |
478 |
* @return array |
|
479 |
* an associative array with the following elements: |
|
474 |
* |
|
475 |
* @return AnnotationsAndSources |
|
476 |
* an object with the following elements: |
|
480 | 477 |
* - foot_note_keys: all footnote keys as markup |
481 | 478 |
* - source_references: an array of the source references citations |
482 | 479 |
* - names used in source: an associative array of the names in source, |
483 | 480 |
* the name in source strings are de-duplicated |
484 | 481 |
* !!!NOTE!!!!: this field will most probably be removed soon (TODO) |
485 |
* |
|
486 | 482 |
*/ |
487 |
function handle_annotations_and_sources($entity, $inline_text_prefix = null, $footnote_list_key_suggestion = null) { |
|
483 |
function handle_annotations_and_sources($entity, $inline_text_prefix = null, $footnote_list_key_suggestion = null, AnnotationsAndSources $annotationsAndSources = null) {
|
|
488 | 484 |
|
489 |
$annotations_and_sources = array( |
|
490 |
'foot_note_keys' => NULL, |
|
491 |
'source_references' => [], |
|
492 |
'names_used_in_source' => [] |
|
493 |
); |
|
485 |
if($annotationsAndSources == null){ |
|
486 |
$annotationsAndSources = new AnnotationsAndSources(); |
|
487 |
} |
|
494 | 488 |
|
495 | 489 |
// some entity types only have single sources: |
496 | 490 |
$sources = cdm_entity_sources_sorted($entity); |
... | ... | |
508 | 502 |
|
509 | 503 |
if ($reference_citation) { |
510 | 504 |
if (empty($inline_text_prefix)) { |
511 |
$annotations_and_sources['source_references'][] = $reference_citation;
|
|
505 |
$annotationsAndSources->addSourceReferencesCitation($reference_citation);
|
|
512 | 506 |
} else { |
513 |
$annotations_and_sources['source_references'][] = ' (' . $reference_citation . ')';
|
|
507 |
$annotationsAndSources->addSourceReferencesCitation(' (' . $reference_citation . ')');
|
|
514 | 508 |
} |
515 | 509 |
} |
516 | 510 |
|
... | ... | |
522 | 516 |
); |
523 | 517 |
|
524 | 518 |
if (!empty($name_in_source_render_array)) { |
525 |
$annotations_and_sources['names_used_in_source'][$name_in_source_render_array['#_plaintext']] = drupal_render($name_in_source_render_array);
|
|
519 |
$annotationsAndSources->putNamesUsedInSource($name_in_source_render_array['#_plaintext'], drupal_render($name_in_source_render_array));
|
|
526 | 520 |
} |
527 | 521 |
} |
528 | 522 |
} // END of loop over sources |
529 | 523 |
|
530 | 524 |
// annotations footnotes separate from sources |
531 |
$annotations_and_sources['foot_note_keys'] = render_footnote_keys( |
|
532 |
cdm_entity_annotations_as_footnote_keys($entity, $footnote_list_key_suggestion), ', ' |
|
533 |
); |
|
525 |
$footnote_keys = cdm_entity_annotations_as_footnote_keys($entity, $footnote_list_key_suggestion); |
|
526 |
$annotationsAndSources->addAllFootNoteKeys($footnote_keys); |
|
534 | 527 |
|
535 | 528 |
} // END of references inline |
536 | 529 |
|
537 | 530 |
// footnotes for sources and annotations or put into into bibliography if requested ... |
538 | 531 |
if ($config['add_footnote_keys']) { |
539 |
$annotations_and_sources['foot_note_keys'] = render_entity_footnotes(
|
|
540 |
$entity, ',',
|
|
532 |
$annotationsAndSources->addAllFootNoteKeys(cdm_entity_footnotes(
|
|
533 |
$entity, |
|
541 | 534 |
$footnote_list_key_suggestion, |
542 | 535 |
$config['link_to_reference'], |
543 | 536 |
$config['link_to_name_used_in_source'], |
544 | 537 |
(!empty($config['bibliography_aware']) ? $config['bibliography_aware'] : FALSE) |
545 |
); |
|
538 |
));
|
|
546 | 539 |
} |
547 |
return $annotations_and_sources;
|
|
540 |
return $annotationsAndSources;
|
|
548 | 541 |
} |
549 | 542 |
|
550 | 543 |
/** |
modules/cdm_dataportal/includes/name.inc | ||
---|---|---|
256 | 256 |
* @param $name_link |
257 | 257 |
* URI to the taxon, @param $reference_link |
258 | 258 |
* URI to the reference, |
259 |
* @param bool $show_annotations |
|
260 |
* turns the display of annotations on (default: true) |
|
259 |
* @param bool $show_taxon_name_annotations |
|
260 |
* Enable the display of footnotes for annotations on the taxon and name |
|
261 |
* (default: true) |
|
261 | 262 |
* @param bool $is_type_designation |
262 | 263 |
* To indicate that the supplied taxon name is a name type designation. |
263 | 264 |
* (default: false) |
... | ... | |
276 | 277 |
* @see path_to_reference(), must be processed by url() before passing to this method |
277 | 278 |
*/ |
278 | 279 |
function render_taxon_or_name($taxon_name_or_taxon_base, $name_link = NULL, $reference_link = NULL, |
279 |
$show_annotations = true, $is_type_designation = false, $skip_render_template_parts = [], $is_invalid = false) { |
|
280 |
$show_taxon_name_annotations = true, $is_type_designation = false, $skip_render_template_parts = [], $is_invalid = false) {
|
|
280 | 281 |
|
281 | 282 |
$is_doubtful = false; |
282 | 283 |
$taxon_base = null; |
284 |
$nom_status_fkey = null; // FootNoteKey |
|
283 | 285 |
if($taxon_name_or_taxon_base->class == 'Taxon' || $taxon_name_or_taxon_base->class == 'Synonym'){ |
284 | 286 |
$taxon_base = $taxon_name_or_taxon_base; |
285 | 287 |
if(isset($taxon_name_or_taxon_base->name)){ |
... | ... | |
416 | 418 |
// default separator |
417 | 419 |
$separator = ''; |
418 | 420 |
|
419 |
// [Eckhard]:"Komma nach dem Taxonnamen ist grunsätzlich falsch, |
|
421 |
// [Eckhard]:"Komma nach dem Taxonnamen ist grundsätzlich falsch,
|
|
420 | 422 |
// Komma nach dem Autornamen ist überall dort falsch, wo ein "in" folgt." |
421 | 423 |
if (isset($renderTemplate['referencePart']['reference'])) { |
422 | 424 |
$microreference = NULL; |
... | ... | |
482 | 484 |
if($tt->type == 'nomStatus'&& isset($tt->entityReference)) { |
483 | 485 |
$nom_status = cdm_ws_get(CDM_WS_NOMENCLATURALSTATUS, array($tt->entityReference->uuid)); |
484 | 486 |
$nom_status_fkey = handle_nomenclatural_status_as_footnote($nom_status); |
485 |
$tt->text .= $nom_status_fkey; |
|
486 | 487 |
$tt_to_markup_options['html'] = true; |
487 | 488 |
} |
488 | 489 |
} |
... | ... | |
577 | 578 |
$partHtml .= '<span class="' . $part . '">' . $html . '</span>'; |
578 | 579 |
} |
579 | 580 |
if ($uri) { |
580 |
// cannot use l() here since the #uri aleady should have been processed through uri() at this point |
|
581 |
// cannot use l() here since the #uri already should have been processed through uri() at this point
|
|
581 | 582 |
$out .= $separator . '<a href="' . $uri . '" class="' . $partName . '">' . $partHtml . '</a>'; |
582 | 583 |
|
583 | 584 |
} |
... | ... | |
586 | 587 |
} |
587 | 588 |
} |
588 | 589 |
$out .= '</span>'; |
589 |
if ($show_annotations) { |
|
590 |
$footnote_keys = []; |
|
590 |
|
|
591 |
$annotations_and_sources = new AnnotationsAndSources(); |
|
592 |
if($nom_status_fkey){ |
|
593 |
// the nomenclatural status footnote key refers to the source citation |
|
594 |
$annotations_and_sources->addFootNoteKey($nom_status_fkey); |
|
595 |
} |
|
596 |
if ($show_taxon_name_annotations) { |
|
591 | 597 |
if($taxon_base){ |
592 |
$annotations_and_sources_taxon = handle_annotations_and_sources($taxon_base);
|
|
593 |
$footnote_keys[] = $annotations_and_sources_taxon['foot_note_keys'];
|
|
598 |
$annotations_and_sources = handle_annotations_and_sources($taxon_base,
|
|
599 |
null, null, $annotations_and_sources);
|
|
594 | 600 |
} |
595 |
$annotations_and_sources_name = handle_annotations_and_sources($taxon_name); |
|
596 |
$footnote_keys[] = $annotations_and_sources_name['foot_note_keys']; |
|
597 |
// FIXME the glue should be inside of the <span class="footnote-key ... DOM |
|
598 |
// element, see render_footnote_key() |
|
599 |
$out .= implode(',', array_filter($footnote_keys, 'strlen')); |
|
601 |
$annotations_and_sources = handle_annotations_and_sources($taxon_name, |
|
602 |
null, null, $annotations_and_sources); |
|
600 | 603 |
} |
604 |
$out .= $annotations_and_sources->footNoteKeysMarkup(); |
|
601 | 605 |
return $out; |
602 | 606 |
} |
603 | 607 |
|
... | ... | |
971 | 975 |
} |
972 | 976 |
RenderHints::setAnnotationsAndSourceConfig(annotations_and_sources_config_typedesignations()); |
973 | 977 |
$annotations_and_sources = handle_annotations_and_sources($name_type_designation); |
974 |
$out .= $annotations_and_sources['foot_note_keys'];
|
|
978 |
$out .= $annotations_and_sources->footNoteKeysMarkup();
|
|
975 | 979 |
} |
976 | 980 |
} // END NameTypeDesignation |
977 | 981 |
|
... | ... | |
1042 | 1046 |
if(!empty($derivedUnitFacadeInstance->preferredStableUri)){ |
1043 | 1047 |
$out .= ' ' . l($derivedUnitFacadeInstance->preferredStableUri, $derivedUnitFacadeInstance->preferredStableUri, array('absolute' => true)); |
1044 | 1048 |
} |
1045 |
$out .= $annotations_and_sources['foot_note_keys'];
|
|
1049 |
$out .= $annotations_and_sources->footNoteKeysMarkup();
|
|
1046 | 1050 |
} |
1047 | 1051 |
$out .= '</'. $element_tag .'>'; |
1048 | 1052 |
} |
... | ... | |
1065 | 1069 |
$annotations_and_sources = handle_annotations_and_sources($textual_type_designation); |
1066 | 1070 |
$encasement = $textual_type_designation->verbatim ? '"' : ''; |
1067 | 1071 |
$out .= '<' . $element_tag . ' class="' . html_class_attribute_ref($textual_type_designation) . '">' . type_designation_status_label_markup(null) |
1068 |
. ': ' . $encasement . trim($textual_type_designation->text_L10n->text) . $encasement . $annotations_and_sources['foot_note_keys'] .'</' . $element_tag . '>';
|
|
1069 |
// if(is_array( $annotations_and_sources['source_references'])){
|
|
1070 |
// $citation_markup = join(', ', $annotations_and_sources['source_references']);
|
|
1072 |
. ': ' . $encasement . trim($textual_type_designation->text_L10n->text) . $encasement . $annotations_and_sources->footNoteKeysMarkup() .'</' . $element_tag . '>';
|
|
1073 |
// if($annotations_and_sources->hasSourceReferences())){
|
|
1074 |
// $citation_markup = join(', ', getSourceReferences());
|
|
1071 | 1075 |
// } |
1072 | 1076 |
// $out .= $citation_markup; |
1073 | 1077 |
} |
... | ... | |
1145 | 1149 |
RenderHints::setAnnotationsAndSourceConfig(annotations_and_sources_config_typedesignations()); |
1146 | 1150 |
$annotations_and_sources = handle_annotations_and_sources($name_type_entity_ref); |
1147 | 1151 |
|
1148 |
$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>: " |
|
1152 |
$render_array[] = markup_to_render_array('<div class="name_type_designation ' . html_class_attribute_ref($name_type_entity_ref) . |
|
1153 |
'"><span class="type-status">'. ucfirst($type_status) . "</span>: " |
|
1149 | 1154 |
. $name_type_entity_ref->label |
1150 | 1155 |
. ($preferredStableUri ? " ". l($preferredStableUri, $preferredStableUri) : '') |
1151 |
. $annotations_and_sources['foot_note_keys']
|
|
1156 |
. $annotations_and_sources->footNoteKeysMarkup()
|
|
1152 | 1157 |
. '</div>'); |
1153 | 1158 |
} |
1154 | 1159 |
} |
... | ... | |
1195 | 1200 |
// annotations and sources for the $derived_unit_facade_dto |
1196 | 1201 |
RenderHints::setAnnotationsAndSourceConfig(annotations_and_sources_config_typedesignations()); |
1197 | 1202 |
$annotations_and_sources = handle_annotations_and_sources($derived_unit_facade_dto); |
1198 |
$source_citations = $annotations_and_sources['source_references'];
|
|
1199 |
$foot_note_keys = $annotations_and_sources['foot_note_keys'];
|
|
1203 |
$source_citations = $annotations_and_sources->getSourceReferences();
|
|
1204 |
$foot_note_keys = $annotations_and_sources->footNoteKeysMarkup();
|
|
1200 | 1205 |
|
1201 | 1206 |
// preferredStableUri |
1202 | 1207 |
if(isset($type_designation->typeSpecimen->preferredStableUri) && $type_designation->typeSpecimen->preferredStableUri){ |
... | ... | |
1224 | 1229 |
// citation and detail for the media specimen |
1225 | 1230 |
RenderHints::setAnnotationsAndSourceConfig(annotations_and_sources_config_typedesignations()); |
1226 | 1231 |
$annotations_and_sources = handle_annotations_and_sources($mediaSpecimen); |
1227 |
if(is_array( $annotations_and_sources['source_references'])){
|
|
1228 |
$source_citations = array_merge($source_citations, $annotations_and_sources['source_references']);
|
|
1232 |
if($annotations_and_sources->hasSourceReferences()){
|
|
1233 |
$source_citations = array_merge($source_citations, $annotations_and_sources->getSourceReferences());
|
|
1229 | 1234 |
} |
1230 |
if($annotations_and_sources['foot_note_keys']){
|
|
1231 |
$foot_note_keys .= ', ' . $annotations_and_sources['foot_note_keys'];
|
|
1235 |
if($annotations_and_sources->hasFootnoteKeys()){
|
|
1236 |
$foot_note_keys .= ', ' . $annotations_and_sources->footNoteKeysMarkup();
|
|
1232 | 1237 |
} |
1233 | 1238 |
} |
1234 | 1239 |
|
... | ... | |
1262 | 1267 |
} |
1263 | 1268 |
|
1264 | 1269 |
/** |
1265 |
* Creates the markup for the given name relationship |
|
1270 |
* Creates the markup for the given name relationship.
|
|
1266 | 1271 |
* |
1267 |
* @param $name_rel the CDM NameRelationship entity |
|
1268 |
* @param $current_name_uuid |
|
1272 |
* For the footnotes see handle_annotations_and_sources(). |
|
1273 |
* |
|
1274 |
* @param $other_name |
|
1275 |
* The other name from the NameRelationship see get_other_name() |
|
1269 | 1276 |
* @param $current_taxon_uuid |
1270 | 1277 |
* @param $show_name_cache_only |
1271 | 1278 |
* The nameCache will be shown instead of the titleCache if this parameter is true. |
1272 | 1279 |
* @return null|string |
1273 | 1280 |
* The markup or null |
1281 |
* |
|
1282 |
* @see \get_other_name |
|
1274 | 1283 |
*/ |
1275 |
function name_relationship_markup($name_rel, $current_name_uuid, $current_taxon_uuid, $show_name_cache_only = false){
|
|
1284 |
function name_relationship_markup($current_name_uuid, $name_rel, $current_taxon_uuid, $show_name_cache_only = false){
|
|
1276 | 1285 |
|
1277 | 1286 |
$relationship_markup = null; |
1278 | 1287 |
|
1279 |
$current_name_is_toName = $current_name_uuid == $name_rel->toName->uuid;
|
|
1288 |
$other_name = get_other_name($current_name_uuid, $name_rel);
|
|
1280 | 1289 |
|
1281 |
if($current_name_is_toName){ |
|
1282 |
$name = $name_rel->fromName; |
|
1283 |
} else { |
|
1284 |
$name = $name_rel->toName; |
|
1285 |
} |
|
1286 |
|
|
1287 |
cdm_load_tagged_full_title($name); |
|
1290 |
cdm_load_tagged_full_title($other_name); |
|
1288 | 1291 |
|
1289 |
$highlited_synonym_uuid = isset ($name->taxonBases[0]->uuid) ? $name->taxonBases[0]->uuid : ''; |
|
1290 |
if(!$show_name_cache_only){ |
|
1291 |
$relationship_markup = render_taxon_or_name($name, |
|
1292 |
url(path_to_name($name->uuid, $current_taxon_uuid, $highlited_synonym_uuid, false)) |
|
1293 |
); |
|
1294 |
} else { |
|
1292 |
$highlited_synonym_uuid = isset ($other_name->taxonBases[0]->uuid) ? $other_name->taxonBases[0]->uuid : ''; |
|
1293 |
if($show_name_cache_only){ |
|
1295 | 1294 |
$relationship_markup = l( |
1296 |
'<span class="' . html_class_attribute_ref($name) . '"">' . $name->nameCache . '</span>',
|
|
1297 |
path_to_name($name->uuid, $current_taxon_uuid, $highlited_synonym_uuid, false), |
|
1295 |
'<span class="' . html_class_attribute_ref($other_name) . '"">' . $other_name->nameCache . '</span>',
|
|
1296 |
path_to_name($other_name->uuid, $current_taxon_uuid, $highlited_synonym_uuid, false),
|
|
1298 | 1297 |
array('html' => true) |
1299 | 1298 |
); |
1300 |
$annotations_and_sources = handle_annotations_and_sources($name); |
|
1301 |
$relationship_markup .= $annotations_and_sources['foot_note_keys']; |
|
1299 |
$annotations_and_sources = handle_annotations_and_sources($other_name); |
|
1300 |
$relationship_markup .= $annotations_and_sources->footNoteKeysMarkup(); |
|
1301 |
} else { |
|
1302 |
$relationship_markup = render_taxon_or_name($other_name, |
|
1303 |
url(path_to_name($other_name->uuid, $current_taxon_uuid, $highlited_synonym_uuid, false)) |
|
1304 |
); |
|
1302 | 1305 |
} |
1303 | 1306 |
|
1304 | 1307 |
return $relationship_markup; |
1305 | 1308 |
} |
1306 | 1309 |
|
1310 |
/** |
|
1311 |
* Determined the other name which is contained in the NameRelationship entity. |
|
1312 |
* |
|
1313 |
* @param $current_name_uuid |
|
1314 |
* The uuid of this name. |
|
1315 |
* @param $name_rel |
|
1316 |
* The cdm NameRelationship entity |
|
1317 |
* |
|
1318 |
* @return object |
|
1319 |
* The other cdm Name entity. |
|
1320 |
*/ |
|
1321 |
function get_other_name($current_name_uuid, $name_rel) { |
|
1322 |
$current_name_is_toName = $current_name_uuid == $name_rel->toName->uuid; |
|
1323 |
|
|
1324 |
if ($current_name_is_toName) { |
|
1325 |
$name = $name_rel->fromName; |
|
1326 |
} |
|
1327 |
else { |
|
1328 |
$name = $name_rel->toName; |
|
1329 |
} |
|
1330 |
return $name; |
|
1331 |
} |
|
1332 |
|
|
1307 | 1333 |
|
1308 | 1334 |
/** |
1309 | 1335 |
* Composes an inline representation of selected name relationships |
... | ... | |
1492 | 1518 |
usort($name_relations, 'compare_name_relations_by_term_order_index'); |
1493 | 1519 |
|
1494 | 1520 |
// compose |
1521 |
$show_name_cache_only = FALSE; |
|
1495 | 1522 |
foreach ($name_relations as $name_rel) { |
1496 | 1523 |
|
1497 | 1524 |
$is_inverse_relation = $current_name_uuid == $name_rel->toName->uuid; |
1498 |
|
|
1499 |
$rel_footnote_key_markup = handle_name_relationship_as_footnote($name_rel); |
|
1500 |
$relationship_markup = name_relationship_markup($name_rel, $current_name_uuid, $current_taxon_uuid); |
|
1501 |
|
|
1525 |
$rel_footnote_key_markup = render_footnote_key(handle_name_relationship_as_footnote($name_rel),''); |
|
1526 |
$relationship_markup = name_relationship_markup($current_name_uuid, $name_rel, $current_taxon_uuid, $show_name_cache_only); |
|
1502 | 1527 |
$label = cdm_relationship_type_term_abbreviated_label($name_rel->type, $is_inverse_relation); |
1528 |
|
|
1503 | 1529 |
$symbol = cdm_relationship_type_term_symbol($name_rel->type, $is_inverse_relation); |
1504 | 1530 |
$symbol_markup = '<span class="symbol" title="' . $label . '">' . $symbol . '</span>' . $rel_footnote_key_markup . ' '; |
1505 | 1531 |
$relationship_markup = $symbol_markup . $relationship_markup; |
... | ... | |
1514 | 1540 |
// name relationships to be displayed as non nec |
1515 | 1541 |
if (count($non_nec_name_rels) > 0) { |
1516 | 1542 |
$non_nec_markup = ''; |
1543 |
$show_name_cache_only = FALSE; |
|
1517 | 1544 |
foreach ($non_nec_name_rels as $name_rel) { |
1545 |
|
|
1518 | 1546 |
$is_inverse_relation = $current_name_uuid == $name_rel->toName->uuid; |
1519 |
$rel_footnote_key_markup = handle_name_relationship_as_footnote($name_rel);
|
|
1520 |
$relationship_markup = name_relationship_markup($name_rel, $current_name_uuid, $current_taxon_uuid);
|
|
1547 |
$rel_footnote_key_markup = render_footnote_key(handle_name_relationship_as_footnote($name_rel),'');
|
|
1548 |
$relationship_markup = name_relationship_markup($current_name_uuid, $name_rel, $current_taxon_uuid, $show_name_cache_only);
|
|
1521 | 1549 |
$label = cdm_relationship_type_term_abbreviated_label($name_rel->type, $is_inverse_relation); |
1550 |
|
|
1522 | 1551 |
$symbol = $non_nec_markup ? ' nec ' : 'non'; |
1523 | 1552 |
$symbol_markup = '<span class="symbol" title="' . $label . '">' . $symbol . '</span>' . $rel_footnote_key_markup . ' '; |
1524 | 1553 |
$non_nec_markup .= $symbol_markup . $relationship_markup; |
... | ... | |
1533 | 1562 |
|
1534 | 1563 |
// orthographic variants |
1535 | 1564 |
if (count($orthographic_variants) > 0) { |
1565 |
$show_name_cache_only = TRUE; |
|
1536 | 1566 |
foreach ($orthographic_variants as $name_rel) { |
1537 | 1567 |
|
1538 | 1568 |
$is_inverse_relation = $current_name_uuid == $name_rel->toName->uuid; |
1539 |
$rel_footnote_key_markup = handle_name_relationship_as_footnote($name_rel); |
|
1540 |
$relationship_markup = name_relationship_markup($name_rel, $current_name_uuid, $current_taxon_uuid, TRUE); |
|
1541 |
$nomref_footnote_key_markup = handle_nomenclatural_reference_as_footnote($name_rel->toName); |
|
1569 |
$rel_footnote_key_markup = render_footnote_key(handle_name_relationship_as_footnote($name_rel),''); |
|
1570 |
$relationship_markup = name_relationship_markup($current_name_uuid, $name_rel, $current_taxon_uuid, $show_name_cache_only); |
|
1542 | 1571 |
$label = cdm_relationship_type_term_abbreviated_label($name_rel->type, $is_inverse_relation); |
1543 | 1572 |
$symbol = cdm_relationship_type_term_symbol($name_rel->type, $is_inverse_relation); |
1544 | 1573 |
$symbol_markup = '<span class="symbol" title="' . $label . '">' . $symbol . '</span>' . $rel_footnote_key_markup . ' '; |
1545 |
$relationship_markup_has_footnote_key = strpos($relationship_markup, 'footnote-key footnote-key-') > 0; |
|
1546 |
$relationship_markup = $symbol_markup . $relationship_markup . ($relationship_markup_has_footnote_key ? ',' : '') . $nomref_footnote_key_markup; |
|
1574 |
$relationship_markup = $symbol_markup . $relationship_markup; |
|
1547 | 1575 |
} |
1548 | 1576 |
if (isset($relationship_markup) && $relationship_markup) { |
1549 | 1577 |
$render_array['list']['items'][] = markup_to_render_array($relationship_markup, |
modules/cdm_dataportal/includes/occurrences.inc | ||
---|---|---|
543 | 543 |
'bibliography_aware' => FALSE |
544 | 544 |
]); |
545 | 545 |
$annotations_and_sources = handle_annotations_and_sources($specimen_or_observation); |
546 |
if (!empty($annotations_and_sources['source_references'])) {
|
|
547 |
@_description_list_group_add($groups, t('Sources') . ':', join(', ', $annotations_and_sources['source_references']), '', 12);
|
|
546 |
if ($annotations_and_sources->hasSourceReferences()) {
|
|
547 |
@_description_list_group_add($groups, t('Sources') . ':', join(', ', $annotations_and_sources->getSourceReferences()), '', 12);
|
|
548 | 548 |
} |
549 | 549 |
break; |
550 | 550 |
|
modules/cdm_dataportal/includes/taxon-node.inc | ||
---|---|---|
44 | 44 |
} |
45 | 45 |
$classification = cdm_ws_get(CDM_WS_CLASSIFICATION, array($taxon_node->classificationUUID)); |
46 | 46 |
$status_markup_tokens[$state_label . '-' . $taxon_node->uuid] = [ |
47 |
'status' => '<span class="' . html_class_attribute_ref($taxon_node) .'">' . $state_label . $annotations_and_sources['foot_note_keys'] . '%s</span>', // %s will be replaced by the $classification_markup or by '',
|
|
47 |
'status' => '<span class="' . html_class_attribute_ref($taxon_node) .'">' . $state_label . $annotations_and_sources->footNoteKeysMarkup() . '%s</span>', // %s will be replaced by the $classification_markup or by '',
|
|
48 | 48 |
'classification' => ' <span class="' . html_class_attribute_ref($classification) .'">[' . $classification->titleCache . ']</span>' |
49 | 49 |
]; |
50 | 50 |
} |
modules/cdm_dataportal/includes/taxon.inc | ||
---|---|---|
432 | 432 |
$referenceUri = url(path_to_reference($synonym->name->nomenclaturalSource->citation->uuid)); |
433 | 433 |
} |
434 | 434 |
$out .= render_taxon_or_name($synonym->name, NULL, $referenceUri); |
435 |
$annotations_and_sources = handle_annotations_and_sources( |
|
436 |
$synonym, |
|
437 |
synonymy_annotations_and_source_config() |
|
438 |
); |
|
439 |
$out .= $annotations_and_sources['foot_note_keys']; |
|
435 |
RenderHints::setAnnotationsAndSourceConfig(synonymy_annotations_and_source_config()); |
|
436 |
$annotations_and_sources = handle_annotations_and_sources($synonym); |
|
437 |
$out .= $annotations_and_sources->footNoteKeysMarkup(); |
|
440 | 438 |
$out .= '</span>'; |
441 | 439 |
} |
442 | 440 |
RenderHints::popFromRenderStack(); |
modules/cdm_dataportal/theme/cdm_dataportal.media.theme | ||
---|---|---|
233 | 233 |
'bibliography_aware' => FALSE |
234 | 234 |
]); |
235 | 235 |
$annotations_and_sources = handle_annotations_and_sources( |
236 |
$media, |
|
237 |
NULL, |
|
238 |
$footnote_list_key |
|
236 |
$media, NULL, $footnote_list_key |
|
239 | 237 |
); |
240 | 238 |
|
241 | 239 |
$out = ''; |
... | ... | |
243 | 241 |
// Title. |
244 | 242 |
if ($doTitle) { |
245 | 243 |
$title_string = $media_metadata['title'] |
246 |
. $annotations_and_sources['foot_note_keys']; // placing the footnote keys here is not optimal, see #6329 A.1.
|
|
244 |
. $annotations_and_sources->footNoteKeysMarkup(); // placing the footnote keys here is not optimal, see #6329 A.1.
|
|
247 | 245 |
$title_string = trim($title_string); |
248 | 246 |
if (empty($title_string) && !($doDescription && $media_metadata['description'])) { |
249 | 247 |
// Use filename as fallback option if no description and no source citations are available. |
... | ... | |
295 | 293 |
$groups = array_merge($groups, cdm_rights_as_dl_groups($media_metadata['rights'])); |
296 | 294 |
} |
297 | 295 |
|
298 |
if(!empty($annotations_and_sources['source_references'])){
|
|
299 |
$sources_label = count($annotations_and_sources['source_references']) > 1 ? t('Sources') : t('Source');
|
|
300 |
_description_list_group_add($groups, $sources_label . ':', markup_to_render_array(join('; ', $annotations_and_sources['source_references'])) );
|
|
296 |
if($annotations_and_sources->hasSourceReferences()){
|
|
297 |
$sources_label = count(count($annotations_and_sources->getSourceReferences())) > 1 ? t('Sources') : t('Source');
|
|
298 |
_description_list_group_add($groups, $sources_label . ':', markup_to_render_array(join('; ', $annotations_and_sources->getSourceReferences())) );
|
|
301 | 299 |
} |
302 | 300 |
|
303 | 301 |
// TODO add all other metadata elements generically. |
src/test/java/eu/etaxonomy/dataportal/selenium/tests/reference/NameRelationshipsTest.java | ||
---|---|---|
72 | 72 |
assertEquals("is validating3 Nodosilinea radiophila Heidari & Hauer in Fottea 18(2): 142. fig. 5C, D. 1 Nov 2018, nom. illeg.4", nameRelationshipElements.get(2).getText()); |
73 | 73 |
assertEquals("non Nodosilinea blockensis, New Species in the solar system5 nec Nodosilinea sensensia, Plantas vasculares de Oz6 nec Nodosilinea sensensia, Species solaris7", nameRelationshipElements.get(3).getText()); |
74 | 74 |
BaseElement orthVarElement = nameRelationshipElements.get(4); |
75 |
assertEquals("orth. var.8 Nodosilinea sensensi9,10", orthVarElement.getText());
|
|
75 |
assertEquals("orth. var.8 Nodosilinea sensensi9", orthVarElement.getText()); |
|
76 | 76 |
assertEquals("has orthographic variant", orthVarElement.getElement().findElement(By.className("symbol")).getAttribute("title")); |
77 | 77 |
|
78 | 78 |
List<BaseElement> footnotes = regItem.getRegistrationFootnotes(); |
79 |
assertEquals(10, footnotes.size());
|
|
79 |
assertEquals(9, footnotes.size());
|
|
80 | 80 |
assertEquals( |
81 | 81 |
"1. Art. 99.9 Turland, N.J., Wiersema, J.H., Barrie, F.R. & al., International Code of Nomenclature for algae, fungi, and plants (Shenzhen Code) adopted by the Nineteenth International Botanical Congress Shenzhen, China, July 2017: 11", |
82 | 82 |
footnotes .get(0).getText()); |
... | ... | |
104 | 104 |
assertEquals( |
105 | 105 |
"9. Editorial annotation on Nodosilinea sensensi", |
106 | 106 |
footnotes .get(8).getText()); |
107 |
assertEquals( |
|
108 |
"10. Lem, Nonsens species of the developers Vol1. 2001", |
|
109 |
footnotes .get(9).getText()); |
|
107 |
|
|
110 | 108 |
} |
111 | 109 |
|
112 | 110 |
@Test |
... | ... | |
116 | 114 |
|
117 | 115 |
WebElement accName = p.getAcceptedName(); |
118 | 116 |
assertEquals("Nodosilinea sensensia (Blanco) Heidari & Hauer ex Lem, Nonsens species of the developers Vol1. 2001, comb. nov.1,2 [non Nodosilinea sensensia3 " |
119 |
+ "nec Nodosilinea sensensia4 nec Nodosilinea blockensis5 orth. var.6 Nodosilinea sensensi7,8]", accName.getText());
|
|
117 |
+ "nec Nodosilinea sensensia4 nec Nodosilinea blockensis5 orth. var.6 Nodosilinea sensensi7]", accName.getText()); |
|
120 | 118 |
|
121 | 119 |
List<BaseElement> footnotes = p.getHomotypicalGroupFootNotes(); |
122 |
assertEquals(8, footnotes.size());
|
|
120 |
assertEquals(7, footnotes.size());
|
|
123 | 121 |
assertEquals( |
124 | 122 |
"1. Art. 99.9 Turland, N.J., Wiersema, J.H., Barrie, F.R. & al., International Code of Nomenclature for algae, fungi, and plants (Shenzhen Code) adopted by the Nineteenth International Botanical Congress Shenzhen, China, July 2017: 11", |
125 | 123 |
footnotes .get(0).getText()); |
... | ... | |
141 | 139 |
assertEquals( |
142 | 140 |
"7. Editorial annotation on Nodosilinea sensensi", |
143 | 141 |
footnotes.get(6).getText()); |
144 |
assertEquals( |
|
145 |
"8. Lem, Nonsens species of the developers Vol1. 2001", |
|
146 |
footnotes.get(7).getText()); |
|
147 | 142 |
|
148 | 143 |
} |
149 | 144 |
|
Also available in: Unified diff
ref #9235 annotations and sources as class for better merging of footnote keys of multiple enities