Merge branch 'w24_MDL-33670_m21_ofadmin' of git://github.com/skodak/moodle into MOODL...
[moodle.git] / mod / wiki / prettyview.php
blob6556ed76488279900fd05a24d568cc2d444d4e95
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-2.0
21 * @copyrigth 2009 Marc Alier, Jordi Piguillem marc.alier@upc.edu
22 * @copyrigth 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_login($course->id, true, $cm);
56 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
57 require_capability('mod/wiki:viewpage', $context);
59 $wikipage = new page_wiki_prettyview($wiki, $subwiki, $cm);
61 $wikipage->set_page($page);
62 add_to_log($course->id, "wiki", "view", "prettyview.php?pageid=".$pageid, $pageid, $cm->id);
64 $wikipage->print_header();
65 $wikipage->print_content();
66 $wikipage->print_footer();