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 MytsMp3 extends MyTextSanitizerExtension
25: {
26: 27: 28: 29: 30:
31: public function encode($textarea_id)
32: {
33: $code = "<button type='button' class='btn btn-default' onclick='xoopsCodeMp3(\"{$textarea_id}\",\""
34: . htmlspecialchars(_XOOPS_FORM_ENTERMP3URL, ENT_QUOTES)
35: . "\");' onmouseover='style.cursor=\"hand\"' title='" . _XOOPS_FORM_ALTMP3
36: . "'><span class='fa fa-fw fa-music' aria-hidden='true'></span></button>";
37:
38: $javascript = <<<EOF
39: function xoopsCodeMp3(id, enterMp3Phrase)
40: {
41: var selection = xoopsGetSelect(id);
42: if (selection.length > 0) {
43: var text = selection;
44: } else {
45: var text = prompt(enterMp3Phrase, "");
46: }
47: var domobj = xoopsGetElementById(id);
48: if (text.length > 0) {
49: var result = "[mp3]" + text + "[/mp3]";
50: xoopsInsertText(domobj, result);
51: }
52: domobj.focus();
53: }
54: EOF;
55:
56: return array(
57: $code,
58: $javascript);
59: }
60:
61: 62: 63: 64: 65:
66: public static function myCallback($match)
67: {
68: return self::decode($match[1]);
69: }
70:
71: 72: 73: 74: 75:
76: public function load($ts)
77: {
78:
79:
80:
81: $ts->callbackPatterns[] = "/\[mp3\](.*?)\[\/mp3\]/s";
82: $ts->callbacks[] = __CLASS__ . '::myCallback';
83:
84:
85: return true;
86: }
87:
88: 89: 90: 91: 92:
93: public static function decode($url, $width, $height)
94: {
95: $rp = "<embed flashvars=\"playerID=1&bg=0xf8f8f8&leftbg=0x3786b3&lefticon=0x78bee3&rightbg=0x3786b3&rightbghover=0x78bee3&righticon=0x78bee3&righticonhover=0x3786b3&text=0x666666&slider=0x3786b3&track=0xcccccc&border=0x666666&loader=0x78bee3&loop=no&soundFile={$url}\" quality='high' menu='false' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' src='" . XOOPS_URL . "/images/form/player.swf' width=290 height=24 type='application/x-shockwave-flash'></embed>";
96:
97: return $rp;
98: }
99: }
100: