<?php
    use Orchard\Service\SegmentAnalyticsTracking;

    $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
    $action = Zend_Controller_Front::getInstance()->getRequest()->getActionName();
    $loadImage = new Alw_View_Helper_Loadingimage();
    $faviconImagePath = $loadImage->getCdnImagePath('images/icons/favicon.ico');
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta charset="utf-8">
    <link rel="shortcut icon" href="<? echo $faviconImagePath ?>" type="image/x-icon">
    <link rel="preconnect" href="https://api.segment.io">
    <link rel="preconnect" href="https://bam.nr-data.net">
    <link rel="preconnect" href="https://js-agent.newrelic.com">
    <link rel="preconnect" href="https://www.google-analytics.com">
    <link rel="preconnect" href="https://cdn.ravenjs.com">
    <link rel="preconnect" href="https://cdn.mouseflow.com">
    <link rel="preconnect" href="https://n2.mouseflow.com">
    <link rel="preconnect" href="https://images.theorchard.com">
    <link href="https://fonts.googleapis.com/css?family=Rubik:400,500" rel="stylesheet" type="text/css" >
    <link rel="preload" href="<?php echo $this->frontendWorkstationJsUrl ?>" as="script">
    <link rel="preload" href="<?php echo $this->frontendWorkstationCssUrl ?>" as="style">
<?php
    echo $this->headLink() . "\n";
    echo $this->headTitle() . "\n";
    echo $this->partial('partials/auth0-session-keepalive.phtml', [
        'configs' => yaml_parse_file(APPLICATION_PATH . '/configs/auth0.yml')
    ]);
?>
<?php
    if ($this->isIntercomChatWidgetEnabled)
        echo $this->partial('partials/intercom_chat_widget.phtml');
?>
</head>
<body id="mainBody" class="<?php echo $controller . '-' . $action ?>">
<?php
    echo $this->partial('partials/subaccount_impersonation_banner.phtml', ['session', $_SESSION]);
?>
<noscript><?=$this->translate->_('Javascript appears to be turned off. In order to use this page, you must have it turned on.');?></noscript>

    <div class="container fix-width-grid">
        <div class="row">
            <div class="main-content">
                <?= $this->layout()->content ?>
                <div class="clear"></div>
            </div>
        </div>
    </div>
    <?php
        echo $this->partial('partials/segment-analytics.phtml', array(
            'configs' => SegmentAnalyticsTracking::getTraitsFromSession($_SESSION, 'workstation')
        ));

        if (!empty($this->bottom_scripts) && is_array($this->bottom_scripts)) {
            echo "
                <script>
                    var bottomScripts = " . json_encode($this->bottom_scripts) . ";

                    function addBottomScript(bottomScript) {
                        var element = document.createElement('script');
                        element.src = bottomScript.src;
                        document.body.appendChild(element);
                    }

                    window.addEventListener('load', function() {
                        bottomScripts.forEach(addBottomScript);
                    }, false);
                </script>
            ";
        }
    ?>
</body>
</html>
