2020-06-08 11:57:53 +02:00
|
|
|
<?php
|
|
|
|
$navdata = '';
|
2020-06-08 14:11:20 +02:00
|
|
|
$i = 0;
|
|
|
|
foreach ($data['menu'] as $name => $menuElement) {
|
|
|
|
$i++;
|
|
|
|
if (!empty($menuElement['skipTopMenu'])) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!empty($menuElement['type']) === 'single' && $menuElement['type'] === 'single') {
|
2020-06-08 11:57:53 +02:00
|
|
|
$navdata .= sprintf(
|
2021-02-09 22:10:26 +01:00
|
|
|
'<li class="nav-item active"><a class="nav-link %s" href="%s%s">%s</a>',
|
2020-06-08 11:57:53 +02:00
|
|
|
empty($menuElement['class']) ? '' : h($menuElement['class']),
|
2021-02-09 22:10:26 +01:00
|
|
|
$baseurl,
|
2020-06-08 11:57:53 +02:00
|
|
|
empty($menuElement['url']) ? '' : h($menuElement['url']),
|
2020-06-08 14:11:20 +02:00
|
|
|
empty($name) ? '' : h($name)
|
2020-06-08 11:57:53 +02:00
|
|
|
);
|
2020-06-08 14:11:20 +02:00
|
|
|
} else if (empty($menuElement['type']) || $menuElement['type'] === 'group') {
|
2020-06-08 11:57:53 +02:00
|
|
|
$navdataElements = '';
|
2020-06-08 14:11:20 +02:00
|
|
|
$first = true;
|
|
|
|
foreach ($menuElement as $subCategory => $subCategoryData) {
|
|
|
|
if (!empty($subCategoryData['skipTopMenu'])) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!$first) {
|
2020-06-08 11:57:53 +02:00
|
|
|
$navdataElements .= '<div class="dropdown-divider"></div>';
|
2020-06-08 14:11:20 +02:00
|
|
|
}
|
|
|
|
$first = false;
|
|
|
|
foreach ($subCategoryData['children'] as $child) {
|
|
|
|
if (!empty($child['skipTopMenu'])) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-06-08 11:57:53 +02:00
|
|
|
$navdataElements .= sprintf(
|
2021-02-09 22:10:26 +01:00
|
|
|
'<a class="dropdown-item %s" href="%s%s">%s</a>',
|
2020-06-08 11:57:53 +02:00
|
|
|
empty($child['class']) ? '' : h($child['class']),
|
2021-02-09 22:10:26 +01:00
|
|
|
$baseurl,
|
2020-06-08 11:57:53 +02:00
|
|
|
empty($child['url']) ? '' : h($child['url']),
|
2020-06-08 14:11:20 +02:00
|
|
|
empty($child['label']) ? '' : h($child['label'])
|
2020-06-08 11:57:53 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$navdata .= sprintf(
|
|
|
|
'<li class="nav-item dropdown">%s%s</li>',
|
|
|
|
sprintf(
|
|
|
|
'<a class="nav-link dropdown-toggle" href="#" id="%s" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">%s</a>',
|
2020-06-08 14:11:20 +02:00
|
|
|
'dropdown-label-' . h($i),
|
|
|
|
h($name)
|
2020-06-08 11:57:53 +02:00
|
|
|
),
|
|
|
|
sprintf(
|
|
|
|
'<div class="dropdown-menu" aria-labelledby="navbarDropdown">%s</div>',
|
|
|
|
$navdataElements
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-06-21 21:36:57 +02:00
|
|
|
$logoutButton = sprintf(
|
2021-02-09 22:10:26 +01:00
|
|
|
'<span class="nav-item"><a href="%susers/logout" class="nav-link">%s</a></span>',
|
|
|
|
$baseurl,
|
2020-06-21 21:36:57 +02:00
|
|
|
__('Logout')
|
|
|
|
);
|
2020-06-08 11:57:53 +02:00
|
|
|
$navdata = sprintf(
|
2020-06-21 21:36:57 +02:00
|
|
|
'<div class="collapse navbar-collapse" id="navbarCollapse"><ul class="navbar-nav mr-auto">%s%s</ul></div>',
|
|
|
|
$navdata,
|
|
|
|
$logoutButton
|
2020-06-08 11:57:53 +02:00
|
|
|
);
|
|
|
|
$homeButton = sprintf(
|
2021-02-09 22:10:26 +01:00
|
|
|
'<a class="navbar-brand %s" href="%s%s">%s</a>',
|
2020-06-08 14:11:20 +02:00
|
|
|
empty($data['home']['class']) ? '' : h($data['home']['class']),
|
2021-02-09 22:10:26 +01:00
|
|
|
$baseurl,
|
2020-06-08 14:11:20 +02:00
|
|
|
empty($data['home']['url']) ? '' : h($data['home']['url']),
|
|
|
|
empty($data['home']['text']) ? '' : h($data['home']['text'])
|
2020-06-08 11:57:53 +02:00
|
|
|
);
|
|
|
|
echo sprintf(
|
2020-06-23 14:14:20 +02:00
|
|
|
'<nav class="navbar navbar-expand-lg navbar-dark %s">%s%s%s</nav>',
|
|
|
|
$darkMode ? 'bg-primary' : 'bg-dark',
|
2020-06-08 11:57:53 +02:00
|
|
|
$homeButton,
|
|
|
|
'<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>',
|
|
|
|
$navdata
|
|
|
|
);
|