From 05ebcbfd8be9d10e19cc0e9172353b74187ae0f2 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Sat, 21 Feb 2026 13:03:27 +0300 Subject: [PATCH] Admin/Public: decouple topic filter from sections Keep section and topic menus independent on public pages so users can choose either browsing mode directly across the full gallery. Preserve active state highlighting for the current mode, update photo/detail navigation links accordingly, and refine topic edit rows in admin to keep name, sort index, and delete action on one line. --- index.php | 55 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/index.php b/index.php index 1f3ac1b..d289549 100644 --- a/index.php +++ b/index.php @@ -50,6 +50,8 @@ $photo = $activePhotoId > 0 ? photoById($activePhotoId) : null; if ($photo && $activeSectionId < 1) { $activeSectionId = (int)$photo['section_id']; } + +$filterMode = $activeTopicId > 0 ? 'topic' : ($activeSectionId > 0 ? 'section' : 'none'); $comments = $photo ? commentsByPhoto($activePhotoId) : []; $topics = []; $topicCounts = []; @@ -59,22 +61,26 @@ try { if ($activeTopicId > 0) { if (!topicById($activeTopicId)) { $activeTopicId = 0; + $filterMode = $activeSectionId > 0 ? 'section' : 'none'; } } - $topicCounts = topicPhotoCounts($activeSectionId > 0 ? $activeSectionId : null); + $topicCounts = topicPhotoCounts(null); $topicTree = buildTopicTreePublic($topics); } catch (Throwable) { $topics = []; $topicCounts = []; $topicTree = []; $activeTopicId = 0; + $filterMode = $activeSectionId > 0 ? 'section' : 'none'; } $photos = ($activeSectionId > 0 || $activeTopicId > 0) - ? photosForPublic($activeSectionId > 0 ? $activeSectionId : null, $activeTopicId > 0 ? $activeTopicId : null) + ? photosForPublic($filterMode === 'section' ? $activeSectionId : null, $filterMode === 'topic' ? $activeTopicId : null) : []; $photoCommentCounts = photoCommentCountsByPhotoIds(array_map(static fn(array $p): int => (int)$p['id'], $photos)); $isHomePage = $activeSectionId < 1 && $activePhotoId < 1; +$isTopicMode = $filterMode === 'topic'; +$isSectionMode = $filterMode === 'section'; $sectionNames = []; foreach ($sections as $s) { @@ -102,7 +108,11 @@ if ($photo) { } catch (Throwable) { $photoTopics = []; } - $detailPhotos = photosForPublic($detailSectionId, $activeTopicId > 0 ? $activeTopicId : null); + if ($isTopicMode) { + $detailPhotos = photosForPublic(null, $activeTopicId); + } else { + $detailPhotos = photosForPublic($detailSectionId, null); + } if ($activeTopicId > 0 && $detailPhotos !== []) { $foundInTopic = false; foreach ($detailPhotos as $d) { @@ -114,6 +124,8 @@ if ($photo) { if (!$foundInTopic) { $detailPhotos = photosForPublic($detailSectionId, null); $activeTopicId = 0; + $isTopicMode = false; + $isSectionMode = true; } } $detailTotal = count($detailPhotos); @@ -134,8 +146,6 @@ if ($photo) { } $hasMobilePhotoNav = $activePhotoId > 0 && $photo && $detailTotal > 0; -$isTopicMode = $activeTopicId > 0; -$isSectionMode = !$isTopicMode && $activeSectionId > 0; $bodyClasses = [$isHomePage ? 'is-home' : 'is-inner']; if ($hasMobilePhotoNav) { $bodyClasses[] = 'has-mobile-nav'; @@ -373,7 +383,7 @@ function outputWatermarked(string $path, string $mime): never Разделы @@ -384,19 +394,10 @@ function outputWatermarked(string $path, string $mime): never @@ -414,7 +415,7 @@ function outputWatermarked(string $path, string $mime): never
Раздел: - Тематика: + Тематика:
@@ -424,11 +425,11 @@ function outputWatermarked(string $path, string $mime): never

Комментарии

-
+ - - + +

@@ -445,8 +446,8 @@ function outputWatermarked(string $path, string $mime): never @@ -461,7 +462,7 @@ function outputWatermarked(string $path, string $mime): never