diff --git a/src/Venom/Routing/SeoController.php b/src/Venom/Controller/SeoController.php similarity index 100% rename from src/Venom/Routing/SeoController.php rename to src/Venom/Controller/SeoController.php diff --git a/src/Venom/Routing/Router.php b/src/Venom/Routing/Router.php index ca5a5ce..8632246 100644 --- a/src/Venom/Routing/Router.php +++ b/src/Venom/Routing/Router.php @@ -41,6 +41,7 @@ class Router public function findRoute($url, $method): ?array { $url = $this->removeIfFirst($url, $this->prefix); + $url = $this->removeTrailingSlash($url); // check if full match... this can easily done if the url isset select the empty! $method = strtoupper($method); $route = $this->getRouteByName($url, $method); @@ -64,14 +65,16 @@ class Router return $rawString; } - /* @todo implement Security Check if SecurityModule is used */ private function getRouteByName($url, $method, $subRoute = '*', $params = []): ?array { - $routeAvailable = isset($this->routes[$url]); - $subRouteFound = isset($this->routes[$url]['routes'][$subRoute]); - $methodFound = isset($this->routes[$url]['routes'][$subRoute][$method]); - if ($routeAvailable && $subRouteFound && $methodFound) { - if ((Config::getInstance()->getSecurity()->useSecurity || $this->id === self::ADMIN_ROUTER) && isset($this->routes[$url]['roles'])) { + if (isset($this->routes[$url]) + && isset($this->routes[$url]['routes']) + && isset($this->routes[$url]['routes'][$subRoute]) + && isset($this->routes[$url]['routes'][$subRoute][$method]) + ) { + if ((Config::getInstance()->getSecurity()->useSecurity || $this->id === self::ADMIN_ROUTER) + && isset($this->routes[$url]['roles']) + ) { $roles = $this->routes[$url]['roles']; if (!in_array(User::GUEST_ROLE, $roles, true) && !Security::get()->hasRoles($roles)) { return null; @@ -122,4 +125,10 @@ class Router return false; } } + + private function removeTrailingSlash(string $rawString) + { + $len = strlen($rawString); + return $rawString[$len - 1] === '/' ? substr($rawString, 0, strlen($rawString) - 1) : $rawString; + } } \ No newline at end of file diff --git a/src/modules/MetaDataModule.php b/src/modules/MetaDataModule.php index 5650cc5..47e2859 100644 --- a/src/modules/MetaDataModule.php +++ b/src/modules/MetaDataModule.php @@ -51,7 +51,7 @@ class MetaDataModule implements Module, Route AdminHelper::sendResponse([ 'metaData' => [ ['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'], - ['id' => 2, 'name' => 'versustunze', 'icon' => 'vt-edit'] + ['id' => 2, 'name' => 'versustunez', 'icon' => 'vt-edit'] ] ]); } diff --git a/src/modules/PageModule.php b/src/modules/PageModule.php index 4b5771e..f677fa5 100644 --- a/src/modules/PageModule.php +++ b/src/modules/PageModule.php @@ -55,7 +55,7 @@ class PageModule implements Module, Route ['id' => 3, 'name' => 'Aufbau und Umbau des neuen VENOMs Plugins', 'icon' => 'vt-edit'], ['id' => 4, 'name' => 'Aber Mama hat gesagt!', 'icon' => 'vt-edit'], ['id' => 5, 'name' => 'Frische Fische nur heute!', 'icon' => 'vt-edit'] - ] + ], ]); } @@ -76,6 +76,10 @@ class PageModule implements Module, Route 'id' => $id, 'name' => 'Admin', 'icon' => 'vt-visibility', + 'users' => [ + ['value' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'], + ['value' => 2, 'name' => 'versustunez', 'icon' => 'vt-edit'] + ] ]); } } \ No newline at end of file diff --git a/src/modules/UserModule.php b/src/modules/UserModule.php index 1648c35..7daa631 100644 --- a/src/modules/UserModule.php +++ b/src/modules/UserModule.php @@ -51,7 +51,7 @@ class UserModule implements Module, Route AdminHelper::sendResponse([ 'users' => [ ['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'], - ['id' => 2, 'name' => 'versustunze', 'icon' => 'vt-edit'] + ['id' => 2, 'name' => 'versustunez', 'icon' => 'vt-edit'] ] ]); } diff --git a/src/modules/VenomStatusModule.php b/src/modules/VenomStatusModule.php index 97fdad7..4ff9c19 100644 --- a/src/modules/VenomStatusModule.php +++ b/src/modules/VenomStatusModule.php @@ -51,7 +51,7 @@ class VenomStatusModule implements Module, Route AdminHelper::sendResponse([ 'users' => [ ['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'], - ['id' => 2, 'name' => 'versustunze', 'icon' => 'vt-edit'] + ['id' => 2, 'name' => 'versustunez', 'icon' => 'vt-edit'] ] ]); } diff --git a/tpl/admin/jsTemplates/pageEdit.tpl b/tpl/admin/jsTemplates/pageEdit.tpl index 5939dcc..8d8eed7 100644 --- a/tpl/admin/jsTemplates/pageEdit.tpl +++ b/tpl/admin/jsTemplates/pageEdit.tpl @@ -13,14 +13,7 @@ {include(includes/input;class=input-group;label=Page Name;name=PageName;error=Page Name is required;default=Turbinen sind geil)}