fix: clarify resource region fields

dev
admin 2 months ago
parent 069c7f1b56
commit f2c624b2db

@ -8,6 +8,7 @@ use App\Services\Cloud\CloudAdminBillingService;
use App\Services\Cloud\CloudAdminInstanceService;
use App\Services\Cloud\CloudAdminOperationsService;
use App\Services\Cloud\CloudAdminResourceService;
use App\Services\Cloud\CloudCountryCatalog;
use App\Services\Cloud\CloudError;
/** Admin pages use database-only first paints; JSON APIs repeat authorisation. */
@ -52,7 +53,8 @@ final class CloudPageController extends AdminController
public function hosts($request, $response, $args)
{
return $this->view()->display('admin/hosts/index.tpl');
return $this->view()->assign('cloud_country_options', CloudCountryCatalog::options())
->display('admin/hosts/index.tpl');
}
public function templates($request, $response, $args)

@ -3,12 +3,14 @@
namespace App\Controllers\Admin;
use App\Controllers\AdminController;
use App\Services\Cloud\CloudCountryCatalog;
/** Layout preparation only: no credentials, host mutation or remote connection. */
final class HostController extends AdminController
{
public function index($request, $response, $args)
{
return $this->view()->display('admin/hosts/index.tpl');
return $this->view()->assign('cloud_country_options', CloudCountryCatalog::options())
->display('admin/hosts/index.tpl');
}
}

@ -4,6 +4,7 @@ namespace App\Controllers;
use App\Models\CloudHost;
use App\Services\Cloud\CloudAccess;
use App\Services\Cloud\CloudAdminHostSchedulingService;
use App\Services\Cloud\CloudCountryCatalog;
use App\Services\Cloud\CloudDeploymentPageService;
use App\Services\Cloud\CloudEngineClient;
use App\Services\Cloud\CloudError;
@ -14,7 +15,6 @@ use App\Services\Cloud\CloudUserIsoFeature;
final class CloudAdminController
{
private const HOST_COUNTRY_CODES = ['CN', 'JP', 'US', 'SG'];
private const CLOUD_IMAGE_UPLOAD_MAX_BYTES = 4 * 1024 * 1024 * 1024;
private const CLOUD_IMAGE_UPLOAD_MIN_BYTES = 1024 * 1024;
private const CLOUD_IMAGE_VERSIONS = [
@ -121,10 +121,7 @@ final class CloudAdminController
throw new CloudError('具体地区需为 1 至 64 字符,例如 HongKong 或 Tokyo');
}
$body['region'] = trim($region);
$countryCode = $body['country_code'] ?? null;
if (!is_string($countryCode) || !in_array($countryCode, self::HOST_COUNTRY_CODES, true)) {
throw new CloudError('国家代码无效,请选择中国、日本、美国或新加坡');
}
$countryCode = CloudCountryCatalog::normalize($body['country_code'] ?? null);
$privateKey = $body['private_key'] ?? '';
if (!is_string($privateKey)) {
throw new CloudError('SSH 私钥格式无效');

@ -37,6 +37,7 @@ final class CloudAdminResourceService
return array_merge($catalog, [
'view' => $view,
'line_feature_enabled' => CloudNetworkLineFeature::enabled(),
'country_options' => CloudCountryCatalog::options(),
'reservations' => $reservationPage,
'generated_at' => time(),
]);
@ -122,14 +123,9 @@ final class CloudAdminResourceService
$region = $id === null ? new CloudRegion() : self::findRegion($id);
$code = self::code(self::value($body, 'code', $region, $id === null), 32, '地区代码');
$name = self::name(self::value($body, 'name', $region, $id === null), 80, '地区名称');
$countryValue = self::value($body, 'country_code', $region, $id === null);
if (!is_string($countryValue)) {
throw new CloudError('国家代码必须为两位 ISO 字母');
}
$countryCode = strtoupper(self::safeText($countryValue, 2));
if (preg_match('/^[A-Z]{2}$/D', $countryCode) !== 1) {
throw new CloudError('国家代码必须为两位 ISO 字母');
}
$countryCode = CloudCountryCatalog::normalize(
self::value($body, 'country_code', $region, $id === null)
);
$status = self::choice(self::value($body, 'status', $region, $id === null),
self::REGION_STATUSES, '地区状态');
$sort = self::sort(self::value($body, 'sort', $region, false, 0));
@ -592,11 +588,14 @@ final class CloudAdminResourceService
$regionRows = [];
foreach ($regions as $region) {
$regionId = (int) $region->id;
$country = CloudCountryCatalog::option((string) $region->country_code);
$regionRows[] = [
'id' => $regionId,
'code' => (string) $region->code,
'name' => (string) $region->name,
'country_code' => (string) $region->country_code,
'country_code' => $country['code'],
'country_name' => $country['name'],
'country_flag' => $country['flag'],
'status' => (string) $region->status,
'sort' => (int) $region->sort,
'line_count' => $regionLineCounts[$regionId] ?? 0,

@ -0,0 +1,57 @@
<?php
namespace App\Services\Cloud;
/** Shared country/region choices used by region and host administration. */
final class CloudCountryCatalog
{
private const COUNTRIES = [
'CN' => ['name' => '中国', 'flag' => '🇨🇳'],
'HK' => ['name' => '中国香港', 'flag' => '🇭🇰'],
'JP' => ['name' => '日本', 'flag' => '🇯🇵'],
'US' => ['name' => '美国', 'flag' => '🇺🇸'],
'SG' => ['name' => '新加坡', 'flag' => '🇸🇬'],
];
public static function options(): array
{
$options = [];
foreach (self::COUNTRIES as $code => $country) {
$options[] = [
'code' => $code,
'name' => $country['name'],
'flag' => $country['flag'],
];
}
return $options;
}
public static function normalize($value): string
{
if (!is_string($value)) {
throw new CloudError('国家/地区无效,请从列表中选择');
}
$code = strtoupper(trim($value));
if (!array_key_exists($code, self::COUNTRIES)) {
throw new CloudError('国家/地区无效,请从列表中选择');
}
return $code;
}
public static function option($value): array
{
$code = is_string($value) ? strtoupper(trim($value)) : '';
if (!array_key_exists($code, self::COUNTRIES)) {
return [
'code' => $code,
'name' => '未支持的国家 / 地区',
'flag' => '🌐',
];
}
return [
'code' => $code,
'name' => self::COUNTRIES[$code]['name'],
'flag' => self::COUNTRIES[$code]['flag'],
];
}
}

@ -109,6 +109,28 @@ function configureEditor(kind, item = null) {
? '排空会阻止新实例进入,但已有实例继续运行;停用用于长期下线。'
: '停用会阻止新销售和新调度,但不会删除历史记录。';
const codePresentation = {
region: {
label: '地区标识',
placeholder: '例如 jp-tokyo',
help: '地区的内部唯一标识,仅使用英文字母、数字和中划线;保存时转换为小写,创建后不建议修改。',
},
line: {
label: '线路标识',
placeholder: '例如 standard',
help: '线路的内部唯一标识,仅使用英文字母、数字和中划线;保存时转换为小写,创建后不建议修改。',
},
pool: {
label: '资源池标识',
placeholder: '例如 jp-standard-1',
help: '资源池的内部唯一标识,仅使用英文字母、数字和中划线;保存时转换为小写,创建后不建议修改。',
},
}[kind];
const codeInput = form.elements.namedItem('code');
byId('resource-code-label').textContent = codePresentation.label;
byId('resource-code-help').textContent = codePresentation.help;
codeInput.placeholder = codePresentation.placeholder;
const visible = new Set({ region: ['country_code'], line: ['region_id', 'is_default'], pool: ['line_id', 'scheduling_policy'] }[kind]);
for (const field of form.querySelectorAll('[data-resource-field]')) {
const enabled = visible.has(field.dataset.resourceField);
@ -159,7 +181,7 @@ byId('resource-editor-form')?.addEventListener('submit', async event => {
if (!meta) return setEditorNotice('资源类型无效,请刷新页面。', 'error');
const id = form.elements.namedItem('id').value;
const body = {
code: form.elements.namedItem('code').value.trim(),
code: form.elements.namedItem('code').value.trim().toLowerCase(),
name: form.elements.namedItem('name').value.trim(),
status: form.elements.namedItem('status').value,
sort: Number(form.elements.namedItem('sort').value),

@ -2,7 +2,7 @@
{assign var=admin_active value='resources'}
{include file='admin/static_header.tpl'}
{if !$resource_page}
{assign var=resource_page value=['view'=>'overview','line_feature_enabled'=>false,'summary'=>['regions'=>0,'active_regions'=>0,'lines'=>0,'active_pools'=>0,'hosts'=>0,'schedulable_hosts'=>0,'held_reservations'=>0,'uncertain_reservations'=>0,'capacity'=>['cpu'=>['configured'=>0,'allocated'=>0,'reserved'=>0,'free'=>0],'memory'=>['configured'=>0,'allocated'=>0,'reserved'=>0,'free'=>0],'disk'=>['configured'=>0,'allocated'=>0,'reserved'=>0,'free'=>0],'ip'=>['total'=>0,'allocated'=>0,'reserved'=>0,'free'=>0]]],'regions'=>[],'lines'=>[],'pools'=>[],'reservations'=>['items'=>[],'filters'=>['state'=>'','pool_id'=>'','q'=>''],'pagination'=>['page'=>1,'per_page'=>20,'total'=>0,'total_pages'=>1,'from'=>0,'to'=>0]]]}
{assign var=resource_page value=['view'=>'overview','line_feature_enabled'=>false,'summary'=>['regions'=>0,'active_regions'=>0,'lines'=>0,'active_pools'=>0,'hosts'=>0,'schedulable_hosts'=>0,'held_reservations'=>0,'uncertain_reservations'=>0,'capacity'=>['cpu'=>['configured'=>0,'allocated'=>0,'reserved'=>0,'free'=>0],'memory'=>['configured'=>0,'allocated'=>0,'reserved'=>0,'free'=>0],'disk'=>['configured'=>0,'allocated'=>0,'reserved'=>0,'free'=>0],'ip'=>['total'=>0,'allocated'=>0,'reserved'=>0,'free'=>0]]],'country_options'=>[],'regions'=>[],'lines'=>[],'pools'=>[],'reservations'=>['items'=>[],'filters'=>['state'=>'','pool_id'=>'','q'=>''],'pagination'=>['page'=>1,'per_page'=>20,'total'=>0,'total_pages'=>1,'from'=>0,'to'=>0]]]}
{/if}
<main data-admin-resources>
@ -38,9 +38,9 @@
</section>
{elseif $resource_page.view == 'regions'}
<section class="card" aria-labelledby="resource-region-title">
<div class="card-header d-flex justify-content-between align-items-center gap-2 flex-wrap"><div><h2 class="h5 card-title mb-1" id="resource-region-title">地区</h2><span class="text-muted fs-13">地区是用户选择的销售位置;代码创建后应保持稳定。</span></div>{if $admin_can_manage|default:false}<button class="btn btn-primary" type="button" data-resource-create="region"><i class="mdi mdi-plus me-1"></i>新建地区</button>{/if}</div>
<div class="card-body"><div class="table-responsive admin-resource-table-wrap"><table class="table table-hover align-middle mb-0"><thead><tr><th>名称</th><th>代码</th><th>国家</th><th>线路</th><th>资源池</th><th>销售方案</th><th>状态</th>{if $admin_can_manage|default:false}<th>操作</th>{/if}</tr></thead><tbody>
{foreach $resource_page.regions as $region}<tr><td><strong>{$region.name|escape}</strong></td><td class="admin-mono">{$region.code|escape}</td><td>{$region.country_code|escape}</td><td>{$region.line_count|escape}{if $region.active_default_line_count != 1}<span class="d-block text-warning fs-12">默认线路配置待修正</span>{/if}</td><td>{$region.pool_count|escape}</td><td>{$region.offer_count|escape}</td><td><span class="badge {if $region.status == 'active'}bg-success-subtle text-success-emphasis{else}bg-light text-dark{/if}">{if $region.status == 'active'}启用{else}停用{/if}</span></td>{if $admin_can_manage|default:false}<td><button class="btn btn-light btn-sm" type="button" data-resource-edit="region" data-resource-id="{$region.id|escape}">编辑</button></td>{/if}</tr>{foreachelse}<tr><td colspan="8" class="text-center text-muted py-4">尚未建立地区。</td></tr>{/foreach}
<div class="card-header d-flex justify-content-between align-items-center gap-2 flex-wrap"><div><h2 class="h5 card-title mb-1" id="resource-region-title">地区</h2><span class="text-muted fs-13">地区是用户选择的销售位置;地区标识创建后应保持稳定。</span></div>{if $admin_can_manage|default:false}<button class="btn btn-primary" type="button" data-resource-create="region"><i class="mdi mdi-plus me-1"></i>新建地区</button>{/if}</div>
<div class="card-body"><div class="table-responsive admin-resource-table-wrap"><table class="table table-hover align-middle mb-0"><thead><tr><th>显示名称</th><th>地区标识</th><th>国家 / 地区</th><th>线路</th><th>资源池</th><th>销售方案</th><th>状态</th>{if $admin_can_manage|default:false}<th>操作</th>{/if}</tr></thead><tbody>
{foreach $resource_page.regions as $region}<tr><td><strong>{$region.name|escape}</strong></td><td class="admin-mono">{$region.code|escape}</td><td>{$region.country_flag|default:'🌐'|escape} {$region.country_name|default:'未识别'|escape} <span class="admin-mono">({$region.country_code|escape})</span></td><td>{$region.line_count|escape}{if $region.active_default_line_count != 1}<span class="d-block text-warning fs-12">默认线路配置待修正</span>{/if}</td><td>{$region.pool_count|escape}</td><td>{$region.offer_count|escape}</td><td><span class="badge {if $region.status == 'active'}bg-success-subtle text-success-emphasis{else}bg-light text-dark{/if}">{if $region.status == 'active'}启用{else}停用{/if}</span></td>{if $admin_can_manage|default:false}<td><button class="btn btn-light btn-sm" type="button" data-resource-edit="region" data-resource-id="{$region.id|escape}">编辑</button></td>{/if}</tr>{foreachelse}<tr><td colspan="8" class="text-center text-muted py-4">尚未建立地区。</td></tr>{/foreach}
</tbody></table></div></div>
</section>
{elseif $resource_page.view == 'lines'}
@ -76,9 +76,9 @@
<div class="admin-resource-form-fields">
<label data-resource-field="region_id"><span class="form-label">所属地区</span><select class="form-select" name="region_id">{foreach $resource_page.regions as $region}<option value="{$region.id|escape}">{$region.name|escape} · {$region.code|escape}</option>{/foreach}</select></label>
<label data-resource-field="line_id"><span class="form-label">所属线路</span><select class="form-select" name="line_id">{foreach $resource_page.lines as $line}<option value="{$line.id|escape}">{$line.region_name|escape} · {$line.name|escape}</option>{/foreach}</select></label>
<label><span class="form-label">代码</span><input class="form-control admin-mono" name="code" maxlength="32" pattern="[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" required autocomplete="off" spellcheck="false"></label>
<label data-resource-field="country_code"><span class="form-label">国家 / 地区</span><select class="form-select" name="country_code"><option value="">请选择国家或地区</option>{foreach $resource_page.country_options as $country}<option value="{$country.code|escape}">{$country.flag|escape} {$country.name|escape}({$country.code|escape})</option>{/foreach}</select><span class="form-text">用于用户侧显示地区旗帜与国家名称。</span></label>
<label><span class="form-label">显示名称</span><input class="form-control" name="name" maxlength="80" required autocomplete="off"></label>
<label data-resource-field="country_code"><span class="form-label">国家代码</span><input class="form-control admin-mono" name="country_code" maxlength="2" minlength="2" pattern="[A-Za-z]{2}" autocomplete="off" spellcheck="false"></label>
<label><span class="form-label" id="resource-code-label">资源标识</span><input class="form-control admin-mono" name="code" maxlength="32" pattern="[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?" title="仅能使用英文字母、数字和中划线,不能以中划线开头或结尾" required autocomplete="off" spellcheck="false" aria-describedby="resource-code-help"><span class="form-text" id="resource-code-help">仅使用英文字母、数字和中划线,保存时会转换为小写。</span></label>
<label data-resource-field="is_default" class="form-check"><input class="form-check-input" name="is_default" type="checkbox" value="1"><span class="form-check-label">设为该地区默认线路</span></label>
<label><span class="form-label">状态</span><select class="form-select" name="status"><option value="active">启用</option><option value="draining" data-pool-status>排空</option><option value="disabled">停用</option></select></label>
<label data-resource-field="scheduling_policy"><span class="form-label">调度策略</span><select class="form-select" name="scheduling_policy"><option value="balanced">均衡调度</option></select></label>

@ -83,7 +83,7 @@
</div>
<div class="cloud-admin-form-grid">
<div><label for="host-name" class="form-label">名称</label><input id="host-name" class="form-control" required maxlength="80"></div>
<div><label for="host-country-code" class="form-label">国家</label><select id="host-country-code" class="form-select" required><option value="">请选择国家</option><option value="CN">🇨🇳 中国</option><option value="JP">🇯🇵 日本</option><option value="US">🇺🇸 美国</option><option value="SG">🇸🇬 新加坡</option></select></div>
<div><label for="host-country-code" class="form-label">国家 / 地区</label><select id="host-country-code" class="form-select" required><option value="">请选择国家或地区</option>{foreach $cloud_country_options as $country}<option value="{$country.code|escape}">{$country.flag|escape} {$country.name|escape}({$country.code|escape})</option>{/foreach}</select></div>
<div class="cloud-admin-full"><label for="host-region" class="form-label">具体地区</label><input id="host-region" class="form-control" required maxlength="64" placeholder="例如 HongKong 或 Tokyo"></div>
</div>
</section>

@ -1,2 +1,2 @@
{* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *}
{assign var=venix_asset_version value='2026100313' scope='global'}
{assign var=venix_asset_version value='2026100314' scope='global'}

@ -20,6 +20,7 @@ $middleware = $read($root . '/app/Middleware/CloudApi.php');
$pageController = $read($root . '/app/Controllers/Admin/CloudPageController.php');
$apiController = $read($root . '/app/Controllers/CloudAdminResourceController.php');
$service = $read($root . '/app/Services/Cloud/CloudAdminResourceService.php');
$countryCatalog = $read($root . '/app/Services/Cloud/CloudCountryCatalog.php');
$placement = $read($root . '/app/Services/Cloud/CloudPlacementService.php');
$worker = $read($root . '/app/Services/Cloud/CloudWorkerService.php');
$feature = $read($root . '/app/Services/Cloud/CloudNetworkLineFeature.php');
@ -59,6 +60,13 @@ $assert(str_contains($feature, "CONFIG_KEY = 'cloud_network_lines_enabled'")
&& str_contains($service, 'CloudHostCapacitySnapshot')
&& !str_contains($service, 'CloudEngineClient'),
'Resource projections must be DB-only, reserve capacity explicitly and retain a disabled-by-default line feature.');
$assert(str_contains($service, "'country_options' => CloudCountryCatalog::options()")
&& str_contains($service, 'CloudCountryCatalog::normalize(')
&& str_contains($service, "'country_name' => \$country['name']")
&& str_contains($service, "'country_flag' => \$country['flag']")
&& str_contains($countryCatalog, '$code = strtoupper(trim($value));')
&& !str_contains($service, 'strtoupper(self::safeText($countryValue, 2))'),
'Regions must use the shared country catalog and reject rather than truncate invalid input.');
$assert(str_contains($placement,
"->whereIn('state', ['held', 'uncertain', 'committed'])")
&& str_contains($placement, "->orderBy('id')->lockForUpdate()->get([")
@ -111,6 +119,16 @@ $assert(str_contains($script, 'window.VenixDrawerMotion')
&& !str_contains($script, 'is_super_admin')
&& !str_contains($script, 'data-can-manage'),
'Resource JavaScript must use shared motion and CSRF without duplicating authorization rules.');
$assert(str_contains($template, '<span class="form-label">国家 / 地区</span>')
&& str_contains($template, '{foreach $resource_page.country_options as $country}')
&& str_contains($template, 'id="resource-code-label"')
&& str_contains($template, 'id="resource-code-help"')
&& str_contains($template, 'pattern="[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?"')
&& str_contains($script, "label: '地区标识'")
&& str_contains($script, "label: '线路标识'")
&& str_contains($script, "label: '资源池标识'")
&& str_contains($script, '.value.trim().toLowerCase()'),
'Resource forms must explain identifiers, provide readable countries and normalize codes consistently.');
$assert(str_contains($styles, '[data-admin-resources] .admin-resource-tabs')
&& str_contains($styles, '[data-admin-resource-drawer] .admin-resource-form-fields')

@ -0,0 +1,40 @@
<?php
use App\Services\Cloud\CloudCountryCatalog;
use App\Services\Cloud\CloudError;
require dirname(__DIR__) . '/app/Services/Cloud/CloudError.php';
require dirname(__DIR__) . '/app/Services/Cloud/CloudCountryCatalog.php';
$assert = static function ($condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$options = CloudCountryCatalog::options();
$codes = array_column($options, 'code');
$assert($codes === ['CN', 'HK', 'JP', 'US', 'SG'],
'Country options must remain ordered, explicit and unique.');
$assert(CloudCountryCatalog::normalize(' jp ') === 'JP',
'Country normalization must trim and uppercase a complete code.');
foreach (['JPN', 'ZZ', '', null, 81] as $invalid) {
try {
CloudCountryCatalog::normalize($invalid);
throw new RuntimeException('Invalid country input was accepted: ' . var_export($invalid, true));
} catch (CloudError $error) {
$assert($error->httpStatus === 422,
'Invalid country input must remain a validation error.');
}
}
$known = CloudCountryCatalog::option('hk');
$assert($known['code'] === 'HK' && $known['name'] === '中国香港'
&& $known['flag'] === '🇭🇰',
'Known country metadata did not round-trip through the shared catalog.');
$unsupported = CloudCountryCatalog::option('de');
$assert($unsupported['code'] === 'DE' && $unsupported['flag'] === '🌐',
'Historical unsupported codes must remain readable without crashing the resource page.');
echo "Cloud country catalog checks passed.\n";

@ -4,6 +4,9 @@
$root = dirname(__DIR__);
$schema = file_get_contents($root . '/sql/cloud.sql');
$controller = file_get_contents($root . '/app/Controllers/CloudAdminController.php');
$pageController = file_get_contents($root . '/app/Controllers/Admin/CloudPageController.php');
$legacyPageController = file_get_contents($root . '/app/Controllers/Admin/HostController.php');
$catalog = file_get_contents($root . '/app/Services/Cloud/CloudCountryCatalog.php');
$template = file_get_contents($root . '/resources/views/venix/admin/hosts/index.tpl');
$client = file_get_contents($root . '/public/cloud/admin.js');
@ -17,9 +20,10 @@ $assert(str_contains($schema, "country_code CHAR(2) NOT NULL DEFAULT ''")
&& str_contains($schema,
"ALTER TABLE cloud_hosts ADD COLUMN IF NOT EXISTS\n country_code CHAR(2) NOT NULL DEFAULT '' AFTER region"),
'Fresh and upgraded cloud_hosts schemas must contain the structured country code.');
$assert(str_contains($controller,
"private const HOST_COUNTRY_CODES = ['CN', 'JP', 'US', 'SG'];")
&& str_contains($controller, "'region', 'country_code'")
$assert(str_contains($controller, "'region', 'country_code'")
&& str_contains($controller,
"CloudCountryCatalog::normalize(\$body['country_code'] ?? null)")
&& !str_contains($controller, 'HOST_COUNTRY_CODES')
&& str_contains($controller,
"unset(\$body['name'], \$body['enabled'], \$body['country_code']);")
&& str_contains($controller, '$host->country_code = $countryCode;'),
@ -29,10 +33,22 @@ $unsetAt = strpos($controller,
$enginePutAt = strpos($controller, "'PUT', 'host', \$actor, \$body");
$assert($unsetAt !== false && $enginePutAt !== false && $unsetAt < $enginePutAt,
'country_code must be removed before the strict engine HostBody receives the request.');
foreach (['CN', 'JP', 'US', 'SG'] as $code) {
$assert(str_contains($template, '<option value="' . $code . '">'),
'Host country selector is missing ' . $code . '.');
}
$assert(str_contains($catalog, "'CN' => ['name' => '中国'")
&& str_contains($catalog, "'HK' => ['name' => '中国香港'")
&& str_contains($catalog, "'JP' => ['name' => '日本'")
&& str_contains($catalog, "'US' => ['name' => '美国'")
&& str_contains($catalog, "'SG' => ['name' => '新加坡'")
&& str_contains($catalog, '$code = strtoupper(trim($value));')
&& !str_contains($catalog, 'safeText'),
'The shared country catalog must normalize complete values without truncation.');
$assert(str_contains($pageController,
"assign('cloud_country_options', CloudCountryCatalog::options())")
&& str_contains($legacyPageController,
"assign('cloud_country_options', CloudCountryCatalog::options())")
&& str_contains($template, '{foreach $cloud_country_options as $country}')
&& str_contains($template, '{$country.name|escape}')
&& str_contains($template, '({$country.code|escape})'),
'Host country selector must render the shared readable country catalog.');
$assert(str_contains($template, 'id="host-country-code"')
&& preg_match('/id="host-region"[^>]*required[^>]*maxlength="64"/', $template) === 1
&& str_contains($controller, '具体地区需为 1 至 64 字符'),

Loading…
Cancel
Save