Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403]

   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.
  13  //
  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/>.
  16  
  17  /**
  18   * This file contains all necessary code to get a printable version of a wiki page
  19   *
  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
  23   *
  24   * @author Jordi Piguillem
  25   * @author Marc Alier
  26   * @author David Jimenez
  27   * @author Josep Arus
  28   * @author Kenneth Riba
  29   *
  30   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  31   */
  32  
  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');
  37  
  38  $pageid = required_param('pageid', PARAM_INT); // Page ID
  39  
  40  if (!$page = wiki_get_page($pageid)) {
  41      throw new \moodle_exception('incorrectpageid', 'wiki');
  42  }
  43  if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
  44      throw new \moodle_exception('incorrectsubwikiid', 'wiki');
  45  }
  46  if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) {
  47      throw new \moodle_exception('invalidcoursemodule');
  48  }
  49  $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
  50  if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
  51      throw new \moodle_exception('incorrectwikiid', 'wiki');
  52  }
  53  
  54  require_course_login($course, true, $cm);
  55  
  56  if (!wiki_user_can_view($subwiki, $wiki)) {
  57      throw new \moodle_exception('cannotviewpage', 'wiki');
  58  }
  59  
  60  $wikipage = new page_wiki_prettyview($wiki, $subwiki, $cm);
  61  
  62  $wikipage->set_page($page);
  63  
  64  $context = context_module::instance($cm->id);
  65  
  66  $other = array('prettyview' => true);
  67  wiki_page_view($wiki, $page, $course, $cm, $context, null, $other, $subwiki);
  68  
  69  $wikipage->print_header();
  70  $wikipage->print_content();
  71  $wikipage->print_footer();