diff --git a/index.php b/index.php index c4284c0..903289b 100644 --- a/index.php +++ b/index.php @@ -76,6 +76,19 @@ $photos = ($activeSectionId > 0 || $activeTopicId > 0) $photoCommentCounts = photoCommentCountsByPhotoIds(array_map(static fn(array $p): int => (int)$p['id'], $photos)); $isHomePage = $activeSectionId < 1 && $activePhotoId < 1; +$sectionNames = []; +foreach ($sections as $s) { + $sectionNames[(int)$s['id']] = (string)$s['name']; +} + +$activeTopicName = ''; +foreach ($topics as $t) { + if ((int)$t['id'] === $activeTopicId) { + $activeTopicName = (string)$t['full_name']; + break; + } +} + $detailTotal = 0; $detailIndex = 0; $prevPhotoId = 0; @@ -122,6 +135,13 @@ if ($hasMobilePhotoNav) { $bodyClasses[] = 'has-mobile-nav'; } +$detailLocationLabel = ''; +if ($activeTopicId > 0 && $activeTopicName !== '') { + $detailLocationLabel = 'в тематике «' . $activeTopicName . '»'; +} elseif ($detailSectionId > 0 && isset($sectionNames[$detailSectionId])) { + $detailLocationLabel = 'в разделе «' . $sectionNames[$detailSectionId] . '»'; +} + function h(string $v): string { return htmlspecialchars($v, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } function assetUrl(string $path): string { $f=__DIR__ . '/' . ltrim($path,'/'); $v=is_file($f)?(string)filemtime($f):(string)time(); return $path . '?v=' . rawurlencode($v); } function limitText(string $text, int $len): string { return function_exists('mb_substr') ? mb_substr($text, 0, $len) : substr($text, 0, $len); } @@ -294,8 +314,7 @@ function outputWatermarked(string $path, string $mime): never .detail .img-box{min-height:200px;border-radius:10px;border:1px solid #e5e7eb} .detail .img-box img{max-width:100%;height:auto;border:0;border-radius:0} @keyframes skeleton{to{background-position:-200% 0}} - .sidebar-head{display:flex;align-items:center;justify-content:space-between;gap:10px} - .sidebar-head h3{margin:0} + .sidebar-head{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin-bottom:6px} .sidebar-toggle{display:none} .sidebar-toggle,.sidebar-close{border:1px solid #d1d5db;background:#fff;color:#1f2937;border-radius:10px;padding:8px 12px;font-size:14px;font-weight:600;cursor:pointer} .sidebar-close{display:none;width:34px;height:34px;padding:0;line-height:1;font-size:24px} @@ -336,12 +355,11 @@ function outputWatermarked(string $path, string $mime): never