|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace luya\web\jsonld; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* JsonLd - Article Trait |
|
7
|
|
|
* |
|
8
|
|
|
* @see http://schema.org/Article |
|
9
|
|
|
* |
|
10
|
|
|
* @author Alex Schmid <[email protected]> |
|
11
|
|
|
* @since 1.0.1 |
|
12
|
|
|
*/ |
|
13
|
|
|
trait ArticleTrait |
|
14
|
|
|
{ |
|
15
|
|
|
use CreativeWorkTrait; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* The actual body of the article. |
|
19
|
|
|
* |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
private $_articleBody; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @return string |
|
26
|
|
|
*/ |
|
27
|
|
|
public function getArticleBody() |
|
28
|
|
|
{ |
|
29
|
|
|
return $this->_articleBody; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param string $articleBody |
|
34
|
|
|
* @return Article|ArticleTrait |
|
35
|
|
|
*/ |
|
36
|
|
|
public function setArticleBody($articleBody) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->_articleBody = $articleBody; |
|
39
|
|
|
return $this; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Articles may belong to one or more 'sections' in a magazine or newspaper, such as Sports, Lifestyle, etc. |
|
44
|
|
|
* |
|
45
|
|
|
* @var string |
|
46
|
|
|
*/ |
|
47
|
|
|
private $_articleSection; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return string |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getArticleSection() |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->_articleSection; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param string $articleSection |
|
59
|
|
|
* @return Article|ArticleTrait |
|
60
|
|
|
*/ |
|
61
|
|
|
public function setArticleSection($articleSection) |
|
62
|
|
|
{ |
|
63
|
|
|
$this->_articleSection = $articleSection; |
|
64
|
|
|
return $this; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* The page on which the work ends; for example "138" or "xvi". |
|
69
|
|
|
* |
|
70
|
|
|
* @var int|string |
|
71
|
|
|
*/ |
|
72
|
|
|
private $_pageEnd; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return int|string |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getPageEnd() |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->_pageEnd; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param int|string $pageEnd |
|
84
|
|
|
* @return Article|ArticleTrait |
|
85
|
|
|
*/ |
|
86
|
|
|
public function setPageEnd($pageEnd) |
|
87
|
|
|
{ |
|
88
|
|
|
$this->_pageEnd = $pageEnd; |
|
89
|
|
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* The page on which the work starts; for example "135" or "xiii". |
|
94
|
|
|
* |
|
95
|
|
|
* @var int|string |
|
96
|
|
|
*/ |
|
97
|
|
|
private $_pageStart; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @return int|string |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getPageStart() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->_pageStart; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @param int|string $pageStart |
|
109
|
|
|
* @return Article|ArticleTrait |
|
110
|
|
|
*/ |
|
111
|
|
|
public function setPageStart($pageStart) |
|
112
|
|
|
{ |
|
113
|
|
|
$this->_pageStart = $pageStart; |
|
114
|
|
|
return $this; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Any description of pages that is not separated into pageStart and pageEnd; |
|
119
|
|
|
* for example, "1-6, 9, 55" or "10-12, 46-49". |
|
120
|
|
|
* |
|
121
|
|
|
* @var string |
|
122
|
|
|
*/ |
|
123
|
|
|
private $_pagination; |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @return string |
|
127
|
|
|
*/ |
|
128
|
|
|
public function getPagination() |
|
129
|
|
|
{ |
|
130
|
|
|
return $this->_pagination; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @param string $pagination |
|
135
|
|
|
* @return Article|ArticleTrait |
|
136
|
|
|
*/ |
|
137
|
|
|
public function setPagination($pagination) |
|
138
|
|
|
{ |
|
139
|
|
|
$this->_pagination = $pagination; |
|
140
|
|
|
return $this; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Indicates sections of a Web page that are particularly 'speakable' in the sense of being highlighted as being |
|
145
|
|
|
* especially appropriate for text-to-speech conversion. Other sections of a page may also be usefully spoken in |
|
146
|
|
|
* particular circumstances; the 'speakable' property serves to indicate the parts most likely |
|
147
|
|
|
* to be generally useful for speech. |
|
148
|
|
|
* |
|
149
|
|
|
* The speakable property can be repeated an arbitrary number of times, |
|
150
|
|
|
* with three kinds of possible 'content-locator' values: |
|
151
|
|
|
* |
|
152
|
|
|
* 1.) id-value URL references - uses id-value of an element in the page being annotated. The simplest use |
|
153
|
|
|
* of speakable has (potentially relative) URL values, referencing identified sections of the document concerned. |
|
154
|
|
|
* |
|
155
|
|
|
* 2.) CSS Selectors - addresses content in the annotated page, eg. via class attribute. Use the cssSelector property. |
|
156
|
|
|
* |
|
157
|
|
|
* 3.) XPaths - addresses content via XPaths (assuming an XML view of the content). Use the xpath property. |
|
158
|
|
|
* |
|
159
|
|
|
* For more sophisticated markup of speakable sections beyond simple ID references, either CSS selectors |
|
160
|
|
|
* or XPath expressions to pick out document section(s) as speakable. For this we define a supporting type, |
|
161
|
|
|
* SpeakableSpecification which is defined to be a possible value of the speakable property. |
|
162
|
|
|
* |
|
163
|
|
|
* @var SpeakableSpecification|URL |
|
164
|
|
|
*/ |
|
165
|
|
|
private $_speakable; |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* @return SpeakableSpecification|URL |
|
169
|
|
|
*/ |
|
170
|
|
|
public function getSpeakable() |
|
171
|
|
|
{ |
|
172
|
|
|
return $this->_speakable; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/** |
|
176
|
|
|
* @param SpeakableSpecification|URL $speakable |
|
177
|
|
|
* @return Article|ArticleTrait |
|
178
|
|
|
*/ |
|
179
|
|
|
public function setSpeakable($speakable) |
|
180
|
|
|
{ |
|
181
|
|
|
$this->_speakable = $speakable; |
|
182
|
|
|
return $this; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* The number of words in the text of the Article. |
|
187
|
|
|
* |
|
188
|
|
|
* @var int |
|
189
|
|
|
*/ |
|
190
|
|
|
private $_wordCount; |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* @return int |
|
194
|
|
|
*/ |
|
195
|
|
|
public function getWordCount() |
|
196
|
|
|
{ |
|
197
|
|
|
return $this->_wordCount; |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* @param int $wordCount |
|
202
|
|
|
* @return Article|ArticleTrait |
|
203
|
|
|
*/ |
|
204
|
|
|
public function setWordCount($wordCount) |
|
205
|
|
|
{ |
|
206
|
|
|
$this->_wordCount = $wordCount; |
|
207
|
|
|
return $this; |
|
208
|
|
|
} |
|
209
|
|
|
} |