Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 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 * Book print lib 19 * 20 * @package booktool_print 21 * @copyright 2011 Petr Skoda {@link http://skodak.org} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die; 26 27 require_once (__DIR__.'/lib.php'); 28 require_once($CFG->dirroot.'/mod/book/locallib.php'); 29 30 /** 31 * Generate toc structure and titles 32 * 33 * @deprecated since Moodle 3.7 34 * @param array $chapters 35 * @param stdClass $book 36 * @param stdClass $cm 37 * @return array 38 */ 39 function booktool_print_get_toc($chapters, $book, $cm) { 40 debugging('booktool_print_get_toc() is deprecated. Please use booktool_print renderer 41 function render_print_book_toc().', DEBUG_DEVELOPER); 42 43 $first = true; 44 $titles = array(); 45 46 $context = context_module::instance($cm->id); 47 48 $toc = ''; // Representation of toc (HTML). 49 50 switch ($book->numbering) { 51 case BOOK_NUM_NONE: 52 $toc .= html_writer::start_tag('div', array('class' => 'book_toc_none')); 53 break; 54 case BOOK_NUM_NUMBERS: 55 $toc .= html_writer::start_tag('div', array('class' => 'book_toc_numbered')); 56 break; 57 case BOOK_NUM_BULLETS: 58 $toc .= html_writer::start_tag('div', array('class' => 'book_toc_bullets')); 59 break; 60 case BOOK_NUM_INDENTED: 61 $toc .= html_writer::start_tag('div', array('class' => 'book_toc_indented')); 62 break; 63 } 64 65 $toc .= html_writer::tag('a', '', array('name' => 'toc')); // Representation of toc (HTML). 66 67 $toc .= html_writer::tag('h2', get_string('toc', 'mod_book')); 68 $toc .= html_writer::start_tag('ul'); 69 foreach ($chapters as $ch) { 70 if (!$ch->hidden) { 71 $title = book_get_chapter_title($ch->id, $chapters, $book, $context); 72 if (!$ch->subchapter) { 73 74 if ($first) { 75 $toc .= html_writer::start_tag('li'); 76 } else { 77 $toc .= html_writer::end_tag('ul'); 78 $toc .= html_writer::end_tag('li'); 79 $toc .= html_writer::start_tag('li'); 80 } 81 82 } else { 83 84 if ($first) { 85 $toc .= html_writer::start_tag('li'); 86 $toc .= html_writer::start_tag('ul'); 87 $toc .= html_writer::start_tag('li'); 88 } else { 89 $toc .= html_writer::start_tag('li'); 90 } 91 92 } 93 $titles[$ch->id] = $title; 94 $toc .= html_writer::link(new moodle_url('#ch'.$ch->id), $title, array('title' => s($title))); 95 if (!$ch->subchapter) { 96 $toc .= html_writer::start_tag('ul'); 97 } else { 98 $toc .= html_writer::end_tag('li'); 99 } 100 $first = false; 101 } 102 } 103 104 $toc .= html_writer::end_tag('ul'); 105 $toc .= html_writer::end_tag('li'); 106 $toc .= html_writer::end_tag('ul'); 107 $toc .= html_writer::end_tag('div'); 108 109 $toc = str_replace('<ul></ul>', '', $toc); // Cleanup of invalid structures. 110 111 return array($toc, $titles); 112 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body