1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Saito - The Threaded Web Forum |
6
|
|
|
* |
7
|
|
|
* @copyright Copyright (c) the Saito Project Developers |
8
|
|
|
* @link https://github.com/Schlaefer/Saito |
9
|
|
|
* @license http://opensource.org/licenses/MIT |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace BbcodeParser\Lib\jBBCode\Definitions; |
13
|
|
|
|
14
|
|
|
use BbcodeParser\Lib\Helper\UrlParserTrait; |
15
|
|
|
|
16
|
|
|
//@codingStandardsIgnoreStart |
17
|
|
|
class Html5Audio extends CodeDefinition |
18
|
|
|
//@codingStandardsIgnoreEnd |
19
|
|
|
{ |
20
|
|
|
use UrlParserTrait; |
21
|
|
|
|
22
|
|
|
protected $_sTagName = 'audio'; |
23
|
|
|
|
24
|
|
|
protected $_sParseContent = false; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inheritDoc} |
28
|
|
|
*/ |
29
|
|
|
protected function _parse($content, $attributes, \JBBCode\ElementNode $node) |
30
|
|
|
{ |
31
|
|
|
if (!empty($attributes['src']) && $attributes['src'] === 'upload') { |
32
|
|
|
$content = $this->_linkToUploadedFile($content); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
// Better: preload='metadata'. But Safari 12 doesn't support it. |
36
|
|
|
return "<audio src='$content' controls='controls' preload='auto' x-webkit-airplay='allow'></audio>"; |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
//@codingStandardsIgnoreStart |
41
|
|
|
class Html5AudioWithAttributes extends Html5Audio |
42
|
|
|
//@codingStandardsIgnoreEnd |
43
|
|
|
{ |
44
|
|
|
protected $_sUseOptions = true; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
//@codingStandardsIgnoreStart |
48
|
|
|
class Html5Video extends CodeDefinition |
49
|
|
|
//@codingStandardsIgnoreEnd |
50
|
|
|
{ |
51
|
|
|
use UrlParserTrait; |
52
|
|
|
|
53
|
|
|
protected $_sTagName = 'video'; |
54
|
|
|
|
55
|
|
|
protected $_sParseContent = false; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* {@inheritDoc} |
59
|
|
|
*/ |
60
|
|
|
protected function _parse($content, $attributes, \JBBCode\ElementNode $node) |
61
|
|
|
{ |
62
|
|
|
if (!empty($attributes['src']) && $attributes['src'] === 'upload') { |
63
|
|
|
$content = $this->_linkToUploadedFile($content); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
// Better: preload='metadata'. But Safari 12 doesn't support it and |
67
|
|
|
// only shows a blank preview. |
68
|
|
|
return "<video src='$content' controls='controls' preload='auto' x-webkit-airplay='allow'></video>"; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
//@codingStandardsIgnoreStart |
73
|
|
|
class Html5VideoWithAttributes extends Html5Video |
74
|
|
|
//@codingStandardsIgnoreEnd |
75
|
|
|
{ |
76
|
|
|
protected $_sUseOptions = true; |
77
|
|
|
} |
78
|
|
|
|