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:
2018-06-13 20:07:24 +02:00
committed by Stefan Rohde-Enslin
parent 227c91963e
commit a49746ab10
114 changed files with 4422 additions and 47 deletions

97
edit/editHTMLPage.php Normal file
View File

@ -0,0 +1,97 @@
<?PHP
/**
* This page offers the opportunity to edit static page elements: the side bar and the footer.
*/
/*
* Require files and ensure environment.
*/
require_once __DIR__ . "/inc/functions.php";
ensureEnvironment(); // Ensure existence of system files.
$translations = loadLanguage(); // Load translations.
ensureBackendEnv(); // Ensure session is started etc.
$pages = loadPages(); // Load overview of pages.
/*
* Load contents
*/
// Check for vars.
loadHttpToGlobals(["id", "task", "content"]);
define("targetFile", __DIR__ . "/../data/$id.htm");
if (!isset($id) or !in_array($id, ['footer', 'aside', 'banner'])) {
echo printErrorPage($translations['specifyToEdit']); return;
}
// Read file contents if there is no new content sent by $_POST.
if (!isset($content)) {
if (file_exists(targetFile)) {
$content = file_get_contents(targetFile);
}
else $content = "";
}
// Set page title
$pageTitle = $translations['edit'] . ': ' . $translations[$id];
/*
* Store if need be
*/
if (isset($task) and $task == "update") {
file_put_contents(targetFile, $content, LOCK_EX);
header('Location: editHTMLPage.php?id=' . $id);
return;
}
/*
* Output
*/
if (!isset($public)) $public = false;
echo printBackendHead($pageTitle);
echo printBackendHeader($pageTitle, $translations["help$id"]);
echo '
<div id="mainWrapper">
';
echo printBackendNav($translations);
echo '
<main class="noPadding">
<form action="" method="POST">
<textarea type="text" name="content" id="pageContent" class="mceEditor" placeholder="' . $translations['staticPageTitle'] . '" required>';
if (isset($content)) echo $content;
echo '
</textarea>
<span>
<button type="submit">' . $translations['submit'] . '</button>
' . printHiddenInputs(["task" => "update", "id" => $id]) . '
</span>
</form>
</main>
</div>
<script src="./js/tinymce471/js/tinymce/tinymce.min.js"></script>
<script type="text/javascript" src="./js/runTinyMCE.js"></script>
';
echo printBackendEnd();
?>