|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* citeproc-php |
|
4
|
|
|
* |
|
5
|
|
|
* @link http://github.com/seboettg/citeproc-php for the source repository |
|
6
|
|
|
* @copyright Copyright (c) 2016 Sebastian Böttger. |
|
7
|
|
|
* @license https://opensource.org/licenses/MIT |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Seboettg\CiteProc; |
|
11
|
|
|
use Seboettg\CiteProc\Data\DataList; |
|
12
|
|
|
use Seboettg\CiteProc\Locale\Locale; |
|
13
|
|
|
use Seboettg\CiteProc\Style\Bibliography; |
|
14
|
|
|
use Seboettg\CiteProc\Style\Citation; |
|
15
|
|
|
use Seboettg\CiteProc\Style\Macro; |
|
16
|
|
|
use Seboettg\CiteProc\Style\Options\BibliographyOptions; |
|
17
|
|
|
use Seboettg\CiteProc\Style\Options\CitationOptions; |
|
18
|
|
|
use Seboettg\CiteProc\Style\Options\GlobalOptions; |
|
19
|
|
|
use Seboettg\CiteProc\Style\Sort\Sort; |
|
20
|
|
|
use Seboettg\CiteProc\Style\Root; |
|
21
|
|
|
use Seboettg\Collection\ArrayList; |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Class Context |
|
26
|
|
|
* @package Seboettg\CiteProc |
|
27
|
|
|
* |
|
28
|
|
|
* @author Sebastian Böttger <[email protected]> |
|
29
|
|
|
*/ |
|
30
|
|
|
class Context |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @var ArrayList |
|
34
|
|
|
*/ |
|
35
|
|
|
private $macros; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var Locale |
|
39
|
|
|
*/ |
|
40
|
|
|
private $locale; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var Bibliography |
|
44
|
|
|
*/ |
|
45
|
|
|
private $bibliography; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var Citation |
|
49
|
|
|
*/ |
|
50
|
|
|
private $citation; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var Sort |
|
54
|
|
|
*/ |
|
55
|
|
|
private $sorting; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @var string |
|
59
|
|
|
*/ |
|
60
|
|
|
private $mode; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @var DataList |
|
64
|
|
|
*/ |
|
65
|
|
|
private $citationItems; |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @var ArrayList |
|
69
|
|
|
*/ |
|
70
|
|
|
private $results; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @var Root |
|
74
|
|
|
*/ |
|
75
|
|
|
private $root; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @var CiteProc |
|
79
|
|
|
*/ |
|
80
|
|
|
private $citeProc; |
|
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @var GlobalOptions |
|
84
|
|
|
*/ |
|
85
|
|
|
private $globalOptions; |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @var BibliographyOptions |
|
89
|
|
|
*/ |
|
90
|
|
|
private $bibliographySpecificOptions; |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @var CitationOptions |
|
94
|
|
|
*/ |
|
95
|
|
|
private $citationSpecificOptions; |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @var string (sorting|rendering) |
|
99
|
|
|
*/ |
|
100
|
|
|
private $renderingState; |
|
101
|
|
|
|
|
102
|
|
|
public function __construct($locale = null) |
|
103
|
|
|
{ |
|
104
|
|
|
if (!empty($locale)) { |
|
105
|
|
|
$this->locale = $locale; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
$this->macros = new ArrayList(); |
|
109
|
|
|
$this->citationItems = new DataList(); |
|
110
|
|
|
$this->results = new ArrayList(); |
|
111
|
|
|
$this->renderingState = "rendering"; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function addMacro($key, $macro) |
|
115
|
|
|
{ |
|
116
|
|
|
$this->macros->add($key, $macro); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param $key |
|
121
|
|
|
* @return Macro |
|
122
|
|
|
*/ |
|
123
|
|
|
public function getMacro($key) |
|
124
|
|
|
{ |
|
125
|
|
|
return $this->macros->get($key); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* @param Locale $locale |
|
130
|
|
|
*/ |
|
131
|
|
|
public function setLocale(Locale $locale) |
|
132
|
|
|
{ |
|
133
|
|
|
$this->locale = $locale; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* @return Locale |
|
138
|
|
|
*/ |
|
139
|
|
|
public function getLocale() |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->locale; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* @return Bibliography |
|
146
|
|
|
*/ |
|
147
|
|
|
public function getBibliography() |
|
148
|
|
|
{ |
|
149
|
|
|
return $this->bibliography; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* @param Bibliography $bibliography |
|
154
|
|
|
*/ |
|
155
|
|
|
public function setBibliography(Bibliography $bibliography) |
|
156
|
|
|
{ |
|
157
|
|
|
$this->bibliography = $bibliography; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* @return Citation |
|
162
|
|
|
*/ |
|
163
|
|
|
public function getCitation() |
|
164
|
|
|
{ |
|
165
|
|
|
return $this->citation; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* @param Citation $citation |
|
170
|
|
|
*/ |
|
171
|
|
|
public function setCitation($citation) |
|
172
|
|
|
{ |
|
173
|
|
|
$this->citation = $citation; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
public function setSorting($sorting) |
|
177
|
|
|
{ |
|
178
|
|
|
$this->sorting = $sorting; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
public function getSorting() |
|
182
|
|
|
{ |
|
183
|
|
|
return $this->sorting; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* return the render mode (citation|bibliography) |
|
188
|
|
|
* @return string |
|
189
|
|
|
*/ |
|
190
|
|
|
public function getMode() |
|
191
|
|
|
{ |
|
192
|
|
|
return $this->mode; |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
/** |
|
196
|
|
|
* @param string $mode |
|
197
|
|
|
*/ |
|
198
|
|
|
public function setMode($mode) |
|
199
|
|
|
{ |
|
200
|
|
|
$this->mode = $mode; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* returns true if the render mode is set to citation |
|
205
|
|
|
* @return bool |
|
206
|
|
|
*/ |
|
207
|
|
|
public function isModeCitation() |
|
208
|
|
|
{ |
|
209
|
|
|
return $this->mode === "citation"; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* returns true if the render mode is set to bibliography |
|
214
|
|
|
* @return bool |
|
215
|
|
|
*/ |
|
216
|
|
|
public function isModeBibliography() |
|
217
|
|
|
{ |
|
218
|
|
|
return $this->mode === "bibliography"; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* @return DataList |
|
223
|
|
|
*/ |
|
224
|
|
|
public function getCitationItems() |
|
225
|
|
|
{ |
|
226
|
|
|
return $this->citationItems; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
/** |
|
230
|
|
|
* @param DataList $citationItems |
|
231
|
|
|
*/ |
|
232
|
|
|
public function setCitationItems(&$citationItems) |
|
233
|
|
|
{ |
|
234
|
|
|
$this->citationItems = $citationItems; |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
public function hasCitationItems() |
|
238
|
|
|
{ |
|
239
|
|
|
return ($this->citationItems->count() > 0); |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* @return ArrayList |
|
244
|
|
|
*/ |
|
245
|
|
|
public function getMacros() |
|
246
|
|
|
{ |
|
247
|
|
|
return $this->macros; |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
/** |
|
251
|
|
|
* @return ArrayList |
|
252
|
|
|
*/ |
|
253
|
|
|
public function getResults() |
|
254
|
|
|
{ |
|
255
|
|
|
return $this->results; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
/** |
|
259
|
|
|
* @return Root |
|
260
|
|
|
*/ |
|
261
|
|
|
public function getRoot() |
|
262
|
|
|
{ |
|
263
|
|
|
return $this->root; |
|
264
|
|
|
} |
|
265
|
|
|
|
|
266
|
|
|
/** |
|
267
|
|
|
* @param Root $root |
|
268
|
|
|
*/ |
|
269
|
|
|
public function setRoot($root) |
|
270
|
|
|
{ |
|
271
|
|
|
$this->root = $root; |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
/** |
|
275
|
|
|
* @return GlobalOptions |
|
276
|
|
|
*/ |
|
277
|
|
|
public function getGlobalOptions() |
|
278
|
|
|
{ |
|
279
|
|
|
return $this->globalOptions; |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
/** |
|
283
|
|
|
* @param GlobalOptions $globalOptions |
|
284
|
|
|
*/ |
|
285
|
|
|
public function setGlobalOptions($globalOptions) |
|
286
|
|
|
{ |
|
287
|
|
|
$this->globalOptions = $globalOptions; |
|
288
|
|
|
} |
|
289
|
|
|
|
|
290
|
|
|
/** |
|
291
|
|
|
* @return string |
|
292
|
|
|
*/ |
|
293
|
|
|
public function getRenderingState() |
|
294
|
|
|
{ |
|
295
|
|
|
return $this->renderingState; |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* @param string $renderingState |
|
300
|
|
|
*/ |
|
301
|
|
|
public function setRenderingState($renderingState) |
|
302
|
|
|
{ |
|
303
|
|
|
$this->renderingState = $renderingState; |
|
304
|
|
|
} |
|
305
|
|
|
|
|
306
|
|
|
/** |
|
307
|
|
|
* @return BibliographyOptions |
|
308
|
|
|
*/ |
|
309
|
|
|
public function getBibliographySpecificOptions() |
|
310
|
|
|
{ |
|
311
|
|
|
return $this->bibliographySpecificOptions; |
|
312
|
|
|
} |
|
313
|
|
|
|
|
314
|
|
|
/** |
|
315
|
|
|
* @param BibliographyOptions $bibliographySpecificOptions |
|
316
|
|
|
*/ |
|
317
|
|
|
public function setBibliographySpecificOptions($bibliographySpecificOptions) |
|
318
|
|
|
{ |
|
319
|
|
|
$this->bibliographySpecificOptions = $bibliographySpecificOptions; |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
/** |
|
323
|
|
|
* @return CitationOptions |
|
324
|
|
|
*/ |
|
325
|
|
|
public function getCitationSpecificOptions() |
|
326
|
|
|
{ |
|
327
|
|
|
return $this->citationSpecificOptions; |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
/** |
|
331
|
|
|
* @param CitationOptions $citationSpecificOptions |
|
332
|
|
|
*/ |
|
333
|
|
|
public function setCitationSpecificOptions($citationSpecificOptions) |
|
334
|
|
|
{ |
|
335
|
|
|
$this->citationSpecificOptions = $citationSpecificOptions; |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
|
|
339
|
|
|
} |
This check marks private properties in classes that are never used. Those properties can be removed.