Files
mrbs-equbao-2026/lib/MRBS/Form/FieldTimeWithUnits.php
T
人事系统开发 1ba6efd8ed MRBS 1.12.2 等保2.0二级整改完整提交
包含:登录失败锁定、90天密码有效期、30分钟会话超时、
强制改密、登录审计日志、屏幕水印、企业背景图、
备案信息固定底部、favicon、JS空集合保护、
会话过期体验优化(403 JSON)、display_errors 关闭、
固定 key 根治 Integrity check failed 等全部改动

注意:config.inc.php/.htaccess/.user.ini 含敏感信息,
通过 .gitignore 排除,勿推送到公开仓库。
2026-09-09 16:55:02 +08:00

63 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace MRBS\Form;
use function MRBS\toTimeString;
class FieldTimeWithUnits extends FieldDiv
{
// Constructs a field that has an enabling checkbox and then inputs for
// the quantity and units of time.
//
// $param_names An array of the parameter names, indexed by
// 'enabler', 'quantity' and 'seconds'
// $enabled The current value of the enabling checkbox
// $seconds The current value of the field, in seconds
// $suffix Optional text that can appear after the units
// $input_attributes Optional array of additional attributes for the input
public function __construct(array $param_names, $enabled, $seconds, $suffix=null, ?array $input_attributes=null)
{
parent::__construct();
// Convert the raw seconds into as large a unit as possible
$duration = $seconds;
toTimeString($duration, $units);
// The checkbox, which enables or disables the field
$checkbox = new ElementInputCheckbox();
$checkbox->setAttributes(array('name' => $param_names['enabler'],
'class' => 'enabler'))
->setChecked($enabled);
$this->addControlElement($checkbox);
// The quantity element
$input = new ElementInputNumber();
$attributes = array('name' => $param_names['quantity'],
'value' => $duration);
if (isset($input_attributes))
{
$attributes = array_merge($attributes, $input_attributes);
}
$input->setAttributes($attributes);
$this->addControlElement($input);
// The select element for the units
$options = Form::getTimeUnitOptions();
$select = new ElementSelect();
$select->setAttribute('name', $param_names['units'])
->addSelectOptions($options, array_search($units, $options), true);
$this->addControlElement($select);
// The suffix
if (isset($suffix))
{
$span = new ElementSpan();
$span->setText($suffix);
$this->addControlElement($span);
}
}
}