diff --git a/README.md b/README.md index 40c609a7..e30bb3ec 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ your wishes for any kind of occasion ([demo](https://wishthis.online)). [![Matrix](https://badgen.net/matrix/members/wishthis/matrix.org/?label=Matrix&color=purple)](https://matrix.to/#/#wishthis:matrix.org) ## Requirements -* PHP 8 +* PHP 8.1 ## Installation 1. Download the latest [release](https://github.com/grandeljay/wishthis/releases) and upload all files to your server diff --git a/src/classes/page.php b/src/classes/page.php index 3dcb3b69..55da0a05 100644 --- a/src/classes/page.php +++ b/src/classes/page.php @@ -8,6 +8,16 @@ namespace wishthis; use wishthis\{User, URL}; +enum Navigation: int +{ + case Wishlists = 1; + case System = 2; + case Settings = 3; + case Account = 4; + case Login = 5; + case Register = 6; +} + class Page { /** @@ -260,14 +270,21 @@ class Page { $user = new User(); + $wishlists = Navigation::Wishlists->value; + $system = Navigation::System->value; + $settings = Navigation::Settings->value; + $account = Navigation::Account->value; + $login = Navigation::Login->value; + $register = Navigation::Register->value; + $pages = array( - 'system' => array( + $system => array( 'text' => 'System', 'icon' => 'wrench', 'alignment' => 'right', 'items' => array(), ), - 'account' => array( + $account => array( 'text' => 'Account', 'icon' => 'user circle', 'alignment' => 'right', @@ -275,8 +292,8 @@ class Page ), ); - if ($user && $user->isLoggedIn()) { - $pages['wishlists'] = array( + if ($user->isLoggedIn()) { + $pages[$wishlists] = array( 'text' => 'Wishlists', 'alignment' => 'left', 'items' => array( @@ -289,21 +306,21 @@ class Page ); } - if ($user && $user->isLoggedIn()) { + if ($user->isLoggedIn()) { if (100 === $user->power) { - $pages['account']['items'][] = array( + $pages[$account]['items'][] = array( 'url' => '/?page=login-as', 'text' => 'Login as', 'icon' => 'sign out alternate', ); } - $pages['account']['items'][] = array( + $pages[$account]['items'][] = array( 'url' => '/?page=logout', 'text' => 'Logout', 'icon' => 'sign out alternate', ); } else { - $pages['login'] = array( + $pages[$login] = array( 'text' => 'Login', 'alignment' => 'right', 'items' => array( @@ -314,7 +331,7 @@ class Page ) ), ); - $pages['register'] = array( + $pages[$register] = array( 'text' => 'Register', 'alignment' => 'right', 'items' => array( @@ -327,23 +344,25 @@ class Page ); } + global $options; + + if ($options->getOption('updateAvailable') && $user && 100 === $user->power) { + $pages[$system]['items'][] = array( + 'url' => '/?page=update', + 'text' => 'Update', + 'icon' => 'upload', + ); + } + if (100 === $user->power) { - $pages['system']['items'][] = array( + $pages[$system]['items'][] = array( 'url' => '/?page=settings', 'text' => 'Settings', 'icon' => 'cog', ); } - global $options; - - if ($options->getOption('updateAvailable') && $user && 100 === $user->power) { - $pages['system']['items'][] = array( - 'url' => '/?page=update', - 'text' => 'Update', - 'icon' => 'upload', - ); - } + ksort($pages); ?>