1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Xoops\Core\Text\Sanitizer\Extensions; |
13
|
|
|
|
14
|
|
|
use Xoops\Core\Text\Sanitizer; |
15
|
|
|
use Xoops\Core\Text\Sanitizer\ExtensionAbstract; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Sanitizer extension for rtsp, real player |
19
|
|
|
* |
20
|
|
|
* @category Sanitizer |
21
|
|
|
* @package Xoops\Core\Text |
22
|
|
|
* @author Taiwen Jiang <[email protected]> |
23
|
|
|
* @copyright 2000-2019 XOOPS Project (https://xoops.org) |
24
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) |
25
|
|
|
*/ |
26
|
|
|
class Rtsp extends ExtensionAbstract |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var array default configuration values |
30
|
|
|
*/ |
31
|
|
|
protected static $defaultConfiguration = [ |
32
|
|
|
'enabled' => false, |
33
|
|
|
'enable_rtsp_entry' => false, // false to disable entry button in editor, existing content will still play |
34
|
|
|
]; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Provide button and javascript code used by the DhtmlTextArea |
38
|
|
|
* |
39
|
|
|
* @param string $textAreaId dom element id |
40
|
|
|
* |
41
|
|
|
* @return string[] editor button as HTML, supporting javascript |
42
|
|
|
*/ |
43
|
3 |
|
public function getDhtmlEditorSupport($textAreaId) |
44
|
|
|
{ |
45
|
3 |
|
if (false === $this->config['enable_rtsp_entry']) { |
46
|
3 |
|
return parent::getDhtmlEditorSupport($textAreaId); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$buttonCode = $this->getEditorButtonHtml( |
50
|
|
|
$textAreaId, |
51
|
|
|
'fa fa-fw fa-comment-o', |
52
|
|
|
\XoopsLocale::REAL_PLAYER, |
53
|
|
|
'xoopsCodeRtsp', |
54
|
|
|
\XoopsLocale::RTSP_URL, |
55
|
|
|
\XoopsLocale::HEIGHT, |
56
|
|
|
\XoopsLocale::WIDTH |
57
|
|
|
); |
58
|
|
|
|
59
|
|
|
$javascript = <<<EOH |
60
|
|
|
function xoopsCodeRtsp(id,enterRtspPhrase, enterRtspHeightPhrase, enterRtspWidthPhrase){ |
61
|
|
|
var selection = xoopsGetSelect(id); |
62
|
|
|
if (selection.length > 0) { |
63
|
|
|
var selection = "rtsp://"+selection; |
64
|
|
|
var text = selection; |
65
|
|
|
} else { |
66
|
|
|
var text = prompt(enterRtspPhrase+" Rtsp or http", "Rtsp://"); |
67
|
|
|
} |
68
|
|
|
var domobj = xoopsGetElementById(id); |
69
|
|
|
if ( text.length > 0 && text!="rtsp://") { |
70
|
|
|
var text2 = prompt(enterRtspWidthPhrase, "480"); |
71
|
|
|
var text3 = prompt(enterRtspHeightPhrase, "330"); |
72
|
|
|
var result = "[rtsp="+text2+","+text3+"]" + text + "[/rtsp]"; |
73
|
|
|
xoopsInsertText(domobj, result); |
74
|
|
|
} |
75
|
|
|
domobj.focus(); |
76
|
|
|
} |
77
|
|
|
EOH; |
78
|
|
|
return array($buttonCode, $javascript); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Register extension with the supplied sanitizer instance |
83
|
|
|
* |
84
|
|
|
* @return void |
85
|
|
|
*/ |
86
|
11 |
|
public function registerExtensionProcessing() |
87
|
|
|
{ |
88
|
|
|
|
89
|
11 |
|
$this->shortcodes->addShortcode( |
90
|
11 |
|
'rtsp', |
91
|
|
|
function ($attributes, $content, $tagName) { |
|
|
|
|
92
|
1 |
|
$args = ltrim($attributes[0], '='); |
93
|
1 |
|
list($width, $height) = explode(',', $args); |
94
|
1 |
|
$url = $content; |
95
|
|
|
|
96
|
|
|
$template = <<<'EOT' |
97
|
1 |
|
<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" HEIGHT="%3$s" ID=Player WIDTH="%2$s" VIEWASTEXT> |
98
|
|
|
<param NAME="_ExtentX" VALUE="12726"> |
99
|
|
|
<param NAME="_ExtentY" VALUE="8520"> |
100
|
|
|
<param NAME="AUTOSTART" VALUE="0"> |
101
|
|
|
<param NAME="SHUFFLE" VALUE="0"> |
102
|
|
|
<param NAME="PREFETCH" VALUE="0"> |
103
|
|
|
<param NAME="NOLABELS" VALUE="0"> |
104
|
|
|
<param NAME="CONTROLS" VALUE="ImageWindow"> |
105
|
|
|
<param NAME="CONSOLE" VALUE="_master"> |
106
|
|
|
<param NAME="LOOP" VALUE="0"> |
107
|
|
|
<param NAME="NUMLOOP" VALUE="0"> |
108
|
|
|
<param NAME="CENTER" VALUE="0"> |
109
|
|
|
<param NAME="MAINTAINASPECT" VALUE="1"> |
110
|
|
|
<param NAME="BACKGROUNDCOLOR" VALUE="#000000"> |
111
|
|
|
<param NAME="SRC" VALUE="%1$s"> |
112
|
|
|
<embed autostart="0" src="%1$s" type="audio/x-pn-realaudio-plugin" HEIGHT="%3$s" WIDTH="%2$s" controls="ImageWindow" console="cons"> </embed> |
113
|
|
|
</object> |
114
|
|
|
<br /> |
115
|
|
|
<object CLASSID=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA HEIGHT=32 ID=Player WIDTH="%2$s" VIEWASTEXT> |
116
|
|
|
<param NAME="_ExtentX" VALUE="18256"> |
117
|
|
|
<param NAME="_ExtentY" VALUE="794"> |
118
|
|
|
<param NAME="AUTOSTART" VALUE="0"> |
119
|
|
|
<param NAME="SHUFFLE" VALUE="0"> |
120
|
|
|
<param NAME="PREFETCH" VALUE="0"> |
121
|
|
|
<param NAME="NOLABELS" VALUE="0"> |
122
|
|
|
<param NAME="CONTROLS" VALUE="controlpanel"> |
123
|
|
|
<param NAME="CONSOLE" VALUE="_master"> |
124
|
|
|
<param NAME="LOOP" VALUE="0"> |
125
|
|
|
<param NAME="NUMLOOP" VALUE="0"> |
126
|
|
|
<param NAME="CENTER" VALUE="0"> |
127
|
|
|
<param NAME="MAINTAINASPECT" VALUE="0"> |
128
|
|
|
<param NAME="BACKGROUNDCOLOR" VALUE="#000000"> |
129
|
|
|
<param NAME="SRC" VALUE="%1$s"> |
130
|
|
|
<embed autostart="0" src="%1$s" type="audio/x-pn-realaudio-plugin" HEIGHT='30' WIDTH='%2$s' controls="ControlPanel" console="cons"> </embed> |
131
|
|
|
</object> |
132
|
|
|
EOT; |
133
|
|
|
|
134
|
1 |
|
$newContent = sprintf($template, $url, $width, $height); |
135
|
1 |
|
return $newContent; |
136
|
11 |
|
} |
137
|
|
|
); |
138
|
11 |
|
} |
139
|
|
|
} |
140
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.