blob: 7d3e3b01cb60f606f6e1db513e3b025a1acce269 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
<?php declare(strict_types = 0);
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
use Zabbix\Widgets\CWidgetField;
abstract class CWidgetFieldView {
protected CWidgetField $field;
protected string $form_name = '';
protected ?CTag $hint = null;
protected $help_hint;
public function setFormName($form_name): self {
$this->form_name = $form_name;
return $this;
}
public function setHint(CTag $hint): self {
$this->hint = $hint;
return $this;
}
public function setHelpHint($help_hint): self {
$this->help_hint = $help_hint;
return $this;
}
public function getLabel(): ?CLabel {
$label = $this->field->getLabel();
if ($label === null) {
return null;
}
return new CLabel([
$label,
$this->hint,
$this->help_hint !== null ? makeHelpIcon($this->help_hint) : null
], zbx_formatDomId($this->field->getName()));
}
/**
* @return null|array|CTag
*/
public function getView() {
return null;
}
public function getJavaScript(): string {
return '';
}
public function getTemplates(): array {
return [];
}
public function isNotEmpty(): bool {
return ($this->field->getFlags() & CWidgetField::FLAG_NOT_EMPTY) !== 0;
}
public function isRequired(): bool {
return ($this->field->getFlags() & CWidgetField::FLAG_LABEL_ASTERISK) !== 0;
}
public function isDisabled(): bool {
return ($this->field->getFlags() & CWidgetField::FLAG_DISABLED) !== 0;
}
}
|