|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
4
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
5
|
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
6
|
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
7
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
8
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace TwitterWidgets\Options; |
|
12
|
|
|
|
|
13
|
|
|
use InvalidArgumentException; |
|
14
|
|
|
use Zend\Stdlib\AbstractOptions; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class for the client side cumtomization |
|
18
|
|
|
* |
|
19
|
|
|
* @license MIT |
|
20
|
|
|
* @link https://dev.twitter.com/web/embedded-timelines#customization |
|
21
|
|
|
* @author mpalourdio <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class WidgetOptions extends AbstractOptions implements WidgetOptionsInterface |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var string |
|
27
|
|
|
* |
|
28
|
|
|
* CSS class for the timeline. Provides the twitter one by default |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $class = 'twitter-timeline'; |
|
31
|
|
|
/** |
|
32
|
|
|
* @var string |
|
33
|
|
|
* |
|
34
|
|
|
* Timeline URL |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $href; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var string |
|
40
|
|
|
* |
|
41
|
|
|
* Text for the link that appears above the timeline |
|
42
|
|
|
* ie: tweets from @mpalourdio |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $hrefText; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var string |
|
48
|
|
|
* |
|
49
|
|
|
* Your widget ID |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $dataWidgetId; |
|
52
|
|
|
/** |
|
53
|
|
|
* @var string |
|
54
|
|
|
* |
|
55
|
|
|
* Set by adding a data-theme="dark" attribute to the embed code. |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $dataTheme; |
|
58
|
|
|
/** |
|
59
|
|
|
* @var string |
|
60
|
|
|
* |
|
61
|
|
|
* Theme: Set by adding a data-link-color="#cc0000" attribute. |
|
62
|
|
|
* Note that some icons in the widget will also appear this color. |
|
63
|
|
|
*/ |
|
64
|
|
|
protected $dataLinkColor; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @var int |
|
68
|
|
|
* |
|
69
|
|
|
* Set using the standard HTML width attribute on the embed code (units are pixels.) |
|
70
|
|
|
*/ |
|
71
|
|
|
protected $width; |
|
72
|
|
|
/** |
|
73
|
|
|
* @var int |
|
74
|
|
|
* |
|
75
|
|
|
* Set using the standard HTML height attribute on the embed code (units are pixels.) |
|
76
|
|
|
*/ |
|
77
|
|
|
protected $height; |
|
78
|
|
|
/** |
|
79
|
|
|
* @var string |
|
80
|
|
|
* |
|
81
|
|
|
* Control the widget layout and chrome |
|
82
|
|
|
*/ |
|
83
|
|
|
protected $dataChrome; |
|
84
|
|
|
/** |
|
85
|
|
|
* @var string |
|
86
|
|
|
* |
|
87
|
|
|
* Change the border color used by the widget. Takes an #abc123 hex format color e.g. data-border-color="#cc0000" |
|
88
|
|
|
*/ |
|
89
|
|
|
protected $dataBorderColor; |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @var string |
|
93
|
|
|
* |
|
94
|
|
|
* The widget language is detected from the page, based on the HTML lang attribute of your content. |
|
95
|
|
|
* You can also set the HTML lang attribute on the embed code itself. |
|
96
|
|
|
*/ |
|
97
|
|
|
protected $language; |
|
98
|
|
|
/** |
|
99
|
|
|
* @var int |
|
100
|
|
|
* |
|
101
|
|
|
* To fix the size of a timeline to a preset number of Tweets, use the data-tweet-limit="5" attribute with any value |
|
102
|
|
|
* between 1 and 20 Tweets. The timeline will render the specified number of Tweets from the timeline, expanding the |
|
103
|
|
|
* height of the widget to display all Tweets without scrolling. Since the widget is of a fixed size, it will not |
|
104
|
|
|
* poll for updates when using this option. |
|
105
|
|
|
*/ |
|
106
|
|
|
protected $dataTweetLimit; |
|
107
|
|
|
/** |
|
108
|
|
|
* @var string |
|
109
|
|
|
* |
|
110
|
|
|
* As per the Tweet and follow buttons, you may provide a comma-separated list of user screen names as suggested |
|
111
|
|
|
* followers to a user after they reply, Retweet, or favorite a Tweet in the timeline. Use a |
|
112
|
|
|
* data-related="benward,endform" attribute on the embed code. |
|
113
|
|
|
*/ |
|
114
|
|
|
protected $dataRelated; |
|
115
|
|
|
/** |
|
116
|
|
|
* @var string |
|
117
|
|
|
* |
|
118
|
|
|
* ARIA is an accessibility system that aids people using assistive technology interacting with dynamic web content. |
|
119
|
|
|
* Read more about ARIA on W3C’s website. By default, the embedded timeline uses the least obtrusive |
|
120
|
|
|
* setting: aria-polite="polite". If you’re using an embedded timeline as a primary source of content on your |
|
121
|
|
|
* page, you may wish to override this to the assertive setting, using data-aria-polite="assertive". |
|
122
|
|
|
*/ |
|
123
|
|
|
protected $dataAriaPolite; |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @return string |
|
127
|
|
|
*/ |
|
128
|
|
|
public function getDataChrome() |
|
129
|
|
|
{ |
|
130
|
|
|
return $this->dataChrome; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @param string $dataChrome |
|
135
|
|
|
* @throws InvalidArgumentException |
|
136
|
|
|
* @return self |
|
137
|
|
|
*/ |
|
138
|
|
|
public function setDataChrome($dataChrome) |
|
139
|
|
|
{ |
|
140
|
|
|
if (!is_string($dataChrome) && null !== $dataChrome) { |
|
141
|
|
|
throw new InvalidArgumentException('An string is expected for chrome parameter'); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
$this->dataChrome = $dataChrome; |
|
145
|
|
|
|
|
146
|
|
|
return $this; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @return string |
|
151
|
|
|
*/ |
|
152
|
|
|
public function getClass() |
|
153
|
|
|
{ |
|
154
|
|
|
return $this->class; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @param string $class |
|
159
|
|
|
* @throws InvalidArgumentException |
|
160
|
|
|
* @return self |
|
161
|
|
|
*/ |
|
162
|
|
|
public function setClass($class) |
|
163
|
|
|
{ |
|
164
|
|
|
if (!is_string($class) && null !== $class) { |
|
165
|
|
|
throw new InvalidArgumentException('String expected for class parameter'); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
$this->class = $class; |
|
169
|
|
|
|
|
170
|
|
|
return $this; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* @return string |
|
175
|
|
|
*/ |
|
176
|
|
|
public function getDataAriaPolite() |
|
177
|
|
|
{ |
|
178
|
|
|
return $this->dataAriaPolite; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* @param string $dataAriaPolite |
|
183
|
|
|
* @throws InvalidArgumentException |
|
184
|
|
|
* @return self |
|
185
|
|
|
*/ |
|
186
|
|
|
public function setDataAriaPolite($dataAriaPolite) |
|
187
|
|
|
{ |
|
188
|
|
|
if (!is_string($dataAriaPolite) && null !== $dataAriaPolite) { |
|
189
|
|
|
throw new InvalidArgumentException('String expected for dataAriaPolite parameter'); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
$this->dataAriaPolite = $dataAriaPolite; |
|
193
|
|
|
|
|
194
|
|
|
return $this; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* @return string |
|
199
|
|
|
*/ |
|
200
|
|
|
public function getDataBorderColor() |
|
201
|
|
|
{ |
|
202
|
|
|
return $this->dataBorderColor; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
/** |
|
206
|
|
|
* @param string $dataBorderColor |
|
207
|
|
|
* @throws InvalidArgumentException |
|
208
|
|
|
* @return self |
|
209
|
|
|
*/ |
|
210
|
|
|
public function setDataBorderColor($dataBorderColor) |
|
211
|
|
|
{ |
|
212
|
|
|
if (!is_string($dataBorderColor) && null !== $dataBorderColor) { |
|
213
|
|
|
throw new InvalidArgumentException('String expected for dataBorderColor parameter'); |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
$this->dataBorderColor = $dataBorderColor; |
|
217
|
|
|
|
|
218
|
|
|
return $this; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* @return string |
|
223
|
|
|
*/ |
|
224
|
|
|
public function getDataLinkColor() |
|
225
|
|
|
{ |
|
226
|
|
|
return $this->dataLinkColor; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
/** |
|
230
|
|
|
* @param string $dataLinkColor |
|
231
|
|
|
* @throws InvalidArgumentException |
|
232
|
|
|
* @return self |
|
233
|
|
|
*/ |
|
234
|
|
|
public function setDataLinkColor($dataLinkColor) |
|
235
|
|
|
{ |
|
236
|
|
|
if (!is_string($dataLinkColor) && null !== $dataLinkColor) { |
|
237
|
|
|
throw new InvalidArgumentException('String expected for dataLinkColor parameter'); |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
$this->dataLinkColor = $dataLinkColor; |
|
241
|
|
|
|
|
242
|
|
|
return $this; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
/** |
|
246
|
|
|
* @return string |
|
247
|
|
|
*/ |
|
248
|
|
|
public function getDataRelated() |
|
249
|
|
|
{ |
|
250
|
|
|
return $this->dataRelated; |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* @param string $dataRelated |
|
255
|
|
|
* @throws InvalidArgumentException |
|
256
|
|
|
* @return self |
|
257
|
|
|
*/ |
|
258
|
|
|
public function setDataRelated($dataRelated) |
|
259
|
|
|
{ |
|
260
|
|
|
if (!is_string($dataRelated) && null !== $dataRelated) { |
|
261
|
|
|
throw new InvalidArgumentException('String expected for dataRelated parameter'); |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
$this->dataRelated = $dataRelated; |
|
265
|
|
|
|
|
266
|
|
|
return $this; |
|
267
|
|
|
} |
|
268
|
|
|
|
|
269
|
|
|
/** |
|
270
|
|
|
* @return string |
|
271
|
|
|
*/ |
|
272
|
|
|
public function getDataTheme() |
|
273
|
|
|
{ |
|
274
|
|
|
return $this->dataTheme; |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
/** |
|
278
|
|
|
* @param string $dataTheme |
|
279
|
|
|
* @throws InvalidArgumentException |
|
280
|
|
|
* @return self |
|
281
|
|
|
*/ |
|
282
|
|
|
public function setDataTheme($dataTheme) |
|
283
|
|
|
{ |
|
284
|
|
|
if (!is_string($dataTheme) && null !== $dataTheme) { |
|
285
|
|
|
throw new InvalidArgumentException('String expected for dataTheme parameter'); |
|
286
|
|
|
} |
|
287
|
|
|
|
|
288
|
|
|
$this->dataTheme = $dataTheme; |
|
289
|
|
|
|
|
290
|
|
|
return $this; |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
/** |
|
294
|
|
|
* @return int |
|
295
|
|
|
*/ |
|
296
|
|
|
public function getDataTweetLimit() |
|
297
|
|
|
{ |
|
298
|
|
|
return $this->dataTweetLimit; |
|
299
|
|
|
} |
|
300
|
|
|
|
|
301
|
|
|
/** |
|
302
|
|
|
* @param int $dataTweetLimit |
|
303
|
|
|
* @throws InvalidArgumentException |
|
304
|
|
|
* @return self |
|
305
|
|
|
*/ |
|
306
|
|
|
public function setDataTweetLimit($dataTweetLimit) |
|
307
|
|
|
{ |
|
308
|
|
|
if (!is_int($dataTweetLimit) && null !== $dataTweetLimit) { |
|
309
|
|
|
throw new InvalidArgumentException('Integer expected for dataTweetLimit parameter'); |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
$this->dataTweetLimit = $dataTweetLimit; |
|
313
|
|
|
|
|
314
|
|
|
return $this; |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
/** |
|
318
|
|
|
* @return string |
|
319
|
|
|
*/ |
|
320
|
|
|
public function getDataWidgetId() |
|
321
|
|
|
{ |
|
322
|
|
|
return $this->dataWidgetId; |
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
/** |
|
326
|
|
|
* @param string $dataWidgetId |
|
327
|
|
|
* @throws InvalidArgumentException |
|
328
|
|
|
* @return self |
|
329
|
|
|
* |
|
330
|
|
|
* Note: long integers will be converted to float (32 bits). Give this setter a string |
|
331
|
|
|
*/ |
|
332
|
|
|
public function setDataWidgetId($dataWidgetId) |
|
333
|
|
|
{ |
|
334
|
|
|
if (!is_string($dataWidgetId) && null !== $dataWidgetId) { |
|
335
|
|
|
throw new InvalidArgumentException( |
|
336
|
|
|
'String is expected for dataWidgetId (long int can lead to float conversion)' |
|
337
|
|
|
); |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
$this->dataWidgetId = $dataWidgetId; |
|
341
|
|
|
|
|
342
|
|
|
return $this; |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
/** |
|
346
|
|
|
* @return int |
|
347
|
|
|
*/ |
|
348
|
|
|
public function getHeight() |
|
349
|
|
|
{ |
|
350
|
|
|
return $this->height; |
|
351
|
|
|
} |
|
352
|
|
|
|
|
353
|
|
|
/** |
|
354
|
|
|
* @param int $height |
|
355
|
|
|
* @throws InvalidArgumentException |
|
356
|
|
|
* @return self |
|
357
|
|
|
*/ |
|
358
|
|
|
public function setHeight($height) |
|
359
|
|
|
{ |
|
360
|
|
|
if (!is_int($height) && null !== $height) { |
|
361
|
|
|
throw new InvalidArgumentException('Integer expected for height parameter'); |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
$this->height = $height; |
|
365
|
|
|
|
|
366
|
|
|
return $this; |
|
367
|
|
|
} |
|
368
|
|
|
|
|
369
|
|
|
/** |
|
370
|
|
|
* @return string |
|
371
|
|
|
*/ |
|
372
|
|
|
public function getHref() |
|
373
|
|
|
{ |
|
374
|
|
|
return $this->href; |
|
375
|
|
|
} |
|
376
|
|
|
|
|
377
|
|
|
/** |
|
378
|
|
|
* @param string $href |
|
379
|
|
|
* @throws InvalidArgumentException |
|
380
|
|
|
* @return self |
|
381
|
|
|
*/ |
|
382
|
|
|
public function setHref($href) |
|
383
|
|
|
{ |
|
384
|
|
|
if (!is_string($href) && null !== $href) { |
|
385
|
|
|
throw new InvalidArgumentException('String expected for href parameter'); |
|
386
|
|
|
} |
|
387
|
|
|
|
|
388
|
|
|
$this->href = $href; |
|
389
|
|
|
|
|
390
|
|
|
return $this; |
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
/** |
|
394
|
|
|
* @return string |
|
395
|
|
|
*/ |
|
396
|
|
|
public function getHrefText() |
|
397
|
|
|
{ |
|
398
|
|
|
return $this->hrefText; |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
/** |
|
402
|
|
|
* @param string $hrefText |
|
403
|
|
|
* @throws InvalidArgumentException |
|
404
|
|
|
* @return self |
|
405
|
|
|
*/ |
|
406
|
|
|
public function setHrefText($hrefText) |
|
407
|
|
|
{ |
|
408
|
|
|
if (!is_string($hrefText) && null !== $hrefText) { |
|
409
|
|
|
throw new InvalidArgumentException('String expected for hrefText parameter'); |
|
410
|
|
|
} |
|
411
|
|
|
|
|
412
|
|
|
$this->hrefText = $hrefText; |
|
413
|
|
|
|
|
414
|
|
|
return $this; |
|
415
|
|
|
} |
|
416
|
|
|
|
|
417
|
|
|
/** |
|
418
|
|
|
* @return string |
|
419
|
|
|
*/ |
|
420
|
|
|
public function getLanguage() |
|
421
|
|
|
{ |
|
422
|
|
|
return $this->language; |
|
423
|
|
|
} |
|
424
|
|
|
|
|
425
|
|
|
/** |
|
426
|
|
|
* @param string $language |
|
427
|
|
|
* @throws InvalidArgumentException |
|
428
|
|
|
* @return self |
|
429
|
|
|
*/ |
|
430
|
|
|
public function setLanguage($language) |
|
431
|
|
|
{ |
|
432
|
|
|
if (!is_string($language) && null !== $language) { |
|
433
|
|
|
throw new InvalidArgumentException('String expected for language parameter'); |
|
434
|
|
|
} |
|
435
|
|
|
|
|
436
|
|
|
$this->language = $language; |
|
437
|
|
|
|
|
438
|
|
|
return $this; |
|
439
|
|
|
} |
|
440
|
|
|
|
|
441
|
|
|
/** |
|
442
|
|
|
* @return int |
|
443
|
|
|
*/ |
|
444
|
|
|
public function getWidth() |
|
445
|
|
|
{ |
|
446
|
|
|
return $this->width; |
|
447
|
|
|
} |
|
448
|
|
|
|
|
449
|
|
|
/** |
|
450
|
|
|
* @param int $width |
|
451
|
|
|
* @throws InvalidArgumentException |
|
452
|
|
|
* @return self |
|
453
|
|
|
*/ |
|
454
|
|
|
public function setWidth($width) |
|
455
|
|
|
{ |
|
456
|
|
|
if (!is_int($width) && null !== $width) { |
|
457
|
|
|
throw new InvalidArgumentException('Integer expected for width parameter'); |
|
458
|
|
|
} |
|
459
|
|
|
|
|
460
|
|
|
$this->width = $width; |
|
461
|
|
|
|
|
462
|
|
|
return $this; |
|
463
|
|
|
} |
|
464
|
|
|
} |
|
465
|
|
|
|