DSP Project first push, date: 29/01/2026
This commit is contained in:
108
includes/nav_owner.php
Normal file
108
includes/nav_owner.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?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 OWNER</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 OWNER
|
||||
</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_owner/dashboard.php' => ['Dashboard', 'fa-tachometer-alt'],
|
||||
'data_owner/manage_my_datasources.php' => ['My Data Sources', 'fa-database'],
|
||||
'data_owner/manage_permissions.php' => ['Data Permissions', 'fa-user-shield'],
|
||||
],
|
||||
'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_owner/run_r_scripts.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;
|
||||
}
|
||||
$fragment = parse_url($file, PHP_URL_FRAGMENT);
|
||||
if (!empty($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>
|
||||
Reference in New Issue
Block a user