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 MytsWmp extends MyTextSanitizerExtension
25: {
26: 27: 28: 29: 30:
31: public function encode($textarea_id)
32: {
33: $config = parent::loadConfig(__DIR__);
34: if ($config['enable_wmp_entry'] === false) {
35: return array();
36: }
37:
38: $code = "<button type='button' class='btn btn-default btn-sm' onclick='xoopsCodeWmp(\"{$textarea_id}\",\""
39: . htmlspecialchars(_XOOPS_FORM_ENTERWMPURL, ENT_QUOTES) . "\",\""
40: . htmlspecialchars(_XOOPS_FORM_ALT_ENTERHEIGHT, ENT_QUOTES) . "\",\""
41: . htmlspecialchars(_XOOPS_FORM_ALT_ENTERWIDTH, ENT_QUOTES)
42: . "\");' onmouseover='style.cursor=\"hand\"' title='" . _XOOPS_FORM_ALTWMP
43: . "'><span class='fa fa-fw fa-windows' aria-hidden='true'></span></button>";
44:
45:
46: $javascript = <<<EOH
47: function xoopsCodeWmp(id, enterWmpPhrase, enterWmpHeightPhrase, enterWmpWidthPhrase)
48: {
49: var selection = xoopsGetSelect(id);
50: if (selection.length > 0) {
51: var text = selection;
52: } else {
53: var text = prompt(enterWmpPhrase, "");
54: }
55: var domobj = xoopsGetElementById(id);
56: if (text.length > 0) {
57: var text2 = prompt(enterWmpWidthPhrase, "480");
58: var text3 = prompt(enterWmpHeightPhrase, "330");
59: var result = "[wmp="+text2+","+text3+"]" + text + "[/wmp]";
60: xoopsInsertText(domobj, result);
61: }
62: domobj.focus();
63: }
64: EOH;
65:
66: return array(
67: $code,
68: $javascript);
69: }
70:
71: 72: 73:
74: public function load($ts)
75: {
76: $ts->patterns[] = "/\[wmp=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/wmp\]/sU";
77: $rp = "<object classid=\"clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6\" id=\"WindowsMediaPlayer\" width=\"\\2\" height=\"\\3\">\n";
78: $rp .= "<param name=\"URL\" value=\"\\4\">\n";
79: $rp .= "<param name=\"AutoStart\" value=\"0\">\n";
80: $rp .= "<embed autostart=\"0\" src=\"\\4\" type=\"video/x-ms-wmv\" width=\"\\2\" height=\"\\3\" controls=\"ImageWindow\" console=\"cons\"> </embed>";
81: $rp .= "</object>\n";
82: $ts->replacements[] = $rp;
83: }
84: }
85: