Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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
namespace block_site_main_menu\output;
18
 
19
use core_courseformat\base as courseformat;
20
use renderable;
21
use section_info;
22
use templatable;
23
 
24
/**
25
 * Class mainsection
26
 *
27
 * @package    block_site_main_menu
28
 * @copyright  2024 Ferran Recio <ferran@moodle.com>
29
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
31
class mainsection implements renderable, templatable {
32
 
33
    /**
34
     * The class constructor.
35
     *
36
     * @param courseformat $format the course format instance
37
     * @param section_info $section the section to render
38
     */
39
    public function __construct(
40
        /** @var courseformat $format the course format instance. */
41
        protected courseformat $format,
42
        /** @var section_info $section the section to render. */
43
        protected section_info $section,
44
    ) {
45
    }
46
 
47
    /**
48
     * Export for template.
49
     *
50
     * @param \renderer_base $output
51
     * @return array
52
     */
53
    public function export_for_template(\renderer_base $output) {
54
        $format = $this->format;
55
        $course = $format->get_course();
56
        $section = $this->section;
57
 
58
        $sectionoutputclass = $format->get_output_classname('content\\section\\cmlist');
59
        $sectionoutput = new $sectionoutputclass($format, $section);
60
 
61
        $cmlist = $output->render($sectionoutput);
62
 
63
        return [
64
            'siteid' => $course->id,
65
            'cmlist' => $cmlist,
66
            'sectionid' => $section->id,
67
            'sectionname' => $format->get_section_name($section),
68
            'sectionnum' => $section->sectionnum,
69
            'editing' => $format->show_editor(),
70
        ];
71
    }
72
}