This repository has been archived on 2022-07-28. You can view files and clone it, but cannot push or open issues or pull requests.
md-cms/edit/inc/standardHTML.php

164 lines
4.3 KiB
PHP
Raw Normal View History

2018-06-12 07:53:27 +02:00
<?PHP
/**
* Functions for forming the HTML output.
*/
/**
* Prints the head element of an HTML page
*
* @param string $page Name / ID of the current page.
* @param string $title Title of the page.
*
* @return string
*/
function printBackendHead(string $page = "home", string $title = "Home"):string {
$output = '<!DOCTYPE html>
<html lang="en" id="' . $page . '">
<head>
<title>' . $title . '</title>
<link rel="stylesheet" type="text/css" href="themes/imports.css">
<link rel="stylesheet" type="text/css" href="themes/default/default.css">
<meta http-equiv="content-type" content="text/html;charset=utf-8">';
$output .= '
<meta name="robots" content="none" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="text/javascript" src="./js/newToolTip.js"></script>
</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>
<span id="toggleTextBlocks"></span>';
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>
</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.
*
* @param string[] $translations Translation variable.
* @param integer[] $numbers Count of the given values.
*
* @return string
*/
function printBackendNav(array $translations, $numbers = []):string {
$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>';
if (isset($numbers['pages'])) $output .= '
<a href="users.php#listUsers">' . $numbers['pages'] . '</a>';
$output .= '
</div>
<div>
<a href="fileUpload.php">' . $translations['fileUpload'] . '</a>
</div>
</div>
<div>
<span>' . $translations['administration'] . '</span>
<div>
<a href="users.php#listUsers">' . $translations['users'] . '</a>
<a href="users.php#addUser"> + </a>';
if (isset($numbers['users'])) $output .= '
<a href="users.php#listUsers">' . $numbers['users'] . '</a>';
$output .= '
</div>
</div>
</nav>
';
return $output;
}
/**
* Prints the finishing elements of an HTML page.
*
* @return string
*/
function printBackendEnd():string {
$output = '
</body>
</html>';
return $output;
}
?>