pics/models/UserMenu.php

60 lines
1.2 KiB
PHP
Raw Permalink Normal View History

<?php
/*****************************************************************************
* UserMenu.php
* Contains the user navigation logic.
*
* Kabuki CMS (C) 2013-2023, Aaron van Geffen
*****************************************************************************/
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'];
}
}
}