2018-06-12 07:53:27 +02:00
|
|
|
<?PHP
|
|
|
|
/**
|
|
|
|
* Functions for forming the HTML output.
|
2018-06-18 13:57:35 +02:00
|
|
|
*
|
|
|
|
* @file
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@jrenslin.de>
|
2018-06-12 07:53:27 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints the head element of an HTML page
|
|
|
|
*
|
2018-06-18 13:57:35 +02:00
|
|
|
* @param array $settings Settings variable.
|
|
|
|
* @param string $page Name / ID of the current page.
|
|
|
|
* @param string $title Title of the page.
|
|
|
|
* @param string $icon The icon of the website.
|
2018-06-12 07:53:27 +02:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-06-18 13:57:35 +02:00
|
|
|
function printBackendHead(array $settings, string $page = "home", string $title = "Home", string $icon = ""):string {
|
2018-06-12 07:53:27 +02:00
|
|
|
|
|
|
|
$output = '<!DOCTYPE html>
|
|
|
|
<html lang="en" id="' . $page . '">
|
|
|
|
<head>
|
|
|
|
|
2018-06-13 20:07:24 +02:00
|
|
|
<!-- Content Security policies -->
|
2018-06-18 13:57:35 +02:00
|
|
|
<meta http-equiv="Content-Security-Policy" content="default-src \'none\'; script-src \'self\'; connect-src \'self\'; img-src \'self\' data: blob: ' . $settings['mdVersion'];
|
|
|
|
if ($settings['CSPimageSources']) $output .= " " . $settings['CSPimageSources']; // Allow embedding of whitelisted images.
|
|
|
|
$output .= '; style-src \'self\' \'unsafe-inline\'; frame-src \'self\'';
|
|
|
|
if ($settings['CSPobjectSources']) $output .= " " . $settings['CSPobjectSources']; // Allow embedding of whitelisted frame contents / objects.
|
|
|
|
$output .= '; object-src \'self\'';
|
|
|
|
if ($settings['CSPobjectSources']) $output .= " " . $settings['CSPobjectSources']; // Allow embedding of whitelisted frame contents / objects.
|
|
|
|
$output .= '; frame-ancestors \'self\';font-src \'self\';" />
|
2018-06-13 20:07:24 +02:00
|
|
|
|
2018-06-12 07:53:27 +02:00
|
|
|
<title>' . $title . '</title>
|
|
|
|
<link rel="stylesheet" type="text/css" href="themes/imports.css">
|
2018-06-18 15:07:38 +02:00
|
|
|
<link rel="stylesheet" type="text/css" href="themes/default/theme.css">
|
2018-06-12 07:53:27 +02:00
|
|
|
<meta http-equiv="content-type" content="text/html;charset=utf-8">';
|
|
|
|
|
2018-06-13 20:07:24 +02:00
|
|
|
if ($icon) {
|
|
|
|
$output .= '
|
2018-06-18 13:57:35 +02:00
|
|
|
<link rel="shortcut icon" href="' . $icon . '" />
|
2018-06-13 20:07:24 +02:00
|
|
|
';
|
|
|
|
}
|
|
|
|
|
2018-06-12 07:53:27 +02:00
|
|
|
$output .= '
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
|
|
|
2018-06-15 11:26:25 +02:00
|
|
|
<script type="text/javascript" src="./js/newToolTip.js" defer></script>
|
2018-06-13 20:07:24 +02:00
|
|
|
<script type="text/javascript" src="./js/main.js"></script>
|
|
|
|
<script type="text/javascript" src="../js/main.js"></script>
|
2018-06-12 07:53:27 +02:00
|
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
';
|
|
|
|
|
|
|
|
if (isset($_SESSION['editHistory'])) {
|
|
|
|
$output .= "<p class='editLine ".$_SESSION['editHistory'][0]."'>".$_SESSION['editHistory'][1]."</p>";
|
|
|
|
unset($_SESSION['editHistory']);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints the header element of an HTML page.
|
|
|
|
*
|
|
|
|
* @param string $title Title of the page.
|
|
|
|
* @param string $helpText Additional help text for the page. Optional.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function printBackendHeader(string $title = "Home", string $helpText = ""):string {
|
|
|
|
|
|
|
|
$output = '
|
|
|
|
|
|
|
|
<header id="mainHeader">
|
|
|
|
|
|
|
|
<span id="toggleNavigation"></span>
|
|
|
|
<h1>' . $title . '</h1>
|
|
|
|
<span>
|
2018-06-13 20:07:24 +02:00
|
|
|
';
|
2018-06-12 07:53:27 +02:00
|
|
|
if ($helpText) $output .= '
|
|
|
|
<span class="newToolTipTag" data-for="pageHelp" id="helpText">
|
|
|
|
<span>?</span>
|
|
|
|
<div class="newToolTip" id="tooltip_pageHelp" data-title="' . $title . '">
|
|
|
|
' . $helpText . '
|
|
|
|
</div>
|
|
|
|
</span>';
|
|
|
|
$output .= '
|
|
|
|
<span id="uploadFile"></span>
|
2018-06-13 20:07:24 +02:00
|
|
|
<a id="logoutLink" href="./?logout"></a>
|
2018-06-12 07:53:27 +02:00
|
|
|
</span>
|
|
|
|
|
|
|
|
</header>
|
|
|
|
';
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns HTML code for a help icon and its attached tooltip.
|
|
|
|
*
|
|
|
|
* @param string $tooltipName Name / ID of the tooltip to generate.
|
|
|
|
* @param string $title Title to print in the tooltip.
|
|
|
|
* @param string $helpText Text to print into the tooltip.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function generateHelpToolTip(string $tooltipName, string $title, string $helpText):string {
|
|
|
|
$output = '
|
|
|
|
<span class="newToolTipTag helpToolTip" data-for="' . $tooltipName . '">
|
|
|
|
<div class="newToolTip" id="tooltip_' . $tooltipName . '" data-title="' . $title . '">
|
|
|
|
' . $helpText . '
|
|
|
|
</div>
|
|
|
|
</span>';
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints the navigation for the backend.
|
|
|
|
*
|
2018-06-13 20:07:24 +02:00
|
|
|
* @param string[] $translations Translation variable.
|
2018-06-12 07:53:27 +02:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-06-13 20:07:24 +02:00
|
|
|
function printBackendNav(array $translations):string {
|
2018-06-12 07:53:27 +02:00
|
|
|
|
|
|
|
$output = '
|
|
|
|
|
|
|
|
<nav id="mainNav">
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<span>' . $translations['edit'] . '</span>
|
|
|
|
<div>
|
|
|
|
<a href=".">' . $translations['start'] . '</a>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<a href="pages.php">' . $translations['pages'] . '</a>
|
|
|
|
<a href="page.php"> + </a>';
|
2018-06-13 20:07:24 +02:00
|
|
|
if (isset($GLOBALS['pages']) and is_array($GLOBALS['pages'])) $output .= '
|
|
|
|
<a href="pages.php">' . count($GLOBALS['pages']) . '</a>';
|
2018-06-12 07:53:27 +02:00
|
|
|
$output .= '
|
|
|
|
</div>
|
|
|
|
<div>
|
2018-06-13 20:07:24 +02:00
|
|
|
<a href="editHTMLPage.php?id=banner">' . $translations['banner'] . '</a>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<a href="editHTMLPage.php?id=footer">' . $translations['footer'] . '</a>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<a href="editHTMLPage.php?id=aside">' . $translations['aside'] . '</a>
|
2018-06-12 07:53:27 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-06-13 20:07:24 +02:00
|
|
|
';
|
|
|
|
|
|
|
|
if ($_SESSION['admin']) {
|
|
|
|
$output .= '
|
2018-06-12 07:53:27 +02:00
|
|
|
<div>
|
|
|
|
<span>' . $translations['administration'] . '</span>
|
|
|
|
<div>
|
|
|
|
<a href="users.php#listUsers">' . $translations['users'] . '</a>
|
|
|
|
<a href="users.php#addUser"> + </a>';
|
2018-06-13 20:07:24 +02:00
|
|
|
if (isset($GLOBALS['users']) and is_array($GLOBALS['users'])) $output .= '
|
|
|
|
<a href="users.php#listUsers">' . count($GLOBALS['users']) . '</a>';
|
|
|
|
$output .= '
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<a href="settings.php">' . $translations['settings'] . '</a>
|
2018-06-12 07:53:27 +02:00
|
|
|
</div>
|
2018-06-18 15:07:38 +02:00
|
|
|
<div>
|
|
|
|
<a href="editHTMLPage.php?id=welcomeMsg">' . $translations['welcomeMsg'] . '</a>
|
|
|
|
</div>
|
2018-06-12 07:53:27 +02:00
|
|
|
</div>
|
2018-06-13 20:07:24 +02:00
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
$output .= '
|
2018-06-12 07:53:27 +02:00
|
|
|
|
|
|
|
</nav>
|
|
|
|
';
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints the finishing elements of an HTML page.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function printBackendEnd():string {
|
|
|
|
|
|
|
|
$output = '
|
|
|
|
</body>
|
|
|
|
</html>';
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-06-13 20:07:24 +02:00
|
|
|
|
2018-06-12 07:53:27 +02:00
|
|
|
?>
|