mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +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
9 changed files with 98 additions and 12 deletions
|
@ -207,6 +207,12 @@ function lesson_upgrade($oldversion) {
|
||||||
table_column('lesson', '', 'displayleftif', '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', '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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ CREATE TABLE `prefix_lesson` (
|
||||||
`retake` int(3) unsigned NOT NULL default '1',
|
`retake` int(3) unsigned NOT NULL default '1',
|
||||||
`tree` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
|
`tree` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
|
||||||
`mediafile` varchar(255) NOT NULL default '',
|
`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',
|
`slideshow` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
|
||||||
`width` INT(10) UNSIGNED NOT NULL DEFAULT '640',
|
`width` INT(10) UNSIGNED NOT NULL DEFAULT '640',
|
||||||
`height` INT(10) UNSIGNED NOT NULL DEFAULT '480',
|
`height` INT(10) UNSIGNED NOT NULL DEFAULT '480',
|
||||||
|
|
|
@ -288,6 +288,12 @@ function lesson_upgrade($oldversion) {
|
||||||
table_column('lesson', '', 'displayleftif', '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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ CREATE TABLE prefix_lesson (
|
||||||
retake INT NOT NULL default '1',
|
retake INT NOT NULL default '1',
|
||||||
tree INT NOT NULL DEFAULT '0',
|
tree INT NOT NULL DEFAULT '0',
|
||||||
mediafile varchar(255) NOT NULL default '',
|
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',
|
slideshow INT NOT NULL DEFAULT '0',
|
||||||
width INT8 NOT NULL DEFAULT '640',
|
width INT8 NOT NULL DEFAULT '640',
|
||||||
height INT8 NOT NULL DEFAULT '480',
|
height INT8 NOT NULL DEFAULT '480',
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
require_once($CFG->libdir.'/filelib.php');
|
require_once($CFG->libdir.'/filelib.php');
|
||||||
|
|
||||||
$id = required_param('id', PARAM_INT); // Course Module ID
|
$id = required_param('id', PARAM_INT); // Course Module ID
|
||||||
|
$printclose = optional_param('printclose', 0, PARAM_INT);
|
||||||
|
|
||||||
if (! $cm = get_record('course_modules', 'id', $id)) {
|
if (! $cm = get_record('course_modules', 'id', $id)) {
|
||||||
error('Course Module ID was incorrect');
|
error('Course Module ID was incorrect');
|
||||||
|
@ -21,13 +22,24 @@
|
||||||
error('Course module is incorrect');
|
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);
|
require_login($course->id, false, $cm);
|
||||||
|
|
||||||
// get the mimetype
|
// get the mimetype
|
||||||
$path_parts = pathinfo($lesson->mediafile);
|
//$path_parts = pathinfo('http://www.apple.com'); //$lesson->mediafile
|
||||||
$mimetype = mimeinfo("type", $path_parts['basename']);
|
$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) {
|
if (substr_count($lesson->mediafile, '//') == 1) {
|
||||||
// OK, taking a leap of faith here. We are assuming that teachers are cool
|
// OK, taking a leap of faith here. We are assuming that teachers are cool
|
||||||
|
@ -43,6 +55,8 @@
|
||||||
$fullurl = "$CFG->wwwroot$relativeurl";
|
$fullurl = "$CFG->wwwroot$relativeurl";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// find the correct type and print it out
|
// find the correct type and print it out
|
||||||
if ($mimetype == "audio/mp3") { // It's an MP3 audio file
|
if ($mimetype == "audio/mp3") { // It's an MP3 audio file
|
||||||
|
|
||||||
|
@ -133,7 +147,43 @@
|
||||||
echo '<noembed></noembed>';
|
echo '<noembed></noembed>';
|
||||||
echo '</object>';
|
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 {
|
} else {
|
||||||
error('Unsupported mime type: '.$mimetype);
|
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)) {
|
if (!isset($form->mediafile)) {
|
||||||
$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)) {
|
if (!isset($form->dependency)) {
|
||||||
$form->dependency = 0;
|
$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);
|
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");
|
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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
/// 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->requires = 2005021600; // Requires this Moodle version
|
||||||
$module->cron = 0; // Period for cron to check this module (secs)
|
$module->cron = 0; // Period for cron to check this module (secs)
|
||||||
|
|
||||||
|
|
|
@ -365,9 +365,8 @@
|
||||||
if (!empty($lesson->mediafile)) {
|
if (!empty($lesson->mediafile)) {
|
||||||
// open our pop-up
|
// open our pop-up
|
||||||
$url = '/mod/lesson/mediafile.php?id='.$cm->id;
|
$url = '/mod/lesson/mediafile.php?id='.$cm->id;
|
||||||
$path_parts = pathinfo($lesson->mediafile);
|
$name = 'lessonmediafile';
|
||||||
$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;
|
||||||
$options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. 650 .',height='. 100;
|
|
||||||
echo "\n<script language=\"javascript\" type=\"text/javascript\">";
|
echo "\n<script language=\"javascript\" type=\"text/javascript\">";
|
||||||
echo "\n<!--\n";
|
echo "\n<!--\n";
|
||||||
echo " openpopup('$url', '$name', '$options', 0);";
|
echo " openpopup('$url', '$name', '$options', 0);";
|
||||||
|
@ -479,9 +478,8 @@
|
||||||
|
|
||||||
if (!empty($lesson->mediafile)) {
|
if (!empty($lesson->mediafile)) {
|
||||||
$url = '/mod/lesson/mediafile.php?id='.$cm->id;
|
$url = '/mod/lesson/mediafile.php?id='.$cm->id;
|
||||||
$options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. 650 .',height='. 100;
|
$options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. $lesson->mediawidth .',height='. $lesson->mediaheight;
|
||||||
$path_parts = pathinfo($lesson->mediafile);
|
$name = 'lessonmediafile';
|
||||||
$name = substr($path_parts['basename'], 0, strstr($path_parts['basename'], '.'));
|
|
||||||
echo '<div align="right">';
|
echo '<div align="right">';
|
||||||
link_to_popup_window ($url, $name, get_string('mediafilepopup', 'lesson'), '', '', get_string('mediafilepopup', 'lesson'), $options);
|
link_to_popup_window ($url, $name, get_string('mediafilepopup', 'lesson'), '', '', get_string('mediafilepopup', 'lesson'), $options);
|
||||||
helpbutton("mediafilestudent", get_string("mediafile", "lesson"), "lesson");
|
helpbutton("mediafilestudent", get_string("mediafile", "lesson"), "lesson");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue