1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Xoops\Core\Text\Sanitizer\Extensions;
13:
14: use Xoops\Core\Text\Sanitizer;
15: use Xoops\Core\Text\Sanitizer\ExtensionAbstract;
16:
17: 18: 19: 20: 21: 22: 23: 24: 25: 26:
27: class Wmp extends ExtensionAbstract
28: {
29: 30: 31:
32: protected static $defaultConfiguration = ['enabled' => false];
33:
34: 35: 36: 37: 38: 39: 40:
41: public function getDhtmlEditorSupport($textAreaId)
42: {
43: $buttonCode = $this->getEditorButtonHtml(
44: $textAreaId,
45: 'wmp.gif',
46: \XoopsLocale::WMP,
47: 'xoopsCodeWmp',
48: \XoopsLocale::WMP_URL,
49: \XoopsLocale::HEIGHT,
50: \XoopsLocale::WIDTH
51: );
52:
53: $javascript = <<<EOH
54: function xoopsCodeWmp(id, enterWmpPhrase, enterWmpHeightPhrase, enterWmpWidthPhrase) {
55: var selection = xoopsGetSelect(id);
56: if (selection.length > 0) {
57: var text = selection;
58: } else {
59: var text = prompt(enterWmpPhrase, "");
60: }
61: var domobj = xoopsGetElementById(id);
62: if ( text.length > 0 ) {
63: var text2 = prompt(enterWmpWidthPhrase, "480");
64: var text3 = prompt(enterWmpHeightPhrase, "330");
65: var result = "[wmp="+text2+","+text3+"]" + text + "[/wmp]";
66: xoopsInsertText(domobj, result);
67: }
68: domobj.focus();
69: }
70: EOH;
71: return [$buttonCode, $javascript];
72: }
73:
74: 75: 76: 77: 78:
79: public function registerExtensionProcessing()
80: {
81: $this->shortcodes->addShortcode(
82: 'wmp',
83: function ($attributes, $content, $tagName) {
84: $args = ltrim($attributes[0], '=');
85: list($width, $height) = explode(',', $args);
86: $url = $content;
87:
88: $template = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"'
89: . ' id="WindowsMediaPlayer" width="%2$s" height="%3$s">' . "\n"
90: . '<param name="URL" value="%1$s">'. "\n"
91: . '<param name="AutoStart" value="0">' . "\n"
92: . '<embed autostart="0" src="%1$s" type="video/x-ms-wmv" width="%2$s" height="%3$s"'
93: . ' controls="ImageWindow" console="cons"> </embed>' . "\n"
94: . '</object>' . "\n";
95: $newContent = sprintf($template, $url, $width, $height);
96: return $newContent;
97: }
98: );
99: }
100: }
101: