<?php

/*!
     * ifsoft.co.uk v1.1
     *
     * http://ifsoft.com.ua, http://ifsoft.co.uk
     * qascript@mail.ru
     *
     * Copyright 2012-2017 Demyanchuk Dmitry (https://vk.com/dmitry.demyanchuk)
     */


    if (auth::isSession()) {

        $msg = new messages($dbo);
        $msg->setRequestFrom(auth::getCurrentUserId());

        $new_messages = $msg->getNewMessagesCount();

        unset($msg);

        $profile_top_bar = new profile($dbo, auth::getCurrentUserId());

        $topbar_notifications = new notify($dbo);
        $topbar_notifications->setRequestFrom(auth::getCurrentUserId());

        $notifications_count = $topbar_notifications->getNewCount($profile_top_bar->getLastNotifyView());

        unset($profile_top_bar);
        unset($topbar_notifications);

        ?>

        <header class="nav-header">

            <div class="wrap">

                <div class="l-sidebar">

                  <span class="navigation-toggle-outer">
                    <span class="navigation-toggle">
                      <span class="navigation-toggle-inner"></span>
                    </span>
                  </span>

                    <a class="nav-logo" href="/">
                        <h1><?php echo APP_TITLE; ?></h1>
                    </a>

                    <nav class="main-nav">
                        <ul>
                            <li class=""><a href="/account/wall"><?php echo $LANG['nav-home']; ?></a></li>
                            <li class=""><a href="/<?php echo auth::getCurrentUserLogin(); ?>"><?php echo $LANG['nav-profile']; ?></a></li>
                            <li class=""><a href="/<?php echo auth::getCurrentUserLogin(); ?>/friends"><?php echo $LANG['nav-friends']; ?></a></li>
                            <li class=""><a href="/account/groups"><?php echo $LANG['nav-communities']; ?></a></li>
                            <li class=""><a href="/account/messages"><?php echo $LANG['nav-messages']; ?> <span id="messages_counter_cont" <?php if ($new_messages == 0) echo "style=\"display: none\""; ?>>(<span id="messages_counter"><?php echo $new_messages; ?></span>)</span></a></li>
                            <li class=""><a href="/account/notifications"><?php echo $LANG['nav-notifications']; ?> <span <?php if ($notifications_count < 1) echo "style=\"display: none\""; ?> id="notifications_counter_cont">(<span id="notifications_counter"><?php echo $notifications_count; ?></span>)</span></a></li>
                            <li class=""><a href="/search/name"><?php echo $LANG['nav-search']; ?></a></li>
                            <li class=""><a href="/account/settings/profile"><?php echo $LANG['nav-settings']; ?></a></li>
                            <li class=""><a href="/logout/?access_token=<?php echo auth::getAccessToken(); ?>&continue=/"><?php echo $LANG['nav-logout']; ?></a></li>
                        </ul>
                    </nav>

                </div>

            </div>

        </header>

        <nav class="sub-nav gone">
            <div class="wrap">
                <ul class="sub-navigation-list">
                    <li class=""><a href="/<?php echo auth::getCurrentUserLogin(); ?>"><?php echo $LANG['nav-profile']; ?></a></li>
                    <li class=""><a href="/account/friends"><?php echo $LANG['nav-friends']; ?></a></li>
                    <li class=""><a href="/account/groups"><?php echo $LANG['nav-communities']; ?></a></li>
                    <li class=""><a href="/account/messages"><?php echo $LANG['nav-messages']; ?> <span id="messages_counter_cont" <?php if ($new_messages == 0) echo "style=\"display: none\""; ?>>(<span id="messages_counter"><?php echo $new_messages; ?></span>)</span></a></li>
                    <li class=""><a href="/account/notifications"><?php echo $LANG['nav-notifications']; ?> <span <?php if ($notifications_count < 1) echo "style=\"display: none\""; ?> id="notifications_counter_cont">(<span id="notifications_counter"><?php echo $notifications_count; ?></span>)</span></a></li>
                    <li class=""><a href="/search/name"><?php echo $LANG['nav-search']; ?></a></li>
                    <li class=""><a href="/account/settings/profile"><?php echo $LANG['nav-settings']; ?></a></li>
                    <li class=""><a href="/logout/?access_token=<?php echo auth::getAccessToken(); ?>&continue=/"><?php echo $LANG['topbar-logout']; ?></a></li>
                </ul>
            </div>
        </nav>

        <div class="header-message gone">
            <div class="wrap">
                <p class="message">You message here :)</p>
            </div>

            <button class="close-message-button">×</button>
        </div>

        <?php

    } else {

        ?>

        <header class="nav-header">

            <div class="wrap">

                <div class="l-sidebar">

                  <span class="navigation-toggle-outer">
                    <span class="navigation-toggle">
                      <span class="navigation-toggle-inner"></span>
                    </span>
                  </span>

                    <a class="nav-logo" href="/">
                        <h1><?php echo APP_TITLE; ?></h1>
                    </a>

                    <nav class="main-nav">
                        <ul>
                            <li class=""><a href="/signup"><?php echo $LANG['topbar-signup']; ?></a></li>
                            <li class=""><a href="/login"><?php echo $LANG['topbar-signin']; ?></a></li>
                        </ul>
                    </nav>

                </div>

            </div>

        </header>

        <nav class="sub-nav gone">
            <div class="wrap">
                <ul class="sub-navigation-list">
                    <li class=""><a href="/signup"><?php echo $LANG['topbar-signup']; ?></a></li>
                    <li class=""><a href="/login"><?php echo $LANG['topbar-signin']; ?></a></li>
                </ul>
            </div>
        </nav>

        <?php
    }
?>