1: | <?php
|
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: |
|
19: | defined('XOOPS_ROOT_PATH') || exit('Restricted access');
|
20: |
|
21: | |
22: | |
23: |
|
24: | class MytsFlash extends MyTextSanitizerExtension
|
25: | {
|
26: | |
27: | |
28: | |
29: | |
30: |
|
31: | public function encode($textarea_id)
|
32: | {
|
33: | $config = parent::loadConfig(__DIR__);
|
34: | if ($config['enable_flash_entry'] === false) {
|
35: | return array();
|
36: | }
|
37: | $code = "<button type='button' class='btn btn-default btn-sm' onclick='xoopsCodeFlash(\"{$textarea_id}\",\""
|
38: | . htmlspecialchars(_XOOPS_FORM_ENTERFLASHURL, ENT_QUOTES) . "\",\""
|
39: | . htmlspecialchars(_XOOPS_FORM_ALT_ENTERHEIGHT, ENT_QUOTES) . "\",\""
|
40: | . htmlspecialchars(_XOOPS_FORM_ALT_ENTERWIDTH, ENT_QUOTES) . "\", \""
|
41: | . $config['detect_dimension'] . "\");' onmouseover='style.cursor=\"hand\"' title='"
|
42: | . _XOOPS_FORM_ALTFLASH . "'><span class='fa fa-fw fa-flash' aria-hidden='true'></span></button>";
|
43: | $javascript = <<<EOF
|
44: | function xoopsCodeFlash(id, enterFlashPhrase, enterFlashHeightPhrase, enterFlashWidthPhrase, enableDimensionDetect)
|
45: | {
|
46: | var selection = xoopsGetSelect(id);
|
47: | if (selection.length > 0) {
|
48: | var text = selection;
|
49: | } else {
|
50: | var text = prompt(enterFlashPhrase, "");
|
51: | }
|
52: | var domobj = xoopsGetElementById(id);
|
53: | if (text.length > 0) {
|
54: | var text2 = enableDimensionDetect ? "" : prompt(enterFlashWidthPhrase, "");
|
55: | var text3 = enableDimensionDetect ? "" : prompt(enterFlashHeightPhrase, "");
|
56: | var result = "[flash="+text2+","+text3+"]" + text + "[/flash]";
|
57: | xoopsInsertText(domobj, result);
|
58: | }
|
59: | domobj.focus();
|
60: | }
|
61: | EOF;
|
62: |
|
63: | return array(
|
64: | $code,
|
65: | $javascript);
|
66: | }
|
67: |
|
68: | |
69: | |
70: | |
71: | |
72: |
|
73: | public static function myCallback($match)
|
74: | {
|
75: | return self::decode($match[5], $match[3], $match[4]);
|
76: | }
|
77: |
|
78: | |
79: | |
80: | |
81: | |
82: |
|
83: | public function load(MyTextSanitizer $myts)
|
84: | {
|
85: | $myts->callbackPatterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/sU";
|
86: | $myts->callbacks[] = __CLASS__ . '::myCallback';
|
87: |
|
88: | return true;
|
89: | }
|
90: |
|
91: | |
92: | |
93: | |
94: | |
95: | |
96: | |
97: |
|
98: | public static function decode($url, $width, $height)
|
99: | {
|
100: | $config = parent::loadConfig(__DIR__);
|
101: |
|
102: | if ((empty($width) || empty($height)) && !empty($config['detect_dimension'])) {
|
103: | if (!$dimension = @getimagesize($url)) {
|
104: | return "<a href='{$url}' rel='external' title=''>{$url}</a>";
|
105: | }
|
106: | if (!empty($width)) {
|
107: | $height = $dimension[1] * $width / $dimension[0];
|
108: | } elseif (!empty($height)) {
|
109: | $width = $dimension[0] * $height / $dimension[1];
|
110: | } else {
|
111: | list($width, $height) = array(
|
112: | $dimension[0],
|
113: | $dimension[1]);
|
114: | }
|
115: | }
|
116: |
|
117: | $rp = "<object width='{$width}' height='{$height}' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'>";
|
118: | $rp .= "<param name='movie' value='{$url}'>";
|
119: | $rp .= "<param name='QUALITY' value='high'>";
|
120: | $rp .= "<PARAM NAME='bgcolor' VALUE='#FFFFFF'>";
|
121: | $rp .= "<param name='wmode' value='transparent'>";
|
122: | $rp .= "<embed src='{$url}' width='{$width}' height='{$height}' quality='high' bgcolor='#FFFFFF' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed>";
|
123: | $rp .= '</object>';
|
124: |
|
125: | return $rp;
|
126: | }
|
127: | }
|
128: | |