Source
xxxxxxxxxx
* @param string|null $templateid Template ID for template dashboards or null for non-template dashboards.
<?php declare(strict_types = 1);
/*
** 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.
**/
class CWidgetConfig {
/**
* Array of deprecated widgets constants.
*/
public const DEPRECATED_WIDGETS = [
WIDGET_DATA_OVER
];
/**
* Classifier for non-template dashboards.
*/
public const CONTEXT_DASHBOARD = 'dashboard';
/**
* Classifier for template and host dashboards.
*/
public const CONTEXT_TEMPLATE_DASHBOARD = 'template_dashboard';
/**
* Get default names for all widget types.
*
* @static
*
* @param string $context CWidgetConfig::CONTEXT_DASHBOARD | CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD
*
* @return array
*/
public static function getKnownWidgetTypes(string $context): array {
$types = [
WIDGET_ACTION_LOG => _('Action log'),
WIDGET_CLOCK => _('Clock'),
WIDGET_DATA_OVER => _('Data overview'),
WIDGET_DISCOVERY => _('Discovery status'),
WIDGET_FAV_GRAPHS => _('Favorite graphs'),
WIDGET_FAV_MAPS => _('Favorite maps'),
WIDGET_GEOMAP => _('Geomap'),
WIDGET_ITEM => _('Item value'),
WIDGET_GRAPH => _('Graph (classic)'),
WIDGET_GRAPH_PROTOTYPE => _('Graph prototype'),
WIDGET_HOST_AVAIL => _('Host availability'),
WIDGET_MAP => _('Map'),
WIDGET_NAV_TREE => _('Map navigation tree'),
WIDGET_PLAIN_TEXT => _('Plain text'),
WIDGET_PROBLEM_HOSTS => _('Problem hosts'),
WIDGET_PROBLEMS => _('Problems'),
WIDGET_PROBLEMS_BY_SV => _('Problems by severity'),
WIDGET_SLA_REPORT => _('SLA report'),
WIDGET_SVG_GRAPH => _('Graph'),
WIDGET_SYSTEM_INFO => _('System information'),
WIDGET_TRIG_OVER => _('Trigger overview'),
WIDGET_URL => _('URL'),
WIDGET_WEB => _('Web monitoring'),
WIDGET_TOP_HOSTS => _('Top hosts')
];
$types = array_filter($types,
function(string $type) use ($context): bool {
return self::isWidgetTypeSupportedInContext($type, $context);
},
ARRAY_FILTER_USE_KEY
);
return $types;
}
/**
* Get JavaScript classes for all widget types.
*
* @static