<?php
/**
 * @version 7.10 [rev.7.10.01]
 */
?>
<div id="mobile-navigation" class="visible-xs">
    <nav class="main-nav navbar navbar-default navbar-fixed-top">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <!-- header menu button -->
            <button type="button" class="navbar-toggle menu-button collapsed" data-toggle="collapse"
                    data-target="#navbar-collapse">
                <i class="fa fa-bars"></i>
            </button>

            <!-- members menu button -->
            <button type="button" class="navbar-toggle user-button collapsed" data-toggle="collapse"
                    data-target="#user-menu-collapse">
                <i class="fa fa-user"></i>
            </button>

            <!-- cart button (no dropdown) -->
            <?php if ($this->settings['enable_shopping_cart']) { ?>
                <a href="<?php echo $this->url('cart'); ?>" class="navbar-toggle cart-button">
                    <i class="fa fa-shopping-cart"></i>
                </a>
            <?php } ?>

            <a href="<?php echo $this->url(null, 'app-home'); ?>"
               title="<?php echo $this->settings['sitename']; ?>">
                <img src="<?php echo $this->thumbnail()->generateImagePath($this->settings['site_logo_path']); ?>"
                     alt="<?php echo $this->settings['sitename']; ?>"
                     class="brand-img img-responsive">
            </a>
        </div>

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

        <!-- search menu dropdown -->
        <div class="mobile-search">
            <div class="row">
                <div class="col-xs-10">
                    <form class="form-inline form-header" action="<?php echo $this->url(null, 'listings-search'); ?>"
                          method="get">
                        <div class="form-group has-feedback">
                            <input id="basic-search" type="text" name="keywords" class="form-control"
                                   value="<?php echo $this->request()->getRequest()->getParam('keywords'); ?>"
                                   placeholder="<?php echo $this->_('Search...'); ?>">
                            <span class="glyphicon glyphicon-search btn-icon-search form-control-feedback"></span>
                        </div>
                    </form>
                </div>
                <div class="col-xs-2">
                    <?php if ($this->settings['user_languages']) { ?>
                        <?php echo $this->language(); ?>
                    <?php } ?>
                </div>
            </div>
        </div>

        <!-- header menu dropdown -->
        <div class="collapse navbar-collapse" id="navbar-collapse">
            <ul class="nav navbar-nav">
                <?php foreach ($this->menu->pages as $page) { ?>
                    <?php if ((!$page->settings || (intval($this->settings[(string)$page->settings['name']]) == $page->settings['value'])) &&
                        ($this->navigation()->accept($page)) && $page->hidden != 'true'
                    ) {
                        ?>
                        <li <?php echo ($page->isActive(true)) ? 'class="active"' : ''; ?>>
                            <a href="<?php echo $this->url($page->params); ?>">
                                <?php echo $page->label; ?>
                            </a>
                        </li>
                    <?php } ?>
                <?php } ?>
            </ul>
        </div>

        <!-- members menu dropdown -->
        <div class="collapse navbar-collapse" id="user-menu-collapse">
            <div>
                <small>
                    <?php echo $this->_('Welcome'); ?>,
                    <strong>
                        <?php echo (isset($this->loggedInUser['username'])) ?
                            $this->loggedInUser['username'] : $this->_('Guest'); ?>
                    </strong>
                </small>
            </div>

            <ul class="nav navbar-nav">
                <?php if (count($this->loggedInUser) > 0) { ?>
                    <li>
                        <a href="<?php echo $this->url(null,
                            'members-index'); ?>"><?php echo $this->_('Members Area'); ?></a>
                    </li>
                    <li>
                        <a href="<?php echo $this->url(null, 'members-logout'); ?>"><?php echo $this->_('Logout'); ?></a>
                    </li>
                    <?php
                }
                else {
                    $registerModal = ($this->settings['registration_type'] == 'quick' && !\Ppb\Form\Element\ReCaptcha::$loaded) ? true : false;
                    ?>
                    <li>
                        <a <?php echo ($registerModal) ? 'class="dialog-box"' : ''; ?>
                                href="<?php echo $this->url(array('module' => 'members', 'controller' => 'user', 'action' => ($registerModal) ? 'register-modal' : 'register')); ?>"
                                title="<?php echo $this->_('Sign up'); ?>"><?php echo $this->_('Sign up'); ?></a>
                    </li>
                    <li>
                        <a class="dialog-box"
                           href="<?php echo $this->url(array('module' => 'members', 'controller' => 'user', 'action' => 'login-modal')); ?>"
                           title="<?php echo $this->_('Sign in'); ?>"><?php echo $this->_('Sign in'); ?></a>
                    </li>
                <?php } ?>
                <li>
                    <a href="<?php echo $this->url(array('module' => 'members', 'controller' => 'tools', 'action' => 'watched-items')); ?>"
                       title="<?php echo $this->_('Wishlist'); ?>"><?php echo $this->_('Wishlist'); ?></a>
                </li>
            </ul>
        </div>

        <!-- /.navbar-collapse -->
    </nav>
</div>

