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 |
* Form for editing multiblock parent block instances.
|
|
|
19 |
*
|
|
|
20 |
* @package block_multiblock
|
|
|
21 |
* @copyright 2019 Peter Spicer <peter.spicer@catalyst-eu.net>
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Form for editing multiblock parent block instances.
|
|
|
27 |
*
|
|
|
28 |
* @package block_multiblock
|
|
|
29 |
* @copyright 2019 Peter Spicer <peter.spicer@catalyst-eu.net>
|
|
|
30 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
31 |
*/
|
|
|
32 |
class block_multiblock_edit_form extends block_edit_form {
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Adds the specific settings from this block to the general block editing form.
|
|
|
36 |
*
|
|
|
37 |
* @param moodleform $mform The block editing form object.
|
|
|
38 |
*/
|
|
|
39 |
protected function specific_definition($mform) {
|
|
|
40 |
global $CFG;
|
|
|
41 |
// Let's have some configuration!
|
|
|
42 |
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
|
|
|
43 |
|
|
|
44 |
// First, the block's title.
|
|
|
45 |
$mform->addElement('text', 'config_title', get_string('blocktitle', 'block_multiblock'));
|
|
|
46 |
$mform->setType('config_title', PARAM_TEXT);
|
|
|
47 |
$mform->setDefault('config_title', get_config('block_multiblock', 'title'));
|
|
|
48 |
|
|
|
49 |
// Then which presentation format we want to use.
|
|
|
50 |
$presentations = block_multiblock::get_valid_presentations();
|
|
|
51 |
$options = [];
|
|
|
52 |
foreach ($presentations as $presentationid => $presentation) {
|
|
|
53 |
$suggested = $presentation->get_suggested_use();
|
|
|
54 |
if (!in_array($suggested, ['main', 'sidebar'])) {
|
|
|
55 |
continue;
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
$suggestedstring = get_string('layout:' . $suggested, 'block_multiblock');
|
|
|
59 |
|
|
|
60 |
if (!isset($options[$suggestedstring])) {
|
|
|
61 |
$options[$suggestedstring] = [];
|
|
|
62 |
}
|
|
|
63 |
$options[$suggestedstring][$presentationid] = $presentation->get_name();
|
|
|
64 |
}
|
|
|
65 |
$mform->addElement('selectgroups', 'config_presentation', get_string('presentation', 'block_multiblock'), $options);
|
|
|
66 |
$mform->setDefault('config_presentation', block_multiblock::get_default_presentation());
|
|
|
67 |
}
|
|
|
68 |
}
|