route bugfix, localization
This commit is contained in:
@@ -105,6 +105,7 @@ class DatabaseEntityQuery extends Select {
|
||||
return $this;
|
||||
}
|
||||
|
||||
// TODO: fix cycle detection + rather use deterministic aliases instead of t1, t2, t3...?
|
||||
private function fetchRelation(string $propertyName, string $tableName, DatabaseEntityHandler $src, DatabaseEntityHandler $relationHandler,
|
||||
bool $recursive = false, string $relationColumnPrefix = "", array &$visited = []) {
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Core\Objects\DatabaseEntity {
|
||||
}
|
||||
}
|
||||
|
||||
return new Language(1, "en_US", "American English");
|
||||
return self::getPredefinedValues()[0];
|
||||
}
|
||||
|
||||
public function getEntries(?string $module = null): ?array {
|
||||
@@ -101,7 +101,7 @@ namespace Core\Objects\DatabaseEntity {
|
||||
}
|
||||
}
|
||||
|
||||
return "[$key]";
|
||||
return $key ? "[$key]" : "";
|
||||
}
|
||||
|
||||
public function addModule(string $module, array $entries) {
|
||||
@@ -143,8 +143,8 @@ namespace Core\Objects\DatabaseEntity {
|
||||
|
||||
public static function getPredefinedValues(): array {
|
||||
return [
|
||||
new Language(Language::AMERICAN_ENGLISH, "en_US", 'American English'),
|
||||
new Language(Language::GERMAN_STANDARD, "de_DE", 'Deutsch Standard'),
|
||||
new Language(Language::AMERICAN_ENGLISH, "en_US", 'English (US)'),
|
||||
new Language(Language::GERMAN_STANDARD, "de_DE", 'Deutsch (Standard)'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ namespace Core\Objects\DatabaseEntity {
|
||||
namespace {
|
||||
function L(string $key): string {
|
||||
if (!array_key_exists('LANGUAGE', $GLOBALS)) {
|
||||
return "[$key]";
|
||||
return $key ? "[$key]" : "";
|
||||
}
|
||||
|
||||
global $LANGUAGE;
|
||||
|
||||
@@ -107,15 +107,23 @@ abstract class Route extends DatabaseEntity {
|
||||
return "new $className($args)";
|
||||
}
|
||||
|
||||
private static function getParts(string $url): array {
|
||||
if ($url === "/" || $url === "") {
|
||||
return [];
|
||||
} else {
|
||||
return explode("/", $url);
|
||||
}
|
||||
}
|
||||
|
||||
public function match(string $url) {
|
||||
|
||||
# /test/{abc}/{param:?}/{xyz:int}/{aaa:int?}
|
||||
$patternParts = explode("/", Router::cleanURL($this->pattern, false));
|
||||
$patternParts = self::getParts(Router::cleanURL($this->pattern, false));
|
||||
$countPattern = count($patternParts);
|
||||
$patternOffset = 0;
|
||||
|
||||
# /test/param/optional/123
|
||||
$urlParts = explode("/", Router::cleanURL($url));
|
||||
$urlParts = self::getParts(Router::cleanURL($url));
|
||||
$countUrl = count($urlParts);
|
||||
$urlOffset = 0;
|
||||
|
||||
@@ -235,6 +243,7 @@ abstract class Route extends DatabaseEntity {
|
||||
new DocumentRoute("/admin", false, \Core\Documents\Admin::class),
|
||||
new DocumentRoute("/register", true, \Core\Documents\Account::class, "account/register.twig"),
|
||||
new DocumentRoute("/confirmEmail", true, \Core\Documents\Account::class, "account/confirm_email.twig"),
|
||||
new DocumentRoute("/confirmGPG", true, \Core\Documents\Account::class, "account/confirm_gpg.twig"),
|
||||
new DocumentRoute("/acceptInvite", true, \Core\Documents\Account::class, "account/accept_invite.twig"),
|
||||
new DocumentRoute("/resetPassword", true, \Core\Documents\Account::class, "account/reset_password.twig"),
|
||||
new DocumentRoute("/login", true, \Core\Documents\Account::class, "account/login.twig"),
|
||||
|
||||
Reference in New Issue
Block a user