| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: mediafile.php,v 1.13.2.1 2008/07/10 09:48:47 scyrma Exp $ 2 /** 3 * This file plays the mediafile set in lesson settings. 4 * 5 * Almost all of this code is from /mod/resource/type/file/resource.class.php so major props for resource 6 * 7 * If there is a way to use the resource class instead of this code, please change to do so 8 * 9 * 10 * @version $Id: mediafile.php,v 1.13.2.1 2008/07/10 09:48:47 scyrma Exp $ 11 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 12 * @package lesson 13 **/ 14 15 require_once('../../config.php'); 16 require_once($CFG->libdir.'/filelib.php'); 17 18 $id = required_param('id', PARAM_INT); // Course Module ID 19 $printclose = optional_param('printclose', 0, PARAM_INT); 20 21 if (! $cm = get_coursemodule_from_id('lesson', $id)) { 22 error('Course Module ID was incorrect'); 23 } 24 25 if (! $course = get_record('course', 'id', $cm->course)) { 26 error('Course is misconfigured'); 27 } 28 29 if (! $lesson = get_record('lesson', 'id', $cm->instance)) { 30 error('Course module is incorrect'); 31 } 32 33 require_login($course->id, false, $cm); 34 35 // Get the mimetype 36 $mimetype = mimeinfo("type", $lesson->mediafile); 37 38 if (!is_url($lesson->mediafile) and !in_array($mimetype, array('text/plain', 'text/html'))) { 39 print_header($course->shortname); 40 } 41 42 if ($printclose) { // this is for framesets 43 if ($lesson->mediaclose) { 44 print_header($course->shortname); 45 echo '<div class="lessonmediafilecontrol"> 46 <form> 47 <div> 48 <input type="button" onclick="top.close();" value="'.get_string("closewindow").'" /> 49 </div> 50 </form> 51 </div>'; 52 print_footer(); 53 } 54 exit(); 55 } 56 57 if (is_url($lesson->mediafile)) { 58 $fullurl = $lesson->mediafile; 59 } else { 60 $fullurl = get_file_url($course->id .'/'. $lesson->mediafile); 61 } 62 63 // find the correct type and print it out 64 if ($mimetype == "audio/mp3") { // It's an MP3 audio file 65 66 if (!empty($THEME->resource_mp3player_colors)) { 67 $c = $THEME->resource_mp3player_colors; // You can set this up in your theme/xxx/config.php 68 } else { 69 $c = 'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'. 70 'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&'. 71 'font=Arial&fontColour=3333FF&buffer=10&waitForPlay=no&autoPlay=yes'; 72 } 73 $c .= '&volText='.get_string('vol', 'resource').'&panText='.get_string('pan','resource'); 74 $c = htmlentities($c); 75 echo '<div class="mp3player" class="lessonmediafilecontrol">'; 76 echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'; 77 echo ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '; 78 echo ' width="600" height="70" id="mp3player" align="">'; 79 echo '<param name="movie" value="'.$CFG->wwwroot.'/lib/mp3player/mp3player.swf?src='.$fullurl.'">'; 80 echo '<param name="quality" value="high">'; 81 echo '<param name="bgcolor" value="#333333">'; 82 echo '<param name="flashvars" value="'.$c.'&" />'; 83 echo '<embed src="'.$CFG->wwwroot.'/lib/mp3player/mp3player.swf?src='.$fullurl.'" '; 84 echo ' quality="high" bgcolor="#333333" width="600" height="70" name="mp3player" '; 85 echo ' type="application/x-shockwave-flash" '; 86 echo ' flashvars="'.$c.'&" '; 87 echo ' pluginspage="http://www.macromedia.com/go/getflashplayer">'; 88 echo '</embed>'; 89 echo '</object>'; 90 echo '</div>'; 91 92 } else if (substr($mimetype, 0, 10) == "video/x-ms") { // It's a Media Player file 93 94 echo "<div class=\"lessonmediafilecontrol\"><p>"; 95 echo '<object classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"'; 96 echo ' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" '; 97 echo ' standby="Loading Microsoft(R) Windows(R) Media Player components..." '; 98 echo ' id="msplayer" align="" type="application/x-oleobject">'; 99 echo "<param name=\"Filename\" value=\"$fullurl\">"; 100 echo '<param name="ShowControls" value="true" />'; 101 echo '<param name="AutoRewind" value="true" />'; 102 echo '<param name="AutoStart" value="true" />'; 103 echo '<param name="Autosize" value="true" />'; 104 echo '<param name="EnableContextMenu" value="true" />'; 105 echo '<param name="TransparentAtStart" value="false" />'; 106 echo '<param name="AnimationAtStart" value="false" />'; 107 echo '<param name="ShowGotoBar" value="false" />'; 108 echo '<param name="EnableFullScreenControls" value="true" />'; 109 echo "\n<embed src=\"$fullurl\" name=\"msplayer\" type=\"$mimetype\" "; 110 echo ' ShowControls="1" AutoRewind="1" AutoStart="1" Autosize="0" EnableContextMenu="1"'; 111 echo ' TransparentAtStart="0" AnimationAtStart="0" ShowGotoBar="0" EnableFullScreenControls="1"'; 112 echo ' pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/">'; 113 echo '</embed>'; 114 echo '</object>'; 115 echo "</p></div>"; 116 117 } else if ($mimetype == "video/quicktime") { // It's a Quicktime file 118 119 echo "<div class=\"lessonmediafilecontrol\"><p>"; 120 echo '<object classid="CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"'; 121 echo ' codebase="http://www.apple.com/qtactivex/qtplugin.cab" '; 122 echo ' height="450" width="600"'; 123 echo ' id="quicktime" align="" type="application/x-oleobject">'; 124 echo "<param name=\"src\" value=\"$fullurl\" />"; 125 echo '<param name="autoplay" value="true" />'; 126 echo '<param name="loop" value="true" />'; 127 echo '<param name="controller" value="true" />'; 128 echo '<param name="scale" value="aspect" />'; 129 echo "\n<embed src=\"$fullurl\" name=\"quicktime\" type=\"$mimetype\" "; 130 echo ' height="450" width="600" scale="aspect"'; 131 echo ' autoplay="true" controller="true" loop="true" '; 132 echo ' pluginspage="http://quicktime.apple.com/">'; 133 echo '</embed>'; 134 echo '</object>'; 135 echo "</p></div>"; 136 137 //} else if ($mimetype == "application/x-shockwave-flash") { // It's a flash file 138 139 // error('Flash is not supported yet'); 140 141 } else if ($mimetype == "audio/x-pn-realaudio") { // It's a realmedia file 142 143 echo '<object id="rvocx" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="600" height="50">'; 144 echo "<param name=\"src\" value=\"$fullurl\">"; 145 echo '<param name="console" value="video">'; // not sure what the console param should equal 146 echo '<param name="controls" value="ControlPanel">'; 147 echo '<param name="autostart" value="true">'; 148 echo '<param name="loop" value="true">'; 149 echo '<embed name="rvocx" src="'.$fullurl.'" height="50" width="600" autostart="true" loop="true" nojava="true" console="video" controls="ControlPanel"></embed>'; 150 echo '<noembed></noembed>'; 151 echo '</object>'; 152 153 } else if (is_url($lesson->mediafile) or $mimetype == 'text/html' or $mimetype == 'text/plain') { 154 // might be dangerous to handle all of these in the same fasion. It is being set by a teacher though. 155 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n"; 156 echo "<html dir=\"ltr\">\n"; 157 echo '<head>'; 158 echo '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />'; 159 echo "<title>{$course->shortname}</title></head>\n"; 160 if ($lesson->mediaclose) { 161 echo "<frameset rows=\"90%,*\">"; 162 echo "<frame src=\"$fullurl\" />"; 163 echo "<frame src=\"mediafile.php?id=$cm->id&printclose=1\" />"; 164 echo "</frameset>"; 165 } else { 166 echo "<frameset rows=\"100%\">"; 167 echo "<frame src=\"$fullurl\" />"; 168 echo "</frameset>"; 169 } 170 echo '</html>'; 171 exit(); 172 173 } else if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) { // Image 174 175 echo "<div class=\"lessonmediafilecontrol\"><p>"; 176 echo '<img class="lessonimage" src="'.s($fullurl).'" alt="" />'; 177 echo "</p></div>"; 178 179 } else { // Default 180 181 // Get the file name 182 $file = pathinfo($lesson->mediafile); 183 $filename = basename($file['basename'], '.'.$file['extension']); 184 185 echo "<div class=\"lessonmediafilecontrol\"><p>"; 186 notify(get_string('clicktodownload', 'lesson')); 187 echo "<a href=\"$fullurl\">".format_string($filename).'</a>'; 188 echo "</p></div>"; 189 190 } 191 192 function is_url($test_url) { 193 // the following is barrowed from resource code. Thanks! 194 if (strpos($test_url, '://')) { // eg http:// https:// ftp:// etc 195 return true; 196 } 197 if (strpos($test_url, '/') === 0) { // Starts with slash 198 return true; 199 } 200 return false; 201 } 202 203 if ($lesson->mediaclose) { 204 echo '<div class="lessonmediafilecontrol">'; 205 close_window_button(); 206 echo '</div>'; 207 } 208 209 print_footer(); 210 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |