Files
Web-NibblePoker/commons/DOM/utils.php
Herwin e56eb0aeb6 Finished fixing major styling issues, Leftovers need additions in CSS
Update footer.php, head.php, and 5 more files...
2024-06-12 13:23:55 +02:00

81 lines
2.3 KiB
PHP

<?php
// Making sure the file is included and not accessed directly.
if (basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {
header('HTTP/1.1 403 Forbidden');
die();
}
// Used by 'printMainHeader()'.
$_npDomUtilsHeadingCount = 0;
function getMainHeader(string $text, ?string $iconId = null, ?string $rightText = null, ?string $anchorId = null,
bool $addTopMargin = true, ?string $backgroundClass = "bkgd-grid", int $hLevel = 2,
bool $autoWidth = false, bool $chungusMode = false, bool $makeSmaller = false): string {
if(is_null($backgroundClass)) {
$backgroundClass = "bkgd-grid";
}
$htmlCode = "";
if(!is_null($anchorId)) {
$htmlCode .= '<a class="bland-link" href="#' . $anchorId . '">';
}
$htmlCode .= '<div class="heading-main p-xs border r-s ' . ($addTopMargin > 0 ? "mt-l " : "") . $backgroundClass .
($autoWidth ? " d-inline-block" : "") . '"><h' . $hLevel . ' class="t-w-500 ' .
($chungusMode ? "t-size-16" : ($makeSmaller ? "t-size-11" : "t-size-14")) . '">';
// TODO: Add a simple and nicer divider.
if(!is_null($iconId)) {
$htmlCode .= '<i class="' . $iconId . ' t-muted ' . ($chungusMode ? "t-size-14" : "t-size-12") . '"></i>';
}
$htmlCode .= $text;
if(!is_null($rightText)) {
$htmlCode .= '<span class="f-right mobile-hide ' . ($chungusMode ? "t-size-12 mr-xs" : "t-size-10 t-muted") . '">' . $rightText . '</span>';
}
$htmlCode .= '</h' . $hLevel . '></div>';
if(!is_null($anchorId)) {
$htmlCode .= '</a>';
}
return $htmlCode;
}
function printMainHeader(string $text, ?string $iconId = null, ?string $rightText = null, ?string $anchorId = null,
?string $backgroundClass = "bkgd-grid"): void {
global $_npDomUtilsHeadingCount;
$_npDomUtilsHeadingCount++;
echo(getMainHeader(
$text,
$iconId,
$rightText,
$anchorId,
($_npDomUtilsHeadingCount > 1),
$backgroundClass
));
}
function printSubHeader(string $text, ?string $anchorId = null, ?string $backgroundClass = "bkgd-math"): void {
if(is_null($backgroundClass)) {
$backgroundClass = "bkgd-math";
}
$headingText = getMainHeader(
$text,
null,
null,
$anchorId,
69, // Forcing it as a non-first of main heading.
$backgroundClass,
3
);
$headingText = str_replace("t-size-14", "t-size-11", $headingText);
echo($headingText);
}
?>