<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/**
 * Language switcher template
 */
?>
<?php
    $_helper = $this->helper('Smartwave\Porto\Helper\Data');
    $is_demo = 0;
?>
<?php if (count($block->getStores())>1 || $is_demo == 1): ?>
<?php $id = $block->getIdModifier() ? '-' . $block->getIdModifier() : ''?>
<div class="switcher language switcher-language" data-ui-id="language-switcher" id="switcher-language<?php /* @escapeNotVerified */ echo $id?>">
    <strong class="label switcher-label"><span><?php /* @escapeNotVerified */ echo __('Language') ?></span></strong>
    <div class="actions dropdown options switcher-options">
        <div class="action toggle switcher-trigger" id="switcher-language-trigger<?php /* @escapeNotVerified */ echo $id?>">
            <strong class="view-<?php echo $block->escapeHtml($block->getCurrentStoreCode()) ?>">
                <?php if($_helper->getConfig('porto_settings/header/language_flag')): ?>
                    <img src="<?php echo $_helper->getBaseUrl().'wysiwyg/smartwave/porto/flags/'.$block->escapeHtml($block->escapeHtml($block->getCurrentStoreCode())).'.png'; ?>" alt="" />
                <?php endif; ?>
                <span><?php echo $block->escapeHtml($block->getStoreName()) ?></span>
            </strong>
        </div>
        <ul class="dropdown switcher-dropdown"
            data-mage-init='{"dropdownDialog":{
                "appendTo":"#switcher-language<?php /* @escapeNotVerified */ echo $id ?> > .options",
                "triggerTarget":"#switcher-language-trigger<?php /* @escapeNotVerified */ echo $id ?>",
                "closeOnMouseLeave": false,
                "triggerClass":"active",
                "parentClass":"active",
                "buttons":null}}'>
            <?php foreach ($block->getStores() as $_lang): ?>
                <?php if ($_lang->getId() != $block->getCurrentStoreId()): ?>
                    <li class="view-<?php echo $block->escapeHtml($_lang->getCode()); ?> switcher-option">
                        <a href="#" data-post='<?php echo $this->getTargetStorePostData($_lang); ?>'>
                            <?php if($_helper->getConfig('porto_settings/header/language_flag')): ?>
                                <img src="<?php echo $_helper->getBaseUrl().'wysiwyg/smartwave/porto/flags/'.$block->escapeHtml($_lang->getCode()).'.png'; ?>" alt="" />
                            <?php endif; ?>
                            <?php echo $block->escapeHtml($_lang->getName()) ?></a>
                    </li>
                <?php endif; ?>
            <?php endforeach; ?>
            <?php if ($is_demo == 1 && count($block->getStores()) < 2): ?>
                <li class="view-demo_fr switcher-option">
                    <a href="#" data-post="" title="It will be automatically added once you set up more multi store views.">
                        <?php if($_helper->getConfig('porto_settings/header/language_flag')): ?>
                            <img src="<?php echo $_helper->getBaseUrl().'wysiwyg/smartwave/porto/flags/french.png'; ?>" alt="" />
                        <?php endif; ?>
                        <?php echo __('Add More'); ?>
                    </a>
                </li>
            <?php endif; ?>
        </ul>
    </div>
</div>
<?php endif; ?>
