<?php
require_once "prelude.inc.php";

/**
 * Created by PhpStorm.
 * User: sean
 * Date: 5/26/17
 * Time: 8:57 PM
 */
class View
{

    public function __construct() {
        $this->addNav("Home", ROOT);
        $this->addNav("Meet The Team", ROOT . "about.php");
        $this->addNav("Secure", ROOT ."secure");
        $this->addNav("Course Site", "https://cse.msu.edu/~cse435/");
    }

    public function head(){
        $root = ROOT;
        $html = <<<HTML
    <meta charset="UTF-8">
    <title>$this->title</title>
    <link href="{$root}style/default.css" rel="stylesheet" type="text/css">
HTML;

        return $html;

    }

    public function header(){

        $html = <<<HTML
<header>
<h1>$this->title</h1>
    <nav><p class="nav-bar">|
HTML;
        foreach($this->links as $link){
            $name = $link['name'];
            $to = $link['link'];
            $html .= " <a href='$to'>$name</a> |";
        }
        $html .= <<<HTML
    </p></nav>
</header>
HTML;

        return $html;

    }

    public function page(){

        $html = <<<HTML
        <p>Content coming soon...</p>
HTML;

        return $html;

    }

    public function addNav($name, $link){
        $this->links[] = array("name" => $name, "link" => $link);
    }

    public function footer(){

        $html = <<<HTML
<footer>
</footer>
HTML;

        return $html;

    }

    public function setTitle($title){
        $this->title = $title;
    }

    private $links = array();
    protected $title = "Not Set!";

}
