Added editing function for pages (using tinymce).
Added editing pages for footer, banner, aside. Added page overview. Added public page. Added settings page. Added generator for embed pseudocodes.
This commit is contained in:
95
index.php
95
index.php
@ -5,13 +5,104 @@
|
||||
* @author Joshua Ramon Enslin <joshua@jrenslin.de>
|
||||
*/
|
||||
|
||||
// Check validity of request.
|
||||
|
||||
if (isset($_GET['id']) and !file_exists(__DIR__ . "/data/static/" . $_GET['id'] . ".json")) {
|
||||
echo printErrorPage("File does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Include functions and settings.
|
||||
|
||||
require __DIR__ . "/inc/functions.php";
|
||||
|
||||
ensureEnvironment();
|
||||
// Ensure working environment for frontend.
|
||||
|
||||
echo "hi";
|
||||
ensureEnvironment();
|
||||
$pages = loadPublicPages(); // Load overview of pages.
|
||||
|
||||
/*
|
||||
* Load data.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @var array $tPage The variable contains the main data on the displayed page.
|
||||
*/
|
||||
$tPage = [];
|
||||
|
||||
if (isset($_GET['id'])) $id = $_GET['id'];
|
||||
else if (file_exists(__DIR__ . "/data/static/" . $settings['startPage'] . ".json")) {
|
||||
$id = $settings['startPage'];
|
||||
}
|
||||
else {
|
||||
echo printErrorPage("This file does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
$tPage = json_decode(file_get_contents(__DIR__ . "/data/static/" . $id . ".json"), true);
|
||||
|
||||
if (!$tPage['public']) {
|
||||
if (!(isset($_GET['preview']) and checkPreviewAccess())) {
|
||||
echo printErrorPage("This page is not public."); return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Output
|
||||
*/
|
||||
|
||||
echo printPublicHead($id, $settings['pageTitle'], $settings['logo']);
|
||||
echo printPublicHeader($settings['pageTitle']);
|
||||
echo printStaticPagePart("banner", "header"); // Print aside (if need be)
|
||||
|
||||
echo '<nav>';
|
||||
echo buildPageOrder(
|
||||
$pages,
|
||||
function() {
|
||||
return "<ul>";
|
||||
},
|
||||
function() {
|
||||
return "</ul>";
|
||||
},
|
||||
function($inputs, string $toAdd) {
|
||||
$output = "
|
||||
<li";
|
||||
if (!$inputs['public']) $output .= " class='notPublic'";
|
||||
$output .= ">
|
||||
<a href='./?id=" . $inputs['id'] . "'>" . $inputs['title'] . "</a>
|
||||
$toAdd
|
||||
</li>
|
||||
";
|
||||
return $output;
|
||||
}
|
||||
);
|
||||
echo '</nav>';
|
||||
|
||||
echo '
|
||||
<div id="mainWrapper">
|
||||
';
|
||||
|
||||
// Print main content
|
||||
echo '
|
||||
<main>';
|
||||
|
||||
echo '<h1>' . $tPage['title'] . '</h1>';
|
||||
echo checkForEmbeds($tPage['content']);
|
||||
|
||||
echo '
|
||||
</main>
|
||||
';
|
||||
|
||||
echo printStaticPagePart("aside", "aside"); // Print aside (if need be)
|
||||
|
||||
echo '
|
||||
</div>';
|
||||
|
||||
echo printStaticPagePart("footer", "footer"); // Print footer (if need be)
|
||||
|
||||
echo printPublicEnd();
|
||||
|
||||
?>
|
||||
|
||||
|
Reference in New Issue
Block a user