Merge branch 'm38_MDL-68588_Hide_Backuptempdir_From_Message_And_Debuginfo' of https...
[moodle.git] / mod / wiki / prettyview.php
blob7efc27b4be01d309baf06c51778a7d2a62f12ee5
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * This file contains all necessary code to get a printable version of a wiki page
20 * @package mod_wiki
21 * @copyright 2009 Marc Alier, Jordi Piguillem marc.alier@upc.edu
22 * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
24 * @author Jordi Piguillem
25 * @author Marc Alier
26 * @author David Jimenez
27 * @author Josep Arus
28 * @author Kenneth Riba
30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33 require_once('../../config.php');
34 require_once($CFG->dirroot . '/mod/wiki/lib.php');
35 require_once($CFG->dirroot . '/mod/wiki/locallib.php');
36 require_once($CFG->dirroot . '/mod/wiki/pagelib.php');
38 $pageid = required_param('pageid', PARAM_INT); // Page ID
40 if (!$page = wiki_get_page($pageid)) {
41 print_error('incorrectpageid', 'wiki');
43 if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
44 print_error('incorrectsubwikiid', 'wiki');
46 if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) {
47 print_error('invalidcoursemodule');
49 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
50 if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
51 print_error('incorrectwikiid', 'wiki');
54 require_course_login($course, true, $cm);
56 if (!wiki_user_can_view($subwiki, $wiki)) {
57 print_error('cannotviewpage', 'wiki');
60 $wikipage = new page_wiki_prettyview($wiki, $subwiki, $cm);
62 $wikipage->set_page($page);
64 $context = context_module::instance($cm->id);
66 $other = array('prettyview' => true);
67 wiki_page_view($wiki, $page, $course, $cm, $context, null, $other, $subwiki);
69 $wikipage->print_header();
70 $wikipage->print_content();
71 $wikipage->print_footer();