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