fipamothemekit/index.php

97 lines
2.9 KiB
PHP

<?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)
{
$pageInfo = [
"keywords" => $this->data["keywords"],
"description" => $this->data["description"],
"image" =>
"/src/themes/theme-fipamo-default/fipamo-default/assets/images/global/default-bg.jpg",
];
$menu = $this->data["menu"];
switch ($request) {
case "/":
$recent = $this->data["recent_posts"];
$featured = $this->data["featured_posts"];
$template = "theme-fipamo-default/fipamo-default/index.twig";
$pageOptions = [
"debug" => true,
"title" => "This is Fipamo",
"background" =>
"/src/themes/theme-fipamo-default/fipamo-default/assets/images/global/default-bg.jpg",
"recent" => $recent,
"featured" => $featured,
"info" => $pageInfo,
"menu" => $menu,
];
break;
case "/page":
$content = $this->data["content"];
$meta = $this->data["meta"];
$template = "theme-fipamo-default/fipamo-default/page.twig";
$pageOptions = [
"debug" => true,
"title" => "Page Title",
"background" =>
"/src/themes/theme-fipamo-default/fipamo-default/assets/images/global/default-bg.jpg",
"content" => $content,
"meta" => $meta,
"info" => $pageInfo,
"menu" => $menu,
];
break;
case "/tags":
$tags = $this->data["tag_list"];
$template = "theme-fipamo-default/fipamo-default/tags.twig";
$pageOptions = [
"debug" => true,
"title" => "Pages Tagged as Tag",
"background" =>
"/src/themes/theme-fipamo-default/fipamo-default/assets/images/global/default-bg.jpg",
"tag_list" => $tags,
"info" => $pageInfo,
"menu" => $menu,
];
break;
case "/archive":
$archive = $this->data["archives"];
$template = "theme-fipamo-default/fipamo-default/archive.twig";
$pageOptions = [
"debug" => true,
"title" => "Archive",
"background" =>
"/src/themes/theme-fipamo-default/fipamo-default/assets/images/global/default-bg.jpg",
"archives" => $archive,
"info" => $pageInfo,
"menu" => $menu,
];
break;
default:
http_response_code(404);
require __DIR__ . "/views/404.php";
break;
}
echo $this->twig->render($template, $pageOptions);
}
}
new ThemeEngine();