Source
return $reference === self::REFERENCE_DASHBOARD ? self::DATA_SOURCE_DASHBOARD : self::DATA_SOURCE_WIDGET;
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
namespace Zabbix\Widgets\Fields;
use CAbsoluteTimeParser,
CApiInputValidator,
CParser,
CRangeTimeParser,
CRelativeTimeParser,
CTimePeriodHelper,
DateTimeZone;
use Zabbix\Widgets\CWidgetField;
class CWidgetFieldTimePeriod extends CWidgetField {
public const DEFAULT_VIEW = \CWidgetFieldTimePeriodView::class;
public const DEFAULT_VALUE = ['from' => '', 'to' => ''];
public const DATA_SOURCE_DEFAULT = 0;
public const DATA_SOURCE_WIDGET = 1;
public const DATA_SOURCE_DASHBOARD = 2;
private ?string $from_label = null;
private ?string $to_label = null;
private array $default_period = ['from' => '', 'to' => ''];
private ?int $min_period = 0;
private ?int $max_period = 0;
private ?DateTimeZone $timezone = null;
private bool $is_date_only = false;
public function __construct(string $name, string $label = null) {
parent::__construct($name, $label);
$this
->setDefault(self::DEFAULT_VALUE)
->setMaxLength(255)
->setValidationRules(['type' => API_OBJECT, 'fields' => [
'from' => ['type' => API_STRING_UTF8, 'flags' => API_REQUIRED, 'length' => $this->getMaxLength()],
'to' => ['type' => API_STRING_UTF8, 'flags' => API_REQUIRED, 'length' => $this->getMaxLength()]
]]);
}
public function setValue($value): self {
parent::setValue((array) $value);