diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-21 22:36:11 +0100 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-21 22:36:11 +0100 |
| commit | d63e3c91a97d77b202e280ab0fa007dfbe1baa46 (patch) | |
| tree | cd3533bfb947ea753d91f71a75406644a73d678d /src/app/Controllers/GalleryController.php | |
| parent | f60a390f5c51039fd1efc1df9a6a7f3864ce0062 (diff) | |
| download | camagru-d63e3c91a97d77b202e280ab0fa007dfbe1baa46.tar.gz camagru-d63e3c91a97d77b202e280ab0fa007dfbe1baa46.zip | |
Add editor with webcam/upload capture, overlay compositing, and gallery feed
Diffstat (limited to 'src/app/Controllers/GalleryController.php')
| -rw-r--r-- | src/app/Controllers/GalleryController.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/app/Controllers/GalleryController.php b/src/app/Controllers/GalleryController.php new file mode 100644 index 0000000..2edcd17 --- /dev/null +++ b/src/app/Controllers/GalleryController.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +// Gallery: public paginated feed of all posts, newest first. + +namespace App\Controllers; + +use App\Models\Post; + +class GalleryController +{ + private Post $post; + private const POSTS_PER_PAGE = 5; + + public function __construct() + { + $this->post = new Post(); + } + + public function index(): void + { + $page = max(1, (int) ($_GET['page'] ?? 1)); + $offset = ($page - 1) * self::POSTS_PER_PAGE; + + $posts = $this->post->findAllPaginated(self::POSTS_PER_PAGE, $offset); + $totalPosts = $this->post->countAll(); + $totalPages = max(1, (int) ceil($totalPosts / self::POSTS_PER_PAGE)); + + $content = __DIR__ . '/../Views/gallery/index.php'; + include __DIR__ . '/../Views/layouts/main.php'; + } +} |
