This commit is contained in:
Pinga 2024-01-23 13:52:54 +02:00
parent c8c8cc3c07
commit aaa2971c4b
2 changed files with 26 additions and 14 deletions

View file

@ -971,18 +971,27 @@ class SystemController extends Controller
}
$db = $this->container->get('db');
$types = $db->select("SELECT DISTINCT type FROM reserved_domain_names");
// Get the current URI
$uri = $request->getUri()->getPath();
// Set default types if $types is empty
if (empty($types)) {
$types = [
['type' => 'reserved'],
['type' => 'restricted']
];
$typesResult = $db->select("SELECT DISTINCT type FROM reserved_domain_names");
// Initialize $types as an empty array if the query result is null
$types = $typesResult ?: [];
// Ensure all default types are represented
$defaultTypes = ['reserved', 'restricted'];
foreach ($defaultTypes as $defaultType) {
$found = false;
foreach ($types as $type) {
if ($type['type'] === $defaultType) {
$found = true;
break;
}
}
if (!$found) {
$types[] = ['type' => $defaultType];
}
}
$categories = [];
foreach ($types as $type) {
$typeNames = $db->select(
@ -990,7 +999,6 @@ class SystemController extends Controller
[ $type['type'] ]
);
// Initialize the type with an empty array if no names are found
$categories[$type['type']] = $typeNames ? array_column($typeNames, 'name') : [];
}

View file

@ -36,11 +36,15 @@
<div class="card mb-3">
<div class="card-header">{{ type|capitalize }} Names</div>
<div class="card-body">
<textarea class="form-control" name="domains_{{ type }}" rows="4" placeholder="Enter domain names, one per line" required>{{ names|join('\n') }}</textarea>
{% if names is not empty %}
<textarea class="form-control" name="domains_{{ type }}" rows="4" placeholder="Enter domain names, one per line" required>{{ names|join('\n') }}</textarea>
{% else %}
<textarea class="form-control" name="domains_{{ type }}" rows="4" placeholder="No {{ type|lower }} names. Enter new names, one per line" required></textarea>
{% endif %}
<small class="form-hint">
<strong>{{ type|capitalize }} Names:</strong> These domain names are subject to special regulations or registration requirements. They might be available for registration but under specific conditions, such as proof of eligibility or additional documentation.
<br><em>Enter each {{ type }} name on a new line, without the extension. For instance, use "example" in place of "example.com".</em>
</small>
</small>
</div>
</div>
{% endfor %}