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
 * Configurable Reports
19
 * A Moodle block for creating customizable reports
20
 * @package blocks
21
 * @author: Juan leyva <http://www.twitter.com/jleyvadelgado>
22
 * @date: 2009
23
 */
24
 
25
if (!defined('MOODLE_INTERNAL')) {
26
    //  It must be included from a Moodle page.
27
    die('Direct access to this script is forbidden.');
28
}
29
 
30
require_once($CFG->libdir.'/formslib.php');
31
 
32
class columns_form extends moodleform {
33
    public function definition() {
34
        global $DB, $USER, $CFG;
35
 
36
        $mform =& $this->_form;
37
 
38
        $mform->addElement('header', get_string('reporttable', 'block_configurable_reports'), '');
39
 
40
        $mform->addElement('text', 'tablewidth', get_string('tablewidth', 'block_configurable_reports'));
41
        $mform->setType('tablewidth', PARAM_CLEAN);
42
        $mform->setDefault('tablewidth', '100%');
43
        $mform->addHelpButton('tablewidth', 'reporttable', 'block_configurable_reports');
44
 
45
        $options = array('center' => 'center', 'left' => 'left', 'right' => 'right');
46
 
47
        $mform->addElement('SELECT', 'tablealign', get_string('tablealign', 'block_configurable_reports'), $options);
48
        $mform->setType('tablealign', PARAM_CLEAN);
49
        $mform->setDefault('tablealign', 'center');
50
 
51
        $mform->addElement('text', 'cellspacing', get_string('tablecellspacing', 'block_configurable_reports'));
52
        $mform->setType('cellspacing', PARAM_INT);
53
        $mform->setDefault('cellspacing', '3');
54
        $mform->setAdvanced('cellspacing');
55
 
56
        $mform->addElement('text', 'cellpadding', get_string('tablecellpadding', 'block_configurable_reports'));
57
        $mform->setType('cellpadding', PARAM_INT);
58
        $mform->setDefault('cellpadding', '3');
59
        $mform->setAdvanced('cellpadding');
60
 
61
        $mform->addElement('text', 'class', get_string('tableclass', 'block_configurable_reports'));
62
        $mform->setType('class', PARAM_CLEAN);
63
        $mform->setAdvanced('class');
64
 
65
        // Buttons.
66
        $this->add_action_buttons(true, get_string('update'));
67
    }
68
 
69
    public function validation($data, $files) {
70
        $errors = parent::validation($data, $files);
71
 
72
        if (!preg_match("/^\d+%?$/i", trim($data['tablewidth']))) {
73
            $errors['tablewidth'] = get_string('badtablewidth', 'block_configurable_reports');
74
        }
75
 
76
        return $errors;
77
    }
78
}