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

<?php
$category = $this->getCurrentCategory();
$lookbookCollection = $block->getLookbookLoadedCollection();
$helper = $this->helper('Codazon\Lookbookpro\Helper\Data');
$width = $helper->getConfig('codazon_lookbook/images/lookbook/thumbnail_width') ? : 300;
$height = $helper->getConfig('codazon_lookbook/images/lookbook/thumbnail_height') ? : 300;
$paddingBottom = 100 * $height/$width;
$displayDate = (bool)$helper->getConfig('codazon_lookbook/lookbook_category_list/display_created_date');
$dateFormat = $helper->getConfig('codazon_lookbook/lookbook_category_list/date_format') ? : 'Y M d';
$viewMoreText = __('More Detail');
?>

<?php if ($lookbookCollection->count()) : ?>
<style type="text/css">
<?php echo $helper->getColumnStyle('.lookbook-list', '.lookbook-list .lookbook-item', '.lookbook-list .lookbook-item', 'codazon_lookbook/listing/lookbook_list/'); ?>
</style>
<?= $block->getToolbarHtml() ?>
<div class="products lookbook wrapper">
    <div class="lookbook-list flex-grid">
    <?php foreach($lookbookCollection as $lookbook) : ?>
    <?php
        $name = $this->stripTags($lookbook->getName());
        $description = $this->stripTags($lookbook->getDescription());
        $url = $helper->getLookbookUrl($lookbook, $category);
        $img = $helper->getLookbookThumbnailUrl($lookbook, $width, $height);
    ?>
    <div class="item lookbook-item">
        <div class="lookbook-inner">
            <div class="lookbook-top">
                <div class="auto-pos-wrap" style="padding-bottom: <?= $paddingBottom ?>%">
                    <a title="<?= $name; ?>" href="<?= $url; ?>" class="lookbook-img a-img">
                        <img class="img-center" alt="<?= $name; ?>" src="<?= $img; ?>" />
                    </a>
                </div>
            </div>
            <div class="lookbook-bottom">
				<div class="lookbook-bottom-inner">
					<a class="lookbook-name" href="<?= $url; ?>" title="<?= $name; ?>"><?= $name; ?></a>
					<?php if ($description) : ?>
					<div class="lookbook-desc"><?= $helper->subString($description, 100); ?></div>
					<?php endif ?>
					<div class="actions">
						<?php if ($displayDate) : ?>
						<div class="lookbook-date">
							<?= date($dateFormat, strtotime($lookbook->getData('created_at'))); ?>
						</div>
						<?php endif ?>
						<a class="lookbook-viewmore" href="<?= $url; ?>" title="<?= $viewMoreText; ?>"><?= $viewMoreText; ?></a>
					</div>
				</div>
            </div>
        </div>
    </div>
    <?php endforeach ?>
    </div>
</div>
<?= $block->getToolbarHtml() ?>
<?php else : ?>
<div class="message info empty"><div><?= __('There is no loookbook belong to this category.') ?></div></div>
<?php endif ?>