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 core\output\progress_trace;
18
 
19
use core\output\progress_trace;
20
 
21
/**
22
 * HTML List Progress Tree
23
 *
24
 * @copyright 2009 Tim Hunt
25
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 * @package core
27
 */
28
class html_list_progress_trace extends progress_trace {
29
    /** @var int The current depth of the trace*/
30
    protected int $currentdepth = -1;
31
 
32
    #[\Override]
33
    public function output(
34
        string $message,
35
        int $depth = 0,
36
    ): void {
37
        $samedepth = true;
38
        while ($this->currentdepth > $depth) {
39
            echo "</li>\n</ul>\n";
40
            $this->currentdepth -= 1;
41
            if ($this->currentdepth == $depth) {
42
                echo '<li>';
43
            }
44
            $samedepth = false;
45
        }
46
        while ($this->currentdepth < $depth) {
47
            echo "<ul>\n<li>";
48
            $this->currentdepth += 1;
49
            $samedepth = false;
50
        }
51
        if ($samedepth) {
52
            echo "</li>\n<li>";
53
        }
54
        echo htmlspecialchars($message, ENT_COMPAT);
55
        flush();
56
    }
57
 
58
    #[\Override]
59
    public function finished(): void {
60
        while ($this->currentdepth >= 0) {
61
            echo "</li>\n</ul>\n";
62
            $this->currentdepth -= 1;
63
        }
64
    }
65
}
66
 
67
// Alias this class to the old name.
68
// This file will be autoloaded by the legacyclasses autoload system.
69
// In future all uses of this class will be corrected and the legacy references will be removed.
70
class_alias(html_list_progress_trace::class, \html_list_progress_trace::class);