1: <?php
2: /**
3: * TextSanitizer extension
4: *
5: * You may not change or alter any portion of this comment or credits
6: * of supporting developers from this source code or any supporting source code
7: * which is considered copyrighted (c) material of the original comment or credit authors.
8: * This program is distributed in the hope that it will be useful,
9: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * @copyright (c) 2000-2017 XOOPS Project (www.xoops.org)
13: * @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
14: * @package class
15: * @subpackage textsanitizer
16: * @since 2.3.0
17: * @author Taiwen Jiang <phppp@users.sourceforge.net>
18: */
19: defined('XOOPS_ROOT_PATH') || exit('Restricted access');
20:
21: /**
22: * Class MytsWmp
23: */
24: class MytsWmp extends MyTextSanitizerExtension
25: {
26: /**
27: * @param $textarea_id
28: *
29: * @return array
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: //$code = "<img src='{$this->image_path}/wmp.gif' alt='" . _XOOPS_FORM_ALTWMP . "' title='" . _XOOPS_FORM_ALTWMP . "' '" . "' onclick='xoopsCodeWmp(\"{$textarea_id}\",\"" . htmlspecialchars(_XOOPS_FORM_ENTERWMPURL, ENT_QUOTES) . "\",\"" . htmlspecialchars(_XOOPS_FORM_ALT_ENTERHEIGHT, ENT_QUOTES) . "\",\"" . htmlspecialchars(_XOOPS_FORM_ALT_ENTERWIDTH, ENT_QUOTES) . "\");' onmouseover='style.cursor=\"hand\"'/>&nbsp;";
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: * @param MyTextSanitizer $myts
73: */
74: public function load(MyTextSanitizer $myts)
75: {
76: $myts->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: $myts->replacements[] = $rp;
83: }
84: }
85: