1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* Class AnnotationsAndSources
|
5
|
* - foot_note_keys: array of FootnoteKey objects
|
6
|
* - source_references: an array of the source references citations
|
7
|
* - names used in source: an associative array of the names in source,
|
8
|
* the name in source strings are de-duplicated
|
9
|
* !!!NOTE!!!!: this field will most probably be removed soon (TODO)
|
10
|
*/
|
11
|
class AnnotationsAndSources {
|
12
|
|
13
|
/**
|
14
|
* @var array of FootnoteKey objects
|
15
|
*/
|
16
|
private $footNoteKeys = [];
|
17
|
|
18
|
/**
|
19
|
* @var array an array of the source references citations
|
20
|
*/
|
21
|
private $sourceReferences = [];
|
22
|
|
23
|
/**
|
24
|
* This field is being used when annotations are not handled as footnotes
|
25
|
*
|
26
|
* @var array
|
27
|
* an array of the annotations markup
|
28
|
*/
|
29
|
private $annotations = [];
|
30
|
|
31
|
/**
|
32
|
* @return array
|
33
|
*/
|
34
|
public function getAnnotations() {
|
35
|
return $this->annotations;
|
36
|
}
|
37
|
|
38
|
/**
|
39
|
* @param array $annotations
|
40
|
*/
|
41
|
public function setAnnotations($annotations) {
|
42
|
$this->annotations = $annotations;
|
43
|
}
|
44
|
|
45
|
/**
|
46
|
* @var array an associative array of the names in source,
|
47
|
* the name in source strings are de-duplicated
|
48
|
* !!!NOTE!!!!: this field will most probably be removed soon (TODO)
|
49
|
*/
|
50
|
private $nameUsedInSource = [];
|
51
|
|
52
|
/**
|
53
|
* Pipes the $this->footNoteKeyData) through the render_footnote_keys() function and
|
54
|
* returns the markup
|
55
|
*
|
56
|
* @return string the markup for all $this->footNoteKeyData)
|
57
|
*/
|
58
|
public function footNoteKeysMarkup() {
|
59
|
return render_footnote_keys($this->footNoteKeys, ',');
|
60
|
}
|
61
|
|
62
|
/**
|
63
|
* @return array
|
64
|
*/
|
65
|
public function getFootNoteKeys() {
|
66
|
return $this->footNoteKeys;
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* @param array $footNoteKeys
|
71
|
* Array of FootnoteKey objects
|
72
|
*/
|
73
|
public function setFootNoteKeys( array $footNoteKeys) {
|
74
|
$this->footNoteKeys = $footNoteKeys;
|
75
|
}
|
76
|
|
77
|
public function hasFootnoteKeys(){
|
78
|
return count($this->footNoteKeys) > 0;
|
79
|
}
|
80
|
|
81
|
/**
|
82
|
* @param FootnoteKey $footNoteKey
|
83
|
* The FootnoteKey object to add.
|
84
|
*/
|
85
|
public function addFootNoteKey(FootnoteKey $footNoteKey) {
|
86
|
$this->footNoteKeys[] = $footNoteKey;
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* Add all FootnoteKey objects
|
91
|
*
|
92
|
* @param $footNoteKeys
|
93
|
* The FootnoteKey objects to add.
|
94
|
*/
|
95
|
public function addAllFootNoteKeys(array $footNoteKeys) {
|
96
|
foreach($footNoteKeys as $key){
|
97
|
$this->footNoteKeys[] = $key;
|
98
|
}
|
99
|
}
|
100
|
|
101
|
/**
|
102
|
* @return array
|
103
|
*/
|
104
|
public function getSourceReferences() {
|
105
|
return $this->sourceReferences;
|
106
|
}
|
107
|
|
108
|
public function hasSourceReferences() {
|
109
|
return count($this->sourceReferences) > 0;
|
110
|
}
|
111
|
|
112
|
/**
|
113
|
* Adds a citation string to the
|
114
|
* @param array $sourceReferenceCitation
|
115
|
*/
|
116
|
public function addSourceReferencesCitation($sourceReferenceCitation) {
|
117
|
$this->sourceReferences[] = $sourceReferenceCitation;
|
118
|
}
|
119
|
|
120
|
/**
|
121
|
* @return array
|
122
|
*/
|
123
|
public function getNameUsedInSource() {
|
124
|
return $this->nameUsedInSource;
|
125
|
}
|
126
|
|
127
|
public function hasNameUsedInSource() {
|
128
|
return count($this->nameUsedInSource) > 0;
|
129
|
}
|
130
|
|
131
|
public function putNamesUsedInSource($plaintext_key, $markup) {
|
132
|
$this->nameUsedInSource[$plaintext_key] = $markup;
|
133
|
}
|
134
|
|
135
|
|
136
|
|
137
|
}
|