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
 * Moodle Component Library
19
 *
20
 * A sample of different singlebuttons
21
 *
22
 * @package    tool_componentlibrary
23
 * @copyright  2022 Laurent David <laurent.david@moodle.com>
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
26
 
27
require_once(__DIR__ . '/../../../../config.php');
28
require_once($CFG->dirroot . '/lib/formslib.php');
29
 
30
require_login();
31
require_capability('moodle/site:configview', context_system::instance());
32
 
33
$repeatcount = optional_param('test_repeat', 1, PARAM_INT);
34
 
35
$PAGE->set_pagelayout('embedded');
36
 
37
$url = new moodle_url('/admin/tool/componentlibrary/examples/singlebuttons.php');
38
$PAGE->set_url($url);
39
$PAGE->set_context(context_system::instance());
40
 
41
$PAGE->set_heading('Moodle single buttons');
42
$PAGE->set_title('Moodle single buttons');
43
 
44
$buttondefinitions = [
45
    ['label' => 'Standard'],
46
    ['label' => 'Primary', 'type' => single_button::BUTTON_PRIMARY],
47
    ['label' => 'Danger', 'type' => single_button::BUTTON_DANGER],
48
    ['label' => 'Warning', 'type' => single_button::BUTTON_WARNING],
49
    ['label' => 'Success', 'type' => single_button::BUTTON_SUCCESS],
50
    ['label' => 'Info', 'type' => single_button::BUTTON_INFO],
51
 
52
];
53
echo $OUTPUT->header();
54
foreach ($buttondefinitions as $def) {
55
    $button = new single_button($url, $def['label'], 'post', $def['type'] ??
56
        single_button::BUTTON_SECONDARY, $def['attributes'] ?? []);
57
    echo $OUTPUT->render($button);
58
}
59
echo $OUTPUT->footer();