removed bogus function calls
[moodle.git] / mod / page / view.php
CommitLineData
1ad9ff57 1<?php
2
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.
14//
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/>.
17
18/**
19 * Page module version information
20 *
2c49daf7
PS
21 * @package mod
22 * @subpackage page
23 * @copyright 2009 Petr Skoda (http://skodak.org)
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
1ad9ff57 25 */
26
27require('../../config.php');
28require_once($CFG->dirroot.'/mod/page/locallib.php');
29
30$id = optional_param('id', 0, PARAM_INT); // Course Module ID
31$p = optional_param('p', 0, PARAM_INT); // Page instance ID
32$inpopup = optional_param('inpopup', 0, PARAM_BOOL);
33
34if ($p) {
35 if (!$page = $DB->get_record('page', array('id'=>$p))) {
1ad9ff57 36 print_error('invalidaccessparameter');
37 }
38 $cm = get_coursemodule_from_instance('page', $page->id, $page->course, false, MUST_EXIST);
39
40} else {
41 if (!$cm = get_coursemodule_from_id('page', $id)) {
1ad9ff57 42 print_error('invalidcoursemodule');
43 }
44 $page = $DB->get_record('page', array('id'=>$cm->instance), '*', MUST_EXIST);
45}
46
47$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
48
49require_course_login($course, true, $cm);
50$context = get_context_instance(CONTEXT_MODULE, $cm->id);
51
52add_to_log($course->id, 'page', 'view', 'view.php?id='.$cm->id, $page->id, $cm->id);
53
c15a60e6 54// Update 'viewed' state if required by completion system
518f7d92 55require_once($CFG->libdir . '/completionlib.php');
c15a60e6
SM
56$completion = new completion_info($course);
57$completion->set_module_viewed($cm);
58
a6855934 59$PAGE->set_url('/mod/page/view.php', array('id' => $cm->id));
1ad9ff57 60
61$options = empty($page->displayoptions) ? array() : unserialize($page->displayoptions);
62
63if ($inpopup and $page->display == RESOURCELIB_DISPLAY_POPUP) {
78946b9b 64 $PAGE->set_pagelayout('popup');
1ad9ff57 65 $PAGE->set_title($course->shortname.': '.$page->name);
66 if (!empty($options['printheading'])) {
67 $PAGE->set_heading($page->name);
68 } else {
69 $PAGE->set_heading('');
70 }
71 echo $OUTPUT->header();
72
73} else {
74 $PAGE->set_title($course->shortname.': '.$page->name);
75 $PAGE->set_heading($course->fullname);
76 $PAGE->set_activity_record($page);
0d7f1180 77 echo $OUTPUT->header();
1ad9ff57 78
79 if (!empty($options['printheading'])) {
80 echo $OUTPUT->heading(format_string($page->name), 2, 'main', 'pageheading');
81 }
82}
83
84if (!empty($options['printintro'])) {
85 if (trim(strip_tags($page->intro))) {
86 echo $OUTPUT->box_start('mod_introbox', 'pageintro');
87 echo format_module_intro('page', $page, $cm->id);
88 echo $OUTPUT->box_end();
89 }
90}
91
64f93798 92$content = file_rewrite_pluginfile_urls($page->content, 'pluginfile.php', $context->id, 'mod_page', 'content', $page->revision);
1ad9ff57 93$formatoptions = (object)array('noclean'=>true);
94$content = format_text($content, $page->contentformat, $formatoptions, $course->id);
95echo $OUTPUT->box($content, "generalbox center clearfix");
96
97$strlastmodified = get_string("lastmodified");
98echo "<div class=\"modified\">$strlastmodified: ".userdate($page->timemodified)."</div>";
99
100echo $OUTPUT->footer();