2021-04-21 04:20:42 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require "vendor/autoload.php";
|
|
|
|
|
|
|
|
class ThemeEngine
|
|
|
|
{
|
|
|
|
public $data = [];
|
|
|
|
public $loader;
|
|
|
|
public $twig;
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->data = json_decode(file_get_contents("./config.json"), true);
|
|
|
|
$this->loader = new \Twig\Loader\FilesystemLoader("src/themes/");
|
|
|
|
$this->twig = new \Twig\Environment($this->loader, []);
|
|
|
|
$this->router($_SERVER["REQUEST_URI"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function router(string $request)
|
|
|
|
{
|
|
|
|
switch ($request) {
|
|
|
|
case "/":
|
2021-04-21 08:14:49 +02:00
|
|
|
$recent = $this->data["recent_posts"];
|
|
|
|
$featured = $this->data["featured_posts"];
|
|
|
|
echo $this->twig->render(
|
|
|
|
"theme-fipamo-default/fipamo-default/index.twig",
|
|
|
|
[
|
|
|
|
"debug" => true,
|
|
|
|
"title" => "This is Fipamo",
|
|
|
|
"background" =>
|
|
|
|
"/src/themes/theme-fipamo-default/fipamo-default/assets/images/global/default-bg.jpg",
|
|
|
|
"recent" => $recent,
|
|
|
|
"featured" => $featured,
|
|
|
|
]
|
|
|
|
);
|
2021-04-21 04:20:42 +02:00
|
|
|
break;
|
|
|
|
case "":
|
|
|
|
require __DIR__ . "/views/index.php";
|
|
|
|
break;
|
|
|
|
case "/archive":
|
|
|
|
$archive = $this->data["archives"];
|
|
|
|
echo $this->twig->render(
|
|
|
|
"theme-fipamo-default/fipamo-default/archive.twig",
|
|
|
|
[
|
2021-04-21 08:14:49 +02:00
|
|
|
"debug" => true,
|
2021-04-21 04:20:42 +02:00
|
|
|
"title" => "Archive",
|
2021-04-21 08:14:49 +02:00
|
|
|
"background" =>
|
|
|
|
"/src/themes/theme-fipamo-default/fipamo-default/assets/images/global/default-bg.jpg",
|
2021-04-21 04:20:42 +02:00
|
|
|
"archives" => $archive,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
http_response_code(404);
|
|
|
|
require __DIR__ . "/views/404.php";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new ThemeEngine();
|