[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/wiki/ -> prettyview.php (source)

   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 [email protected]
  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      print_error('incorrectpageid', 'wiki');
  42  }
  43  if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
  44      print_error('incorrectsubwikiid', 'wiki');
  45  }
  46  if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) {
  47      print_error('invalidcoursemodule');
  48  }
  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');
  52  }
  53  
  54  require_login($course, true, $cm);
  55  
  56  if (!wiki_user_can_view($subwiki, $wiki)) {
  57      print_error('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  $event = \mod_wiki\event\page_viewed::create(
  66          array(
  67              'context' => $context,
  68              'objectid' => $pageid,
  69              'other' => array('prettyview' => true)
  70              )
  71          );
  72  $event->add_record_snapshot('wiki_pages', $page);
  73  $event->add_record_snapshot('wiki', $wiki);
  74  $event->add_record_snapshot('wiki_subwikis', $subwiki);
  75  $event->trigger();
  76  
  77  $wikipage->print_header();
  78  $wikipage->print_content();
  79  $wikipage->print_footer();


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1