forked from Wikia/EmbedVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmbedVideo.hooks.php
819 lines (714 loc) · 22.7 KB
/
EmbedVideo.hooks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
<?php
use MediaWiki\MediaWikiServices;
/**
* EmbedVideo
* EmbedVideo Hooks
*
* @license MIT
* @package EmbedVideo
* @link https://www.mediawiki.org/wiki/Extension:EmbedVideo
**/
class EmbedVideoHooks {
/**
* Temporary storage for the current service object.
*
* @var object
*/
static private $service;
/**
* Description Parameter
*
* @var string
*/
static private $description = false;
/**
* Alignment Parameter
*
* @var string
*/
static private $alignment = false;
/**
* Alignment Parameter
*
* @var string
*/
static private $vAlignment = false;
/**
* Container Parameter
*
* @var string
*/
static private $container = false;
/**
* Valid Arguments for the parseEV function hook.
*
* @var array
*/
static private $validArguments = [
'service' => null,
'id' => null,
'defaultid' => null,
'dimensions' => null,
'alignment' => null,
'description' => null,
'container' => null,
'urlargs' => null,
'autoresize' => null,
'valignment' => null
];
/**
* Hook to setup defaults.
*
* @access public
* @return void
*/
public static function onExtension() {
global $wgEmbedVideoDefaultWidth, $wgMediaHandlers, $wgFileExtensions;
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig('main');
if (!isset($wgEmbedVideoDefaultWidth) && (isset($_SERVER['HTTP_X_MOBILE']) && $_SERVER['HTTP_X_MOBILE'] == 'true') && $_COOKIE['stopMobileRedirect'] != 1) {
// Set a smaller default width when in mobile view.
$wgEmbedVideoDefaultWidth = 320;
}
if ($config->get('EmbedVideoEnableAudioHandler')) {
$wgMediaHandlers['application/ogg'] = 'EmbedVideo\AudioHandler';
$wgMediaHandlers['audio/flac'] = 'EmbedVideo\AudioHandler';
$wgMediaHandlers['audio/ogg'] = 'EmbedVideo\AudioHandler';
$wgMediaHandlers['audio/mpeg'] = 'EmbedVideo\AudioHandler';
$wgMediaHandlers['audio/mp4'] = 'EmbedVideo\AudioHandler';
$wgMediaHandlers['audio/wav'] = 'EmbedVideo\AudioHandler';
$wgMediaHandlers['audio/webm'] = 'EmbedVideo\AudioHandler';
$wgMediaHandlers['audio/x-flac'] = 'EmbedVideo\AudioHandler';
}
if ($config->get('EmbedVideoEnableVideoHandler')) {
$wgMediaHandlers['video/mp4'] = 'EmbedVideo\VideoHandler';
$wgMediaHandlers['video/ogg'] = 'EmbedVideo\VideoHandler';
$wgMediaHandlers['video/quicktime'] = 'EmbedVideo\VideoHandler';
$wgMediaHandlers['video/webm'] = 'EmbedVideo\VideoHandler';
$wgMediaHandlers['video/x-matroska'] = 'EmbedVideo\VideoHandler';
}
if ($config->get('EmbedVideoAddFileExtensions')) {
$wgFileExtensions[] = 'flac';
$wgFileExtensions[] = 'mkv';
$wgFileExtensions[] = 'mov';
$wgFileExtensions[] = 'mp3';
$wgFileExtensions[] = 'mp4';
$wgFileExtensions[] = 'oga';
$wgFileExtensions[] = 'ogg';
$wgFileExtensions[] = 'ogv';
$wgFileExtensions[] = 'wav';
$wgFileExtensions[] = 'webm';
}
}
/**
* Sets up this extension's parser functions.
*
* @access public
* @param Parser $parser Parser object passed as a reference.
* @return boolean true
*/
public static function onParserFirstCallInit(Parser &$parser) {
$parser->setFunctionHook("ev", "EmbedVideoHooks::parseEV");
$parser->setFunctionHook("evt", "EmbedVideoHooks::parseEVT");
$parser->setFunctionHook("evp", "EmbedVideoHooks::parseEVP");
$parser->setFunctionHook("evu", "EmbedVideoHooks::parseEVU");
$parser->setHook("embedvideo", "EmbedVideoHooks::parseEVTag");
$parser->setHook('evlplayer', "EmbedVideoHooks::parseEVLPlayer");
$parser->setFunctionHook('evl', "EmbedVideoHooks::parseEVL");
// don't step on VideoLink's toes.
if (!class_exists('FXVideoLink')) {
$parser->setHook('vplayer', "EmbedVideoHooks::parseEVLPlayer");
$parser->setFunctionHook('vlink', "EmbedVideoHooks::parseEVL");
}
// smart handling of service name tags (if they aren't already implamented)
$tags = $parser->getTags();
$services = \EmbedVideo\VideoService::getAvailableServices();
$create = array_diff($services, $tags);
// We now have a list of services we can create tags for that aren't already implamented
foreach ($create as $service) {
$parser->setHook($service, "EmbedVideoHooks::parseServiceTag{$service}");
}
return true;
}
/**
* Handle passing parseServiceTagSERVICENAME to the parseServiceTag method.
*
* @param string $name
* @param array $args
* @return mixed
*/
public static function __callStatic($name, $args) {
if (substr($name, 0, 15) == "parseServiceTag") {
$service = str_replace("parseServiceTag", "", $name);
return self::parseServiceTag($service, $args[0], $args[1], $args[2], $args[3]);
}
}
/**
* Parse tag with service name
*
* @access public
* @param string $service
* @param string $input Raw User Input
* @param array $args Arguments on the tag.
* @param Parser $parser Parser object.
* @param PPFrame $frame PPFrame object.
* @return array Error Message
*/
public static function parseServiceTag($service, $input, array $args, Parser $parser, PPFrame $frame) {
$args = array_merge(self::$validArguments, $args);
// accept input as default, but also allow url param.
if (empty($input) && isset($args['url'])) {
$input = $args['url'];
}
return self::parseEV(
$parser,
$service,
$input,
$args['dimensions'],
$args['alignment'],
$args['description'],
$args['container'],
$args['urlargs'],
$args['autoresize'],
$args['valignment']
);
}
/**
* Parse EVL (and vlink) Tags
*
* @param Parser $parser
* @return array
*/
public static function parseEVL(Parser &$parser) {
$args = func_get_args();
array_shift($args);
// handle comma separated video id list
$ids = explode(',', $args[0]);
$id = isset($args[2]) && is_numeric($args[2]) ? $args[2] - 1 : false;
$video = $id !== false && isset($ids[$id]) ? $ids[$id] : array_shift($ids);
// standardize first 2 arguments into strings that parse_str can handle.
$args[0] = "id=" . $video;
$args[1] = "linktitle=" . $args[1];
$options = [];
parse_str(implode("&", $args), $options);
// default service to youtube for compatibility with vlink
$options['service'] = isset($options['service']) ? $options['service'] : "youtube";
// force to youtubevidelink or youtube if video list is provided
if (count($ids) > 0) {
if ($options['service'] != 'youtube' && $options['service'] != 'youtubevideolist') {
$options['notice'] = "The video list feature only works with the youtube service. Your service is being overridden.";
}
$options['service'] = count($ids) > 0 && $id === false ? "youtubevideolist" : "youtube";
}
$options = array_merge(self::$validArguments, $options);
// fix for youtube ids that VideoLink would have handled.
if ($options['service'] == 'youtube' && strpos($options['id'], ';') !== false) {
// transform input like Oh8KRy2WV0o;C5rePhJktn0 into Oh8KRy2WV0o
$options['notice'] = "Use of semicolon delimited video lists is deprecated. Only the first video in this list will play.";
$options['id'] = strstr($options['id'], ';', true);
}
// force start time on youtube videos from "start".
if ($options['service'] == 'youtube' && isset($options['start']) && preg_match('/^([0-9]+:){0,2}[0-9]+(?:\.[0-9]+)?$/', $options['start'])) {
$te = explode(':', $options['start']);
$tc = count($te);
for ($i = 1, $startTime = floatval($te[0]); $i < $tc; $i++) {
$startTime = $startTime * 60 + floatval($te[$i]);
}
if (!isset($options['urlargs']) || empty($options['urlargs'])) {
// just set the url args to the start time string
$options['urlargs'] = "start={$startTime}";
} else {
// break down the url args and inject the start time in.
$urlargs = [];
parse_str($options['urlargs'], $urlargs);
$urlargs['start'] = $startTime;
$options['urlargs'] = http_build_query($urlargs);
}
}
// handle adding playlist for video links for a play all link
if ($options['service'] == 'youtubevideolist' && count($ids) > 0) {
$playlist = implode(',', $ids);
if (!isset($options['urlargs']) || empty($options['urlargs'])) {
// just set the url args to the playlist
$options['urlargs'] = "playlist={$playlist}";
} else {
// break down the url args and inject the playlist.
$urlargs = [];
parse_str($options['urlargs'], $urlargs);
$urlargs['playlist'] = $playlist;
$options['urlargs'] = http_build_query($urlargs);
}
}
if ($options['linktitle'] == "") {
$options['linktitle'] = wfMessage('ev_default_play_desc')->text();
}
$json = json_encode($options);
$link = Xml::element('a', [
'href' => '#',
'data-video-json' => $json,
'class' => 'embedvideo-evl vplink'
], $options['linktitle']);
$parser->getOutput()->addModules(['ext.embedVideo-evl', 'ext.embedVideo.styles']);
return [$link, 'noparse' => true, 'isHTML' => true];
}
/**
* Parse EVLPlayer (and vplayer) Tags
*
* @param string $input
* @param array $args
* @param Parser $parser
* @param PPFrame $frame
* @return array
*/
public static function parseEVLPlayer($input, array $args, Parser $parser, PPFrame $frame) {
$args = array_merge(self::$validArguments, $args);
$pid = isset($args['id']) ? $args['id'] : 'default';
$w = min(2000, max(240, isset($args['w']) ? (int)$args['w'] : 800));
$h = min(1200, max(80, isset($args['h']) ? (int)$args['h'] : (9 * $w / 16)));
$style = isset($args['style']) ? ' ' . $args['style'] : '';
$class = isset($args['class']) ? ' ' . $args['class'] : '';
if ($args['defaultid'] && $args['service']) {
// so we don't have to deal with any screwy parsing of tags by the HTML class.
$input = "DEFAULT PLAYER REPLACEMENT";
}
// Parse internal content
$content = $parser->recursiveTagParse($input, $frame);
$div = Html::rawElement('div', [
'id' => 'vplayerbox-' . $pid,
'class' => 'embedvideo-evlbox vplayerbox' . $class,
'data-size' => $w . 'x' . $h,
'style' => $style,
], $content);
if ($args['defaultid'] && $args['service']) {
$new = self::parseEV(
$parser,
$args['service'],
$args['defaultid'],
"${w}x${h}",
$args['alignment'],
$args['description'],
$args['container'],
$args['urlargs'],
$args['autoresize'],
$args['valignment']
)[0];
// replace the default content with the new content
$div = str_replace($content, $new, $div);
}
return [$div, 'noparse' => true, 'isHTML' => true];
}
/**
* Embeds a video based on the URL
*
* @access public
* @param Parser $parser
* @param string|null $url
* @return array Error Message
*/
public static function parseEVU($parser, $url = null) {
if (!$url) {
return self::error('missingparams', $url);
}
$host = parse_url($url, PHP_URL_HOST);
$host = strtolower($host);
$host = str_ireplace('www.', '', $host); // strip www from any hostname.
$map = \EmbedVideo\VideoService::getServiceHostMap();
$service = false;
if (isset($map[$host])) {
if (!is_array($map[$host])) {
// only one possible answer. Set it.
$service = $map[$host];
} else {
// map by array.
foreach ($map[$host] as $possibleService) {
$evs = \EmbedVideo\VideoService::newFromName($possibleService);
if ($evs) {
$test = $evs->parseVideoID($url);
if ($test !== false && $test !== $url) {
// successful parse - safe assumption that this is correct.
$service = $possibleService;
break;
}
}
}
}
} else {
return self::error('cantdecode_evu', $url);
}
if (!$service) {
return self::error('cantdecode_evu', $url);
}
$arguments = func_get_args();
array_shift($arguments);
$args = [];
foreach ($arguments as $argumentPair) {
$argumentPair = trim($argumentPair);
if (!strpos($argumentPair, '=')) {
continue;
}
list( $key, $value ) = explode('=', $argumentPair, 2);
if (!array_key_exists($key, self::$validArguments)) {
continue;
}
$args[$key] = $value;
}
$args = array_merge(self::$validArguments, $args);
return self::parseEV(
$parser,
$service,
$url,
$args['dimensions'],
$args['alignment'],
$args['description'],
$args['container'],
$args['urlargs'],
$args['autoresize'],
$args['valignment']
);
}
/**
* Adapter to call the new style tag.
*
* @access public
* @param object Parser
* @return array Error Message
*/
public static function parseEVP($parser) {
wfDeprecated(__METHOD__, '2.0', 'EmbedVideo');
return self::error('evp_deprecated');
}
/**
* Adapter to call the EV parser tag with template like calls.
*
* @access public
* @param object Parser
* @return array Error Message
*/
public static function parseEVT($parser) {
$arguments = func_get_args();
array_shift($arguments);
$args = [];
foreach ($arguments as $argumentPair) {
$argumentPair = trim($argumentPair);
if (!strpos($argumentPair, '=')) {
continue;
}
list( $key, $value ) = explode('=', $argumentPair, 2);
if (!array_key_exists($key, self::$validArguments)) {
continue;
}
$args[$key] = $value;
}
$args = array_merge(self::$validArguments, $args);
return self::parseEV(
$parser,
$args['service'],
$args['id'],
$args['dimensions'],
$args['alignment'],
$args['description'],
$args['container'],
$args['urlargs'],
$args['autoresize'],
$args['valignment']
);
}
/**
* Adapter to call the parser hook.
*
* @access public
* @param string $input Raw User Input
* @param array $args Arguments on the tag.
* @param Parser $parser Parser object.
* @param PPFrame $frame PPFrame object.
* @return array Error Message
*/
public static function parseEVTag($input, array $args, Parser $parser, PPFrame $frame) {
$args = array_merge(self::$validArguments, $args);
return self::parseEV(
$parser,
$args['service'],
$input,
$args['dimensions'],
$args['alignment'],
$args['description'],
$args['container'],
$args['urlargs'],
$args['autoresize'],
$args['valignment']
);
}
/**
* Embeds a video of the chosen service.
*
* @access public
* @param Parser $parser Parser
* @param ?string $service [Optional] Which online service has the video.
* @param ?string $id [Optional] Identifier Code or URL for the video on the service.
* @param ?string $dimensions [Optional] Dimensions of video
* @param ?string $alignment [Optional] Horizontal Alignment of the embed container.
* @param ?string $description [Optional] Description to show
* @param ?string $container [Optional] Container to use.(Frame is currently the only option.)
* @param ?string $urlArgs [Optional] Extra URL Arguments
* @param ?string $autoResize [Optional] Automatically Resize video that will break its parent container.
* @param ?string $vAlignment [Optional] Vertical Alignment of the embed container.
* @return array Encoded representation of input params (to be processed later)
*/
public static function parseEV($parser, $service = null, $id = null, $dimensions = null, $alignment = null, $description = null, $container = null, $urlArgs = null, $autoResize = null, $vAlignment = null) {
self::resetParameters();
$service = trim($service);
$id = trim($id);
$alignment = trim($alignment);
$description = trim($description);
$dimensions = trim($dimensions);
$urlArgs = trim($urlArgs);
$width = null;
$height = null;
$autoResize = (isset($autoResize) && strtolower(trim($autoResize)) == "false") ? false : true;
$vAlignment = trim($vAlignment);
// I am not using $parser->parseWidthParam() since it can not handle height only. Example: x100
if (stristr($dimensions, 'x')) {
$dimensions = strtolower($dimensions);
list( $width, $height ) = explode('x', $dimensions);
} elseif (is_numeric($dimensions)) {
$width = $dimensions;
}
/************************************/
/* Twitch Fixes */
/************************************/
// Add parent attribute for Twitch embeds
if ($service == 'twitch' || $service == 'twitchclip' || $service == 'twitchvod') {
global $wgServerName;
if (!isset($urlArgs) || empty($urlArgs)) {
// Set the url args to the parent domain
$urlArgs = "parent=$wgServerName";
} else {
// Break down the url args and inject the parent
$urlargsArr = [];
parse_str($urlArgs, $urlargsArr);
$urlargsArr['parent'] = $wgServerName;
$urlArgs = http_build_query($urlargsArr);
}
}
/************************************/
/* Error Checking */
/************************************/
if (!$service || !$id) {
return self::error('missingparams', $service, $id);
}
self::$service = \EmbedVideo\VideoService::newFromName($service);
if (!self::$service) {
return self::error('service', $service);
}
// Let the service automatically handle bad dimensional values.
self::$service->setWidth($width);
self::$service->setHeight($height);
// If the service has an ID pattern specified, verify the id number.
if (!self::$service->setVideoID($id)) {
return self::error('id', $service, $id);
}
if (!self::$service->setUrlArgs($urlArgs)) {
return self::error('urlargs', $service, $urlArgs);
}
if (!is_null($parser)) {
self::setDescription($description, $parser);
} else {
self::setDescriptionNoParse($description);
}
if (!self::setContainer($container)) {
return self::error('container', $container);
}
if (!self::setAlignment($alignment)) {
return self::error('alignment', $alignment);
}
if (!self::setVerticalAlignment($vAlignment)) {
return self::error('valignment', $vAlignment);
}
/************************************/
/* HMTL Generation */
/************************************/
$html = self::$service->getHtml();
if (!$html) {
return self::error('unknown', $service);
}
if ($autoResize) {
$html = self::generateWrapperHTML($html, null, "autoResize");
} else {
$html = self::generateWrapperHTML($html);
}
if ($parser) {
// dont call this if parser is null (such as in API usage).
$out = $parser->getOutput();
$out->addModules('ext.embedVideo');
$out->addModuleStyles('ext.embedVideo.styles');
}
return [
$html,
'noparse' => true,
'isHTML' => true
];
}
/**
* Generate the HTML necessary to embed the video with the given alignment
* and text description
*
* @access private
* @param string [Optional] Horizontal Alignment
* @param string [Optional] Description
* @param string [Optional] Additional Classes to add to the wrapper
* @return string
*/
private static function generateWrapperHTML($html, $description = null, $addClass = null) {
$classString = "embedvideo";
$styleString = "";
$innerClassString = "embedvideowrap";
$outerClassString = "embedvideo ";
if (self::getContainer() == 'frame') {
$classString .= " thumbinner";
}
if (self::getAlignment() !== false) {
$outerClassString .= " ev_" . self::getAlignment() . " ";
$styleString .= " width: " . (self::$service->getWidth() + 6) . "px;";
}
if (self::getVerticalAlignment() !== false) {
$outerClassString .= " ev_" . self::getVerticalAlignment() . " ";
}
if ($addClass) {
$classString .= " " . $addClass;
$outerClassString .= $addClass;
}
$html = "<div class='thumb $outerClassString' style='width: " . (self::$service->getWidth() + 8) . "px;'><div class='" . $classString . "' style='" . $styleString . "'><div class='" . $innerClassString . "' style='width: " . self::$service->getWidth() . "px;'>{$html}</div>" . (self::getDescription() !== false ? "<div class='thumbcaption'>" . self::getDescription() . "</div>" : null) . "</div></div>";
return $html;
}
/**
* Return the alignment parameter.
*
* @access public
* @return mixed Alignment or false for not set.
*/
private static function getAlignment() {
return self::$alignment;
}
/**
* Set the align parameter.
*
* @access private
* @param string Alignment Parameter
* @return boolean Valid
*/
private static function setAlignment($alignment) {
if (!empty($alignment) && ($alignment == 'left' || $alignment == 'right' || $alignment == 'center' || $alignment == 'inline')) {
self::$alignment = $alignment;
} elseif (!empty($alignment)) {
return false;
}
return true;
}
/**
* Return the valignment parameter.
*
* @access public
* @return mixed Vertical Alignment or false for not set.
*/
private static function getVerticalAlignment() {
return self::$vAlignment;
}
/**
* Set the align parameter.
*
* @access private
* @param string Alignment Parameter
* @return boolean Valid
*/
private static function setVerticalAlignment($vAlignment) {
if (!empty($vAlignment) && ($vAlignment == 'top' || $vAlignment == 'middle' || $vAlignment == 'bottom' || $vAlignment == 'baseline')) {
if ($vAlignment != 'baseline') {
self::$alignment = 'inline';
}
self::$vAlignment = $vAlignment;
} elseif (!empty($vAlignment)) {
return false;
}
return true;
}
/**
* Return description text.
*
* @access private
* @return mixed String description or false for not set.
*/
private static function getDescription() {
return self::$description;
}
/**
* Set the description.
*
* @access private
* @param string $description Description
* @param \Parser $parser Mediawiki Parser object
* @return void
*/
private static function setDescription($description, \Parser $parser) {
self::$description = (!$description ? false : $parser->recursiveTagParse($description));
}
/**
* Set the description without using the parser
*
* @param string Description
*/
private static function setDescriptionNoParse($description) {
self::$description = (!$description ? false : $description);
}
/**
* Return container type.
*
* @access private
* @return mixed String container type or false for not set.
*/
private static function getContainer() {
return self::$container;
}
/**
* Set the container type.
*
* @access private
* @param string Container
* @return boolean Success
*/
private static function setContainer($container) {
if (!empty($container) && ($container == 'frame')) {
self::$container = $container;
} elseif (!empty($container)) {
return false;
}
return true;
}
/**
* Reset parameters between parses.
*
* @access private
* @return void
*/
private static function resetParameters() {
self::$description = false;
self::$alignment = false;
self::$container = false;
}
/**
* Error Handler
*
* @access private
* @param string [Optional] Error Type
* @param mixed [...] Multiple arguments to be retrieved with func_get_args().
* @return array Printable Error Message
*/
private static function error($type = 'unknown') {
$arguments = func_get_args();
array_shift($arguments);
$message = wfMessage('error_embedvideo_' . $type, $arguments)->escaped();
return [
"<div class='errorbox'>{$message}</div>",
'noparse' => true,
'isHTML' => true
];
}
}