You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.4 KiB
PHP
38 lines
1.4 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__, 2);
|
|
$read = static function (string $path) use ($root): string {
|
|
$content = file_get_contents($root . '/' . $path);
|
|
if ($content === false) {
|
|
throw new RuntimeException('Cannot read ' . $path);
|
|
}
|
|
return $content;
|
|
};
|
|
$assert = static function (bool $condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
$adminTemplate = $read('web/resources/views/venix/admin/config.tpl');
|
|
$adminController = $read('web/app/Controllers/Admin/ConfigController.php');
|
|
$assert(!str_contains($adminTemplate, 'name="language"')
|
|
&& !str_contains($adminTemplate, 'id="language"')
|
|
&& !str_contains($adminTemplate, '英文落地页'),
|
|
'The retired administrator language toggle is still visible.');
|
|
$assert(!preg_match("/'language'\\s*=>/", $adminController),
|
|
'The retired language key is still writable through the administrator configuration API.');
|
|
|
|
foreach ([
|
|
'web/app/Controllers/HomeController.php',
|
|
'web/app/Controllers/AuthController.php',
|
|
'web/app/Controllers/PasswordController.php',
|
|
] as $path) {
|
|
$source = $read($path);
|
|
$assert(!str_contains($source, "get('language'")
|
|
&& !str_contains($source, "where('name', 'language')"),
|
|
'The retired global language configuration is still read by ' . $path . '.');
|
|
}
|
|
|
|
echo "Administrator forced-language removal contract passed.\n";
|