Skip to content

A free, self-hostable news aggregator…

2.1 KB
Raw Blame
<?php
	declare(strict_types=1);
	/** @var FreshRSS_View $this */
	$c = Minz_Request::controllerName();
	$a = Minz_Request::actionName();
	$params = array_filter($_GET, 'is_string', ARRAY_FILTER_USE_KEY);
?>
<?php if ($this->pageCount > 1) { ?>
<nav class="nav-pagination nav-list">
	<div class="pagination-wrapper">
		<ul class="pagination">
			<?php
				/** @var string $getter from Minz_Paginator::render() */
				$params[$getter] = 1;
			?>
			<li class="item pager-first">
				<a href="<?= Minz_Url::display(['c' => $c, 'a' => $a, 'params' => $params]) ?>">« <?= _t('conf.logs.pagination.first') ?></a>
			</li>

			<?php $params[$getter] = $this->currentPage - 1; ?>

			<li class="item pager-previous">
				<?php if ($this->currentPage > 1) { ?>
				<a href="<?= Minz_Url::display(['c' => $c, 'a' => $a, 'params' => $params]) ?>">‹ <?= _t('conf.logs.pagination.previous') ?></a>
				<?php } ?>
			</li>

			<?php if ($this->currentPage - 2 > 1) { ?>
			<li class="item">…</a></li>
			<?php } ?>

			<?php
			for ($i = $this->currentPage - 2; $i <= $this->currentPage + 2; $i++) {
				if ($i > 0 && $i <= $this->pageCount) {
					$params[$getter] = $i;
					if ($i != $this->currentPage) {
						$class = '';
						$aria = 'false';
					} else {
						$class = ' active';
						$aria = 'true';
					} ?>
					<li class="item<?= $class ?>"><a href="<?= Minz_Url::display(['c' => $c, 'a' => $a, 'params' => $params]) ?>" aria-current="<?= $aria ?>"><?= $i ?></a></li>
				<?php
				}
			} ?>

			<?php if ($this->pageCount > $this->currentPage + 2) { ?>
			<li class="item">…</a></li>
			<?php } ?>

			<?php $params[$getter] = $this->currentPage + 1; ?>

			<li class="item pager-next">
				<?php if ($this->currentPage < $this->pageCount) { ?>
				<a href="<?= Minz_Url::display(['c' => $c, 'a' => $a, 'params' => $params]) ?>"><?= _t('conf.logs.pagination.next') ?> ›</a>
				<?php } ?>
			</li>

			<?php $params[$getter] = $this->pageCount; ?>
			<li class="item pager-last">
				<a href="<?= Minz_Url::display(['c' => $c, 'a' => $a, 'params' => $params]) ?>"><?= _t('conf.logs.pagination.last') ?> »</a>
			</li>
		</ul>
	</div>
</nav>
<?php } ?>