|
|
|
@ -101,24 +101,47 @@ class DashControl
|
|
|
|
|
if (Session::active()) {
|
|
|
|
|
$template = "dash/page-edit.twig";
|
|
|
|
|
$mode = $args["third"];
|
|
|
|
|
if ($mode == "edit") {
|
|
|
|
|
$uuid = $args["fourth"];
|
|
|
|
|
$customPages = (new Themes())->getCustomViews();
|
|
|
|
|
$pageOptions = [
|
|
|
|
|
"title" => "Fipamo | Edit Page",
|
|
|
|
|
"page" => (new Book("../content/pages"))->findPageById($uuid),
|
|
|
|
|
"mode" => $mode,
|
|
|
|
|
"token" => Session::get("form_token"),
|
|
|
|
|
"status" => Session::active(),
|
|
|
|
|
"views" => $customPages,
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
$pageOptions = [
|
|
|
|
|
"title" => "Fipamo | Create Page",
|
|
|
|
|
"token" => Session::get("form_token"),
|
|
|
|
|
"mode" => $mode,
|
|
|
|
|
"status" => Session::active(),
|
|
|
|
|
];
|
|
|
|
|
$uuid = $args["fourth"];
|
|
|
|
|
switch ($mode) {
|
|
|
|
|
case "edit":
|
|
|
|
|
$customPages = (new Themes())->getCustomViews();
|
|
|
|
|
$pageOptions = [
|
|
|
|
|
"title" => "Fipamo | Edit Page",
|
|
|
|
|
"page" => (new Book("../content/pages"))->findPageById($uuid),
|
|
|
|
|
"mode" => $mode,
|
|
|
|
|
"token" => Session::get("form_token"),
|
|
|
|
|
"status" => Session::active(),
|
|
|
|
|
"views" => $customPages,
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
case "preview":
|
|
|
|
|
$config = new Settings();
|
|
|
|
|
$settings = $config->getSettings();
|
|
|
|
|
$loader = new \Twig\Loader\FilesystemLoader(
|
|
|
|
|
"../content/themes"
|
|
|
|
|
);
|
|
|
|
|
$display = new \Twig\Environment($loader, []);
|
|
|
|
|
|
|
|
|
|
$book = new Book("../content/pages");
|
|
|
|
|
$page = $book->findPageById($uuid);
|
|
|
|
|
$pageOptions = Sorting::page($page);
|
|
|
|
|
$preview =
|
|
|
|
|
$settings["global"]["theme"] .
|
|
|
|
|
"/" .
|
|
|
|
|
$page["layout"] .
|
|
|
|
|
".twig";
|
|
|
|
|
$html = $display->render($preview, $pageOptions);
|
|
|
|
|
$response->getBody()->write($html);
|
|
|
|
|
return $response;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$pageOptions = [
|
|
|
|
|
"title" => "Fipamo | Create Page",
|
|
|
|
|
"token" => Session::get("form_token"),
|
|
|
|
|
"mode" => $mode,
|
|
|
|
|
"status" => Session::active(),
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
header("Location: /dashboard");
|
|
|
|
|