110 lines
4.5 KiB
PHP
110 lines
4.5 KiB
PHP
<?php
|
|
$currentScript = $_SERVER['PHP_SELF'] ?? '';
|
|
$currentPage = basename($currentScript);
|
|
$scriptDir = trim(dirname($currentScript), '/');
|
|
$segmentCount = $scriptDir === '' ? 0 : substr_count($scriptDir, '/') + 1;
|
|
$rootPrefix = $segmentCount ? str_repeat('../', $segmentCount) : '';
|
|
?>
|
|
|
|
<!-- Mobile Topbar -->
|
|
<div id="mobile-topbar" class="d-lg-none d-flex justify-content-between align-items-center px-3 shadow-sm bg-success text-white">
|
|
<h4 class="m-0 fw-bold">DSP DATA Contributor</h4>
|
|
<button class="btn btn-outline-light rounded" onclick="toggleSidebar()">
|
|
<i class="fas fa-bars"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Mobile overlay -->
|
|
<div id="overlay" onclick="toggleSidebar()"></div>
|
|
|
|
<!-- Sidebar -->
|
|
<nav class="sidebar d-lg-block shadow">
|
|
<!-- Desktop only header -->
|
|
<div class="admin-header d-none d-lg-block text-center">
|
|
DATA Contributor
|
|
</div>
|
|
|
|
<ul class="nav flex-column py-0">
|
|
<li class="nav-item mt-0 border-top border-secondary pt-2">
|
|
<?php
|
|
$sections = [
|
|
'Data Management' => [
|
|
'data_hybrid/dashboard.php' => ['Dashboard', 'fa-tachometer-alt'],
|
|
'data_hybrid/manage_my_datasources.php' => ['Data Sources', 'fa-database'],
|
|
'data_hybrid/manage_permissions.php' => ['Data Permissions', 'fa-user-shield'],
|
|
'data_hybrid/my_permissions.php' => ['My data Request', 'fa-user-shield'],
|
|
'data_hybrid/my_downloads.php' => ['My Downloads', 'fa-chart-bar'],
|
|
'data_hybrid/browse_datasources.php' => ['Browse All Data', 'fa-database'],
|
|
],
|
|
'Resources' => [
|
|
'user_guide.php' => ['User Guide', 'fa-book-open'],
|
|
],
|
|
'Account' => [
|
|
'profile.php' => ['My Profile', 'fa-id-card'],
|
|
],
|
|
];
|
|
if (!empty($_SESSION['can_run_r'])) {
|
|
$sections['Data Management']['data_hybrid/r_in_jupyter.php'] = ['R in JupyterHub', 'fa-code'];
|
|
}
|
|
|
|
echo '<style>
|
|
.nav-section {
|
|
background: rgba(255, 255, 255, 0.04);
|
|
border: 1px solid rgba(255,255,255,0.06);
|
|
border-radius: 10px;
|
|
padding: 0.9rem 0.75rem;
|
|
margin: 0 0.75rem 1.2rem 0.75rem;
|
|
}
|
|
.nav-section legend {
|
|
font-size: 0.72rem;
|
|
letter-spacing: 0.08em;
|
|
text-transform: uppercase;
|
|
color: rgba(255,255,255,0.55);
|
|
width: auto;
|
|
padding: 0 0.4rem;
|
|
margin-left: 0.35rem;
|
|
}
|
|
</style>';
|
|
|
|
foreach ($sections as $sectionLabel => $items) {
|
|
echo '<fieldset class="nav-section"><legend>' . htmlspecialchars($sectionLabel) . '</legend>';
|
|
foreach ($items as $file => [$title, $icon]) {
|
|
$targetPath = parse_url($file, PHP_URL_PATH);
|
|
$targetPath = ($targetPath === null || $targetPath === false) ? $file : $targetPath;
|
|
$active = ($currentPage === basename($targetPath)) ? 'active' : '';
|
|
$isExternal = preg_match('#^https?://#', $file) === 1;
|
|
if ($isExternal) {
|
|
$href = $file;
|
|
} else {
|
|
$href = $rootPrefix . ltrim($targetPath, '/');
|
|
$query = parse_url($file, PHP_URL_QUERY);
|
|
if (!empty($query)) {
|
|
$href .= '?' . $query;
|
|
}
|
|
if ($fragment = parse_url($file, PHP_URL_FRAGMENT)) {
|
|
$href .= '#' . $fragment;
|
|
}
|
|
}
|
|
$hrefEsc = htmlspecialchars($href, ENT_QUOTES, 'UTF-8');
|
|
$titleEsc = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
|
|
$iconEsc = htmlspecialchars($icon, ENT_QUOTES, 'UTF-8');
|
|
echo <<<HTML
|
|
<li class="nav-item">
|
|
<a class="nav-link $active" href="$hrefEsc">
|
|
<i class="fas $iconEsc me-2"></i> $titleEsc
|
|
</a>
|
|
</li>
|
|
HTML;
|
|
}
|
|
echo '</fieldset>';
|
|
}
|
|
?>
|
|
</li>
|
|
<li class="nav-item mt-2 border-top border-secondary pt-2">
|
|
<a class="nav-link text-danger" href="<?php echo htmlspecialchars($rootPrefix . 'logout.php', ENT_QUOTES, 'UTF-8'); ?>">
|
|
<i class="fas fa-sign-out-alt me-2"></i> Logout
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</nav>
|