1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Plugin\BbcodeParser\src\Lib\jBBCode\Definitions; |
4
|
|
|
|
5
|
|
|
use Plugin\BbcodeParser\src\Lib\Helper\UrlParserTrait; |
6
|
|
|
use Plugin\BbcodeParser\src\Lib\jBBCode\Definitions\CodeDefinition; |
7
|
|
|
|
8
|
|
|
//@codingStandardsIgnoreStart |
9
|
|
View Code Duplication |
class Html5Audio extends CodeDefinition |
|
|
|
|
10
|
|
|
//@codingStandardsIgnoreEnd |
11
|
|
|
{ |
12
|
|
|
use UrlParserTrait; |
13
|
|
|
|
14
|
|
|
protected $_sTagName = 'audio'; |
15
|
|
|
|
16
|
|
|
protected $_sParseContent = false; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* {@inheritDoc} |
20
|
|
|
*/ |
21
|
|
|
protected function _parse($content, $attributes, \JBBCode\ElementNode $node) |
22
|
|
|
{ |
23
|
|
|
if (!empty($attributes['src']) && $attributes['src'] === 'upload') { |
24
|
|
|
$content = $this->_linkToUploadedFile($content); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
// Better: preload='metadata'. But Safari 12 doesn't support it. |
28
|
|
|
return "<audio src='$content' controls='controls' preload='auto' x-webkit-airplay='allow'></audio>"; |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
//@codingStandardsIgnoreStart |
33
|
|
|
class Html5AudioWithAttributes extends Html5Audio |
34
|
|
|
//@codingStandardsIgnoreEnd |
35
|
|
|
{ |
36
|
|
|
protected $_sUseOptions = true; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
//@codingStandardsIgnoreStart |
40
|
|
View Code Duplication |
class Html5Video extends CodeDefinition |
|
|
|
|
41
|
|
|
//@codingStandardsIgnoreEnd |
42
|
|
|
{ |
43
|
|
|
use UrlParserTrait; |
44
|
|
|
|
45
|
|
|
protected $_sTagName = 'video'; |
46
|
|
|
|
47
|
|
|
protected $_sParseContent = false; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritDoc} |
51
|
|
|
*/ |
52
|
|
|
protected function _parse($content, $attributes, \JBBCode\ElementNode $node) |
53
|
|
|
{ |
54
|
|
|
if (!empty($attributes['src']) && $attributes['src'] === 'upload') { |
55
|
|
|
$content = $this->_linkToUploadedFile($content); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
// Better: preload='metadata'. But Safari 12 doesn't support it and |
59
|
|
|
// only shows a blank preview. |
60
|
|
|
return "<video src='$content' controls='controls' preload='auto' x-webkit-airplay='allow'></video>"; |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
//@codingStandardsIgnoreStart |
65
|
|
|
class Html5VideoWithAttributes extends Html5Video |
66
|
|
|
//@codingStandardsIgnoreEnd |
67
|
|
|
{ |
68
|
|
|
protected $_sUseOptions = true; |
69
|
|
|
} |
70
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.