Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * Site main menu block.
19
 *
20
 * @package    block_site_main_menu
21
 * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
1441 ariadna 24
class block_site_main_menu extends block_base {
1 efrain 25
    function init() {
26
        $this->title = get_string('pluginname', 'block_site_main_menu');
27
    }
28
 
29
    function applicable_formats() {
30
        return array('site' => true);
31
    }
32
 
33
    function get_content() {
34
        if ($this->content !== NULL) {
35
            return $this->content;
36
        }
37
 
38
        $this->content = new stdClass();
1441 ariadna 39
        $this->content->text = '';
1 efrain 40
        $this->content->footer = '';
41
 
42
        if (empty($this->instance)) {
43
            return $this->content;
44
        }
45
 
46
        $course = get_site();
47
 
48
        course_create_sections_if_missing($course, 0);
1441 ariadna 49
        $format = course_get_format($course);
50
        $modinfo = $format->get_modinfo();
1 efrain 51
        $section = $modinfo->get_section_info(0);
52
 
1441 ariadna 53
        $courserenderer = $format->get_renderer($this->page);
1 efrain 54
 
1441 ariadna 55
        $output = new block_site_main_menu\output\mainsection($format, $section);
1 efrain 56
 
1441 ariadna 57
        $this->content->text = $courserenderer->render($output);
1 efrain 58
 
59
        if ($this->page->course->id === SITEID) {
1441 ariadna 60
            $this->content->footer = $courserenderer->course_section_add_cm_control(
61
                course: $course,
62
                section: 0,
63
                sectionreturn: null,
64
                displayoptions: ['inblock' => true],
65
            );
1 efrain 66
        }
67
        return $this->content;
68
    }
69
}