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
 * Form for editing a multiblock subblock.
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
namespace block_multiblock\form;
26
use block_multiblock;
27
use block_multiblock\form\editblock_constructor;
28
 
29
defined('MOODLE_INTERNAL') || die();
30
 
31
require_once($CFG->libdir . '/formslib.php');
32
 
33
/**
34
 * Form for editing a multiblock subblock in Moodle.
35
 *
36
 * @package   block_multiblock
37
 * @copyright 2019 Peter Spicer <peter.spicer@catalyst-eu.net>
38
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39
 */
40
class editblock extends editblock_base {
41
 
42
    /**
43
     * Sets up the form definition - this will intentionally override the normal block
44
     * block configuration so we only get the parts specific to the subblock.
45
     */
46
    public function definition() {
47
        $mform =& $this->_form;
48
 
49
        $this->specific_definition($mform);
50
 
51
        if (!empty($this->multiblock) && $mform->elementExists('config_title')) {
52
            $presentations = block_multiblock::get_valid_presentations();
53
            $defaultconfig = (object) ['presentation' => block_multiblock::get_default_presentation()];
54
            $config = !empty($this->multiblock->config) ? $this->multiblock->config : $defaultconfig;
55
            if ($presentations[$config->presentation]->requires_title()) {
56
                $requiredmsg = get_string('requirestitle', 'block_multiblock', $this->multiblock->get_title());
57
                $mform->addRule('config_title', $requiredmsg, 'required', null, 'client');
58
            }
59
        }
60
 
61
        $this->add_save_buttons();
62
    }
63
}