Differences Between: [Versions 310 and 400] [Versions 39 and 400]
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 * Renderer for the section links block. 19 * 20 * @since Moodle 2.5 21 * @package block_section_links 22 * @copyright 2013 Sam Hemelryk 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 /** 27 * Renderer for the section links block. 28 * 29 * @package block_section_links 30 * @copyright 2013 Sam Hemelryk 31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 32 */ 33 class block_section_links_renderer extends plugin_renderer_base { 34 35 /** 36 * Render a series of section links. 37 * 38 * @param stdClass $course The course we are rendering for. 39 * @param array $sections An array of section objects to render. 40 * @param bool|int The section to provide a jump to link for. 41 * @param bool $showsectionname Whether or not section name should be displayed. 42 * @return string The HTML to display. 43 */ 44 public function render_section_links(stdClass $course, array $sections, $jumptosection = false, $showsectionname = false) { 45 $olparams = $showsectionname ? ['class' => 'unlist'] : ['class' => 'inline-list']; 46 $html = html_writer::start_tag('ol', $olparams); 47 foreach ($sections as $section) { 48 $attributes = array(); 49 if (!$section->visible) { 50 $attributes['class'] = 'dimmed'; 51 } 52 $html .= html_writer::start_tag('li'); 53 $sectiontext = $section->section; 54 if ($showsectionname) { 55 $sectiontext .= ': ' . $section->name; 56 } 57 if ($section->highlight) { 58 $sectiontext = html_writer::tag('strong', $sectiontext); 59 } 60 $html .= html_writer::link(course_get_url($course, $section->section), $sectiontext, $attributes); 61 $html .= html_writer::end_tag('li').' '; 62 } 63 $html .= html_writer::end_tag('ol'); 64 if ($jumptosection && isset($sections[$jumptosection])) { 65 66 if ($course->format == 'weeks') { 67 $linktext = new lang_string('jumptocurrentweek', 'block_section_links'); 68 } else if ($course->format == 'topics') { 69 $linktext = new lang_string('jumptocurrenttopic', 'block_section_links'); 70 } 71 72 $attributes = array(); 73 if (!$sections[$jumptosection]->visible) { 74 $attributes['class'] = 'dimmed'; 75 } 76 $html .= html_writer::link(course_get_url($course, $jumptosection), $linktext, $attributes); 77 } 78 79 return $html; 80 } 81 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body