MDL-21695 adding help string
[moodle.git] / mod / lesson / mediafile.php
blob4d993e51fb013c2edff3fbd1e99d7b1a5ac801ae
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * This file plays the mediafile set in lesson settings.
21 * If there is a way to use the resource class instead of this code, please change to do so
24 * @package lesson
25 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 **/
29 require_once('../../config.php');
30 require_once($CFG->dirroot.'/mod/lesson/locallib.php');
32 $id = required_param('id', PARAM_INT); // Course Module ID
33 $printclose = optional_param('printclose', 0, PARAM_INT);
35 $url = new moodle_url('/mod/lesson/mediafile.php', array('id'=>$id));
36 if ($printclose !== '') {
37 $url->param('printclose', $printclose);
39 $PAGE->set_url($url);
41 try {
42 $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);;
43 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
44 $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST));
45 } catch (Exception $e) {
46 print_error('invalidcoursemodule');
48 require_login($course, false, $cm);
50 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
51 $lessonoutput = $PAGE->get_renderer('mod_lesson');
53 // Get the mimetype
54 $mimetype = mimeinfo("type", $lesson->mediafile);
56 if ($printclose) { // this is for framesets
57 if ($lesson->mediaclose) {
58 $PAGE->set_title($course->shortname);
59 echo $lessonoutput->header($lesson, $cm);
60 echo $OUTPUT->box('<form><div><input type="button" onclick="top.close();" value="'.get_string("closewindow").'" /></div></form>', 'lessonmediafilecontrol');
61 echo $lessonoutput->footer();
63 exit();
66 $mediafilehtml = lesson_get_media_html($lesson, $context);
68 $PAGE->set_title($course->shortname);
69 echo $lessonoutput->header($lesson, $cm);
70 // print the embedded media html code
71 echo $OUTPUT->box($mediafilehtml);
73 if ($lesson->mediaclose) {
74 echo '<div class="lessonmediafilecontrol">';
75 echo $OUTPUT->close_window_button();
76 echo '</div>';
79 echo $lessonoutput->footer();