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
namespace core_admin\output;
18
 
19
use moodle_url;
20
use renderable;
21
use renderer_base;
22
use stdClass;
23
use templatable;
24
 
25
/**
26
 * Theme selector renderable.
27
 *
28
 * @package    core_admin
29
 * @copyright  2023 David Woloszyn <david.woloszyn@moodle.com>
30
 * @license    https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31
 */
32
class theme_selector implements renderable, templatable {
33
 
34
    /** @var array $themedata Theme data to pass to the template. */
35
    private $themedata = null;
36
 
37
    /** @var bool Whether $CFG->theme is defined in config.php. */
38
    private $definedinconfig;
39
 
40
    /**
41
     * Constructor.
42
     *
43
     * @param array $themedata Theme data used for template.
44
     * @param bool $definedinconfig Whether $CFG->theme is defined in config.php.
45
     */
46
    public function __construct(array $themedata, bool $definedinconfig = false) {
47
        $this->themedata = $themedata;
48
        $this->definedinconfig = $definedinconfig;
49
    }
50
 
51
    /**
52
     * Export this data so it can be used as the context for a mustache template.
53
     *
54
     * @param renderer_base $output Renderer base.
55
     * @return stdClass
56
     */
57
    public function export_for_template(renderer_base $output): stdClass {
58
 
59
        $data = new stdClass();
60
        // Theme data used to populate cards and modal.
61
        $data->themes = $this->themedata;
62
        // Reset theme caches button.
63
        $reseturl = new moodle_url('/admin/themeselector.php', ['sesskey' => sesskey(), 'reset' => 1]);
64
        $resetbutton = new \single_button($reseturl, get_string('themeresetcaches', 'admin'), 'post',
65
            \single_button::BUTTON_SECONDARY);
66
        $data->resetbutton = $resetbutton->export_for_template($output);
67
        $data->definedinconfig = $this->definedinconfig;
68
 
69
        return $data;
70
    }
71
}