<?php
/**
 * Maho
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2024 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Category layered navigation state
 *
 * @see Mage_Catalog_Block_Layer_State
 * @var Mage_Catalog_Block_Layer_State $this 
 */
?>
<?php
$_filters = $this->getActiveFilters();
$_renderers = $this->getParentBlock()->getChild('state_renderers')->getSortedChildren();
?>
<?php if(!empty($_filters)): ?>
<div class="currently">
    <p class="block-subtitle"><?= $this->__('Currently Shopping by:') ?></p>
    <ol>
    <?php foreach ($_filters as $_filter): ?>
        <?php
        $_rendered = false;
        foreach ($_renderers as $_rendererName):
            $_renderer = $this->getParentBlock()->getChild('state_renderers')->getChild($_rendererName);
            if (method_exists($_renderer, 'shouldRender') && $_renderer->shouldRender($_filter)):
                $_renderer->setFilter($_filter);
                echo $_renderer->toHtml();
                $_rendered = true;
                break;
            endif;
        endforeach;

        if (!$_rendered):
        ?>
        <li>
            <?php
                $clearLinkUrl = $_filter->getClearLinkUrl();
                if ($clearLinkUrl):
            ?>
                <a  class="btn-previous" href="<?= $_filter->getRemoveUrl() ?>" title="<?= Mage::helper('core')->quoteEscape($this->__('Previous')) ?>"><?= $this->__('Previous') ?></a>
                <a  class="btn-remove" title="<?= $this->escapeHtml($_filter->getFilter()->getClearLinkText()) ?>" href="<?= $clearLinkUrl ?>"><?= $this->escapeHtml($_filter->getFilter()->getClearLinkText()) ?></a>
            <?php else: ?>
                <a  class="btn-remove" href="<?= $_filter->getRemoveUrl() ?>" title="<?= Mage::helper('core')->quoteEscape($this->__('Remove This Item')) ?>"><?= $this->__('Remove This Item') ?></a>
            <?php endif ?>
            <span class="label"><?= $this->__($_filter->getName()) ?>:</span> <span class="value"><?= $this->stripTags($_filter->getLabel()) ?></span>
        </li>
        <?php endif ?>
    <?php endforeach ?>
    </ol>
</div>
<?php endif ?>
