<?php

function fillHead($rootPageURL, $pageTitle, $darkTheme, $lightTheme) {

    echo ('<meta charset="UTF-8">');
    echo ('<meta name="viewport" content="width=device-width, initial-scale=1.0">');
    echo ('<link rel="stylesheet" href="' . $rootPageURL . 'src/css/style.css">');
    echo ('<link rel="icon" href="' . $rootPageURL . 'src/img/favicon.ico">');

    echo ('<style>');

    echo ('@media (prefers-color-scheme: dark) {');
    echo ($darkTheme);
    echo ('}');

    echo ('@media (prefers-color-scheme: light) {');
    echo ($lightTheme);
    echo ('}');

    echo ('</style>');

    echo ('<title>' . $pageTitle . '</title>');
}


function fillHeader($rootPageURL, $headerTitle, $headerSubtitle) {

    echo ('<div class="logo-container">');

    echo ('<a href="' . $rootPageURL . '">');
    echo ('<img src="' . $rootPageURL . 'src/img/athena-mono.png" class="logo-img">');
    echo ('</a>');

    echo ('</div>');

    echo ('<div class="content">');

    echo ('<div class="header-title-container">');
    echo ('<div class="header-title">' . $headerTitle . '</div>');
    echo ('<div class="header-subtitle">' . $headerSubtitle . '</div>');
    echo ('</div>');

    echo ('</div>');
}


function fillNav($rootPageURL) {

    echo ('<a href="' . $rootPageURL . 'news"><div class="nav-link">News</div></a>');
    echo ('<a href="' . $rootPageURL . 'about"><div class="nav-link">A propos</div></a>');

    if ($_SESSION['userRole'] >= 3) {
        echo ('<a href="' . $rootPageURL . 'admin"><div class="nav-link">Admin</div></a>');
    }

    if(isset($_SESSION['userID'])) {
        echo ('<a href="' . $rootPageURL . 'account"><div class="nav-link">Profil</div></a>');
        echo ('<a href="' . $rootPageURL . 'settings"><div class="nav-link">Options</div></a>');
        echo ('<a href="' . $rootPageURL . 'login/logout.php"><div class="nav-link">Déconnexion</div></a>');
    } else {
        echo ('<a href="' . $rootPageURL . 'login"><div class="nav-link">Se connecter</div></a>');
    }
}


function fillFooter($footerText) {
    echo($footerText);
}

?>