<?php
/**
 * OpenMage
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
 * @copyright   Copyright (c) 2021-2022 The OpenMage Contributors (https://www.openmage.org)
 * @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">
                <?php echo $this->__('%s-%s of %s', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
            </p>
            <?php else: ?>
            <p class="amount amount--no-pages">
                <strong><?php echo $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><?php echo $this->__('Show') ?></label>
                <select onchange="setLocation(this.value)" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Results per page')); ?>">
                <?php foreach ($availableLimits as $_key => $_limit): ?>
                    <option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
                        <?php echo $_limit ?>
                    </option>
                <?php endforeach ?>
                </select>
            </div>
        <?php endif ?>
    </div>
    <?php endif ?>

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

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

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

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


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

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

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

    </div>
    <?php endif ?>

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

<?php endif ?>
