<?php
/**
 * @version 7.9 [rev.7.9.03]
 */

/** @var \Cube\Controller\Request $request */
$request = $this->request()->getRequest();
$module = $request->getModule();
$controller = $request->getController();
$action = $request->getAction();

$indexPage = ($module == 'App' && $controller == 'Index' && $action == 'Index') ? true : false;
$browsePage = ($module == 'Listings' && $controller == 'Browse' && $action == 'Index') ? true : false;

$parentId = $request->getParam('parent_id');

$this->setGlobal('themeFolder', $this->baseUrl . '/' . $this->themesFolder . '/' . 'green');
$this->setGlobal('indexPage', $indexPage);
$this->setGlobal('browsePage', $browsePage);

?>
<!DOCTYPE html>

<html dir="<?php echo $htmlDir = $this->htmlDir(); ?>" lang="<?php echo $this->htmlLang(); ?>">
<head>
    <?php echo $this->headTitle(); ?>

    <?php
    $this->headMeta()
        ->appendName('viewport', 'width=device-width, initial-scale=1.0')
        ->appendHttpEquiv('X-UA-Compatible', 'IE=edge');
    echo $this->headMeta();

    /** add rtl bootstrap css if the case */
    if ($htmlDir == \Cube\View\Helper\HtmlDir::RTL) {
        $this->script()
            ->addHeaderCode('<link href="' . $this->baseUrl . '/css/bootstrap-rtl.min.css" rel="stylesheet" type="text/css">')
            ->addHeaderCode('<link href="' . $this->baseUrl . '/css/style.rtl.css" media="all" rel="stylesheet" type="text/css">');
    }

    $this->script()->addHeaderCode('<link href="' . $this->themeFolder . '/css/style.css" media="all" rel="stylesheet" type="text/css">')
        ->addHeaderCode('<link href="' . $this->themeFolder . '/css/navigation.css" media="all" rel="stylesheet" type="text/css">')
        ->addHeaderCode('<link href="' . $this->themeFolder . '/css/responsive.css" media="all" rel="stylesheet" type="text/css">');
    ?>

    <?php echo $this->script()->displayHeaderCode(); ?>
</head>
<body>

<header>
    <!-- desktop & mobile headers -->
    <?php
    $container = $this->navigation()->getInitialContainer()->findOneBy('id', 'header');

    // desktop header partial
    echo $this->navigation()
        ->setContainer($container)
        ->setPartial('navigation/desktop.phtml')
        ->menu();

    // mobile header partial
    echo $this->navigation()
        ->setPartial('navigation/mobile.phtml')
        ->menu();
    ?>
</header>


<!--container fluid -->
<div id="wrapper">

    <div class="container">
        <!-- layout content -->
        <?php if ($this->isMembersModule === true) { ?>
            <?php echo $this->render('_members.phtml'); ?>
            <?php
        }
        else {
            ?>
            <?php echo $this->render('_heading.phtml'); ?>
            <?php echo $this->getContent(); ?>
        <?php } ?>

        <div class="clearfix"></div>

        <?php
        if ($this->settings['enable_recently_viewed_listings']) {
            echo $this->action('recently-viewed', 'browse', 'listings');
        }
        ?>
    </div>
    <!-- end container fluid -->
</div>

<footer>
    <div class="container">


        <!-- footer adverts -->
        <?php
        $advert = $this->advert()->findBySection('footer', false, array($parentId));

        if ($advert !== null) {
            ?>
            <p class="text-center">
                <?php echo $this->advert($advert)->display(); ?>
            </p>
        <?php } ?>

        <div class="col-sm-5 col-xs-12">
            <div>
                Powered by <a href="http://www.phpprobid.com/" target="_blank">PHP Pro Bid</a>.
                &copy;<?php echo date('Y'); ?> Online Ventures Software
            </div>
            <?php if ($this->settings['enable_social_network_links']) { ?>
                <div class="social">
                    <?php echo $this->social()->clearListing()->display(); ?>
                </div>
            <?php } ?>
        </div>

        <div class="col-sm-7 col-xs-12">
            <?php
            $contentSectionsService = $this->contentSections()->getContentSections();
            $contentSections = $this->contentSections(
                $contentSectionsService->getTable()
                    ->select()
                    ->where('parent_id IS NULL')
                    ->order('order_id ASC')
            );
            ?>
            <!-- these links are only temporary - will alter all of this while in beta -->

            <ul class="links">
                <?php
                /** @var \Ppb\Db\Table\Row\ContentSection $section */
                foreach ($contentSections as $section) {
                    ?>
                    <li>
                        &nbsp;
                        <a href="<?php echo $this->url($section->link()); ?>">
                            <?php echo $this->_($section['name']); ?>
                        </a>
                    </li>
                <?php } ?>
            </ul>


            <?php if ($this->settings['newsletter_subscription_box']) { ?>
                <div class="box-newsletter-subscription text-right hidden-xs">
                    <?php echo $this->partial('partials/newsletter-subscription.phtml'); ?>
                </div>
            <?php } ?>
        </div>
    </div>
</footer>

<div class="loading-modal"></div>

<!-- cookie usage confirmation helper -->
<?php echo $this->cookieUsage(); ?>

<!-- Scroll to Top -->
<a class="scroll-top" style="display: none; ">&#8679;</a>

<?php
$this->script()->addBodyCode('<script src="' . $this->themeFolder . '/js/all.js" type="text/javascript"></script>');
?>

<!-- client side scripts [loaded in bootstrap] -->
<?php echo $this->script()->displayBodyCode(); ?>

</body>
</html>
