Proyectos de Subversion Moodle

Rev

| 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
 * myprofile renderer.
19
 *
20
 * @package    theme_universe
21
 * @copyright  Copyright © 2021 onwards Marcin Czaja
22
 * @author     G J Barnard - {@link http://moodle.org/user/profile.php?id=442195}
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 *
25
 */
26
 
27
namespace theme_universe\output\core_user\myprofile;
28
 
29
defined('MOODLE_INTERNAL') || die;
30
 
31
use core_user\output\myprofile\category;
32
use core_user\output\myprofile\node;
33
use core_user\output\myprofile\tree;
34
use html_writer;
35
 
36
require_once($CFG->dirroot . '/user/lib.php');
37
 
38
/**
39
 * myprofile renderer.
40
 * @copyright Copyright (c) 2017 Manoj Solanki (Coventry University)
41
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
42
 */
43
class renderer extends \core_user\output\myprofile\renderer {
44
 
45
    /**
46
     * Render a category.
47
     *
48
     * @param category $category
49
     *
50
     * @return string
51
     */
52
    public function render_category(category $category) {
53
        $classes = $category->classes;
54
        if (empty($classes)) {
55
            $return = \html_writer::start_tag(
56
                'section',
57
                array('class' => 'node_category card d-inline-block w-100 mb-5')
58
            );
59
            $return .= \html_writer::start_tag('div', array('class' => 'card-body'));
60
        } else {
61
            $return = \html_writer::start_tag(
62
                'section',
63
                array('class' => 'node_category card d-inline-block w-100 mb-3' . $classes)
64
            );
65
            $return .= \html_writer::start_tag('div', array('class' => 'card-body'));
66
        }
67
        $return .= \html_writer::tag('h5', $category->title, array('class' => 'card-title'));
68
        $nodes = $category->nodes;
69
        if (empty($nodes)) {
70
            // No nodes, nothing to render.
71
            return '';
72
        }
73
        $return .= \html_writer::start_tag('ul');
74
        foreach ($nodes as $node) {
75
            $return .= $this->render($node);
76
        }
77
        $return .= \html_writer::end_tag('ul');
78
        $return .= \html_writer::end_tag('div');
79
        $return .= \html_writer::end_tag('section');
80
        return $return;
81
    }
82
}