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 outputting the weeks course format.
19 *
20 * @package format_weeks
21 * @copyright 2012 Dan Poltawski
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 * @since Moodle 2.3
24 */
25
26
27defined('MOODLE_INTERNAL') || die();
28require_once($CFG->dirroot.'/course/format/renderer.php');
29require_once($CFG->dirroot.'/course/format/weeks/lib.php');
30
31
32/**
33 * Basic renderer for weeks format.
34 *
35 * @copyright 2012 Dan Poltawski
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 */
38class format_weeks_renderer extends format_section_renderer_base {
39    /**
40     * Generate the starting container html for a list of sections
41     * @return string HTML to output.
42     */
43    protected function start_section_list() {
44        return html_writer::start_tag('ul', array('class' => 'weeks'));
45    }
46
47    /**
48     * Generate the closing container html for a list of sections
49     * @return string HTML to output.
50     */
51    protected function end_section_list() {
52        return html_writer::end_tag('ul');
53    }
54
55    /**
56     * Generate the title for this section page
57     * @return string the page title
58     */
59    protected function page_title() {
60        return get_string('weeklyoutline');
61    }
62
63    /**
64     * Generate the section title, wraps it in a link to the section page if page is to be displayed on a separate page
65     *
66     * @param stdClass $section The course_section entry from DB
67     * @param stdClass $course The course entry from DB
68     * @return string HTML to output.
69     */
70    public function section_title($section, $course) {
71        return $this->render(course_get_format($course)->inplace_editable_render_section_name($section));
72    }
73
74    /**
75     * Generate the section title to be displayed on the section page, without a link
76     *
77     * @param stdClass $section The course_section entry from DB
78     * @param stdClass $course The course entry from DB
79     * @return string HTML to output.
80     */
81    public function section_title_without_link($section, $course) {
82        return $this->render(course_get_format($course)->inplace_editable_render_section_name($section, false));
83    }
84}
85