<?php
$logo = StockieSettings::get_logo(false);
switch (StockieSettings::get('fullscreen_menu_style', 'global')) {
    case 'centered':
        $logo = StockieSettings::get_logo(true);
        break;
    case 'split':
        $logo = StockieSettings::get_logo(true);
        break;
}
$logo_as_image = is_array($logo);
$have_wpml = function_exists('icl_get_languages');

$menu_class = '';
switch (StockieSettings::get('fullscreen_menu_style', 'global')) {
    case 'centered':
        $menu_class .= ' centered';
        break;
    case 'split':
        $menu_class .= ' split';
        break;
}
$header_have_social = have_rows('global_header_menu_social_links', 'option');
?>

<div class="fullscreen-nav<?php echo esc_attr($menu_class); ?>" id="fullscreen-mega-menu">
    <div class="close close-bar" id="fullscreen-menu-close">
        <div class="close-bar-btn btn-round round-animation" tabindex="0">
            <i class="ion ion-md-close"></i>
        </div>
    </div>

    <!-- Nav -->
    <div class="fullscreen-nav-wrap">
        <div id="fullscreen-mega-menu-wrap">
            <?php
            if (StockieSettings::get('hamburger_menu', 'global')) {
                wp_nav_menu(array('menu' => StockieSettings::get('hamburger_menu' , 'global'), 'menu_id' => 'secondary-menu'));
            } else {
            if ( has_nav_menu( 'primary' ) ) {
                wp_nav_menu( array( 'theme_location' => 'primary', 'menu_id' => 'secondary-menu' ) );
            } else {
                    echo '<span class="menu-not-assigned">' . sprintf(esc_html__('Please, %1$sassign a menu%2$s', 'stockie'), '<a target="_blank" href="' . esc_url(home_url('/')) . 'wp-admin/nav-menus.php">', '</a>') . '</span>';
                }
            }
            ?>
        </div>
    </div>

    <!-- Nav -->
    <div class="copyright">
        <!-- Language dropdown -->
        <?php
        if ($have_wpml) {
            $languages = icl_get_languages('skip_missing=1');
            if (!empty($languages)) : ?>
                <div class="select-small">
                    <div class="select select-top select-dropdown">
                        <div class="select-styled">
                            <?php
                            // $languages = icl_get_languages('skip_missing=1');
                            $curr_lang = array();
                            if (!empty($languages)) {
                                foreach ($languages as $language) {
                                    if (!empty($language['active'])) {
                                        $curr_lang = $language; // This will contain current language info.
                                        break;
                                    }
                                }
                                echo '<img src="' . $curr_lang['country_flag_url'] . '" alt="' . $curr_lang['code'] . '" class="icon">';
                                echo esc_html($curr_lang['translated_name']);
                            }
                            ?>
                        </div>
                        <ul class="select-options">
                            <?php
                            $languages = icl_get_languages('orderby=name');
                            foreach ($languages as $language) {
                                $class = ($language['active']) ? ' class="active"' : '';
                                printf('<li%s><a href="%s"><img src="%s" alt="%s">%s</a></li>', $class, $language['url'],
                                    $language['country_flag_url'], $language['code'], $language['native_name']);
                            }
                            ?>
                        </ul>
                    </div>
                </div>
            <?php endif; ?>
        <?php } ?>

        <div class="content">
            <?php echo wp_kses(StockieSettings::get('footer_copyright_left', 'global'), 'post'); ?>
            <br>
            <?php echo wp_kses(StockieSettings::get('footer_copyright_right', 'global'), 'post'); ?>
        </div>

        <?php if ($header_have_social) : ?>
            <div class="socialbar small">
                <?php while (have_rows('global_header_menu_social_links', 'option')): the_row(); ?>
                    <?php switch (get_sub_field('social_network')) {
                        case 'facebook':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="facebook"><i class="icon fa fa-facebook"></i></a>';
                            break;
                        case 'twitter':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="twitter"><i class="icon fa fa-twitter"></i></a>';
                            break;
                        case 'googleplus':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="googleplus"><i class="icon fa fa-google-plus"></i></a>';
                            break;
                        case 'instagram':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="instagram"><i class="icon fa fa-instagram"></i></a>';
                            break;
                        case 'dribbble':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="dribbble"><i class="icon fa fa-dribbble"></i></a>';
                            break;
                        case 'github':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="github"><i class="icon fa fa-github-alt"></i></a>';
                            break;
                        case 'linkedin':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="linkedin"><i class="icon fa fa-linkedin"></i></a>';
                            break;
                        case 'vimeo':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="vimeo"><i class="icon fa fa-vimeo"></i></a>';
                            break;
                        case 'youtube':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="youtube"><i class="icon fa fa-youtube"></i></a>';
                            break;
                        case 'vk':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="vk"><i class="icon fa fa-vk"></i></a>';
                            break;
                        case 'behance':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="behance"><i class="icon fa fa-behance"></i></a>';
                            break;
                        case 'flickr':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="flickr"><i class="icon fa fa-flickr"></i></a>';
                            break;
                        case 'reddit':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="reddit"><i class="icon fa fa-reddit-alien"></i></a>';
                            break;
                        case 'snapchat':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="snapchat"><i class="icon fa fa-snapchat"></i></a>';
                            break;
                        case 'whatsapp':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="whatsapp"><i class="icon fa fa-whatsapp"></i></a>';
                            break;
                        case 'quora':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="quora"><i class="icon fa fa-quora"></i></a>';
                            break;
                        case 'vine':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="vine"><i class="icon fa fa-vine"></i></a>';
                            break;
                        case 'periscope':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="periscope"><i class="icon fa fa-periscope"></i></a>';
                            break;
                        case 'digg':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="digg"><i class="icon fa fa-digg"></i></a>';
                            break;
                        case 'viber':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="viber"><i class="icon fa fa-viber"></i></a>';
                            break;
                        case 'foursqure':
                            echo '<a href="' . esc_url(get_sub_field('url')) . '" class="foursquare"><i class="icon fa fa-foursquare"></i></a>';
                            break;
                    } ?>
                <?php endwhile; ?>
            </div>
        <?php endif; ?>
    </div>
</div>
