3 // note: modified from the original filter/mediaplugin/filter.php
5 // given a href for a movie or sound file, it returns an appropriate tag
7 * @package questionbank
8 * @subpackage importexport
10 function custom_mediaplugin_filter($text, $width = null, $height = null) {
12 if (is_null($width) ||
$width == 0) {
20 if (empty($CFG->filter_mediaplugin_ignore_mp3
)) {
21 $search = '/<a(.*?)href=\"([^<]+)\.mp3\"([^>]*)>(.*?)<\/a>/i';
23 $replace = '\\0 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
24 $replace .= ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
25 $replace .= ' width="35" height="18" id="mp3player" align="">';
26 $replace .= " <param name=movie value=\"$CFG->wwwroot/filter/mediaplugin/mp3player.swf?src=\\2.mp3\">";
27 $replace .= ' <param name=quality value=high>';
28 $replace .= ' <param name=bgcolor value="#333333">';
29 $replace .= " <embed src=\"$CFG->wwwroot/filter/mediaplugin/mp3player.swf?src=\\2.mp3\" ";
30 $replace .= " quality=high bgcolor=\"#333333\" width=\"35\" height=\"18\" name=\"mp3player\" ";
31 $replace .= ' type="application/x-shockwave-flash" ';
32 $replace .= ' pluginspage="http://www.macromedia.com/go/getflashplayer">';
33 $replace .= '</embed>';
34 $replace .= '</object> ';
36 $text = preg_replace($search, $replace, $text);
39 if (empty($CFG->filter_mediaplugin_ignore_swf
)) {
40 $search = '/<a(.*?)href=\"([^<]+)\.swf\"([^>]*)>(.*?)<\/a>/i';
41 $replace = '\\0<object '.
42 'type="application/x-shockwave-flash" ' .
44 'width="' . $width . '" ' .
45 'height="' . $height . '"> ' .
46 '<param name="movie" value="\\2.swf" /> ' .
47 '<param name="wmode" value="transparent" />' .
51 /* $replace = '\\0<p class="mediaplugin"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
52 $replace .= ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
53 $replace .= ' width="' . $width . '" height="' . $height . '" id="mp3player" align="">';
54 $replace .= " <param name=movie value=\"\\2.swf\">";
55 $replace .= ' <param name=quality value=high>';
56 $replace .= " <embed src=\"\\2.swf\" ";
57 $replace .= " quality=high width=\"$width\" height=\"$height\" name=\"flashfilter\" ";
58 $replace .= ' type="application/x-shockwave-flash" ';
59 $replace .= ' pluginspage="http://www.macromedia.com/go/getflashplayer">';
60 $replace .= '</embed>';
61 $replace .= '</object></p>';*/
63 $text = preg_replace($search, $replace, $text);
66 if (empty($CFG->filter_mediaplugin_ignore_mov
)) {
67 $search = '/<a(.*?)href=\"([^<]+)\.mov\"([^>]*)>(.*?)<\/a>/i';
69 $replace = '\\0<p class="mediaplugin"><object classid="CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
70 $replace .= ' codebase="http://www.apple.com/qtactivex/qtplugin.cab" ';
71 $replace .= ' height="' . $height . '" width="' . $width . '"';
72 $replace .= ' id="quicktime" align="" type="application/x-oleobject">';
73 $replace .= "<param name=\"src\" value=\"\\2.mov\" />";
74 $replace .= '<param name="autoplay" value=false />';
75 $replace .= '<param name="loop" value=true />';
76 $replace .= '<param name="controller" value=true />';
77 $replace .= '<param name="scale" value="aspect" />';
78 $replace .= "\n<embed src=\"\\2.mov\" name=\"quicktime\" type=\"video/quicktime\" ";
79 $replace .= ' height="' . $height . '" width="' . $width . '" scale="aspect" ';
80 $replace .= ' autoplay="false" controller="true" loop="true" ';
81 $replace .= ' pluginspage="http://quicktime.apple.com/">';
82 $replace .= '</embed>';
83 $replace .= '</object> ';
85 $text = preg_replace($search, $replace, $text);
88 if (empty($CFG->filter_mediaplugin_ignore_wmv
)) {
89 $search = '/<a(.*?)href=\"([^<]+)\.wmv\"([^>]*)>(.*?)<\/a>/i';
91 $replace = '\\0<p class="mediaplugin"><object classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"';
92 $replace .= ' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';
93 $replace .= ' standby="Loading Microsoft? Windows? Media Player components..." ';
94 $replace .= ' id="msplayer" align="" type="application/x-oleobject">';
95 $replace .= "<param name=\"Filename\" value=\"\\2.wmv\">";
96 $replace .= '<param name="ShowControls" value=true />';
97 $replace .= '<param name="AutoRewind" value=true />';
98 $replace .= '<param name="AutoStart" value=false />';
99 $replace .= '<param name="Autosize" value=true />';
100 $replace .= '<param name="EnableContextMenu" value=true />';
101 $replace .= '<param name="TransparentAtStart" value=false />';
102 $replace .= '<param name="AnimationAtStart" value=false />';
103 $replace .= '<param name="ShowGotoBar" value=false />';
104 $replace .= '<param name="EnableFullScreenControls" value=true />';
105 $replace .= "\n<embed src=\"\\2.wmv\" name=\"msplayer\" type=\"video/x-ms\" ";
106 $replace .= ' ShowControls="1" AutoRewind="1" AutoStart="0" Autosize="0" EnableContextMenu="1"';
107 $replace .= ' TransparentAtStart="0" AnimationAtStart="0" ShowGotoBar="0" EnableFullScreenControls="1"';
108 $replace .= ' pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/">';
109 $replace .= '</embed>';
110 $replace .= '</object> ';
112 $text = preg_replace($search, $replace, $text);
120 if (empty($CFG->filter_mediaplugin_ignore_mpg
)) {
121 $search = '/<a(.*?)href=\"([^<]+)\.(mpe?g)\"([^>]*)>(.*?)<\/a>/i';
123 $replace = '\\0<p class="mediaplugin"><object width="' . $width . '" height="' . $height . '">';
124 $replace .= '<param name="src" value="\\2.\\3">';
125 $replace .= '<param name="controller" value="true">';
126 $replace .= '<param name="autoplay" value="false">';
127 $replace .= '<embed src="\\2.\\3" width="' . $width . '" height="' . $height . '" controller="true" autoplay="false"> </embed>';
128 $replace .= '</object></p>';
130 $text = preg_replace($search, $replace, $text);
133 if (empty($CFG->filter_mediaplugin_ignore_avi
)) {
134 $search = '/<a(.*?)href=\"([^<]+)\.avi\"([^>]*)>(.*?)<\/a>/i';
136 $replace = '\\0<p class="mediaplugin"><object width="' . $width . '" height="' . $height . '">';
137 $replace .= '<param name="src" value="\\2.avi">';
138 $replace .= '<param name="controller" value="true">';
139 $replace .= '<param name="autoplay" value="false">';
140 $replace .= '<embed src="\\2.avi" width="' . $width . '" height="' . $height . '" controller="true" autoplay="false"> </embed>';
141 $replace .= '</object> ';
143 $text = preg_replace($search, $replace, $text);