*/ /** * Prints the head element of an HTML page in the public frontend. * * @param array $settings Settings variable. * @param string $page ID of the current page. * @param string $title Title of the page. * @param string $icon The icon of the website. * @param string $additional Additional HTML to inject. * * @return string */ function printPublicHead(array $settings, string $page = "home", string $title = "Home", string $icon = "", $additional = ""):string { $output = ' ' . $title . ' '; $output .= $additional; if ($icon) { $output .= ' '; } $output .= ' '; if (isset($_SESSION['editHistory'])) { $output .= "

".$_SESSION['editHistory'][1]."

"; unset($_SESSION['editHistory']); } return $output; } /** * Prints the header element of an HTML page. * * @param string $title Title of the page. * * @return string */ function printPublicHeader(string $title = "Home"):string { $output = '

' . $title . '

' . generateSearchBar() . '
'; return $output; } /** * Prints the finishing elements of public HTML pages. * * @return string */ function printPublicEnd():string { $output = ' '; return $output; } /** * This function prints a file (the sidebar, the banner, or the footer) if it is not empty. * * @param string $file File name. Must be either aside, banner or footer. * @param string $elem Encapsulating HTML element. * * @return string */ function printStaticPagePart(string $file, string $elem):string { if (!in_array($file, ['footer', 'aside', 'banner', 'welcomeMsg'])) { echo "Trying to access disallowed file."; } if (!file_exists(__DIR__ . "/../data/$file.htm") || !filesize(__DIR__ . "/../data/$file.htm") > 5) return ""; $content = file_get_contents(__DIR__ . "/../data/$file.htm"); $output = " <$elem> $content "; return $output; } /** * This function prints an error page. * * @param array $settings General site settings / including the CSS. * @param string $content The error message. * * @return string */ function printErrorPage(array $settings, string $content):string { $output = ' ' . $content . '
' . $content . '
'; return $output; } /** * Function for generating the standard navigation of the public parts of the page. * * @param array $pages List of all pages. * * @return string */ function generatePublicNav($pages):string { $output = ''; return $output; } /** * Function for printing the search bar. * * @return string */ function generateSearchBar():string { $output = '
'; return $output; } ?>