<?php
/**
 * Maho
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2022 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
/**
 * Pager template
 *
 * @var Mage_Page_Block_Html_Pager $this
 */
?>
<?php if($this->getCollection()->getSize()): ?>

    <?php if($this->getUseContainer()): ?>
    <div class="pager pager-no-toolbar">
    <?php endif ?>

    <?php if($this->getShowAmounts() || $this->getShowPerPage()): ?>
    <div class="count-container">
        <?php if($this->getShowAmounts()): ?>
            <?php if($this->getLastPageNum()>1): ?>
            <p class="amount amount--has-pages">
                <?= $this->__('%s-%s of %s', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
            </p>
            <?php else: ?>
            <p class="amount amount--no-pages">
                <strong><?= $this->__('%s Item(s)', $this->getTotalNum()) ?></strong>
            </p>
            <?php endif ?>
        <?php endif ?>

        <?php $availableLimits = $this->getAvailableLimit() ?>
        <?php if (count($availableLimits) > 1): ?>
            <div class="limiter">
                <label><?= $this->__('Show') ?></label>
                <select onchange="setLocation(this.value)" title="<?= Mage::helper('core')->quoteEscape($this->__('Results per page')) ?>">
                <?php foreach ($availableLimits as $_key => $_limit): ?>
                    <option value="<?= $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
                        <?= $_limit ?>
                    </option>
                <?php endforeach ?>
                </select>
            </div>
        <?php endif ?>
    </div>
    <?php endif ?>

    <?php if($this->getLastPageNum()>1): ?>
    <div class="pages">
        <strong><?= $this->__('Page:') ?></strong>
        <ol>
        <?php if (!$this->isFirstPage()): ?>
            <li>
                <a class="previous<?php if(!$this->getAnchorTextForPrevious()): ?> i-previous<?php endif ?>" href="<?= $this->getPreviousPageUrl() ?>" title="<?= Mage::helper('core')->quoteEscape($this->__('Previous')) ?>">
                    <?php if(!$this->getAnchorTextForPrevious()): ?>
                        <?= $this->__('Previous') ?>
                    <?php else: ?>
                        <?= $this->getAnchorTextForPrevious() ?>
                    <?php endif ?>
                </a>
            </li>
        <?php endif ?>

        <?php if ($this->canShowFirst()): ?>
            <li><a class="first" href="<?= $this->getFirstPageUrl() ?>">1</a></li>
        <?php endif ?>

        <?php if ($this->canShowPreviousJump()): ?>
            <li><a class="previous_jump" title="" href="<?= $this->getPreviousJumpUrl() ?>">...</a></li>
        <?php endif ?>

        <?php foreach ($this->getFramePages() as $_page): ?>
            <?php if ($this->isPageCurrent($_page)): ?>
                <li class="current"><?= $_page ?></li>
            <?php else: ?>
                <li><a href="<?= $this->getPageUrl($_page) ?>"><?= $_page ?></a></li>
            <?php endif ?>
        <?php endforeach ?>


        <?php if ($this->canShowNextJump()): ?>
            <li><a class="next_jump" title="" href="<?= $this->getNextJumpUrl() ?>">...</a></li>
        <?php endif ?>

        <?php if ($this->canShowLast()): ?>
          <li><a class="last" href="<?= $this->getLastPageUrl() ?>"><?= $this->getLastPageNum() ?></a></li>
        <?php endif ?>

        <?php if (!$this->isLastPage()): ?>
            <li>
                <a class="next<?php if(!$this->getAnchorTextForNext()): ?> i-next<?php endif ?>" href="<?= $this->getNextPageUrl() ?>" title="<?= Mage::helper('core')->quoteEscape($this->__('Next')) ?>">
                    <?php if(!$this->getAnchorTextForNext()): ?>
                        <?= $this->__('Next') ?>
                    <?php else: ?>
                        <?= $this->getAnchorTextForNext() ?>
                    <?php endif ?>
                </a>
            </li>
        <?php endif ?>
        </ol>

    </div>
    <?php endif ?>

    <?php if($this->getUseContainer()): ?>
    </div>
    <?php endif ?>

<?php endif ?>
