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($ts)
84: {
85:
86:
87:
88:
89: $ts->callbackPatterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/sU";
90: $ts->callbacks[] = __CLASS__ . '::myCallback';
91:
92:
93: return true;
94: }
95:
96: 97: 98: 99: 100: 101: 102:
103: public static function decode($url, $width, $height)
104: {
105: $config = parent::loadConfig(__DIR__);
106:
107: if ((empty($width) || empty($height)) && !empty($config['detect_dimension'])) {
108: if (!$dimension = @getimagesize($url)) {
109: return "<a href='{$url}' rel='external' title=''>{$url}</a>";
110: }
111: if (!empty($width)) {
112: $height = $dimension[1] * $width / $dimension[0];
113: } elseif (!empty($height)) {
114: $width = $dimension[0] * $height / $dimension[1];
115: } else {
116: list($width, $height) = array(
117: $dimension[0],
118: $dimension[1]);
119: }
120: }
121:
122: $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'>";
123: $rp .= "<param name='movie' value='{$url}'>";
124: $rp .= "<param name='QUALITY' value='high'>";
125: $rp .= "<PARAM NAME='bgcolor' VALUE='#FFFFFF'>";
126: $rp .= "<param name='wmode' value='transparent'>";
127: $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>";
128: $rp .= '</object>';
129:
130: return $rp;
131: }
132: }
133: