See Release Notes
Long Term Support Release
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 * Class containing data for the view book page. 19 * 20 * @package booktool_print 21 * @copyright 2019 Mihail Geshoski 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace booktool_print\output; 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 use moodle_url; 29 use renderable; 30 use renderer_base; 31 use stdClass; 32 use templatable; 33 use context_module; 34 35 /** 36 * Class containing data for the print book page. 37 * 38 * @copyright 2019 Mihail Geshoski 39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 40 */ 41 class print_book_page implements renderable, templatable { 42 43 /** 44 * @var object $book The book object. 45 */ 46 protected $book; 47 48 /** 49 * @var object $cm The course module object. 50 */ 51 protected $cm; 52 53 /** 54 * Construct this renderable. 55 * 56 * @param object $book The book 57 * @param object $cm The course module 58 */ 59 public function __construct($book, $cm) { 60 $this->book = $book; 61 $this->cm = $cm; 62 } 63 64 /** 65 * Export this data so it can be used as the context for a mustache template. 66 * 67 * @param renderer_base $output 68 * @return stdClass 69 */ 70 public function export_for_template(renderer_base $output) { 71 global $OUTPUT, $CFG, $SITE, $USER; 72 73 $context = context_module::instance($this->cm->id); 74 $chapters = book_preload_chapters($this->book); 75 $course = get_course($this->book->course); 76 77 $data = new stdClass(); 78 // Print dialog link. 79 $data->printdialoglink = $output->render_print_book_dialog_link(); 80 $data->booktitle = $OUTPUT->heading(format_string($this->book->name, true, 81 array('context' => $context)), 1); 82 $introtext = file_rewrite_pluginfile_urls($this->book->intro, 'pluginfile.php', $context->id, 'mod_book', 'intro', null); 83 $data->bookintro = format_text($introtext, $this->book->introformat, 84 array('noclean' => true, 'context' => $context)); 85 $data->sitelink = \html_writer::link(new moodle_url($CFG->wwwroot), 86 format_string($SITE->fullname, true, array('context' => $context))); 87 $data->coursename = format_string($course->fullname, true, array('context' => $context)); 88 $data->modulename = format_string($this->book->name, true, array('context' => $context)); 89 $data->username = fullname($USER, true); 90 $data->printdate = userdate(time()); 91 $data->toc = $output->render_print_book_toc($chapters, $this->book, $this->cm); 92 foreach ($chapters as $ch) { 93 list($chaptercontent, $chaptervisible) = $output->render_print_book_chapter($ch, $chapters, $this->book, 94 $this->cm); 95 $chapter = new stdClass(); 96 $chapter->content = $chaptercontent; 97 $chapter->visible = $chaptervisible; 98 $data->chapters[] = $chapter; 99 } 100 101 return $data; 102 } 103 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body