1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Thepixeldeveloper\Sitemap\Subelements; |
4
|
|
|
|
5
|
|
|
use Thepixeldeveloper\Sitemap\AppendAttributeInterface; |
6
|
|
|
use Thepixeldeveloper\Sitemap\OutputInterface; |
7
|
|
|
use XMLWriter; |
8
|
|
|
|
9
|
|
|
class Video implements OutputInterface, AppendAttributeInterface |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var |
13
|
|
|
*/ |
14
|
|
|
protected $thumbnailLoc; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var |
18
|
|
|
*/ |
19
|
|
|
protected $title; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var |
23
|
|
|
*/ |
24
|
|
|
protected $description; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var |
28
|
|
|
*/ |
29
|
|
|
protected $contentLoc; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var |
33
|
|
|
*/ |
34
|
|
|
protected $playerLoc; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var |
38
|
|
|
*/ |
39
|
|
|
protected $live; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var |
43
|
|
|
*/ |
44
|
|
|
protected $duration; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var |
48
|
|
|
*/ |
49
|
|
|
protected $platform; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var |
53
|
|
|
*/ |
54
|
|
|
protected $requiresSubscription; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var |
58
|
|
|
*/ |
59
|
|
|
protected $price; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var |
63
|
|
|
*/ |
64
|
|
|
protected $galleryLoc; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var |
68
|
|
|
*/ |
69
|
|
|
protected $restriction; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @var array |
73
|
|
|
*/ |
74
|
|
|
protected $tags = []; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var |
78
|
|
|
*/ |
79
|
|
|
protected $category; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var |
83
|
|
|
*/ |
84
|
|
|
protected $familyFriendly; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var |
88
|
|
|
*/ |
89
|
|
|
protected $publicationDate; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @var |
93
|
|
|
*/ |
94
|
|
|
protected $viewCount; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @var |
98
|
|
|
*/ |
99
|
|
|
protected $uploader; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @var |
103
|
|
|
*/ |
104
|
|
|
protected $rating; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @var |
108
|
|
|
*/ |
109
|
|
|
protected $expirationDate; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Video constructor. |
113
|
|
|
* |
114
|
|
|
* @param $thumbnailLoc |
115
|
|
|
* @param $title |
116
|
|
|
* @param $description |
117
|
|
|
*/ |
118
|
|
|
public function __construct($thumbnailLoc, $title, $description) |
119
|
|
|
{ |
120
|
|
|
$this->thumbnailLoc = $thumbnailLoc; |
121
|
|
|
$this->title = $title; |
122
|
|
|
$this->description = $description; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @return mixed |
127
|
|
|
*/ |
128
|
|
|
public function getPlayerLoc() |
129
|
|
|
{ |
130
|
|
|
return $this->playerLoc; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @param mixed $playerLoc |
135
|
|
|
* |
136
|
|
|
* @return Video |
137
|
|
|
*/ |
138
|
|
|
public function setPlayerLoc($playerLoc) |
139
|
|
|
{ |
140
|
|
|
$this->playerLoc = $playerLoc; |
141
|
|
|
|
142
|
|
|
return $this; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function generateXML(XMLWriter $XMLWriter) |
146
|
|
|
{ |
147
|
|
|
$XMLWriter->startElement('video:video'); |
148
|
|
|
|
149
|
|
|
$XMLWriter->writeElement('video:thumbnail_loc', $this->getThumbnailLoc()); |
150
|
|
|
$XMLWriter->writeElement('video:title', $this->getTitle()); |
151
|
|
|
$XMLWriter->writeElement('video:description', $this->getDescription()); |
152
|
|
|
|
153
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:content_loc', $this->getContentLoc()); |
154
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:player_loc', $this->playerLoc); |
155
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:duration', $this->getDuration()); |
156
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:expiration_date', $this->getExpirationDate()); |
157
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:rating', $this->getRating()); |
158
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:view_count', $this->getViewCount()); |
159
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:publication_date', $this->getPublicationDate()); |
160
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:family_friendly', $this->getFamilyFriendly()); |
161
|
|
|
|
162
|
|
|
foreach ($this->getTags() as $tag) { |
163
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:tag', $tag); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:category', $this->getCategory()); |
167
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:restriction', $this->getRestriction()); |
168
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:gallery_loc', $this->getGalleryLoc()); |
169
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:price', $this->getPrice()); |
170
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:requires_subscription', $this->getRequiresSubscription()); |
171
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:uploader', $this->getUploader()); |
172
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:platform', $this->getPlatform()); |
173
|
|
|
$this->optionalWriteElement($XMLWriter, 'video:live', $this->getLive()); |
174
|
|
|
|
175
|
|
|
$XMLWriter->endElement(); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @return mixed |
180
|
|
|
*/ |
181
|
|
|
public function getThumbnailLoc() |
182
|
|
|
{ |
183
|
|
|
return $this->thumbnailLoc; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @return mixed |
188
|
|
|
*/ |
189
|
|
|
public function getTitle() |
190
|
|
|
{ |
191
|
|
|
return $this->title; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @return mixed |
196
|
|
|
*/ |
197
|
|
|
public function getDescription() |
198
|
|
|
{ |
199
|
|
|
return $this->description; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @param XMLWriter $XMLWriter |
204
|
|
|
* @param string $name |
205
|
|
|
* @param string $value |
206
|
|
|
*/ |
207
|
|
|
protected function optionalWriteElement(XMLWriter $XMLWriter, $name, $value) |
208
|
|
|
{ |
209
|
|
|
if ($value) { |
210
|
|
|
$XMLWriter->writeElement($name, $value); |
211
|
|
|
} |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @return mixed |
216
|
|
|
*/ |
217
|
|
|
public function getContentLoc() |
218
|
|
|
{ |
219
|
|
|
return $this->contentLoc; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* @param mixed $contentLoc |
224
|
|
|
* |
225
|
|
|
* @return Video |
226
|
|
|
*/ |
227
|
|
|
public function setContentLoc($contentLoc) |
228
|
|
|
{ |
229
|
|
|
$this->contentLoc = $contentLoc; |
230
|
|
|
|
231
|
|
|
return $this; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* @return mixed |
236
|
|
|
*/ |
237
|
|
|
public function getDuration() |
238
|
|
|
{ |
239
|
|
|
return $this->duration; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* @param mixed $duration |
244
|
|
|
* |
245
|
|
|
* @return Video |
246
|
|
|
*/ |
247
|
|
|
public function setDuration($duration) |
248
|
|
|
{ |
249
|
|
|
$this->duration = $duration; |
250
|
|
|
|
251
|
|
|
return $this; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* @return mixed |
256
|
|
|
*/ |
257
|
|
|
public function getExpirationDate() |
258
|
|
|
{ |
259
|
|
|
return $this->expirationDate; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @param mixed $expirationDate |
264
|
|
|
* |
265
|
|
|
* @return Video |
266
|
|
|
*/ |
267
|
|
|
public function setExpirationDate($expirationDate) |
268
|
|
|
{ |
269
|
|
|
$this->expirationDate = $expirationDate; |
270
|
|
|
|
271
|
|
|
return $this; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* @return mixed |
276
|
|
|
*/ |
277
|
|
|
public function getRating() |
278
|
|
|
{ |
279
|
|
|
return $this->rating; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* @param mixed $rating |
284
|
|
|
* |
285
|
|
|
* @return Video |
286
|
|
|
*/ |
287
|
|
|
public function setRating($rating) |
288
|
|
|
{ |
289
|
|
|
$this->rating = $rating; |
290
|
|
|
|
291
|
|
|
return $this; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* @return mixed |
296
|
|
|
*/ |
297
|
|
|
public function getViewCount() |
298
|
|
|
{ |
299
|
|
|
return $this->viewCount; |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* @param mixed $viewCount |
304
|
|
|
* |
305
|
|
|
* @return Video |
306
|
|
|
*/ |
307
|
|
|
public function setViewCount($viewCount) |
308
|
|
|
{ |
309
|
|
|
$this->viewCount = $viewCount; |
310
|
|
|
|
311
|
|
|
return $this; |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
/** |
315
|
|
|
* @return mixed |
316
|
|
|
*/ |
317
|
|
|
public function getPublicationDate() |
318
|
|
|
{ |
319
|
|
|
return $this->publicationDate; |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* @param mixed $publicationDate |
324
|
|
|
* |
325
|
|
|
* @return Video |
326
|
|
|
*/ |
327
|
|
|
public function setPublicationDate($publicationDate) |
328
|
|
|
{ |
329
|
|
|
$this->publicationDate = $publicationDate; |
330
|
|
|
|
331
|
|
|
return $this; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* @return mixed |
336
|
|
|
*/ |
337
|
|
|
public function getFamilyFriendly() |
338
|
|
|
{ |
339
|
|
|
return $this->familyFriendly; |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
/** |
343
|
|
|
* @param mixed $familyFriendly |
344
|
|
|
* |
345
|
|
|
* @return Video |
346
|
|
|
*/ |
347
|
|
|
public function setFamilyFriendly($familyFriendly) |
348
|
|
|
{ |
349
|
|
|
$this->familyFriendly = $familyFriendly; |
350
|
|
|
|
351
|
|
|
return $this; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
/** |
355
|
|
|
* @return array |
356
|
|
|
*/ |
357
|
|
|
public function getTags() |
358
|
|
|
{ |
359
|
|
|
return $this->tags; |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
/** |
363
|
|
|
* @param array $tags |
364
|
|
|
* |
365
|
|
|
* @return Video |
366
|
|
|
*/ |
367
|
|
|
public function setTags($tags) |
368
|
|
|
{ |
369
|
|
|
$this->tags = $tags; |
370
|
|
|
|
371
|
|
|
return $this; |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* @return mixed |
376
|
|
|
*/ |
377
|
|
|
public function getCategory() |
378
|
|
|
{ |
379
|
|
|
return $this->category; |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* @param mixed $category |
384
|
|
|
* |
385
|
|
|
* @return Video |
386
|
|
|
*/ |
387
|
|
|
public function setCategory($category) |
388
|
|
|
{ |
389
|
|
|
$this->category = $category; |
390
|
|
|
|
391
|
|
|
return $this; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
/** |
395
|
|
|
* @return mixed |
396
|
|
|
*/ |
397
|
|
|
public function getRestriction() |
398
|
|
|
{ |
399
|
|
|
return $this->restriction; |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
/** |
403
|
|
|
* @param mixed $restriction |
404
|
|
|
* |
405
|
|
|
* @return Video |
406
|
|
|
*/ |
407
|
|
|
public function setRestriction($restriction) |
408
|
|
|
{ |
409
|
|
|
$this->restriction = $restriction; |
410
|
|
|
|
411
|
|
|
return $this; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* @return mixed |
416
|
|
|
*/ |
417
|
|
|
public function getGalleryLoc() |
418
|
|
|
{ |
419
|
|
|
return $this->galleryLoc; |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* @param mixed $galleryLoc |
424
|
|
|
* |
425
|
|
|
* @return Video |
426
|
|
|
*/ |
427
|
|
|
public function setGalleryLoc($galleryLoc) |
428
|
|
|
{ |
429
|
|
|
$this->galleryLoc = $galleryLoc; |
430
|
|
|
|
431
|
|
|
return $this; |
432
|
|
|
} |
433
|
|
|
|
434
|
|
|
/** |
435
|
|
|
* @return mixed |
436
|
|
|
*/ |
437
|
|
|
public function getPrice() |
438
|
|
|
{ |
439
|
|
|
return $this->price; |
440
|
|
|
} |
441
|
|
|
|
442
|
|
|
/** |
443
|
|
|
* @param mixed $price |
444
|
|
|
* |
445
|
|
|
* @return Video |
446
|
|
|
*/ |
447
|
|
|
public function setPrice($price) |
448
|
|
|
{ |
449
|
|
|
$this->price = $price; |
450
|
|
|
|
451
|
|
|
return $this; |
452
|
|
|
} |
453
|
|
|
|
454
|
|
|
/** |
455
|
|
|
* @return mixed |
456
|
|
|
*/ |
457
|
|
|
public function getRequiresSubscription() |
458
|
|
|
{ |
459
|
|
|
return $this->requiresSubscription; |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
/** |
463
|
|
|
* @param mixed $requiresSubscription |
464
|
|
|
* |
465
|
|
|
* @return Video |
466
|
|
|
*/ |
467
|
|
|
public function setRequiresSubscription($requiresSubscription) |
468
|
|
|
{ |
469
|
|
|
$this->requiresSubscription = $requiresSubscription; |
470
|
|
|
|
471
|
|
|
return $this; |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
/** |
475
|
|
|
* @return mixed |
476
|
|
|
*/ |
477
|
|
|
public function getUploader() |
478
|
|
|
{ |
479
|
|
|
return $this->uploader; |
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
/** |
483
|
|
|
* @param mixed $uploader |
484
|
|
|
* |
485
|
|
|
* @return Video |
486
|
|
|
*/ |
487
|
|
|
public function setUploader($uploader) |
488
|
|
|
{ |
489
|
|
|
$this->uploader = $uploader; |
490
|
|
|
|
491
|
|
|
return $this; |
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
/** |
495
|
|
|
* @return mixed |
496
|
|
|
*/ |
497
|
|
|
public function getPlatform() |
498
|
|
|
{ |
499
|
|
|
return $this->platform; |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
/** |
503
|
|
|
* @param mixed $platform |
504
|
|
|
* |
505
|
|
|
* @return Video |
506
|
|
|
*/ |
507
|
|
|
public function setPlatform($platform) |
508
|
|
|
{ |
509
|
|
|
$this->platform = $platform; |
510
|
|
|
|
511
|
|
|
return $this; |
512
|
|
|
} |
513
|
|
|
|
514
|
|
|
/** |
515
|
|
|
* @return mixed |
516
|
|
|
*/ |
517
|
|
|
public function getLive() |
518
|
|
|
{ |
519
|
|
|
return $this->live; |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* @param mixed $live |
524
|
|
|
* |
525
|
|
|
* @return Video |
526
|
|
|
*/ |
527
|
|
|
public function setLive($live) |
528
|
|
|
{ |
529
|
|
|
$this->live = $live; |
530
|
|
|
|
531
|
|
|
return $this; |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
/** |
535
|
|
|
* @param XMLWriter $XMLWriter |
536
|
|
|
*/ |
537
|
|
|
public function appendAttributeToCollectionXML(XMLWriter $XMLWriter) |
538
|
|
|
{ |
539
|
|
|
$XMLWriter->writeAttribute('xmlns:video', 'http://www.google.com/schemas/sitemap-video/1.1'); |
540
|
|
|
} |
541
|
|
|
} |
542
|
|
|
|