Source
* @param int $format Use time zone name (from database) if short or time zone title (from list) if long.
<?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 Widgets\Clock\Actions;
use API,
CControllerDashboardWidgetView,
CControllerResponseData,
CTimezoneHelper,
DateTime,
DateTimeZone,
Exception,
Manager;
use Widgets\Clock\Widget;
class WidgetView extends CControllerDashboardWidgetView {
protected function doAction(): void {
$config_defaults = [
'name' => $this->widget->getDefaultName(),
'type' => $this->fields_values['clock_type'],
'time' => null,
'time_zone_offset' => null,
'date' => date(ZBX_DATE),
'time_zone' => TIMEZONE_DEFAULT_LOCAL,
'is_enabled' => true,
'critical_error' => null
];
switch ($this->fields_values['time_type']) {
case TIME_TYPE_HOST:
$clock_data = $this->configureHostTime() + $config_defaults;
break;
case TIME_TYPE_SERVER:
$clock_data = $this->configureFields() + $config_defaults;
$clock_data['name'] = _('Server');
break;
default:
$clock_data = $this->configureFields() + $config_defaults;
$clock_data['name'] = _('Local');
break;
}
// Pass clock configuration to browser script.
if ($this->fields_values['clock_type'] === Widget::TYPE_DIGITAL) {
$clock_data['show'] = $this->fields_values['show'];
$clock_data['bg_color'] = $this->fields_values['bg_color'];