37 lines
1008 B
PHP
37 lines
1008 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
class SiteController extends BaseController
|
|
{
|
|
public function home(): void
|
|
{
|
|
$page = max(1, (int) ($this->f3->get('GET.page') ?? 1));
|
|
$media = new Media($this->db);
|
|
$result = (new Post($this->db))->paginateList($page, 12, $media);
|
|
|
|
$this->render('site/home.html', [
|
|
'pageTitle' => 'Accueil',
|
|
'posts' => $result['posts'],
|
|
'pagination' => $result,
|
|
'paginationAlias' => 'home',
|
|
], 300);
|
|
}
|
|
|
|
public function show(): void
|
|
{
|
|
$media = new Media($this->db);
|
|
$post = (new Post($this->db))->findBySlug((string) $this->f3->get('PARAMS.slug'), $media);
|
|
if ($post === null) {
|
|
$this->f3->error(404, 'Article introuvable.');
|
|
return;
|
|
}
|
|
|
|
$this->render('site/post.html', [
|
|
'pageTitle' => $post['title'],
|
|
'metaDescription' => $post['excerpt'],
|
|
'post' => $post,
|
|
], 3600);
|
|
}
|
|
}
|