<?php
$escape = $this->plugin('escapeHtml');
$this->htmlElement('html')->setAttribute('lang', 'en');
$this->headMeta()->setCharset('utf-8');
$this->headMeta()->appendName('viewport', 'width=device-width, initial-scale=1');
$this->headTitle($this->setting('installation_title', 'Omeka S'))->setSeparator(' · ');
$this->headLink()->prependStylesheet($this->assetUrl('css/style.css'));
$this->headLink()->prependStylesheet($this->assetUrl('css/iconfonts.css', 'Omeka'));
$this->headLink()->prependStylesheet('//fonts.googleapis.com/css?family=Open+Sans:400,400italic,600,600italic,700italic,700');
$this->headScript()->prependFile($this->assetUrl('js/default.js'));
$this->headScript()->prependFile($this->assetUrl('js/jquery.js', 'Omeka'));
$this->trigger('view.layout');
$title = $this->pageTitle($site->title());
$logo = $this->themeSettingAssetUrl('logo');
if ($logo):
    $title = '<img src="' . $this->escapeHtml($logo) . '">';
endif;
?>
<?php echo $this->doctype(); ?>
<?php echo $this->htmlElement('html'); ?>
    <head>
        <?php echo $this->headMeta(); ?>
        <?php echo $this->headTitle(); ?>
        <?php echo $this->headLink(); ?>
        <?php echo $this->headStyle(); ?>
        <?php echo $this->headScript(); ?>
    </head>

    <?php echo $this->htmlElement('body'); ?>
        <header>
            <?php if ($this->themeSetting('logo')): ?>
            <a href="<?php echo $site->url(); ?>" class="site-title"><img src="<?php echo $this->themeSettingAssetUrl('logo'); ?>" title="Logo"></a>
            <?php else: ?>
            <a href="<?php echo $site->url(); ?>" class="site-title"><?php echo $this->pageTitle($site->title()); ?></a>
            <?php endif; ?>
            <div id="search">
                <form action="<?php echo $this->escapeHtml($this->url('site/resource', ['controller' => 'item','action' => 'browse'], true)); ?>" id="search-form">
                    <?php $searchValue = isset($_GET['property'][0]['in'][0]) ? $_GET['property'][0]['in'][0] : ''; ?>
                    <input type="text" name="property[0][in][]" value="<?php echo $escape($searchValue); ?>" placeholder="<?php echo $this->translate('Search items'); ?>">
                    <button type="submit"><?php echo $this->translate('Search'); ?></button>
                </form>
            </div>

            <nav>
            <?php
            echo $site->publicNav()->menu()->renderMenu(null, [
                'maxDepth' => $this->themeSetting('nav_depth') - 1
            ]);
            ?>
            </nav>
        </header>
        <div id="content" role="main">
            <?php echo $this->content; ?>
        </div>
        <footer>
            <?php if ($footerContent = $this->themeSetting('footer')): ?>
            <?php echo $footerContent; ?>
            <?php else: ?>
                <?php echo $this->translate('Powered by Omeka S'); ?>
            <?php endif; ?>
        </footer>
    </body>
</html>
