Source
xxxxxxxxxx
* @param array $data['tasks'] List of tasks. Used to determine current problem status.
<?php declare(strict_types = 0);
/*
** Zabbix
** Copyright (C) 2001-2023 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.
**/
namespace Widgets\Problems\Includes;
use CButtonIcon,
CCol,
CColHeader,
CHintBoxHelper,
CIcon,
CLink,
CLinkAction,
CMacrosResolverHelper,
CMenuPopupHelper,
CRow,
CScreenProblem,
CSeverityHelper,
CSpan,
CTableInfo,
CUrl;
class WidgetProblems extends CTableInfo {
private array $data;
public function __construct(array $data) {
$this->data = $data;
parent::__construct();
}
private function build(): void {
$sort_div = (new CSpan())->addClass(
($this->data['sortorder'] === ZBX_SORT_DOWN) ? ZBX_STYLE_ARROW_DOWN : ZBX_STYLE_ARROW_UP
);
$show_timeline = ($this->data['sortfield'] === 'clock' && $this->data['fields']['show_timeline']);
$show_recovery_data = in_array($this->data['fields']['show'],
[TRIGGERS_OPTION_RECENT_PROBLEM, TRIGGERS_OPTION_ALL]
);
$header_time = (new CColHeader(($this->data['sortfield'] === 'clock')
? [_x('Time', 'compact table header'), $sort_div]
: _x('Time', 'compact table header')))->addStyle('width: 120px;');
$header = [];
if ($this->data['show_three_columns']) {
$header[] = new CColHeader();
$header[] = (new CColHeader())->addClass(ZBX_STYLE_CELL_WIDTH);
}
elseif ($this->data['show_two_columns']) {
$header[] = new CColHeader();
}
if ($show_timeline) {
$header[] = $header_time->addClass(ZBX_STYLE_RIGHT);
$header[] = (new CColHeader())->addClass(ZBX_STYLE_TIMELINE_TH);
$header[] = (new CColHeader())->addClass(ZBX_STYLE_TIMELINE_TH);
}
else {
$header[] = $header_time;
}
$this->setHeader(array_merge($header, [
$show_recovery_data
? _x('Recovery time', 'compact table header')
: null,
$show_recovery_data
? _x('Status', 'compact table header')
: null,
_x('Info', 'compact table header'),
($this->data['sortfield'] === 'host')
? [_x('Host', 'compact table header'), $sort_div]