Post list errors are shown in nicer way

This commit is contained in:
Marcin Kurczewski 2014-02-20 19:06:06 +01:00
parent db8e13ec35
commit 4420fa588d
4 changed files with 21 additions and 5 deletions

View file

@ -47,6 +47,7 @@ class PostController
$this->context->viewName = 'post-list-wrapper';
$this->context->source = $source;
$this->context->additionalInfo = $additionalInfo;
$this->context->handleExceptions = true;
//redirect requests in form of /posts/?query=... to canonical address
$formQuery = InputHelper::get('query');

View file

@ -1,4 +1,7 @@
<?php
if (!isset($this->context->transport->paginator))
return;
$page = $this->context->transport->paginator->page;
$pageCount = $this->context->transport->paginator->pageCount;

View file

@ -2,10 +2,19 @@
LayoutHelper::setSubTitle('posts');
$tabs = [];
if (PrivilegesHelper::confirm(Privilege::ListPosts)) $tabs []= ['All posts', \Chibi\UrlHelper::route('post', 'list')];
if (PrivilegesHelper::confirm(Privilege::ListPosts)) $tabs []= ['Random', \Chibi\UrlHelper::route('post', 'random')];
if (PrivilegesHelper::confirm(Privilege::ListPosts)) $tabs []= ['Favorites', \Chibi\UrlHelper::route('post', 'favorites')];
if (PrivilegesHelper::confirm(Privilege::MassTag)) $tabs []= ['Mass tag', \Chibi\UrlHelper::route('post', 'list', ['query' => isset($this->context->transport->searchQuery) ? htmlspecialchars($this->context->transport->searchQuery) : '', 'source' => 'mass-tag', 'page' => $this->context->transport->paginator->page])];
if (PrivilegesHelper::confirm(Privilege::ListPosts))
$tabs []= ['All posts', \Chibi\UrlHelper::route('post', 'list')];
if (PrivilegesHelper::confirm(Privilege::ListPosts))
$tabs []= ['Random', \Chibi\UrlHelper::route('post', 'random')];
if (PrivilegesHelper::confirm(Privilege::ListPosts))
$tabs []= ['Favorites', \Chibi\UrlHelper::route('post', 'favorites')];
if (PrivilegesHelper::confirm(Privilege::MassTag))
$tabs []= ['Mass tag', \Chibi\UrlHelper::route('post', 'list', [
'source' => 'mass-tag',
'query' => isset($this->context->transport->searchQuery) ? htmlspecialchars($this->context->transport->searchQuery) : '',
'page' => isset($this->context->transport->paginator) ? $this->context->transport->paginator->page : 1])];
$activeTab = 0;
if ($this->context->route->simpleActionName == 'random') $activeTab = 1;

View file

@ -7,7 +7,10 @@ LayoutHelper::addScript('post-list.js');
<?php $this->renderFile('tag-mass-tag') ?>
<?php endif ?>
<?php if (empty($this->context->transport->posts)): ?>
<?php if (!empty($this->context->transport->message)): ?>
<?php $this->renderFile('message') ?>
<?php elseif (empty($this->context->transport->posts)): ?>
<p class="alert alert-warning">No posts to show.</p>
<?php else: ?>
<div class="posts-wrapper">