Revision 38a98e54
Added by Andreas Kohlbecker about 3 years ago
modules/cdm_dataportal/includes/footnotes.inc | ||
---|---|---|
49 | 49 |
* For original sources the $footnote_list_key will be overwritten |
50 | 50 |
* by bibliography_footnote_list_key() when |
51 | 51 |
* $is_bibliography_aware is set TRUE. |
52 |
* @param bool $add_annotations |
|
53 |
* Footnotes for annotations will not be created if this is FALSE |
|
54 |
* |
|
52 | 55 |
* @return array |
53 | 56 |
* An array of the footnote keys for the supplied cdm entity |
54 | 57 |
* |
... | ... | |
59 | 62 |
$footnote_list_key = NULL, |
60 | 63 |
$do_link_to_reference = FALSE, |
61 | 64 |
$do_link_to_name_used_in_source = FALSE, |
62 |
$is_bibliography_aware = FALSE |
|
65 |
$is_bibliography_aware = FALSE, |
|
66 |
$add_annotations = TRUE |
|
63 | 67 |
){ |
64 | 68 |
|
65 | 69 |
$sources = cdm_entity_sources_sorted($cdm_entity); |
... | ... | |
69 | 73 |
} |
70 | 74 |
|
71 | 75 |
// Annotations as footnotes. |
72 |
$footnote_keys = cdm_entity_annotations_as_footnote_keys($cdm_entity, $footnote_list_key); |
|
76 |
if($add_annotations){ |
|
77 |
$footnote_keys = cdm_entity_annotations_as_footnote_keys($cdm_entity, $footnote_list_key); |
|
78 |
} |
|
73 | 79 |
|
74 | 80 |
// Source references as footnotes. |
75 | 81 |
if($is_bibliography_aware){ |
... | ... | |
139 | 145 |
return $foot_note_keys; |
140 | 146 |
} |
141 | 147 |
|
148 |
/** |
|
149 |
* Fetches the list of visible annotations for the cdm entity or for the comparable |
|
150 |
* object and returns a list of the annotation texts |
|
151 |
* |
|
152 |
* @param stdClass $cdm_entity |
|
153 |
* A single CdmBase instance ore comparable object. |
|
154 |
* |
|
155 |
* @see cdm_fetch_visible_annotations() |
|
156 |
*/ |
|
157 |
function cdm_entity_annotations_as_content(stdClass $cdm_entity) { |
|
158 |
|
|
159 |
$annotation_texts = []; |
|
160 |
$annotations = cdm_fetch_visible_annotations($cdm_entity); |
|
161 |
if (is_array($annotations)) { |
|
162 |
foreach ($annotations as $annotation) { |
|
163 |
if($annotation->text){ |
|
164 |
$annotation_texts[] = $annotation->text; |
|
165 |
} |
|
166 |
} |
|
167 |
} |
|
168 |
return $annotation_texts; |
|
169 |
} |
|
170 |
|
|
142 | 171 |
/** |
143 | 172 |
* Creates markup for an array of foot note keys |
144 | 173 |
* |
... | ... | |
346 | 375 |
|
347 | 376 |
const ANNOTATIONS_AND_SOURCE_CONFIG_DEFAULT = [ |
348 | 377 |
'sources_as_content' => FALSE, |
378 |
'annotations_as_content' => FALSE, |
|
349 | 379 |
'link_to_name_used_in_source' => TRUE, |
350 | 380 |
'link_to_reference' => TRUE, |
351 | 381 |
'add_footnote_keys' => TRUE, |
... | ... | |
528 | 558 |
} // END of references inline |
529 | 559 |
|
530 | 560 |
// footnotes for sources and annotations or put into into bibliography if requested ... |
561 |
$do_foonotes_as_content = isset($config['annotations_as_content']) && $config['annotations_as_content']; |
|
562 |
if($do_foonotes_as_content){ |
|
563 |
$annotationsAndSources->setAnnotations(cdm_entity_annotations_as_content($entity)); |
|
564 |
} |
|
531 | 565 |
if ($config['add_footnote_keys']) { |
532 | 566 |
$annotationsAndSources->addAllFootNoteKeys(cdm_entity_footnotes( |
533 | 567 |
$entity, |
534 | 568 |
$footnote_list_key_suggestion, |
535 | 569 |
$config['link_to_reference'], |
536 | 570 |
$config['link_to_name_used_in_source'], |
537 |
(!empty($config['bibliography_aware']) ? $config['bibliography_aware'] : FALSE) |
|
571 |
(!empty($config['bibliography_aware']) ? $config['bibliography_aware'] : FALSE), |
|
572 |
!$do_foonotes_as_content |
|
538 | 573 |
)); |
539 | 574 |
} |
540 | 575 |
return $annotationsAndSources; |
... | ... | |
557 | 592 |
else { |
558 | 593 |
// try to load the sources |
559 | 594 |
if(isset_not_empty($entity->uuid)){ |
560 |
$sources = cdm_ws_fetch_all(cdm_compose_ws_url('portal/' . cdm_ws_base_uri($entity->class), [ $entity->uuid, 'sources']));
|
|
595 |
$sources = cdm_ws_fetch_all(cdm_compose_url('portal/' . cdm_ws_base_uri($entity->class), [ $entity->uuid, 'sources'])); |
|
561 | 596 |
} else { |
562 | 597 |
// this may happen with DerivedUnitFaced, also with others? |
563 | 598 |
$sources = []; |
Also available in: Unified diff
ref #6866 showing unit annotations (AnnotationsAndSources supports annotations a content now)