mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
basic filter D:
This commit is contained in:
@@ -28,24 +28,37 @@ class TvShowController extends Controller
|
||||
// Get search parameters
|
||||
$search = trim($queryParams['search'] ?? '');
|
||||
|
||||
// Get filter parameters
|
||||
$genres = $queryParams['genres'] ?? [];
|
||||
if (!is_array($genres)) {
|
||||
$genres = [$genres];
|
||||
}
|
||||
$genres = array_filter($genres);
|
||||
|
||||
$years = $queryParams['years'] ?? [];
|
||||
if (!is_array($years)) {
|
||||
$years = [$years];
|
||||
}
|
||||
$years = array_filter($years);
|
||||
|
||||
// Get view mode
|
||||
$viewMode = $queryParams['view'] ?? 'grid'; // grid, list, covers
|
||||
|
||||
// Get TV shows with pagination and search
|
||||
$tvshows = TvShow::getAllWithPagination($this->pdo, $page, $perPage, $search);
|
||||
// Get TV shows with pagination and filters
|
||||
$tvshows = TvShow::getAllWithPagination($this->pdo, $page, $perPage, $search, $genres, $years);
|
||||
|
||||
// Get total count for pagination
|
||||
$totalCount = TvShow::getTotalCount($this->pdo, $search);
|
||||
$totalCount = TvShow::getTotalCount($this->pdo, $search, $genres, $years);
|
||||
|
||||
// Get available filter options
|
||||
$availableGenres = TvShow::getAvailableGenres($this->pdo);
|
||||
$availableYears = TvShow::getAvailableYears($this->pdo);
|
||||
|
||||
// Calculate pagination info
|
||||
$totalPages = ceil($totalCount / $perPage);
|
||||
$hasNextPage = $page < $totalPages;
|
||||
$hasPrevPage = $page > 1;
|
||||
/*
|
||||
echo '<pre>';
|
||||
print_r($tvshows);
|
||||
die();
|
||||
*/
|
||||
|
||||
return $this->view->render($response, 'tvshows/index.twig', [
|
||||
'title' => 'TV Shows',
|
||||
'tvshows' => $tvshows,
|
||||
@@ -61,7 +74,15 @@ class TvShowController extends Controller
|
||||
],
|
||||
'search' => $search,
|
||||
'view_mode' => $viewMode,
|
||||
'view_modes' => ['grid', 'list', 'covers']
|
||||
'view_modes' => ['grid', 'list', 'covers'],
|
||||
'filters' => [
|
||||
'genres' => $genres,
|
||||
'years' => $years
|
||||
],
|
||||
'available_filters' => [
|
||||
'genres' => $availableGenres,
|
||||
'years' => $availableYears
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user