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

View File

@ -7,6 +7,9 @@
* @author Joshua Ramon Enslin <joshua@jrenslin.de>
*/
require __DIR__ . "/standardHTML.php";
require __DIR__ . "/mdEmbeds.php";
/**
* Function ensureDir checks if a directory exists, and creates it if it does not yet.
*
@ -47,7 +50,7 @@ function ensureEnvironment() {
// Ensure existence of directories
foreach ([__DIR__ . "/../data", __DIR__ . "/../data/static", __DIR__ . "/../data/caches", __DIR__ . "/../js"] as $folder) {
foreach ([__DIR__ . "/../files", __DIR__ . "/../data", __DIR__ . "/../data/static", __DIR__ . "/../data/caches", __DIR__ . "/../js"] as $folder) {
ensureDir($folder);
}
@ -56,11 +59,54 @@ function ensureEnvironment() {
foreach ([
__DIR__ . "/../data/settings.json",
__DIR__ . "/../data/caches/pages.json",
__DIR__ . "/../data/caches/publicPages.json",
__DIR__ . "/../data/users.json",
] as $jsonFile) {
ensureJson($jsonFile);
}
// Load settings
$settings = array_merge(
[
"startPage" => "1",
"pageTitle" => "md:cms",
"logo" => "",
"url" => "",
"mdVersion" => "https://www.museum-digital.de/nat/",
"maxFileSize" => 300000,
"defaultLang" => "en"
],
json_decode(file_get_contents(__DIR__ . "/../data/settings.json"), true)
);
$GLOBALS['settings'] = $settings;
}
/**
* Function for loading contents from cache.
*
* @return array
*/
function loadPages() {
$pages = json_decode(file_get_contents(__DIR__ . "/../data/caches/pages.json"), true);
return $pages;
}
/**
* Function for loading contents from cache.
*
* @return array
*/
function loadPublicPages() {
$pages = json_decode(file_get_contents(__DIR__ . "/../data/caches/publicPages.json"), true);
return $pages;
}
/**
@ -216,6 +262,62 @@ function write_common_vars(array $input):string {
}
/**
* Function for e.g. printing the navigation.
*
* @param array $pages Array of all pages to list.
* @param function $start Function to run on the called pages in case a new level is entered.
* @param function $end Function to run on the called pages in case a new level is entered.
* @param function $callbackSameLevel Function to run on the called pages of the current level.
* @param integer $higher Run the callback function on those entries where higher equals the given.
*
* @return string
*/
function buildPageOrder(
array $pages,
$start,
$end,
$callbackSameLevel,
int $higher = 0
):string {
$output = "";
$thisLevel = [];
foreach ($pages as $page) {
if ($page["higher"] != $higher) continue;
$output .= $callbackSameLevel($page, buildPageOrder($pages, $start, $end, $callbackSameLevel, $page["id"]));
}
if ($output) $output = $start() . $output . $end();
return $output;
}
/**
* Function for checking access to previews.
*
* @param bool $sessionStarted Optional parameter depending on the status of the session.
*
* @return bool
*/
function checkPreviewAccess($sessionStarted = false) {
if (!$sessionStarted) {
session_start();
}
if (isset($_SESSION['username'])) $output = true;
else $output = false;
if (!$sessionStarted) {
session_abort();
}
return $output;
}
?>