2013-10-12 22:37:18 +02:00
|
|
|
<?php if (empty($this->context->transport->posts)): ?>
|
2013-10-09 12:19:42 +02:00
|
|
|
<p class="alert alert-warning">No posts to show.</p>
|
2013-10-07 23:17:33 +02:00
|
|
|
<?php else: ?>
|
2013-10-10 00:12:27 +02:00
|
|
|
<div class="posts paginator-content">
|
2013-10-09 12:18:22 +02:00
|
|
|
<?php foreach ($this->context->transport->posts as $post): ?>
|
2013-10-16 08:33:45 +02:00
|
|
|
<a class="post post-type-<?php echo TextHelper::camelCaseToHumanCase(PostType::toString($post['type'])) ?>" href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $post['id']]) ?>">
|
2013-10-09 12:18:22 +02:00
|
|
|
<img src="<?php echo \Chibi\UrlHelper::route('post', 'thumb', ['id' => $post['id']]) ?>" alt="@<?php echo $post['id'] ?>"/>
|
|
|
|
</a>
|
|
|
|
<?php endforeach ?>
|
|
|
|
</div>
|
2013-10-07 23:17:33 +02:00
|
|
|
<?php endif ?>
|
2013-10-09 11:45:18 +02:00
|
|
|
|
|
|
|
<?php
|
|
|
|
if (!function_exists('pageUrl'))
|
|
|
|
{
|
|
|
|
function pageUrl($page)
|
|
|
|
{
|
|
|
|
$context = \Chibi\Registry::getContext();
|
2013-10-09 12:24:25 +02:00
|
|
|
$controller = $context->route->simpleControllerName;
|
|
|
|
$action = $context->route->simpleActionName;
|
2013-10-09 11:45:18 +02:00
|
|
|
$page = max(1, $page);
|
|
|
|
$page = min($context->transport->pageCount, $page);
|
|
|
|
$params = [];
|
|
|
|
$params['page'] = $page;
|
2013-10-13 22:20:06 +02:00
|
|
|
if ($context->transport->searchQuery != '')
|
2013-10-09 11:45:18 +02:00
|
|
|
{
|
|
|
|
$params['query'] = $context->transport->searchQuery;
|
|
|
|
}
|
2013-10-09 12:24:25 +02:00
|
|
|
return \Chibi\UrlHelper::route($controller, $action, $params);
|
2013-10-09 11:45:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
2013-10-13 22:09:52 +02:00
|
|
|
<?php
|
|
|
|
$pagesVisible = [];
|
|
|
|
$pagesVisible []= 1;
|
|
|
|
$pagesVisible []= $this->context->transport->pageCount;
|
|
|
|
$delta = 3;
|
|
|
|
$pagesVisible = array_merge($pagesVisible, range($this->context->transport->page - $delta, $this->context->transport->page + $delta));
|
|
|
|
$pagesVisible = array_filter($pagesVisible, function($x) { return $x >= 1 and $x <= $this->context->transport->pageCount; });
|
|
|
|
$pagesVisible = array_unique($pagesVisible);
|
|
|
|
sort($pagesVisible, SORT_NUMERIC);
|
|
|
|
?>
|
2013-10-09 11:45:18 +02:00
|
|
|
|
2013-10-13 22:09:52 +02:00
|
|
|
<?php if (!empty($pagesVisible)): ?>
|
|
|
|
<nav class="paginator-wrapper">
|
|
|
|
<ul class="paginator">
|
|
|
|
<?php if ($this->context->transport->page > 1): ?>
|
|
|
|
<li class="prev">
|
2013-10-09 11:45:18 +02:00
|
|
|
<?php else: ?>
|
2013-10-15 00:41:04 +02:00
|
|
|
<li class="prev disabled">
|
2013-10-09 11:45:18 +02:00
|
|
|
<?php endif ?>
|
2013-10-13 22:09:52 +02:00
|
|
|
<a href="<?php echo pageUrl($this->context->transport->page - 1) ?>">
|
|
|
|
«
|
2013-10-09 11:45:18 +02:00
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
2013-10-13 22:09:52 +02:00
|
|
|
<?php foreach ($pagesVisible as $page): ?>
|
|
|
|
<?php if ($page == $this->context->transport->page): ?>
|
|
|
|
<li class="active">
|
|
|
|
<?php else: ?>
|
|
|
|
<li>
|
|
|
|
<?php endif ?>
|
|
|
|
<a href="<?php echo pageUrl($page) ?>">
|
|
|
|
<?php echo $page ?>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<?php endforeach ?>
|
|
|
|
|
|
|
|
<?php if ($this->context->transport->page < $this->context->transport->pageCount): ?>
|
|
|
|
<li class="next">
|
|
|
|
<?php else: ?>
|
2013-10-15 00:41:04 +02:00
|
|
|
<li class="next disabled">
|
2013-10-13 22:09:52 +02:00
|
|
|
<?php endif ?>
|
|
|
|
<a href="<?php echo pageUrl($this->context->transport->page + 1) ?>">
|
|
|
|
»
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<?php endif ?>
|