This repository has been archived on 2026-04-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Project_BDE/www/lib/PHP/output/sections.php
smithi_3000 37a2ae2c2d Modified website hierarchy (again !) and files about it.
Everything previously under www/src now are under www/
Moved style.CSS under www/ressources, to allow blocking http requests to
www/lib completly
Moved <head> and <header> generation under lib/PHP/output/sections.php
to reduce redundancy within files. Also implemented a system to allow
them to generate relatif paht for href to ressources depending on their
deepness within www/ hierarchy.
2025-11-16 00:01:32 +01:00

83 lines
No EOL
2 KiB
PHP

<?php
// __DIR__ is needed.
require_once __DIR__.'/../session/sessiontest.php';
function print_website_meta(int $deepness, string $pagetitle)
{
$relative_prefix = str_repeat('../', $deepness);
ECHO <<<_END
<head>
<meta charset="UTF-8">
<title>{$pagetitle}</title>
<link rel="stylesheet" href="{$relative_prefix}ressources/style.css">
</head>
_END;
}
function print_website_header(int $deepness)
{
//The prefix to add to each link to obtain relative path to page.
$relative_prefix = str_repeat('../', $deepness);
//The always-there left nav start
$header = <<<_END
<header>
<div class="header-left">
<a href="{$relative_prefix}search/complete.php" class="icon search-icon">🔍</a>
<a href="{$relative_prefix}index.php" class="icon home-icon">🏠</a>
_END;
//The admin left nav entry
if(has_privileges(ACCOUNT_PRIV_ADMIN)){
$header .= <<<_END
<a href="{$relative_prefix}admin/direct_query.php" class="icon">SQL</a>
_END;
}
//The always-there left nav end
$header .= <<<_END
</div>
_END;
//==========================================
//The always-there center nav
$header .= <<<_END
<nav class="nav-center">
<a href="{$relative_prefix}informations.php" class="nav-item">Informations</a>
</nav>
_END;
//==========================================
//The always-there right nav start
$header .= <<<_END
<div class="header-right">
_END;
//The unlogged user right nav entries
if (!is_logged_in()) {
$header .= <<<_END
<a href="{$relative_prefix}profile/login.php" class="nav-item">Login</a>
<a href="{$relative_prefix}profile/signup.php" class="nav-item">Register</a>
_END;
}else{
//The logged user right nav entries
$dname = $_SESSION["displayname"];
$header .= <<<_END
<div class="user-menu">
<a href="{$relative_prefix}profile/view.php" class="username">
$dname
</a>
</div>
_END;
}
//The always-there right header end
$header .= <<<_END
</div>
</header>
_END;
echo $header;
}