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
 * This layout displays data in a grid of cards.
19
 *
20
 * @package    block_dash
21
 * @copyright  2019 bdecent gmbh <https://bdecent.de>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
namespace block_dash\local\layout;
26
 
27
use block_dash\local\data_source\form\preferences_form;
28
/**
29
 * A layout contains information on how to display data.
30
 * @see abstract_layout for creating new layouts.
31
 *
32
 * This layout displays data in a grid of cards.
33
 *
34
 * @package block_dash
35
 */
36
class grid_layout extends abstract_layout {
37
 
38
    /**
39
     * Get mustache template name.
40
     *
41
     * @return string
42
     */
43
    public function get_mustache_template_name() {
44
        return 'block_dash/layout_grid';
45
    }
46
 
47
    /**
48
     * If the layout supports options.
49
     */
50
    public function supports_download() {
51
        return true;
52
    }
53
 
54
    /**
55
     * If the template should display pagination links.
56
     *
57
     * @return bool
58
     */
59
    public function supports_pagination() {
60
        return true;
61
    }
62
 
63
    /**
64
     * If the template fields can be hidden or shown conditionally.
65
     *
66
     * @return bool
67
     */
68
    public function supports_field_visibility() {
69
        return true;
70
    }
71
 
72
    /**
73
     * If the template should display filters (does not affect conditions).
74
     *
75
     * @return bool
76
     */
77
    public function supports_filtering() {
78
        return true;
79
    }
80
 
81
    /**
82
     * If the layout supports field sorting.
83
     *
84
     * @return mixed
85
     */
86
    public function supports_sorting() {
87
        return true;
88
    }
89
 
90
    /**
91
     * Add form elements to the preferences form when a user is configuring a block.
92
     *
93
     * This extends the form built by the data source. When a user chooses a layout, specific form elements may be
94
     * displayed after a quick refresh of the form.
95
     *
96
     * Be sure to call parent::build_preferences_form() if you override this method.
97
     *
98
     * @param \moodleform $form
99
     * @param \MoodleQuickForm $mform
100
     * @throws \coding_exception
101
     */
102
    public function build_preferences_form(\moodleform $form, \MoodleQuickForm $mform) {
103
 
104
        if ($form->get_tab() == preferences_form::TAB_FIELDS) {
105
 
106
            // Hide the table.
107
            $mform->addElement('advcheckbox', 'config_preferences[hidetable]', get_string('hidetable', 'block_dash'));
108
            $mform->setType('config_preferences[hidetable]', PARAM_BOOL);
109
            $mform->addHelpButton('config_preferences[hidetable]', 'hidetable', 'block_dash');
110
            $mform->setDefault('config_preferences[hidetable]', false);
111
 
112
            // Export the data.
113
            $mform->addElement('advcheckbox', 'config_preferences[exportdata]', get_string('enabledownload', 'block_dash'));
114
            $mform->setType('config_preferences[exportdata]', PARAM_BOOL);
115
            $mform->addHelpButton('config_preferences[exportdata]', 'enabledownload', 'block_dash');
116
            $mform->setDefault('config_preferences[exportdata]', get_config('block_dash', 'exportdata'));
117
        }
118
        parent::build_preferences_form($form, $mform);
119
 
120
    }
121
}