Source
* @param int|null $values['change_indicator'] Change indicator type or NULL if indicator should not be shown.
<?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 CControllerWidgetItemView extends CControllerWidget {
public const CHANGE_INDICATOR_UP = 1;
public const CHANGE_INDICATOR_DOWN = 2;
public const CHANGE_INDICATOR_UP_DOWN = 3;
public function __construct() {
parent::__construct();
$this->setType(WIDGET_ITEM);
$this->setValidationRules([
'name' => 'string',
'fields' => 'json',
'dynamic_hostid' => 'db hosts.hostid'
]);
}
protected function doAction() {
$name = $this->getDefaultName();
$cells = [];
$url = null;
$error = '';
$fields = $this->getForm()->getFieldsData();
$history_period = timeUnitToSeconds(CSettingsHelper::get(CSettingsHelper::HISTORY_PERIOD));
$description = '';
$value = null;
$change_indicator = null;
$time = '';
$units = '';
$decimals = null;
$is_dynamic = ($this->hasInput('dynamic_hostid')
&& ($this->getContext() === CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD
|| $fields['dynamic'] == WIDGET_DYNAMIC_ITEM)
);
if ($is_dynamic) {
$tmp_items = API::Item()->get([
'output' => ['key_'],
'itemids' => $fields['itemid'],
'webitems' => true
]);