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
 * A field is a simple container for a single value within a row/collection.
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\data_grid\data;
26
/**
27
 * A field is a simple container for a single value within a row/collection.
28
 *
29
 * @package block_dash
30
 */
31
class field implements field_interface {
32
 
33
    /**
34
     * @var string
35
     */
36
    private $name;
37
 
38
    /**
39
     * @var mixed|string
40
     */
41
    private $value;
42
 
43
    /**
44
     * @var string
45
     */
46
    private $label;
47
 
48
    /**
49
     * @var bool
50
     */
51
    private $visible;
52
 
53
    /**
54
     * Create a new field.
55
     *
56
     * @param string $name
57
     * @param string $value
58
     * @param string $visible
59
     * @param string $label
60
     */
61
    public function __construct($name, $value, $visible, $label = '') {
62
        $this->name = $name;
63
        $this->value = $value;
64
        $this->visible = $visible;
65
        $this->label = $label;
66
    }
67
 
68
    /**
69
     * Get field name.
70
     *
71
     * @return string
72
     */
73
    public function get_name() {
74
        return $this->name;
75
    }
76
 
77
    /**
78
     * Get field value.
79
     *
80
     * @return mixed|string
81
     */
82
    public function get_value() {
83
        if (!filter_var($this->value, FILTER_VALIDATE_URL)) {
84
            return format_text($this->value, FORMAT_HTML, ['noclean' => true]);
85
        }
86
        return $this->value;
87
    }
88
 
89
    /**
90
     * Get label of field definition.
91
     *
92
     * @return string|null
93
     */
94
    public function get_label() {
95
        return $this->label;
96
    }
97
 
98
    /**
99
     * Check the field is visible.
100
     * @return bool
101
     */
102
    public function is_visible() {
103
        return $this->visible;
104
    }
105
}