File: CWidgetsData.php

package info (click to toggle)
zabbix 1%3A7.0.10%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 272,688 kB
  • sloc: sql: 946,050; ansic: 389,440; php: 292,698; javascript: 83,388; sh: 5,680; makefile: 3,285; java: 1,420; cpp: 694; perl: 64; xml: 56
file content (139 lines) | stat: -rw-r--r-- 4,547 bytes parent folder | download | duplicates (2)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/


use Zabbix\Widgets\Fields\{
	CWidgetFieldMultiSelectGraph,
	CWidgetFieldMultiSelectGraphPrototype,
	CWidgetFieldMultiSelectGroup,
	CWidgetFieldMultiSelectHost,
	CWidgetFieldMultiSelectItem,
	CWidgetFieldMultiSelectItemPrototype,
	CWidgetFieldMultiSelectMap,
	CWidgetFieldMultiSelectService,
	CWidgetFieldMultiSelectSla,
	CWidgetFieldTimePeriod
};

class CWidgetsData {

	public const DATA_TYPE_HOST_GROUP_ID =		'_hostgroupid';
	public const DATA_TYPE_HOST_GROUP_IDS =		'_hostgroupids';
	public const DATA_TYPE_HOST_ID =			'_hostid';
	public const DATA_TYPE_HOST_IDS =			'_hostids';
	public const DATA_TYPE_ITEM_ID =			'_itemid';
	public const DATA_TYPE_ITEM_IDS =			'_itemids';
	public const DATA_TYPE_ITEM_PROTOTYPE_ID =	'_itemprototypeid';
	public const DATA_TYPE_GRAPH_ID =			'_graphid';
	public const DATA_TYPE_GRAPH_PROTOTYPE_ID =	'_graphprototypeid';
	public const DATA_TYPE_MAP_ID =				'_mapid';
	public const DATA_TYPE_SERVICE_ID =			'_serviceid';
	public const DATA_TYPE_SLA_ID =				'_slaid';
	public const DATA_TYPE_TIME_PERIOD =		'_timeperiod';

	/**
	 * Get data types supported by widget communication framework out of the box.
	 *
	 * @return array[]
	 */
	public static function getDataTypes(): array {
		static $data_types;

		if ($data_types === null) {
			$data_types = [
				self::DATA_TYPE_HOST_GROUP_ID => [
					'field_class' => CWidgetFieldMultiSelectGroup::class,
					'label' => _('Host group'),
					'is_multiple' => false,
					'accepts_dashboard' => false
				],
				self::DATA_TYPE_HOST_GROUP_IDS => [
					'field_class' => CWidgetFieldMultiSelectGroup::class,
					'label' => _('Host groups'),
					'is_multiple' => true,
					'accepts_dashboard' => false
				],
				self::DATA_TYPE_HOST_ID => [
					'field_class' => CWidgetFieldMultiSelectHost::class,
					'label' => _('Host'),
					'is_multiple' => false,
					'accepts_dashboard' => true
				],
				self::DATA_TYPE_HOST_IDS => [
					'field_class' => CWidgetFieldMultiSelectHost::class,
					'label' => _('Hosts'),
					'is_multiple' => true,
					'accepts_dashboard' => true
				],
				self::DATA_TYPE_ITEM_ID => [
					'field_class' => CWidgetFieldMultiSelectItem::class,
					'label' => _('Item'),
					'is_multiple' => false,
					'accepts_dashboard' => false
				],
				self::DATA_TYPE_ITEM_IDS => [
					'field_class' => CWidgetFieldMultiSelectItem::class,
					'label' => _('Item'),
					'is_multiple' => true,
					'accepts_dashboard' => false
				],
				self::DATA_TYPE_ITEM_PROTOTYPE_ID => [
					'field_class' => CWidgetFieldMultiSelectItemPrototype::class,
					'label' => _('Item prototype'),
					'is_multiple' => false,
					'accepts_dashboard' => false
				],
				self::DATA_TYPE_GRAPH_ID => [
					'field_class' => CWidgetFieldMultiSelectGraph::class,
					'label' => _('Graph'),
					'is_multiple' => false,
					'accepts_dashboard' => false
				],
				self::DATA_TYPE_GRAPH_PROTOTYPE_ID => [
					'field_class' => CWidgetFieldMultiSelectGraphPrototype::class,
					'label' => _('Graph prototype'),
					'is_multiple' => false,
					'accepts_dashboard' => false
				],
				self::DATA_TYPE_MAP_ID => [
					'field_class' => CWidgetFieldMultiSelectMap::class,
					'label' => _('Map'),
					'is_multiple' => false,
					'accepts_dashboard' => false
				],
				self::DATA_TYPE_SERVICE_ID => [
					'field_class' => CWidgetFieldMultiSelectService::class,
					'label' => _('Service'),
					'is_multiple' => false,
					'accepts_dashboard' => false
				],
				self::DATA_TYPE_SLA_ID => [
					'field_class' => CWidgetFieldMultiSelectSla::class,
					'label' => _('SLA'),
					'is_multiple' => false,
					'accepts_dashboard' => false
				],
				self::DATA_TYPE_TIME_PERIOD => [
					'field_class' => CWidgetFieldTimePeriod::class,
					'label' => _('Time period'),
					'is_multiple' => null,
					'accepts_dashboard' => true
				]
			];
		}

		return $data_types;
	}
}