mirror of
https://github.com/moodle/moodle.git
synced 2025-05-31 21:19:49 +02:00
NEW FEATURE: Media file now works with web pages and with text and html files. Also, the pop-up
window size is configurable as well as an optional close button at the bottom of the window.
This commit is contained in:
parent
525bb31f37
commit
3eca6cf1bf
@ -206,6 +206,12 @@ function lesson_upgrade($oldversion) {
|
||||
table_column('lesson', '', 'progressbar', 'tinyint', '3', 'unsigned', '0', 'not null', 'displayleft');
|
||||
table_column('lesson', '', 'displayleftif', 'int', '3', 'unsigned', '0', 'not null', 'displayleft');
|
||||
}
|
||||
|
||||
if ($oldversion < 2005102800) {
|
||||
table_column('lesson', '', 'mediaclose', 'tinyint', '3', 'unsigned', '0', 'not null', 'mediafile');
|
||||
table_column('lesson', '', 'mediaheight', 'int', '10', 'unsigned', '100', 'not null', 'mediafile');
|
||||
table_column('lesson', '', 'mediawidth', 'int', '10', 'unsigned', '650', 'not null', 'mediafile');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ CREATE TABLE `prefix_lesson` (
|
||||
`retake` int(3) unsigned NOT NULL default '1',
|
||||
`tree` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`mediafile` varchar(255) NOT NULL default '',
|
||||
`mediaheight` INT(10) UNSIGNED NOT NULL DEFAULT '100',
|
||||
`mediawidth` INT(10) UNSIGNED NOT NULL DEFAULT '650',
|
||||
`mediaclose` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`slideshow` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`width` INT(10) UNSIGNED NOT NULL DEFAULT '640',
|
||||
`height` INT(10) UNSIGNED NOT NULL DEFAULT '480',
|
||||
|
@ -287,6 +287,12 @@ function lesson_upgrade($oldversion) {
|
||||
table_column('lesson', '', 'progressbar', 'INT', '3', 'unsigned', '0', 'not null', 'displayleft');
|
||||
table_column('lesson', '', 'displayleftif', 'INT', '3', 'unsigned', '0', 'not null', 'displayleft');
|
||||
}
|
||||
|
||||
if ($oldversion < 2005102800) {
|
||||
table_column('lesson', '', 'mediaclose', 'INT', '3', 'unsigned', '0', 'not null', 'mediafile');
|
||||
table_column('lesson', '', 'mediaheight', 'INT', '10', 'unsigned', '100', 'not null', 'mediafile');
|
||||
table_column('lesson', '', 'mediawidth', 'INT', '10', 'unsigned', '650', 'not null', 'mediafile');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ CREATE TABLE prefix_lesson (
|
||||
retake INT NOT NULL default '1',
|
||||
tree INT NOT NULL DEFAULT '0',
|
||||
mediafile varchar(255) NOT NULL default '',
|
||||
mediaheight INT NOT NULL DEFAULT '100',
|
||||
mediawidth INT NOT NULL DEFAULT '650',
|
||||
mediaclose INT NOT NULL DEFAULT '0',
|
||||
slideshow INT NOT NULL DEFAULT '0',
|
||||
width INT8 NOT NULL DEFAULT '640',
|
||||
height INT8 NOT NULL DEFAULT '480',
|
||||
|
@ -8,6 +8,7 @@
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); // Course Module ID
|
||||
$printclose = optional_param('printclose', 0, PARAM_INT);
|
||||
|
||||
if (! $cm = get_record('course_modules', 'id', $id)) {
|
||||
error('Course Module ID was incorrect');
|
||||
@ -20,14 +21,25 @@
|
||||
if (! $lesson = get_record('lesson', 'id', $cm->instance)) {
|
||||
error('Course module is incorrect');
|
||||
}
|
||||
|
||||
if ($printclose) { // this is for framesets
|
||||
if ($lesson->mediaclose) {
|
||||
echo '<center>
|
||||
<form>
|
||||
<input type="button" onclick="top.close();" value="'.get_string("closewindow").'" />
|
||||
</form>
|
||||
</center>';
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
// get the mimetype
|
||||
$path_parts = pathinfo($lesson->mediafile);
|
||||
$mimetype = mimeinfo("type", $path_parts['basename']);
|
||||
//$path_parts = pathinfo('http://www.apple.com'); //$lesson->mediafile
|
||||
$mimetype = mimeinfo("type", $lesson->mediafile); //$path_parts['basename']
|
||||
|
||||
print_header($path_parts['basename']); // or should it pass "Media File" and not the name?
|
||||
//print_header();
|
||||
|
||||
if (substr_count($lesson->mediafile, '//') == 1) {
|
||||
// OK, taking a leap of faith here. We are assuming that teachers are cool
|
||||
@ -42,6 +54,8 @@
|
||||
}
|
||||
$fullurl = "$CFG->wwwroot$relativeurl";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// find the correct type and print it out
|
||||
if ($mimetype == "audio/mp3") { // It's an MP3 audio file
|
||||
@ -133,7 +147,43 @@
|
||||
echo '<noembed></noembed>';
|
||||
echo '</object>';
|
||||
|
||||
} 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 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
|
||||
echo "<html dir=\"ltr\">\n";
|
||||
echo '<head>';
|
||||
echo '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />';
|
||||
echo "<title>{$course->shortname}</title></head>\n";
|
||||
if ($lesson->mediaclose) {
|
||||
echo "<frameset rows=\"90%,*\">";
|
||||
echo "<frame src=\"$fullurl\" />";
|
||||
echo "<frame src=\"mediafile.php?id=$cm->id&printclose=1\" />";
|
||||
echo "</frameset>";
|
||||
} else {
|
||||
echo "<frameset rows=\"100%\">";
|
||||
echo "<frame src=\"$fullurl\" />";
|
||||
echo "</frameset>";
|
||||
}
|
||||
exit();
|
||||
|
||||
} else {
|
||||
error('Unsupported mime type: '.$mimetype);
|
||||
}
|
||||
|
||||
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 '<p>';
|
||||
close_window_button();
|
||||
echo '</p>';
|
||||
}
|
||||
?>
|
@ -107,6 +107,15 @@ if ($form->mode == "add") {
|
||||
if (!isset($form->mediafile)) {
|
||||
$form->mediafile = '';
|
||||
}
|
||||
if (!isset($form->mediaheight)) {
|
||||
$form->mediafile = 100;
|
||||
}
|
||||
if (!isset($form->mediawidth)) {
|
||||
$form->mediafile = 650;
|
||||
}
|
||||
if (!isset($form->mediaclose)) {
|
||||
$form->mediafile = 0;
|
||||
}
|
||||
if (!isset($form->dependency)) {
|
||||
$form->dependency = 0;
|
||||
}
|
||||
@ -536,6 +545,17 @@ if ($form->mode == "add") {
|
||||
button_to_popup_window ("/files/index.php?id=$course->id&choose=form.mediafile", "coursefiles", $strchooseafile, 500, 750, $strchooseafile);
|
||||
helpbutton("mediafile", get_string("mediafile", "lesson"), "lesson");
|
||||
?>
|
||||
<br /><br />
|
||||
<?php
|
||||
print_string("mediaclose", "lesson");
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "mediaclose", $form->mediaclose, "");
|
||||
?>
|
||||
- <?php print_string("mediaheight", "lesson"); ?>
|
||||
<input type="text" name="mediaheight" maxlength="7" size="4" value="<?php p($form->mediaheight) ?>" />px,
|
||||
<?php print_string("mediawidth", "lesson"); ?>
|
||||
<input type="text" name="mediawidth" maxlength="7" size="4" value="<?php p($form->mediawidth) ?>" />px
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -130,8 +130,8 @@
|
||||
}
|
||||
|
||||
.mod-lesson .branchslidebottom {
|
||||
/* You may choose to not show them at all
|
||||
display: none;*/
|
||||
/* You may choose to not show them at all
|
||||
display: none; */
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -5,7 +5,7 @@
|
||||
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2005101900; // The current module version (Date: YYYYMMDDXX)
|
||||
$module->version = 2005102800; // The current module version (Date: YYYYMMDDXX)
|
||||
$module->requires = 2005021600; // Requires this Moodle version
|
||||
$module->cron = 0; // Period for cron to check this module (secs)
|
||||
|
||||
|
@ -365,9 +365,8 @@
|
||||
if (!empty($lesson->mediafile)) {
|
||||
// open our pop-up
|
||||
$url = '/mod/lesson/mediafile.php?id='.$cm->id;
|
||||
$path_parts = pathinfo($lesson->mediafile);
|
||||
$name = substr($path_parts['basename'], 0, strstr($path_parts['basename'], '.'));
|
||||
$options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. 650 .',height='. 100;
|
||||
$name = 'lessonmediafile';
|
||||
$options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. $lesson->mediawidth .',height='. $lesson->mediaheight;
|
||||
echo "\n<script language=\"javascript\" type=\"text/javascript\">";
|
||||
echo "\n<!--\n";
|
||||
echo " openpopup('$url', '$name', '$options', 0);";
|
||||
@ -479,9 +478,8 @@
|
||||
|
||||
if (!empty($lesson->mediafile)) {
|
||||
$url = '/mod/lesson/mediafile.php?id='.$cm->id;
|
||||
$options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. 650 .',height='. 100;
|
||||
$path_parts = pathinfo($lesson->mediafile);
|
||||
$name = substr($path_parts['basename'], 0, strstr($path_parts['basename'], '.'));
|
||||
$options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. $lesson->mediawidth .',height='. $lesson->mediaheight;
|
||||
$name = 'lessonmediafile';
|
||||
echo '<div align="right">';
|
||||
link_to_popup_window ($url, $name, get_string('mediafilepopup', 'lesson'), '', '', get_string('mediafilepopup', 'lesson'), $options);
|
||||
helpbutton("mediafilestudent", get_string("mediafile", "lesson"), "lesson");
|
||||
|
Loading…
x
Reference in New Issue
Block a user