<?php
// Set doctype explicitly if it is not `HTML4_LOOSE`, i.e. 'HTML 4.01 Transitional'
$this->doctype('HTML5');

// Load translation data
$this->i18nTheme();

//HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries
$this->js([
    pi::url('static/js/html5shiv.js')   => [
        'conditional' => 'lt IE 9',
    ],
    pi::url('static/js/respond.min.js') => [
        'conditional' => 'lt IE 9',
    ],
]);

// Load jQuery
$this->jquery();

// Load Bootstrap css/js and font-awesome
$this->bootstrap([
    'js/bootstrap.bundle.js',
    'font-awesome/css/all.min.css',
]);

// Load front.css
$this->css($this->assetTheme('css/front.css'));

// Load localization css
$this->css($this->assetLocale('locale.css'));

// Apple icons
// Apple icon for iphone
$this->headLink([
    'rel'  => 'apple-touch-icon',
    'href' => $this->assetTheme('image/touch-icon-iphone.png'),
]);
// Apple icon for ipad
$this->headLink([
    'rel'   => 'apple-touch-icon',
    'sizes' => '72x72',
    'href'  => $this->assetTheme('image/touch-icon-ipad.png'),
]);
// Apple icon for iphone retina
$this->headLink([
    'rel'   => 'apple-touch-icon',
    'sizes' => '114x114',
    'href'  => $this->assetTheme('image/touch-icon-iphone-retina.png'),
]);
// Apple icon for ipad retina
$this->headLink([
    'rel'   => 'apple-touch-icon',
    'sizes' => '114x114',
    'href'  => $this->assetTheme('image/touch-icon-ipad-retina.png'),
]);

// Meta Viewport Tag
$this->headMeta('width=device-width, initial-scale=1', 'viewport');

// Explicitly load favicon
$this->headLink([
    'rel'  => 'shortcut icon',
    'type' => 'image/x-icon',
    'href' => $this->favicon(),
]);
$this->headLink([
    'rel'  => 'shortcut icon',
    'type' => 'image/png',
    'href' => $this->favicon('favicon.png'),
]);

// Load google analytics code
$this->ga();

// Get module name
$module = Pi::service('module')->current();

?>
<!DOCTYPE HTML>
<html lang="<?php echo $locale ?>">
<head>
    <meta charset="<?php echo $charset; ?>">
</head>
<body id="pi-<?php echo $module; ?>" class="pi-locale-<?php echo $locale; ?> pi-layout-simple">
<!-- Header: brand, slogan, user bar -->
<header class="pi-header">
    <nav class="navbar navbar-expand-md navbar-dark bg-dark">
            <h1 class="navbar-brand m-0">
                <a class="navbar-brand" href="<?php echo $this->url('home'); ?>">
                    <i class="fas fa-leaf"></i>
                    <strong>Pi</strong>
                </a>
            </h1>

        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbar-collapse" aria-expanded="false" aria-label="<?php echo _escape($sitename); ?>">
            <i class="fas fa-bars"></i>
        </button>
        <div class="collapse navbar-collapse justify-content-end">
            <?php echo $this->widget('system-user-bar', ['type' => 'js']); ?>
        </div>
    </nav>
</header>
<!-- Page main content: flash-messenger,and module content -->
<section class="container-fluid pi-main-container">
    <!-- Flash messenger -->
    <?php include $this->template('flash-messenger'); ?>
    <!-- Module content starts -->
    <?php if (!empty($content)) { ?>
        <div class="<?php echo $module; ?>">
            <div class="pi-module-content" data-ng-app="<?php echo $module; ?>">
                <?php echo $content; ?>
            </div>
        </div>
    <?php } ?>
    <!-- Module content ends -->
</section>
<!-- Footer: sitelink -->
<footer class="pi-footer text-center">
    <div class="container-fluid">
        <?php
        $footer = Pi::config('footer');
        if ($footer) {
            echo $footer;
        } else {
            ?>
            <ul class="pi-footer-links muted list-inline">
                <li class="list-inline-item">
                    <a href="<?php echo Pi::url('www'); ?>" title="<?php echo _escape($sitename); ?>">
                        &copy; <?php echo date('Y') . ' ' . _escape($sitename); ?>
                    </a>
                </li>
                <li class="list-inline-item">-</li>
                <li class="list-inline-item">
                    <a rel="license" href="http://www.piengine.org" title="Pi Engine" target="_blank">
                        Powered by Pi Engine
                    </a>
                </li>
            </ul>
        <?php } ?>
    </div>
</footer>
</body>
</html>