1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* citeproc-php |
4
|
|
|
* |
5
|
|
|
* @link http://github.com/seboettg/citeproc-php for the source repository |
6
|
|
|
* @copyright Copyright (c) 2017 Sebastian Böttger. |
7
|
|
|
* @license https://opensource.org/licenses/MIT |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Seboettg\CiteProc\Style\Options; |
11
|
|
|
|
12
|
|
|
use SimpleXMLElement; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class GlobalOptionsTrait |
16
|
|
|
* @package Seboettg\CiteProc\Style |
17
|
|
|
* @author Sebastian Böttger <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class BibliographyOptions |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* If set, the value of this attribute replaces names in a bibliographic entry that also occur in the preceding |
24
|
|
|
* entry. The exact method of substitution depends on the value of the subsequent-author-substitute-rule attribute. |
25
|
|
|
* Substitution is limited to the names of the first cs:names element rendered. (Bibliography-specific option) |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $subsequentAuthorSubstitute; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Specifies when and how names are substituted as a result of subsequent-author-substitute. |
33
|
|
|
* (Bibliography-specific option) |
34
|
|
|
* |
35
|
|
|
* @var SubsequentAuthorSubstituteRule |
36
|
|
|
*/ |
37
|
|
|
private $subsequentAuthorSubstituteRule; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* If set to “true” (“false” is the default), bibliographic entries are rendered with hanging-indents. |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
private $hangingIndent = false; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* If set, subsequent lines of bibliographic entries are aligned along the second field. With “flush”, the first |
47
|
|
|
* field is flush with the margin. With “margin”, the first field is put in the margin, and subsequent lines are |
48
|
|
|
* aligned with the margin. |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
private $secondFieldAlign; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Specifies vertical line distance. Defaults to “1” (single-spacing), and can be set to any positive integer to |
55
|
|
|
* specify a multiple of the standard unit of line height (e.g. “2” for double-spacing). |
56
|
|
|
* @var string |
57
|
|
|
*/ |
58
|
|
|
private $lineSpacing; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Specifies vertical distance between bibliographic entries. By default (with a value of “1”), entries are |
62
|
|
|
* separated by a single additional line-height (as set by the line-spacing attribute). Can be set to any |
63
|
|
|
* non-negative integer to specify a multiple of this amount. |
64
|
|
|
* @var string |
65
|
|
|
*/ |
66
|
|
|
private $entrySpacing; |
67
|
|
|
|
68
|
|
|
public function __construct(SimpleXMLElement $node) |
69
|
|
|
{ |
70
|
|
|
|
71
|
|
|
/** @var SimpleXMLElement $attribute */ |
72
|
|
|
foreach ($node->attributes() as $attribute) { |
73
|
|
|
switch ($attribute->getName()) { |
74
|
|
|
case 'subsequent-author-substitute': |
75
|
|
|
$this->subsequentAuthorSubstitute = (string) $attribute; |
76
|
|
|
break; |
77
|
|
|
case 'subsequent-author-substitute-rule': |
78
|
|
|
$this->subsequentAuthorSubstituteRule = new SubsequentAuthorSubstituteRule((string) $attribute); |
79
|
|
|
break; |
80
|
|
|
case 'hanging-indent': |
81
|
|
|
$this->hangingIndent = "true" === (string) $attribute ? true : false; |
|
|
|
|
82
|
|
|
break; |
83
|
|
|
case 'second-field-align': |
84
|
|
|
$this->secondFieldAlign = (string) $attribute; |
85
|
|
|
break; |
86
|
|
|
case 'line-spacing': |
87
|
|
|
$this->lineSpacing = (string) $attribute; |
88
|
|
|
break; |
89
|
|
|
case 'entry-spacing': |
90
|
|
|
$this->entrySpacing = (string) $attribute; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
if (empty($this->subsequentAuthorSubstituteRule)) { |
94
|
|
|
$this->subsequentAuthorSubstituteRule = new SubsequentAuthorSubstituteRule("complete-all"); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @return string |
100
|
|
|
*/ |
101
|
|
|
public function getSubsequentAuthorSubstitute() |
102
|
|
|
{ |
103
|
|
|
return $this->subsequentAuthorSubstitute; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @param string $subsequentAuthorSubstitute |
108
|
|
|
*/ |
109
|
|
|
public function setSubsequentAuthorSubstitute($subsequentAuthorSubstitute) |
110
|
|
|
{ |
111
|
|
|
$this->subsequentAuthorSubstitute = $subsequentAuthorSubstitute; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @return SubsequentAuthorSubstituteRule |
116
|
|
|
*/ |
117
|
|
|
public function getSubsequentAuthorSubstituteRule() |
118
|
|
|
{ |
119
|
|
|
return $this->subsequentAuthorSubstituteRule; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param SubsequentAuthorSubstituteRule $subsequentAuthorSubstituteRule |
124
|
|
|
*/ |
125
|
|
|
public function setSubsequentAuthorSubstituteRule($subsequentAuthorSubstituteRule) |
126
|
|
|
{ |
127
|
|
|
$this->subsequentAuthorSubstituteRule = $subsequentAuthorSubstituteRule; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @return string |
132
|
|
|
*/ |
133
|
|
|
public function getHangingIndent() |
134
|
|
|
{ |
135
|
|
|
return $this->hangingIndent; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param string $hangingIndent |
140
|
|
|
*/ |
141
|
|
|
public function setHangingIndent($hangingIndent) |
142
|
|
|
{ |
143
|
|
|
$this->hangingIndent = $hangingIndent; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @return string |
148
|
|
|
*/ |
149
|
|
|
public function getSecondFieldAlign() |
150
|
|
|
{ |
151
|
|
|
return $this->secondFieldAlign; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @param string $secondFieldAlign |
156
|
|
|
*/ |
157
|
|
|
public function setSecondFieldAlign($secondFieldAlign) |
158
|
|
|
{ |
159
|
|
|
$this->secondFieldAlign = $secondFieldAlign; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @return string |
164
|
|
|
*/ |
165
|
|
|
public function getLineSpacing() |
166
|
|
|
{ |
167
|
|
|
return $this->lineSpacing; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @param string $lineSpacing |
172
|
|
|
*/ |
173
|
|
|
public function setLineSpacing($lineSpacing) |
174
|
|
|
{ |
175
|
|
|
$this->lineSpacing = $lineSpacing; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @return string |
180
|
|
|
*/ |
181
|
|
|
public function getEntrySpacing() |
182
|
|
|
{ |
183
|
|
|
return $this->entrySpacing; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param string $entrySpacing |
188
|
|
|
*/ |
189
|
|
|
public function setEntrySpacing($entrySpacing) |
190
|
|
|
{ |
191
|
|
|
$this->entrySpacing = $entrySpacing; |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.