<!DOCTYPE html>
<?php
/**
 * @var \League\Plates\Template\Template $this
 * @var \App\Auth $auth
 * @var \App\Acl $acl
 * @var \App\Http\Router $router
 * @var \App\Session\Flash $flash
 * @var \App\Customization $customization
 * @var \App\Assets $assets
 * @var array $app_settings
 */
?>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<?php
if ($title) {
    $page_title = ($customization->hideProductName()) ? $title : $title.' - '.$app_settings['name'];
} else {
    $page_title = ($customization->hideProductName()) ? '' : $app_settings['name'];
}

if (!APP_IN_PRODUCTION)
    $page_title = '('.ucfirst(APP_APPLICATION_ENV).') '.$page_title;
?>
<title><?=$page_title ?></title>

<?=$this->fetch('partials/icons') ?>

<?php
$assets
    ->load('minimal_header')
    ->load('minimal_body')
    ->load('theme_'.$customization->getPublicTheme())
    ->addInlineCss($customization->getCustomPublicCss())
    ->addInlineJs($customization->getCustomPublicJs());

echo $assets->css();
echo $assets->js();
?>
</head>

<body class="<?=$page_class ?>">
<?=$assets->inlineJs($request) ?>

<?=$this->section('content') ?>

<?php if (!$customization->hideProductName() && !$hide_footer): ?>
    <footer id="footer" class="footer-alt" role="contentinfo">
        <?=sprintf(__('Powered by %s'), '<a href="https://azuracast.com/" target="_blank">'.$app_settings['name'].'</a>'.' ') ?><br>
        <?=sprintf(__('Mascot designed by %s'), '<a href="https://tysontan.deviantart.com/" target="_blank">Tyson Tan</a>') ?>
    </footer>
<?php endif; ?>

<?php if ($flash->hasMessages()): ?>
    <script type="text/javascript" nonce="<?=$assets->getCspNonce() ?>">
        $(function() {
            <?php foreach($flash->getMessages() as $message): ?>
            notify("<?=str_replace(array('"', "\n"), array('\'', '<br>'), $message['text']) ?>", '<?=$message['color'] ?>', true);
            <?php endforeach; ?>
        });
    </script>
<?php endif; ?>
</body>
</html>
