libdir.'/filelib.php'); $id = required_param('id', PARAM_INT); // Course Module ID $printclose = optional_param('printclose', 0, PARAM_INT); if (! $cm = get_coursemodule_from_id('lesson', $id)) { error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { error('Course is misconfigured'); } if (! $lesson = get_record('lesson', 'id', $cm->instance)) { error('Course module is incorrect'); } require_login($course->id, false, $cm); // Get the mimetype $mimetype = mimeinfo("type", $lesson->mediafile); if (!is_url($lesson->mediafile) and !in_array($mimetype, array('text/plain', 'text/html'))) { print_header($course->shortname); } if ($printclose) { // this is for framesets if ($lesson->mediaclose) { print_header($course->shortname); echo '
'; print_footer(); } exit(); } if (is_url($lesson->mediafile)) { $fullurl = $lesson->mediafile; } else { $fullurl = get_file_url($course->id .'/'. $lesson->mediafile); } // find the correct type and print it out if ($mimetype == "audio/mp3") { // It's an MP3 audio file if (!empty($THEME->resource_mp3player_colors)) { $c = $THEME->resource_mp3player_colors; // You can set this up in your theme/xxx/config.php } else { $c = 'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'. 'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&'. 'font=Arial&fontColour=3333FF&buffer=10&waitForPlay=no&autoPlay=yes'; } $c .= '&volText='.get_string('vol', 'resource').'&panText='.get_string('pan','resource'); $c = htmlentities($c); echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; } else if (substr($mimetype, 0, 10) == "video/x-ms") { // It's a Media Player file echo "

"; echo ''; echo ""; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo "\n'; echo ''; echo ''; echo "

"; } else if ($mimetype == "video/quicktime") { // It's a Quicktime file echo "

"; echo ''; echo ""; echo ''; echo ''; echo ''; echo ''; echo "\n'; echo ''; echo ''; echo "

"; //} else if ($mimetype == "application/x-shockwave-flash") { // It's a flash file // error('Flash is not supported yet'); } else if ($mimetype == "audio/x-pn-realaudio") { // It's a realmedia file echo ''; echo ""; echo ''; // not sure what the console param should equal echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } else if (is_url($lesson->mediafile) or $mimetype == 'text/html' or $mimetype == 'text/plain') { // might be dangerous to handle all of these in the same fasion. It is being set by a teacher though. echo "\n"; echo "\n"; echo ''; echo ''; echo "{$course->shortname}\n"; if ($lesson->mediaclose) { echo ""; echo ""; echo "id&printclose=1\" />"; echo ""; } else { echo ""; echo ""; echo ""; } echo ''; exit(); } else if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) { // Image echo "

"; echo ''; echo "

"; } else { // Default // Get the file name $file = pathinfo($lesson->mediafile); $filename = basename($file['basename'], '.'.$file['extension']); echo "

"; notify(get_string('clicktodownload', 'lesson')); echo "".format_string($filename).''; echo "

"; } function is_url($test_url) { // the following is barrowed from resource code. Thanks! if (strpos($test_url, '://')) { // eg http:// https:// ftp:// etc return true; } if (strpos($test_url, '/') === 0) { // Starts with slash return true; } return false; } if ($lesson->mediaclose) { echo '
'; close_window_button(); echo '
'; } print_footer(); ?>