Fix some oversights and add a fallback page for when there are no forums.

This commit is contained in:
flash 2018-05-24 02:57:13 +02:00
parent 8b2e174d40
commit 60d14f9709
4 changed files with 30 additions and 15 deletions

View file

@ -4,6 +4,7 @@ use Misuzu\Database;
require_once __DIR__ . '/../../misuzu.php';
$categories = forum_get_root_categories();
$blankForum = count($categories) <= 1 && $categories[0]['forum_children'] < 1;
foreach ($categories as $key => $category) {
$categories[$key]['forum_subforums'] = forum_get_children($category['forum_id'], $app->getUserId());
@ -20,4 +21,5 @@ foreach ($categories as $key => $category) {
echo $app->getTemplating()->render('forum.index', [
'forum_categories' => $categories,
'forum_empty' => $blankForum,
]);

View file

@ -51,8 +51,10 @@ function forum_fetch(int $forumId): array
WHERE `forum_id` = :forum_id
');
$getForum->bindValue('forum_id', $forumId);
$getForum->execute();
$forums = $getForum->fetch();
return $getForum->execute() ? $getForum->fetch() : [];
return $forums ? $forums : [];
}
function forum_get_root_categories(): array

View file

@ -50,8 +50,10 @@ function forum_topic_fetch(int $topicId): array
AND t.`topic_deleted` IS NULL
');
$getTopic->bindValue('topic_id', $topicId);
$getTopic->execute();
$topic = $getTopic->fetch();
return $getTopic->execute() ? $getTopic->fetch() : [];
return $topic ? $topic : [];
}
function forum_topic_bump(int $topicId): bool

View file

@ -6,21 +6,30 @@
{% set canonical_url = '/forum/' %}
{% block content %}
{% for category in forum_categories %}
{% if category.forum_children > 0 %}
{{ forum_category_listing(category.forum_subforums, category.forum_name) }}
{% endif %}
{% endfor %}
{% if not forum_empty %}
{% for category in forum_categories %}
{% if category.forum_children > 0 %}
{{ forum_category_listing(category.forum_subforums, category.forum_name) }}
{% endif %}
{% endfor %}
<div class="container forum__actions">
<div class="container__title">Actions</div>
<div class="container__content forum__actions__content">
<a class="input__button forum__actions__button">Mark All Read</a>
<a class="input__button forum__actions__button">Unanswered Posts</a>
<a class="input__button forum__actions__button">New Posts</a>
<a class="input__button forum__actions__button">Your Posts</a>
<div class="container forum__actions">
<div class="container__title">Actions</div>
<div class="container__content forum__actions__content">
<a class="input__button forum__actions__button">Mark All Read</a>
<a class="input__button forum__actions__button">Unanswered Posts</a>
<a class="input__button forum__actions__button">New Posts</a>
<a class="input__button forum__actions__button">Your Posts</a>
</div>
</div>
</div>
{% else %}
<div class="container">
<div class="container__title">Forums</div>
<div class="container__content">
<p>There are no forums yet, check back later!</p>
</div>
</div>
{% endif %}
{{ navigation(mio_navigation, '/forum/') }}
{% endblock %}