~ubuntu-branches/ubuntu/breezy/moodle/breezy

« back to all changes in this revision

Viewing changes to mod/quiz/format/qti2/custommediafilter.php

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-10-13 02:00:59 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051013020059-y2qcyo41t7nqppcg
Tags: 1.5.2-1ubuntu1
* Resync with debian (security update)
* changed dependencys to php5
* changed apache dependency to apache2 
* References
  CAN-2005-2247

Show diffs side-by-side

added added

removed removed

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