<?php declare(strict_types=1); ?>
<!doctype html>
<html lang="<?php echo xss($metadata->language); ?>">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="<?php echo xss($metadata->description); ?>">
    <meta name="author" content="<?php echo xss($metadata->author); ?>">
    <meta name="dcterms.rights" content="<?php echo xss($metadata->copyright); ?>">
    <meta name="robots" content="<?php echo xss($metadata->robots); ?>">
    <link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo TFISH_URL . 'rss.php'; ?>" />
    <link rel="schema.dcterms" href="http://purl.org/dc/terms/">

    <?php if (!empty($metadata->canonicalUrl)): ?>
    <!-- Canonical URL -->
    <link rel="canonical" href="<?php echo xss($metadata->canonicalUrl); ?>">
    <?php endif; ?>

    <!-- Favicons -->
    <link rel="apple-touch-icon" sizes="180x180" href="<?php echo TFISH_URL . 'apple-touch-icon.png'; ?>">
    <link rel="icon" type="image/png" sizes="32x32" href="<?php echo TFISH_URL . 'favicon-32x32.png'; ?>">
    <link rel="icon" type="image/png" sizes="16x16" href="<?php echo TFISH_URL . 'favicon-16x16.png'; ?>">
    <link rel="manifest" href="<?php echo TFISH_URL . 'site.webmanifest'; ?>">
    <link rel="mask-icon" href="<?php echo TFISH_URL . 'safari-pinned-tab.svg'; ?>" color="#5bbad5">
    <meta name="msapplication-TileColor" content="#da532c">
    <meta name="theme-color" content="#ffffff">

    <title><?php echo xss($metadata->title); ?></title>

    <!-- jQuery -->
    <script src="<?php echo TFISH_VENDOR_URL . 'jquery/jquery.min.js'; ?>"></script>

    <!-- Bootstrap -->
    <link href="<?php echo TFISH_VENDOR_URL . 'bootstrap/css/bootstrap.min.css'; ?>" rel="stylesheet">
    <script src="<?php echo TFISH_VENDOR_URL . 'bootstrap/js/bootstrap.bundle.min.js'; ?>"></script>

    <!-- htmx -->
    <script src="<?php echo TFISH_VENDOR_URL . 'htmx/htmx.min.js'; ?>"></script>

    <!-- Font Awesome -->
    <script defer src="<?php echo TFISH_VENDOR_URL . 'fontawesome/fontawesome.min.js'; ?>"></script>
    <script defer src="<?php echo TFISH_VENDOR_URL . 'fontawesome/icons-in-use.js'; ?>"></script>

    <?php if ($session->isEditor()): ?>
    <!-- TinyMCE editor -->
    <script src="<?php echo TFISH_VENDOR_URL . 'tinymce/tinymce.min.js'; ?>"></script>
    <script>tinymce.init({
        license_key: 'gpl',
        selector: "#teaser,#description,#experience,#projects,#publications,#html",
        autoresize_max_height: 700,
        entity_encoding: "raw",
        plugins: "anchor,autosave,autoresize,charmap,code,codesample,emoticons,image,link,lists,media,table,wordcount",
        menubar: "view,insert,table",
        toolbar: "code | styles | bold italic underline forecolor | superscript subscript | removeformat | link unlink anchor | bullist numlist blockquote | alignleft aligncenter alignright | image media charmap | table | codesample",
        pasteastext: true,
        image_caption: true,
        convert_urls: false,
        promotion: false,
  });
    </script>

    <!-- Bootstrap-datepicker -->
    <link href="<?php echo TFISH_VENDOR_URL . 'bootstrap-datepicker/css/bootstrap-datepicker3.min.css'; ?>" media="all" rel="stylesheet" type="text/css" />
    <script src="<?php echo TFISH_VENDOR_URL . 'bootstrap-datepicker/js/bootstrap-datepicker.min.js'; ?>"></script>

    <!-- Bootstrap-fileinput uploader -->
    <link href="<?php echo TFISH_VENDOR_URL . 'bootstrap-fileinput/css/fileinput.min.css'; ?>" media="all" rel="stylesheet" type="text/css" />
    <script src="<?php echo TFISH_VENDOR_URL . 'bootstrap-fileinput/js/fileinput.js'; ?>"></script>
    <script src="<?php echo TFISH_VENDOR_URL . 'bootstrap-fileinput/themes/fa/theme.js'; ?>"></script>
    <?php endif; ?>

    <!-- Custom styles for this template -->
    <link href="<?php echo TFISH_THEMES_URL . 'admin/style.css'; ?>" rel="stylesheet">
  </head>

  <body>

    <!-- Navigation -->
    <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
        <div class="container-fluid">
          <a class="navbar-brand" href="<?php echo TFISH_URL; ?>"><?php echo xss($metadata->siteName); ?></a>
          <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="navbarCollapse">
            <ul class="navbar-nav me-auto mb-2 mb-md-0">
              <?php if ($session->isEditor()): ?>
              <li class="nav-item">
                  <a class="nav-link"  href="<?php echo TFISH_ADMIN_URL; ?>"><?php echo TFISH_ADMIN; ?></a>
              </li>
              <li class="nav-item">
                <a class="nav-link"  href="<?php echo TFISH_URL . 'admin/blocks/'; ?>"><?php echo TFISH_ADMIN_BLOCKS; ?></a>
              </li>
              <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" id="settings" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php echo TFISH_SETTINGS; ?></a>
                <ul class="dropdown-menu" aria-labelledby="settings">
                  <?php if ($session->isAdmin()): ?>
                  <a class="dropdown-item" href="<?php echo TFISH_PREFERENCE_URL; ?>"><?php echo TFISH_PREFERENCES; ?></a>
                  <a class="dropdown-item" href="<?php echo TFISH_ADMIN_USER_URL; ?>"><?php echo TFISH_USERS; ?></a>
                  <?php endif; ?>
                  <a class="dropdown-item" href="<?php echo TFISH_PASSWORD_URL; ?>"><?php echo TFISH_PASSWORD; ?></a>
                  <a class="dropdown-item" href="<?php echo TFISH_URL . 'flush/'; ?>"><?php echo TFISH_FLUSH_CACHE; ?></a>
                  <a class="dropdown-item" href="<?php echo TFISH_URL . 'sitemap/'; ?>"><?php echo TFISH_UPDATE_SITEMAP; ?></a>
                </ul>
              </li>
              <?php endif; ?>
              <?php if ($session->isEditor()): ?><li class="nav-item">
                <a class="nav-link" href="<?php echo TFISH_URL . 'logout/'; ?>"><?php echo TFISH_LOGOUT; ?></a>
              </li>
              <?php else: ?>
              <li class="nav-item">
                <a class="nav-link" href="<?php echo TFISH_URL . 'login/'; ?>"><?php echo TFISH_LOGIN; ?></a>
              </li>
              <?php endif; ?>
              <li class="nav-item">
                <a class="nav-link" href="<?php echo TFISH_URL . 'gallery/'; ?>"><?php echo TFISH_IMAGE_GALLERY; ?></a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="<?php echo TFISH_RSS_URL; ?>"><i class="fas fa-rss"></i></a>
              </li>
            </ul>
            <form class="d-flex" method="post" accept-charset="UTF-8" action="<?php echo TFISH_URL . 'admin/search/'; ?>">
              <input class="form-control me-2" name="searchTerms" type="search" placeholder="<?php echo TFISH_KEYWORDS; ?>" aria-label="<?php echo TFISH_KEYWORDS; ?>">
              <input type="hidden" name="action" value="search" />
              <input type="hidden" name="searchType" value="AND" />
              <button class="btn btn-outline-success my-2 my-sm-0" type="submit"><?php echo TFISH_SEARCH; ?></button>
            </form>
          </div>
        </div>
      </nav>

    <main role="main">

      <div class="starter-template">

        <!-- Main page -->
        <?php if ($page ?? null): ?>
        <?php echo $page; ?>
        <?php endif; ?>

        <!-- Footer -->
        <div class="container">
          <div class="row">
            <div class="col">
              <hr>
              <footer class="clearfix">
                <p class="copyright">Copyright &copy; <?php echo xss($metadata->author) . ' ' . \date('Y'); ?> | <?php echo $session->getLoginLink(); ?></p>
              </footer>
            </div>
          </div>
        </div>

      </div>

    </main>

  </body>
</html>
