Improve menu order

This commit is contained in:
Jay Trees 2022-03-08 14:39:40 +01:00
parent 882b5129b9
commit b5b38e152c
2 changed files with 39 additions and 20 deletions

View file

@ -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) [![Matrix](https://badgen.net/matrix/members/wishthis/matrix.org/?label=Matrix&color=purple)](https://matrix.to/#/#wishthis:matrix.org)
## Requirements ## Requirements
* PHP 8 * PHP 8.1
## Installation ## Installation
1. Download the latest [release](https://github.com/grandeljay/wishthis/releases) and upload all files to your server 1. Download the latest [release](https://github.com/grandeljay/wishthis/releases) and upload all files to your server

View file

@ -8,6 +8,16 @@ namespace wishthis;
use wishthis\{User, URL}; 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 class Page
{ {
/** /**
@ -260,14 +270,21 @@ class Page
{ {
$user = new User(); $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( $pages = array(
'system' => array( $system => array(
'text' => 'System', 'text' => 'System',
'icon' => 'wrench', 'icon' => 'wrench',
'alignment' => 'right', 'alignment' => 'right',
'items' => array(), 'items' => array(),
), ),
'account' => array( $account => array(
'text' => 'Account', 'text' => 'Account',
'icon' => 'user circle', 'icon' => 'user circle',
'alignment' => 'right', 'alignment' => 'right',
@ -275,8 +292,8 @@ class Page
), ),
); );
if ($user && $user->isLoggedIn()) { if ($user->isLoggedIn()) {
$pages['wishlists'] = array( $pages[$wishlists] = array(
'text' => 'Wishlists', 'text' => 'Wishlists',
'alignment' => 'left', 'alignment' => 'left',
'items' => array( 'items' => array(
@ -289,21 +306,21 @@ class Page
); );
} }
if ($user && $user->isLoggedIn()) { if ($user->isLoggedIn()) {
if (100 === $user->power) { if (100 === $user->power) {
$pages['account']['items'][] = array( $pages[$account]['items'][] = array(
'url' => '/?page=login-as', 'url' => '/?page=login-as',
'text' => 'Login as', 'text' => 'Login as',
'icon' => 'sign out alternate', 'icon' => 'sign out alternate',
); );
} }
$pages['account']['items'][] = array( $pages[$account]['items'][] = array(
'url' => '/?page=logout', 'url' => '/?page=logout',
'text' => 'Logout', 'text' => 'Logout',
'icon' => 'sign out alternate', 'icon' => 'sign out alternate',
); );
} else { } else {
$pages['login'] = array( $pages[$login] = array(
'text' => 'Login', 'text' => 'Login',
'alignment' => 'right', 'alignment' => 'right',
'items' => array( 'items' => array(
@ -314,7 +331,7 @@ class Page
) )
), ),
); );
$pages['register'] = array( $pages[$register] = array(
'text' => 'Register', 'text' => 'Register',
'alignment' => 'right', 'alignment' => 'right',
'items' => array( '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) { if (100 === $user->power) {
$pages['system']['items'][] = array( $pages[$system]['items'][] = array(
'url' => '/?page=settings', 'url' => '/?page=settings',
'text' => 'Settings', 'text' => 'Settings',
'icon' => 'cog', 'icon' => 'cog',
); );
} }
global $options; ksort($pages);
if ($options->getOption('updateAvailable') && $user && 100 === $user->power) {
$pages['system']['items'][] = array(
'url' => '/?page=update',
'text' => 'Update',
'icon' => 'upload',
);
}
?> ?>
<div class="ui attached stackable vertical menu sidebar"> <div class="ui attached stackable vertical menu sidebar">