2026-04-08 08:49:36 +02:00
|
|
|
<?php
|
2026-04-08 16:10:49 +02:00
|
|
|
include_once './modeles/modeleFilms.php';
|
2026-04-08 08:49:36 +02:00
|
|
|
|
2026-04-08 16:10:49 +02:00
|
|
|
$currentPage = filter_input(
|
|
|
|
|
INPUT_GET,
|
|
|
|
|
'page',
|
|
|
|
|
FILTER_VALIDATE_INT,
|
|
|
|
|
['options' => ['min_range' => 1]]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ($currentPage === null || $currentPage === false) {
|
|
|
|
|
$currentPage = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$perPage = 10;
|
|
|
|
|
$data = getFilms($currentPage, $perPage);
|
|
|
|
|
$films = $data['films'];
|
|
|
|
|
$errorMessage = $data['error'];
|
|
|
|
|
$totalFilms = $data['total'];
|
|
|
|
|
$totalPages = max(1, (int) ceil($totalFilms / $perPage));
|
|
|
|
|
|
|
|
|
|
if ($currentPage > $totalPages && $totalFilms > 0) {
|
|
|
|
|
$currentPage = $totalPages;
|
|
|
|
|
$data = getFilms($currentPage, $perPage);
|
|
|
|
|
$films = $data['films'];
|
|
|
|
|
$errorMessage = $data['error'];
|
|
|
|
|
$totalFilms = $data['total'];
|
|
|
|
|
}
|
2026-04-08 08:49:36 +02:00
|
|
|
|
|
|
|
|
//
|
2026-04-08 16:10:49 +02:00
|
|
|
// on "charge" la vue
|
2026-04-08 08:49:36 +02:00
|
|
|
//
|
|
|
|
|
|
2026-04-08 16:10:49 +02:00
|
|
|
include_once './vues/header.php';
|
|
|
|
|
include_once './vues/vueFilms.php';
|
|
|
|
|
include_once './vues/footer.php';
|
2026-04-08 08:49:36 +02:00
|
|
|
|