2023-03-11 15:14:05 +01:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* UserMenu.php
|
|
|
|
* Contains the user navigation logic.
|
|
|
|
*
|
2023-04-08 21:32:38 +02:00
|
|
|
* Kabuki CMS (C) 2013-2023, Aaron van Geffen
|
2023-03-11 15:14:05 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
class UserMenu extends Menu
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$user = Registry::has('user') ? Registry::get('user') : new Guest();
|
|
|
|
if ($user->isLoggedIn())
|
|
|
|
{
|
|
|
|
$this->items[] = [
|
|
|
|
'label' => $user->getFirstName(),
|
|
|
|
'icon' => 'person-circle',
|
|
|
|
'subs' => [
|
|
|
|
|
|
|
|
[
|
|
|
|
'label' => 'Settings',
|
|
|
|
'uri' => '/accountsettings/',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => 'Log out',
|
|
|
|
'uri' => '/logout/',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->items[] = [
|
|
|
|
'label' => 'Log in',
|
|
|
|
'icon' => 'person-circle',
|
|
|
|
'uri' => '/login/',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->items[] = [
|
|
|
|
'label' => 'Home',
|
|
|
|
'icon' => 'house-door',
|
|
|
|
'uri' => '/',
|
|
|
|
];
|
|
|
|
|
|
|
|
foreach ($this->items as $i => $item)
|
|
|
|
{
|
|
|
|
if (isset($item['uri']))
|
|
|
|
$this->items[$i]['url'] = BASEURL . $item['uri'];
|
|
|
|
|
|
|
|
if (!isset($item['subs']))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
foreach ($item['subs'] as $j => $subitem)
|
|
|
|
$this->items[$i]['subs'][$j]['url'] = BASEURL . $subitem['uri'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|