<?php
/** @var $this \Zend\View\Renderer\PhpRenderer */

/** @var $layoutInfo \App\Entity\LayoutInfo */
$layoutInfo = $this->layoutInfo;

/** @var \App\Entity\IdentityInterface $identity */
$identity = $this->identity();
$identityRole = $identity ? $identity->getRoleId() : null;

if (in_array($identityRole, [\App\Acl\Roles::ROLE_ADMIN]))
{
    $layoutInfo->setLang(\App\Model\Locales::DEFAULT_LANG_ADMIN);
}
$lang = $layoutInfo ? $layoutInfo->getLang() : 'en';

?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>AddCPM</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimal-ui">
    <meta name="theme-color" content="#FFFFFF">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="x-rim-auto-match" content="none">
    <!-- Favicon -->
    <link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png">
    <link rel="icon" type="image/png" href="/favicon/favicon-32x32.png" sizes="32x32">
    <link rel="icon" type="image/png" href="/favicon/favicon-16x16.png" sizes="16x16">
    <link rel="manifest" href="/favicon/manifest.json">
    <link rel="mask-icon" href="/favicon/safari-pinned-tab.svg" color="#5bbad5">
    <meta name="theme-color" content="#ffffff">
    <!-- Styles -->
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/css/gird-column.css">
    <link rel="stylesheet" type="text/css" href="/css/reset-min.css">
    <link rel="stylesheet" type="text/css" href="/css/common-styles.css">
    <link rel="stylesheet" type="text/css" href="/css/jquery.jgrowl.css">
    <link rel="stylesheet" type="text/css" href="/css/jquery.jgrowl.override.css">
    <!-- Scripts -->
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Detect.js/2.2.2/detect.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.1/jquery.validate.min.js"></script>
    <script type="text/javascript" src="/js/iOS-scroll.js"></script>
    <script type="text/javascript" src="/js/common.js"></script>
    <script type="text/javascript" src="/js/jquery.jgrowl.js"></script>
    <script type="text/javascript" src="/js/jquery.jgrowl.defaults.js"></script>
    <script type="text/javascript" src="/js/jquery.message.js"></script>
    <!-- custom page scripts & styles -->
    <?= $this->headLink() ?>
    <?= $this->headScript() ?>
    <?= $this->headStyle() ?>

</head>
<body>
<?php
$urlHome = $this->url(
    in_array($identityRole, [
            \App\Acl\Roles::ROLE_ADMIN,
            \App\Acl\Roles::ROLE_MANAGER]) ?
        'adm.index' :
        'home',
    ['lang' => $lang]);
?>
    
    
<div class="top-panel">
    <a href="<?= $urlHome ?>" title="<?= _t("Main") ?>" class="header-logo col sm-2"></a>
    <div class="button-menu">
        <p></p>
        <p></p>
        <p></p>
    </div>
</div>

<header class="l-header">
    <nav class="wrapp row xs-no-row row-center">
        <a href="<?= $urlHome ?>" title="<?= _t("Main") ?>" class="header-logo col sm-2 xs-1"></a>
        <ul class="header-nav col order-xs-3 sm-6 xs-5">
            <li><a href="<?= $this->url('home', ['lang' => $lang]) ?>" title="" class="text bold"><?= _t("Главная") ?></a></li>
            <li><a href="<?= $this->url('faq', ['lang' => $lang]) ?>" title="" class="text bold"><?= _t("Помощь") ?></a></li>
            <li><a href="<?= $this->url('contacts', ['lang' => $lang]) ?>" title="" class="text bold"><?= _t("Контакты") ?></a></li>
        </ul>
    <?php
    if ($identity ) :
    $gravatar = $this->gravatar($identity->getEmail());
    $gravatar->setDefaultImg(\Zend\View\Helper\Gravatar::DEFAULT_IDENTICON);
    $sxml = new SimpleXMLElement(substr($gravatar, 0, -1) . '/>');
    $src = $sxml['src'];
    ?>
        <!-- Вход произведен -->
        <div class="header-user col sm-3 order-xs-1">
            <picture>
                <img src="/img/bg-img-logo.svg" alt="No logo">
            </picture>
            
            
            <?php
            /*
            $urlCabinet = $this->url(
                in_array($identityRole, [
                        \App\Acl\Roles::ROLE_ADMIN,
                        \App\Acl\Roles::ROLE_MANAGER]) ?
                    'adm.index' :
                    'user.cabinet',
                ['lang' => $lang]);
            */
            $urlCabinet = $this->url('user.cabinet',['lang' => $lang]);
            ?>
            <a href="<?= $urlCabinet ?>" class="annotation" title="<?= _t("Мой кабинет") ?>"><?= $identity->getEmail() ?></a>
                
        </div>
    <?php else : /* ?>        
        <!-- Вход не был произведен -->
        <p class="header-register col sm-3 order-xs-4 xs-2">
            <a href="#" title="<?= _t("Вход") ?>" class="text bold login-button button-open"><?= _t("Вход") ?></a>                                
        </p>        
    <?php */ endif; ?>
    <?= $this->partial('app::partial/language', [
        'lang' => $lang,
        'locales' => $layoutInfo->getLocales(),
        'router' => $layoutInfo->getRouter(),
        'request' => $layoutInfo->getRequest()
    ]); ?>
    </nav>
</header>

<div class="l-popup">

<?php //= $this->partial('app::popup/login', ['lang' => $lang]) ?>
<?= $this->partial('app::popup/to-action', ['lang' => $lang]) ?>
<?= $this->partial('app::popup/connection', ['lang' => $lang]) ?>
<?= $this->partial('app::popup/password-reset', ['lang' => $lang]) ?>
<?= $this->partial('app::popup/confirm', ['lang' => $lang]) ?>

</div>

<main class="l-content">
    <!-- Main content   -->
<?= $this->content ?>

</main>

<footer class="l-footer">
    <div class="wrapp">
        <div class="b-footer__column row row-wrap">
            <div class="b-footer__column-note col order-xs-5 sm-2 xs-12">
                <p class="annotation"><?= _t("Помогаем избавиться от блокировщиков рекламы!") ?></p>
            </div>
            <div class="b-footer__column-item col order-xs-2 sm-2 xs-6">
                <p class="text bold"><?= _t("Помощь") ?></p>
                <ul>
                    <li><a href="<?= $this->url('faq', ['lang' => $lang]) ?>" title="" class="annotation"><?= _t("FAQ") ?></a></li>
                    <li><a href="<?= $this->url('contacts', ['lang' => $lang]) ?>" title="" class="annotation"><?= _t("Поддержка") ?></a></li>
                </ul>
            </div>
            <div class="b-footer__column-item col order-xs-3 sm-2 xs-6">
                
            </div>
            <div class="b-footer__column-item col order-xs-4 sm-2 xs-6">
                <p class="text bold"><?= _t("Контакты") ?></p>
                <ul>
                    <?php foreach ($layoutInfo->getPhones() as $phone) : ?>
                        <?php $phoneInfo = explode(' ', $phone) ?>
                        <li><a href="tel:<?= end($phoneInfo) ?>" title="" class="annotation"><?= $phone ?></a></li>
                    <?php endforeach; ?>
                </ul>
            </div>
            <div class="b-footer__column-item col order-xs-5 sm-2 xs-6">
                <p class="text bold">&nbsp;</p>
                <ul>
                    <?php foreach ($layoutInfo->getMails() as $mail) : ?>
                        <li><a href="mailto:<?= $mail ?>" title="" class="annotation"><?= $mail ?></a></li>
                    <?php endforeach; ?>
                    <?php foreach ($layoutInfo->getSkypes() as $skype) : ?>
                        <li><a href="skype:<?= $skype ?>" title="" class="annotation"><?= $skype ?></a></li>
                    <?php endforeach; ?>
                </ul>
            </div>
        </div>
    </div>
</footer>
</body>
<?php
echo $this->inlineScript();
?>
</html>
