<?php declare(strict_types=1); ?>

<!doctype html>
<html lang="<?php echo $tfPreference->escapeForXss('defaultLanguage'); ?>">
  <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 $tfMetadata->description; ?>">
    <meta name="author" content="<?php echo $tfMetadata->author; ?>">
    <meta name="dcterms.rights" content="<?php echo $tfMetadata->copyright; ?>">
    <meta name="robots" content="<?php echo $tfMetadata->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/">
    
    <!-- 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 $tfMetadata->title; ?></title>
    
    <!-- jQuery -->
    <script src="<?php echo TFISH_JS_URL . 'jquery/jquery.min.js'; ?>"></script>
    
    <!-- Popper -->
    <script src="<?php echo TFISH_JS_URL . 'popper/popper.min.js'; ?>"></script>
    
    <!-- Bootstrap -->
    <link href="<?php echo TFISH_JS_URL . 'bootstrap/css/bootstrap.min.css'; ?>" rel="stylesheet">
    <script src="<?php echo TFISH_JS_URL . 'bootstrap/js/bootstrap.min.js'; ?>"></script>
    
    <!-- Font Awesome -->
    <script defer src="<?php echo TFISH_JS_URL . 'fontawesome/fontawesome-all.min.js'; ?>"></script>

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

  <body>

    <!-- Navigation -->
    <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
      <a class="navbar-brand" href="<?php echo TFISH_URL; ?>"><?php echo $tfPreference->escapeForXss('siteName'); ?></a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarsExampleDefault">
        <ul class="navbar-nav mr-auto">
          <?php if (TfSession::isAdmin()): ?>
          <li class="nav-item dropdown active"><a class="nav-link"  href="<?php echo TFISH_ADMIN_URL . 'admin.php'; ?>"><?php echo TFISH_ADMIN; ?></a></li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" id="settings" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php echo TFISH_SETTINGS; ?></a>
            <div class="dropdown-menu" aria-labelledby="settings">
              <a class="dropdown-item" href="<?php echo TFISH_ADMIN_URL . 'preference.php'; ?>"><?php echo TFISH_PREFERENCES; ?></a>
              <a class="dropdown-item" href="<?php echo TFISH_ADMIN_URL . 'password.php'; ?>"><?php echo TFISH_PASSWORD; ?></a>
              <a class="dropdown-item" href="<?php echo TFISH_ADMIN_URL . 'admin.php?op=flush'; ?>"><?php echo TFISH_FLUSH_CACHE; ?></a>
            </div>
          </li>
          <li class="nav-item"><a class="nav-link" href="<?php echo TFISH_ADMIN_URL . 'gallery.php'; ?>"><?php echo TFISH_IMAGE_GALLERY; ?></a></li>
          <li class="nav-item"><a class="nav-link"  href="<?php echo TFISH_ADMIN_URL . 'login.php?op=logout'; ?>"><?php echo TFISH_LOGOUT; ?></a></li>            
          <?php endif; ?>
        </ul>
          <form class="form-inline my-2 my-lg-0" method="post" accept-charset="UTF-8" action="<?php echo TFISH_URL . 'search.php'; ?>">
              <input class="form-control mr-sm-2" id="searchTerms" name="searchTerms" type="text" placeholder="<?php echo TFISH_KEYWORDS; ?>" aria-label="<?php echo TFISH_KEYWORDS; ?>">
              <input type="hidden" name="op" 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>
    </nav>

    <main role="main" class="container">

      <div class="starter-template">

        <!-- Main page -->
        <?php echo $tfTemplate->render('main'); ?>
        
        <!-- Footer -->
        <div class="row">
          <div class="col">
            <hr>
            <footer class="clearfix">
              <p class="copyright">Copyright &copy; <?php echo $tfPreference->escapeForXss('siteAuthor'); ?> 2018 | <?php echo TfSession::getLoginLink(); ?></p>
            </footer>
          </div>
        </div>
        
      </div>

    </main><!-- /.container -->
    
  </body>
</html>
