Welcome to mirror list, hosted at ThFree Co, Russian Federation.

administration.geomaps.edit.php « views « app « ui - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: aefa0dde59ea12227ae3841efd4f09f81f1f7766 (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
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);
/*
** 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.
**/


/**
 * @var CView $this
 * @var array $data
 */

$this->includeJsFile('administration.geomaps.edit.js.php');

$hintbox_tile_url = makeHelpIcon([
	_('The URL template is used to load and display the tile layer on geographical maps.'),
	BR(),
	BR(),
	_('Example'), ': ', (new CSpan('https://{s}.example.com/{z}/{x}/{y}{r}.png'))->addClass(ZBX_STYLE_MONOSPACE_FONT),
	BR(),
	BR(),
	_('The following placeholders are supported:'),
	(new CList([
		new CListItem([
			(new CSpan('{s}'))->addClass(ZBX_STYLE_MONOSPACE_FONT), ' ',
			_('represents one of the available subdomains;')
		]),
		new CListItem([
			(new CSpan('{z}'))->addClass(ZBX_STYLE_MONOSPACE_FONT), ' ',
			_('represents zoom level parameter in the URL;')
		]),
		new CListItem([
			(new CSpan('{x}'))->addClass(ZBX_STYLE_MONOSPACE_FONT), ' ', _('and'), ' ',
			(new CSpan('{y}'))->addClass(ZBX_STYLE_MONOSPACE_FONT), ' ', _('represent tile coordinates;')
		]),
		new CListItem([
			(new CSpan('{r}'))->addClass(ZBX_STYLE_MONOSPACE_FONT), ' ',
			_('can be used to add "@2x" to the URL to load retina tiles.')
		])
	]))->addClass(ZBX_STYLE_LIST_DASHED)
]);

$hintbox_attribution = makeHelpIcon(
	_('Tile provider attribution data displayed in a small text box on the map.')
);

$hintbox_max_zoom = makeHelpIcon(_('Maximum zoom level of the map.'));

$form_grid = (new CFormGrid())
	->addItem([
		(new CLabel(_('Tile provider'), 'label-provider'))->setAsteriskMark(),
		new CFormField(
			(new CSelect('geomaps_tile_provider'))
				->setValue($data['geomaps_tile_provider'])
				->setFocusableElementId('label-provider')
				->addOptions(CSelect::createOptionsFromArray(
					array_combine(array_keys($data['tile_providers']), array_column($data['tile_providers'], 'name')) +
					['' => _('Other')]
				))
		)
	])
	->addItem([
		(new CLabel([_('Tile URL'), $hintbox_tile_url], 'geomaps_tile_url'))->setAsteriskMark(),
		new CFormField(
			(new CTextBox('geomaps_tile_url', $data['geomaps_tile_url'], false,
				DB::getFieldLength('config', 'geomaps_tile_url'))
			)
				->setWidth(ZBX_TEXTAREA_BIG_WIDTH)
				->setReadonly($data['geomaps_tile_provider'] !== '')
				->setAriaRequired()
		)
	])
	->addItem([
		new CLabel([_('Attribution'), $hintbox_attribution], 'geomaps_attribution'),
		new CFormField(
			(new CTextArea('geomaps_attribution', $data['geomaps_attribution']))
				->addClass(ZBX_STYLE_MONOSPACE_FONT)
				->setWidth(ZBX_TEXTAREA_BIG_WIDTH)
				->setReadonly($data['geomaps_tile_provider'] !== '')
				->setMaxLength(DB::getFieldLength('config', 'geomaps_attribution'))
		)
	])
	->addItem([
		(new CLabel([_('Max zoom level'), $hintbox_max_zoom], 'geomaps_max_zoom'))->setAsteriskMark(),
		new CFormField(
			(new CTextBox('geomaps_max_zoom', $data['geomaps_max_zoom'], false,
				DB::getFieldLength('config', 'geomaps_max_zoom'))
			)
				->setWidth(ZBX_TEXTAREA_TINY_WIDTH)
				->setReadonly($data['geomaps_tile_provider'] !== '')
				->setAriaRequired()
		)
	]);

$form = (new CForm())
	->setId('geomaps-form')
	->setName('geomaps-form')
	->setAction(
		(new CUrl('zabbix.php'))
			->setArgument('action', 'geomaps.update')
			->getUrl()
	)
	->setAttribute('aria-labelledby', CHtmlPage::PAGE_TITLE_ID)
	->addItem(
		(new CTabView())
			->addTab('geomaps_tab', _('Geographical maps'), $form_grid)
			->setFooter(makeFormFooter(
				new CSubmit('update', _('Update'))
			))
	);

(new CHtmlPage())
	->setTitle(_('Geographical maps'))
	->setTitleSubmenu(getAdministrationGeneralSubmenu())
	->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_GEOMAPS_EDIT))
	->addItem($form)
	->show();

(new CScriptTag(
	'view.init('.json_encode([
		'tile_providers' => $data['tile_providers']
	]).');'
))
	->setOnDocumentReady()
	->show();