<?php

use Icinga\Util\Translator;

if (array_key_exists('_dev', $_GET)) {
  $jsfile  = 'js/icinga.dev.js';
  $cssfile = 'css/icinga.css';
} else {
  $jsfile  = 'js/icinga.min.js';
  $cssfile = 'css/icinga.min.css';
}

$ie8jsfile  = 'js/icinga.ie8.js';
$lang = Translator::splitLocaleCode()->language;
$isIframe = $this->layout()->isIframe;
$showFullscreen = $this->layout()->showFullscreen;
$iframeClass = $isIframe ? ' iframe' : '';
$innerLayoutScript = $this->layout()->innerLayout . '.phtml';

?><!DOCTYPE html>
<!--[if IE 8]>
<html class="no-js ie8<?= $iframeClass ?>" lang="<?= $lang ?>"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js<?= $iframeClass ?>" lang="<?= $lang ?>"> <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta name="google" value="notranslate">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta http-equiv="cleartype" content="on">
  <title><?= $this->title ? $this->escape($this->title) : 'Icinga Web' ?></title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="application-name" content="Icinga Web 2">
  <meta name="apple-mobile-web-app-title" content="Icinga">
<?php if ($isIframe): ?>
  <base target="_parent"/>
<?php else: ?>
  <script type="text/javascript">
  (function() {
    var html = document.getElementsByTagName('html')[0];
    html.className = html.className.replace(/no-js/, 'js');
  }());
  </script>
<?php endif ?>
  <link rel="stylesheet" href="<?= $this->href($cssfile) ?>" media="all" type="text/css" />
  <!-- Respond.js IE8 support of media queries -->
  <!--[if lt IE 9]>
  <script src="<?= $this->baseUrl('js/vendor/respond.min.js');?>"></script>
  <![endif]-->
  <link type="image/png" rel="shortcut icon" href="<?= $this->baseUrl('img/favicon.png') ?>" />
  <link rel="apple-touch-icon" href="<?= $this->baseUrl('img/touch-icon.png') ?>">
</head>
<body id="body" class="loading">
<pre id="responsive-debug"></pre>
<div id="layout" class="default-layout<?php if ($showFullscreen): ?> fullscreen-layout<?php endif ?>">
<?= $this->render($innerLayoutScript); ?>
</div>
<iframe id="fileupload-frame-target" name="fileupload-frame-target"></iframe>
<!--[if IE 8]>
<script type="text/javascript" src="<?= $this->href($ie8jsfile) ?>"></script>
<![endif]-->
<!--[if gt IE 8]><!-->
<script type="text/javascript" src="<?= $this->href($jsfile) ?>"></script>
<!--<![endif]-->
<script type="text/javascript">
var icinga = new Icinga({
  baseUrl: '<?= $this->baseUrl(); ?>'
});
</script>
</body>
</html>
