<?php declare(strict_types = 0);
$this->addJsFile('class.calendar.js');
$this->includeJsFile('administration.user.token.edit.js.php');
$widget = (new CWidget())
->setTitle(_('API tokens'))
->setTitleSubmenu(getUserSettingsSubmenu());
$token_form = (new CForm())
->setAttribute('aria-labelledby', ZBX_STYLE_PAGE_TITLE)
->addVar('userid', CWebUser::$data['userid'])
->addVar('action_src', 'user.token.edit')
->addVar('action_dst', ($data['tokenid'] == 0) ? 'user.token.view' : 'user.token.list')
->addVar('action', ($data['tokenid'] == 0) ? 'token.create' : 'token.update')
->addVar('tokenid', $data['tokenid']);
$token_from_list = (new CFormList())
->addRow((new CLabel(_('Name'), 'name'))->setAsteriskMark(),
(new CTextBox('name', $data['name'], false, DB::getFieldLength('token', 'name')))
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
->setAttribute('autofocus', 'autofocus')
->addRow(new CLabel(_('Description'), 'description'),
(new CTextArea('description', $data['description']))
->addClass(ZBX_STYLE_MONOSPACE_FONT)
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
->setMaxLength(DB::getFieldLength('token', 'description'))
->addRow(_('Set expiration date and time'),
(new CCheckBox('expires_state', '1'))
->setChecked($data['expires_state'])
->addRow((new CLabel(_('Expires at'), 'expires_at'))->setAsteriskMark(),