1<?php
2/*
3** Zabbix
4** Copyright (C) 2001-2021 Zabbix SIA
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation; either version 2 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19**/
20
21
22/**
23 * @var CView $this
24 */
25
26$output = [
27	'name' => $data['name']
28];
29
30if ($data['is_resource_available']) {
31	$link_url = ($data['widget']['graph_url'] !== null) ? $data['widget']['graph_url'] : 'javascript:void(0)';
32
33	$output['body'] = (new CDiv())
34		->addClass('flickerfreescreen')
35		->addItem((new CLink(null, $link_url))->addClass(ZBX_STYLE_DASHBOARD_WIDGET_GRAPH_LINK))
36		->toString();
37
38	$output['async_data'] = $data['widget'];
39}
40else {
41	$output['body'] = (new CTableInfo())
42		->setNoDataMessage(_('No permissions to referred object or it does not exist!'))
43		->toString();
44}
45
46if (($messages = getMessages()) !== null) {
47	$output['messages'] = $messages->toString();
48}
49
50if ($data['user']['debug_mode'] == GROUP_DEBUG_MODE_ENABLED) {
51	CProfiler::getInstance()->stop();
52	$output['debug'] = CProfiler::getInstance()->make()->toString();
53}
54
55echo json_encode($output);
56