| Current Path : /home/seto/testhive.pm/admin/ |
| Current File : /home/seto/testhive.pm/admin/_layout.php |
<?php
function layout_head(string $title): void { ?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SAPA Mini — <?= htmlspecialchars($title) ?></title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<style>
body { background:#f8f9fa }
.sidebar { min-height:100vh; background:#212529; }
.sidebar a { color:#adb5bd; text-decoration:none; display:block; padding:8px 16px; border-radius:4px; }
.sidebar a:hover, .sidebar a.active { background:#343a40; color:#fff; }
.sidebar .brand { color:#fff; font-size:1.1rem; font-weight:600; padding:16px; border-bottom:1px solid #343a40; margin-bottom:8px; }
</style>
</head>
<body>
<div class="d-flex">
<div class="sidebar p-2" style="width:200px;flex-shrink:0">
<div class="brand">SAPA Mini</div>
<?php
$cur = basename($_SERVER['PHP_SELF']);
$nav = [
'index.php' => 'Dashboard',
'campaigns.php' => 'Campaigns',
'assignments.php' => 'Assignments',
'donors.php' => 'Доноры',
'pages.php' => 'Страницы',
'stats.php' => 'Статистика',
'settings.php' => 'Настройки',
'../donor-snippet.php' => 'Donor Snippet',
];
foreach ($nav as $file => $label):
$active = ($cur === $file) ? ' active' : '';
?>
<a href="/admin/<?= $file ?>" class="<?= $active ?>"><?= $label ?></a>
<?php endforeach ?>
<hr style="border-color:#343a40">
<a href="/admin/logout.php">Выйти</a>
</div>
<div class="flex-grow-1 p-4">
<h5 class="mb-4"><?= htmlspecialchars($title) ?></h5>
<?php }
function layout_foot(): void { ?>
</div><!-- /flex-grow -->
</div><!-- /d-flex -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<?php }
function paginate(int $total, int $page, int $perPage, string $baseUrl): string {
$pages = (int)ceil($total / $perPage);
if ($pages <= 1) return '';
$sep = str_contains($baseUrl, '?') ? '&' : '?';
$html = '<nav><ul class="pagination pagination-sm mb-0">';
for ($i = 1; $i <= $pages; $i++) {
$active = ($i === $page) ? ' active' : '';
$html .= "<li class=\"page-item{$active}\"><a class=\"page-link\" href=\"{$baseUrl}{$sep}page={$i}\">{$i}</a></li>";
}
$html .= '</ul></nav>';
return $html;
}