diff --git a/app/Http/Controllers/BrowseController.php b/app/Http/Controllers/BrowseController.php index 56f4a6b74..532d1fdea 100644 --- a/app/Http/Controllers/BrowseController.php +++ b/app/Http/Controllers/BrowseController.php @@ -84,21 +84,39 @@ class BrowseController extends BasePageController $catname = 'All'; } elseif ($category !== -1 && $grp === -1) { $catname = $id; + + // Determine the root category ID - either from the category's root_categories_id + // or the category itself if it IS a root category + $rootCategoryId = null; $cdata = Category::find($category); if ($cdata !== null) { - if ($cdata->root_categories_id === Category::GAME_ROOT) { - $covgroup = 'console'; - } elseif ($cdata->root_categories_id === Category::MOVIE_ROOT) { - $covgroup = 'movies'; - } elseif ($cdata->root_categories_id === Category::PC_ROOT) { - $covgroup = 'games'; - } elseif ($cdata->root_categories_id === Category::MUSIC_ROOT) { - $covgroup = 'music'; - } elseif ($cdata->root_categories_id === Category::BOOKS_ROOT) { - $covgroup = 'books'; - } elseif ($cdata->root_categories_id === Category::TV_ROOT) { - $shows = true; - } + $rootCategoryId = $cdata->root_categories_id ?? $category; + } else { + // Category not found in categories table, might be a root category + // Check if it matches a known root category ID + $rootCategoryId = $category; + } + + // Also check RootCategory table for parent categories (when $id is 'All') + if ($id === 'All' && $parentId !== null) { + $rootCategoryId = $parentId; + } + + // Set covgroup based on root category + if ($rootCategoryId === Category::GAME_ROOT) { + $covgroup = 'console'; + } elseif ($rootCategoryId === Category::MOVIE_ROOT) { + $covgroup = 'movies'; + } elseif ($rootCategoryId === Category::PC_ROOT) { + $covgroup = 'games'; + } elseif ($rootCategoryId === Category::MUSIC_ROOT) { + $covgroup = 'music'; + } elseif ($rootCategoryId === Category::BOOKS_ROOT) { + $covgroup = 'books'; + } elseif ($rootCategoryId === Category::XXX_ROOT) { + $covgroup = 'xxx'; + } elseif ($rootCategoryId === Category::TV_ROOT) { + $shows = true; } } else { $catname = $grp; diff --git a/resources/views/books/index.blade.php b/resources/views/books/index.blade.php index 696a38068..27b4eb47f 100644 --- a/resources/views/books/index.blade.php +++ b/resources/views/books/index.blade.php @@ -74,11 +74,20 @@ @if(count($results) > 0)
-

- - {{ $catname ?? 'All' }} Books -

- +
+

+ + {{ $catname ?? 'All' }} Books +

+ +
+ {{ $results->total() }} results found
diff --git a/resources/views/browse/index.blade.php b/resources/views/browse/index.blade.php index 8cf7343ce..92a64f092 100644 --- a/resources/views/browse/index.blade.php +++ b/resources/views/browse/index.blade.php @@ -56,13 +56,14 @@ @endif - @if(isset($covgroup) && $covgroup != '') -
- View: - Covers - | - List -
+ @if(isset($covgroup) && $covgroup != '' || isset($shows) && $shows) + @endif
@@ -136,8 +137,15 @@
- @if($result->cover ?? false) - Cover + @php + $showThumbnails = request()->query('thumbs', '0') === '1'; + $coverUrl = ($result->cover ?? false) ? $result->cover : ($showThumbnails ? getReleaseCover($result) : null); + $hasValidCover = $coverUrl && !str_contains($coverUrl, 'no-cover.png'); + @endphp + @if($hasValidCover) + + Cover + @endif
diff --git a/resources/views/components/view-toggle.blade.php b/resources/views/components/view-toggle.blade.php new file mode 100644 index 000000000..d5c99e72a --- /dev/null +++ b/resources/views/components/view-toggle.blade.php @@ -0,0 +1,118 @@ +@props([ + 'currentView' => 'list', + 'covgroup' => null, + 'category' => null, + 'parentcat' => null, + 'shows' => false +]) + +@php + // Build URLs for toggling views while preserving current query parameters + $currentParams = request()->query(); + + // Map covgroup to correct cover view route + $coverRouteMap = [ + 'movies' => 'Movies', + 'console' => 'Console', + 'games' => 'Games', + 'music' => 'Music', + 'books' => 'Books', + 'xxx' => 'XXX', + ]; + + // Map covgroup to correct list browse parent category + $listParentMap = [ + 'movies' => 'Movies', + 'console' => 'Console', + 'games' => 'PC', + 'music' => 'Audio', + 'books' => 'Books', + 'xxx' => 'XXX', + ]; + + // Parent category IDs - these should not be appended to URLs + $parentCategoryIds = [ + 1000, // Console/Game + 2000, // Movies + 3000, // Audio/Music + 4000, // PC + 5000, // TV + 6000, // XXX + 7000, // Books + 8000, // Other + ]; + + // Check if category is a parent category ID (should not be in URL path) + $isParentCategory = is_numeric($category) && in_array((int)$category, $parentCategoryIds); + + // Build cover view URL + if ($covgroup && isset($coverRouteMap[$covgroup])) { + $coverRoute = $coverRouteMap[$covgroup]; + // Only append category if it's not a parent category ID and not 'All' or -1 + $catParam = ($category && $category !== -1 && $category !== 'All' && !$isParentCategory) ? $category : ''; + $coverUrl = url('/' . $coverRoute . ($catParam ? '/' . $catParam : '')); + } elseif ($shows) { + $coverUrl = route('series'); + } else { + $coverUrl = '#'; + } + + // Build list view URL - preserve query params except view and thumbs for clean URL + $listParams = $currentParams; + unset($listParams['view']); + + // Determine the correct parent category for list view + $listParent = $parentcat; + if ($covgroup && isset($listParentMap[$covgroup])) { + $listParent = $listParentMap[$covgroup]; + } + + // Only append category to list URL if it's not a parent category ID + if ($listParent && $category && $category !== -1 && $category !== 'All' && !$isParentCategory) { + $listUrl = url('/browse/' . $listParent . '/' . $category); + } elseif ($listParent) { + $listUrl = url('/browse/' . $listParent); + } else { + $listUrl = request()->url(); + } + + // Add query string if there are params + if (!empty($listParams)) { + $listUrl .= '?' . http_build_query($listParams); + } + + // Build thumbnail toggle URL for list view + $thumbParams = $currentParams; + $showThumbnails = request()->query('thumbs', '0') === '1'; + $thumbParams['thumbs'] = $showThumbnails ? '0' : '1'; + $thumbUrl = request()->url() . '?' . http_build_query($thumbParams); +@endphp + +
+ View: + + @if($currentView === 'covers') + {{-- Currently in cover view --}} + Covers + | + List + @else + {{-- Currently in list view --}} + @if($covgroup || $shows) + Covers + | + @endif + List + + {{-- Thumbnail toggle in list view --}} + @if($covgroup || $shows) + | + + + {{ $showThumbnails ? 'Hide Thumbs' : 'Show Thumbs' }} + + @endif + @endif +
diff --git a/resources/views/console/index.blade.php b/resources/views/console/index.blade.php index d3a258aff..b9c2f4d81 100644 --- a/resources/views/console/index.blade.php +++ b/resources/views/console/index.blade.php @@ -42,10 +42,13 @@
-
- View: Covers | - List -
+
With Selected: diff --git a/resources/views/games/index.blade.php b/resources/views/games/index.blade.php index 4560a36ae..0cecab8ef 100644 --- a/resources/views/games/index.blade.php +++ b/resources/views/games/index.blade.php @@ -93,11 +93,20 @@ @if(count($results) > 0)
-

- - {{ $catname ?? 'All' }} Games -

- +
+

+ + {{ $catname ?? 'All' }} Games +

+ +
+ {{ $results->total() }} results found
diff --git a/resources/views/movies/index.blade.php b/resources/views/movies/index.blade.php index 0d5e6ae7d..68bf29da4 100644 --- a/resources/views/movies/index.blade.php +++ b/resources/views/movies/index.blade.php @@ -24,7 +24,16 @@
-

Filter Movies

+
+

Filter Movies

+ +