<?php
/**
 * Copyright © 2017 Codazon, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>

<?php
$pageInfo = $block->getPageInfo();
$serchBrandText = $pageInfo->getData('search_input_text') ? : __('Search brand here');
$noResultsText = $pageInfo->getData('no_result_text') ? : __('No brand matches your input');
$searchWidget = [
    'Codazon_Shopbybrandpro/js/brands' => [
        'codazon.searchBrands' => [
            'brandUrl'  => $block->getUrl('brands/index/searchBrands', ['_query' => ['attribute_code' => $pageInfo->getData('attribute_code')]]),
            'noResults' => $noResultsText,
            'resultsS'   => __('There is %1 result.'),
            'resultsP'   => __('There are %1 results.')
        ]
    ]
];
$displayFeaturedBrands = (bool)$pageInfo->getData('display_featured_brands');
$displayBrandSearch = (bool)$pageInfo->getData('display_brand_search');
$allTitle = $pageInfo->getData('all_title') ? : __('All brands');
?>

<div class="brand-container">
    <div class="brand-top">
        <?php if ($displayFeaturedBrands) : ?>
        <div class="block featured-brands-block">
            <div class="block-title">
                <strong class="label"><?= $pageInfo->getData('featured_brand_title')?:__('Featured Brands') ?></strong>
                <?php if ($displayBrandSearch) : ?>
                <div class="brand-search-wrap" data-mage-init='<?= json_encode($searchWidget) ?>'>
                    <div class="brand-form" data-role="brand-form">
                        <label class="search-label"></label>
                        <input data-role="brand_name" placeholder="<?= $serchBrandText ?>" type="text" class="input-text search-input" />
                        <div data-role="list-wrap" class="list-wrap"></div>
                    </div>
                </div>
                <?php endif ?>
            </div>
            <div class="block-content">
                <?= $block->getBlockHtml('featured_brands'); ?>
            </div>
        </div>
        <?php endif ?>
        <div class="page-desc"><?= $pageInfo->getData('description') ?></div>
    </div>
    
    <div class="brand-main">
        <div class="block">
            <div class="block-title">
                <strong class="label"><?= $allTitle ?></strong>
                <?php if ((!$displayFeaturedBrands) && $displayBrandSearch) : ?>
                <div class="brand-search-wrap" data-mage-init='<?= json_encode($searchWidget) ?>'>
                    <div class="brand-form" data-role="brand-form">
                        <label class="search-label"></label>
                        <input data-role="brand_name" placeholder="<?= __('Search brand here') ?>" type="text" class="input-text search-input" />
                        <div data-role="list-wrap" class="list-wrap"></div>
                    </div>
                </div>
                <?php endif ?>
            </div>
            <div class="block-content"><?= $block->getBlockHtml('brand_alphabet_list'); ?></div>
        </div>
    </div>
</div>