VERY basic topic viewer exist now yeet
This commit is contained in:
parent
9aa5ed140e
commit
1559c5bf40
17 changed files with 224 additions and 116 deletions
|
@ -58,11 +58,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&__stats {
|
&__stats {
|
||||||
text-align: right;
|
text-align: center;
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
font-style: italic;
|
|
||||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
|
||||||
|
|
||||||
@media (max-width: @mio-forum-listing-mobile) {
|
@media (max-width: @mio-forum-listing-mobile) {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
flex-shrink: 1;
|
flex-shrink: 1;
|
||||||
padding: 0 2px;
|
padding: 0 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__info,
|
||||||
|
&__activity {
|
||||||
|
&__datetime,
|
||||||
&__title {
|
&__title {
|
||||||
&__link {
|
&__link {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
@ -50,7 +54,7 @@
|
||||||
font-size: .9em;
|
font-size: .9em;
|
||||||
line-height: 1.3em;
|
line-height: 1.3em;
|
||||||
|
|
||||||
&__username {
|
&__name {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
@ -79,18 +83,22 @@
|
||||||
|
|
||||||
&__stats {
|
&__stats {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
padding-left: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__last-post {
|
&__activity {
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
|
padding-left: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__stats,
|
&__stats,
|
||||||
&__last-post {
|
&__activity {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
border-left: 1px solid #9475b2;
|
border-left: 1px solid #9475b2;
|
||||||
padding-left: 1px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
.news__list {
|
.news__list {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
|
box-shadow: initial;
|
||||||
|
|
||||||
&__item {
|
&__item {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
.news__preview {
|
.news__preview {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
box-shadow: initial;
|
||||||
|
|
||||||
&:not(:last-child) {
|
&:not(:last-child) {
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
.news__pagination {
|
.pagination {
|
||||||
border: 1px solid #9475b2;
|
|
||||||
list-style: none;
|
list-style: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 1px;
|
padding: 1px;
|
||||||
|
border: 1px solid #9475b2;
|
||||||
|
|
||||||
&__separator {
|
&__separator {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
height: 20px;
|
height: 20px;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
|
|
||||||
&:not(:last-child){
|
&:not(:last-child) {
|
||||||
margin-right: 1px;
|
margin-right: 1px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,54 +1,4 @@
|
||||||
.settings__pagination {
|
.settings__pagination {
|
||||||
list-style: none;
|
|
||||||
display: flex;
|
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
margin: 2px auto;
|
margin: 2px auto;
|
||||||
padding: 1px;
|
|
||||||
border: 1px solid #9475b2;
|
|
||||||
|
|
||||||
&__separator {
|
|
||||||
flex-grow: 1;
|
|
||||||
flex-shrink: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__option {
|
|
||||||
background: #9475b2;
|
|
||||||
color: #306;
|
|
||||||
height: 20px;
|
|
||||||
width: 20px;
|
|
||||||
|
|
||||||
&:not(:last-child){
|
|
||||||
margin-right: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--disabled {
|
|
||||||
color: #383838;
|
|
||||||
background: #777;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: @mio-news-mobile) {
|
|
||||||
height: 30px;
|
|
||||||
width: 30px;
|
|
||||||
font-size: 1.5em;
|
|
||||||
line-height: 1.5em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__link {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
text-align: center;
|
|
||||||
text-decoration: none;
|
|
||||||
color: inherit;
|
|
||||||
|
|
||||||
&--prev,
|
|
||||||
&--next,
|
|
||||||
&--first,
|
|
||||||
&--last,
|
|
||||||
&--active,
|
|
||||||
&:hover {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,11 +45,12 @@ body {
|
||||||
@import "classes/avatar";
|
@import "classes/avatar";
|
||||||
@import "classes/container";
|
@import "classes/container";
|
||||||
@import "classes/heading";
|
@import "classes/heading";
|
||||||
|
@import "classes/navigation";
|
||||||
|
@import "classes/pagination";
|
||||||
|
|
||||||
// Specific styles
|
// Specific styles
|
||||||
@import "classes/footer";
|
@import "classes/footer";
|
||||||
@import "classes/header";
|
@import "classes/header";
|
||||||
@import "classes/navigation";
|
|
||||||
@import "classes/profile";
|
@import "classes/profile";
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
@ -65,7 +66,6 @@ body {
|
||||||
// News
|
// News
|
||||||
@import "classes/news/container";
|
@import "classes/news/container";
|
||||||
@import "classes/news/list";
|
@import "classes/news/list";
|
||||||
@import "classes/news/pagination";
|
|
||||||
@import "classes/news/preview";
|
@import "classes/news/preview";
|
||||||
@import "classes/news/sidebar";
|
@import "classes/news/sidebar";
|
||||||
@import "classes/news/post"; // post needs to be able to override sidebar
|
@import "classes/news/post"; // post needs to be able to override sidebar
|
||||||
|
|
|
@ -67,8 +67,7 @@ switch ($mode) {
|
||||||
$auth_login_error = '';
|
$auth_login_error = '';
|
||||||
|
|
||||||
while ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
while ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
$ipAddressObj = IPAddress::remote();
|
$ipAddress = IPAddress::remote()->getString();
|
||||||
$ipAddress = $ipAddressObj->getString();
|
|
||||||
|
|
||||||
if (!isset($_POST['username'], $_POST['password'])) {
|
if (!isset($_POST['username'], $_POST['password'])) {
|
||||||
$auth_login_error = "You didn't fill all the forms!";
|
$auth_login_error = "You didn't fill all the forms!";
|
||||||
|
@ -127,12 +126,19 @@ switch ($mode) {
|
||||||
|
|
||||||
$createSession = $db->prepare('
|
$createSession = $db->prepare('
|
||||||
INSERT INTO `msz_sessions`
|
INSERT INTO `msz_sessions`
|
||||||
(`user_id`, `session_ip`, `user_agent`, `session_key`, `created_at`, `expires_on`)
|
(
|
||||||
|
`user_id`, `session_ip`, `session_country`,
|
||||||
|
`user_agent`, `session_key`, `created_at`, `expires_on`
|
||||||
|
)
|
||||||
VALUES
|
VALUES
|
||||||
(:user_id, INET6_ATON(:session_ip), :user_agent, :session_key, NOW(), NOW() + INTERVAL 1 MONTH)
|
(
|
||||||
|
:user_id, INET6_ATON(:session_ip), :session_country,
|
||||||
|
:user_agent, :session_key, NOW(), NOW() + INTERVAL 1 MONTH
|
||||||
|
)
|
||||||
');
|
');
|
||||||
$createSession->bindValue('user_id', $userId);
|
$createSession->bindValue('user_id', $userId);
|
||||||
$createSession->bindValue('session_ip', $ipAddress);
|
$createSession->bindValue('session_ip', $ipAddress);
|
||||||
|
$createSession->bindValue('session_country', get_country_code($ipAddress));
|
||||||
$createSession->bindValue('user_agent', $user_agent);
|
$createSession->bindValue('user_agent', $user_agent);
|
||||||
$createSession->bindValue('session_key', $sessionKey);
|
$createSession->bindValue('session_key', $sessionKey);
|
||||||
|
|
||||||
|
|
|
@ -112,15 +112,14 @@ $getBreadcrumb = $db->prepare('
|
||||||
|
|
||||||
while ($lastParent > 0) {
|
while ($lastParent > 0) {
|
||||||
$getBreadcrumb->bindValue('forum_id', $lastParent);
|
$getBreadcrumb->bindValue('forum_id', $lastParent);
|
||||||
|
$breadcrumb = $getBreadcrumb->execute() ? $getBreadcrumb->fetch() : [];
|
||||||
|
|
||||||
if (!$getBreadcrumb->execute()) {
|
if (!$breadcrumb) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parentForum = $getBreadcrumb->fetch();
|
$breadcrumbs[$breadcrumb['forum_name']] = '/forum/forum.php?f=' . $breadcrumb['forum_id'];
|
||||||
|
$lastParent = $breadcrumb['forum_parent'];
|
||||||
$breadcrumbs[$parentForum['forum_name']] = '/forum/forum.php?f=' . $parentForum['forum_id'];
|
|
||||||
$lastParent = $parentForum['forum_parent'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$breadcrumbs['Forums'] = '/forum/';
|
$breadcrumbs['Forums'] = '/forum/';
|
||||||
|
|
|
@ -3,4 +3,81 @@ use Misuzu\Database;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../misuzu.php';
|
require_once __DIR__ . '/../../misuzu.php';
|
||||||
|
|
||||||
echo $app->getTemplating()->render('forum.topic');
|
$db = Database::connection();
|
||||||
|
$templating = $app->getTemplating();
|
||||||
|
|
||||||
|
$postId = (int)($_GET['p'] ?? 0);
|
||||||
|
$topicId = (int)($_GET['t'] ?? 0);
|
||||||
|
$postsOffset = max((int)($_GET['o'] ?? 0), 0);
|
||||||
|
$postsRange = max(min((int)($_GET['r'] ?? 10), 25), 5);
|
||||||
|
|
||||||
|
// find topic id
|
||||||
|
if ($topicId < 1 && $postId > 0) {
|
||||||
|
$getTopicId = $db->prepare('
|
||||||
|
SELECT `topic_id`
|
||||||
|
FROM `msz_forum_posts`
|
||||||
|
WHERE `post_id` = :post_id
|
||||||
|
');
|
||||||
|
$getTopicId->bindValue('post_id', $postId);
|
||||||
|
$topicId = $getTopicId->execute() ? (int)$getTopicId->fetchColumn() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$getTopic = $db->prepare('
|
||||||
|
SELECT
|
||||||
|
t.`topic_id`, t.`forum_id`, t.`topic_title`, t.`topic_type`, t.`topic_status`,
|
||||||
|
(
|
||||||
|
SELECT MIN(p.`post_id`)
|
||||||
|
FROM `msz_forum_posts` as p
|
||||||
|
WHERE p.`topic_id` = t.`topic_id`
|
||||||
|
) as `topic_first_post_id`
|
||||||
|
FROM `msz_forum_topics` as t
|
||||||
|
WHERE t.`topic_id` = :topic_id
|
||||||
|
AND t.`topic_deleted` IS NULL
|
||||||
|
');
|
||||||
|
$getTopic->bindValue('topic_id', $topicId);
|
||||||
|
$topic = $getTopic->execute() ? $getTopic->fetch() : false;
|
||||||
|
|
||||||
|
if (!$topic) {
|
||||||
|
http_response_code(404);
|
||||||
|
echo $templating->render('errors.404');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$getPosts = $db->prepare('
|
||||||
|
SELECT
|
||||||
|
`post_id`, `post_text`, `post_created`
|
||||||
|
FROM `msz_forum_posts`
|
||||||
|
WHERE `topic_id` = :topic_id
|
||||||
|
AND `post_deleted` IS NULL
|
||||||
|
');
|
||||||
|
$getPosts->bindValue('topic_id', $topic['topic_id']);
|
||||||
|
$posts = $getPosts->execute() ? $getPosts->fetchAll() : [];
|
||||||
|
|
||||||
|
$lastParent = $topic['forum_id'];
|
||||||
|
$breadcrumbs = [];
|
||||||
|
$getBreadcrumb = $db->prepare('
|
||||||
|
SELECT `forum_id`, `forum_name`, `forum_parent`
|
||||||
|
FROM `msz_forum_categories`
|
||||||
|
WHERE `forum_id` = :forum_id
|
||||||
|
');
|
||||||
|
|
||||||
|
while ($lastParent > 0) {
|
||||||
|
$getBreadcrumb->bindValue('forum_id', $lastParent);
|
||||||
|
$breadcrumb = $getBreadcrumb->execute() ? $getBreadcrumb->fetch() : [];
|
||||||
|
|
||||||
|
if (!$breadcrumb) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$breadcrumbs[$breadcrumb['forum_name']] = '/forum/forum.php?f=' . $breadcrumb['forum_id'];
|
||||||
|
$lastParent = $breadcrumb['forum_parent'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$breadcrumbs['Forums'] = '/forum/';
|
||||||
|
$breadcrumbs = array_reverse($breadcrumbs);
|
||||||
|
|
||||||
|
echo $templating->render('forum.topic', [
|
||||||
|
'topic_breadcrumbs' => $breadcrumbs,
|
||||||
|
'topic_info' => $topic,
|
||||||
|
'topic_posts' => $posts,
|
||||||
|
]);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends '@mio/forum/master.twig' %}
|
{% extends '@mio/forum/master.twig' %}
|
||||||
{% from '@mio/macros.twig' import navigation %}
|
{% from '@mio/macros.twig' import navigation, paginate %}
|
||||||
{% from '@mio/forum/macros.twig' import forum_category_listing, forum_topic_listing %}
|
{% from '@mio/forum/macros.twig' import forum_category_listing, forum_topic_listing, forum_category_buttons %}
|
||||||
|
|
||||||
{% set title = forum_info.forum_name %}
|
{% set title = forum_info.forum_name %}
|
||||||
{% set canonical_url = '/forum/forum.php?f=' ~ forum_info.forum_id %}
|
{% set canonical_url = '/forum/forum.php?f=' ~ forum_info.forum_id %}
|
||||||
|
@ -13,7 +13,14 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if forum_info.forum_type == 0 %}
|
{% if forum_info.forum_type == 0 %}
|
||||||
|
{% set fcbuttons = forum_category_buttons(forum_info) %}
|
||||||
|
{% set fcpagination = paginate(forum_topics|length, 20, 0, canonical_url) %}
|
||||||
|
|
||||||
|
{{ fcbuttons }}
|
||||||
|
{{ fcpagination }}
|
||||||
{{ forum_topic_listing(forum_topics) }}
|
{{ forum_topic_listing(forum_topics) }}
|
||||||
|
{{ fcpagination }}
|
||||||
|
{{ fcbuttons }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ navigation(mio_navigation, '/forum/') }}
|
{{ navigation(mio_navigation, '/forum/') }}
|
||||||
|
|
|
@ -24,4 +24,3 @@
|
||||||
|
|
||||||
{{ navigation(mio_navigation, '/forum/') }}
|
{{ navigation(mio_navigation, '/forum/') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -17,25 +17,33 @@
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro forum_category_entry(forum, forum_icon) %}
|
{% macro forum_category_buttons(forum) %}
|
||||||
{% set forum_icon = forum_icon|default(null) %}
|
<div class="forum__actions forum__actions__content">
|
||||||
|
<a class="input__button forum__actions__button">New Topic</a>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
{% if forum_icon is null %}
|
{% macro forum_category_entry(forum, forum_type, forum_read, forum_icon) %}
|
||||||
|
{% set forum_type = forum_type|default(null) %}
|
||||||
|
{% set forum_read = forum_read|default(true) ? 'read' : 'unread' %}
|
||||||
|
{% set forum_icon = forum_icon|default('https://static.flash.moe/images/forum-icons/forum-%s-%s.png') %}
|
||||||
|
|
||||||
|
{% if forum_type is null %}
|
||||||
{% if forum.forum_archived is defined and forum.forum_archived %}
|
{% if forum.forum_archived is defined and forum.forum_archived %}
|
||||||
{% set forum_icon = 'https://static.flash.moe/images/forum-icons/forum-archive-%s.png' %}
|
{% set forum_type = 'archive' %}
|
||||||
{% elseif forum.forum_type is defined %}
|
{% elseif forum.forum_type is defined and forum.forum_type != 0 %}
|
||||||
{% if forum.forum_type == 2 %}
|
{% if forum.forum_type == 2 %}
|
||||||
{% set forum_icon = 'https://static.flash.moe/images/forum-icons/forum-link-%s.png' %}
|
{% set forum_type = 'link' %}
|
||||||
{% elseif forum.forum_type == 1 %}
|
{% elseif forum.forum_type == 1 %}
|
||||||
{% set forum_icon = 'https://static.flash.moe/images/forum-icons/forum-category-%s.png' %}
|
{% set forum_type = 'category' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{% set forum_type = 'default' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% set forum_icon = forum_icon|default('https://static.flash.moe/images/forum-icons/forum-default-%s.png') %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="forum__listing__entry">
|
<div class="forum__listing__entry">
|
||||||
<img src="{{ forum_icon|format('read') }}" alt="read" class="forum__listing__entry__icon">
|
<img src="{{ forum_icon|format(forum_type, forum_read) }}" alt="read" class="forum__listing__entry__icon">
|
||||||
|
|
||||||
<div class="forum__listing__entry__info">
|
<div class="forum__listing__entry__info">
|
||||||
<a href="/forum/forum.php?f={{ forum.forum_id }}" class="forum__listing__entry__title">{{ forum.forum_name }}</a>
|
<a href="/forum/forum.php?f={{ forum.forum_id }}" class="forum__listing__entry__title">{{ forum.forum_name }}</a>
|
||||||
|
@ -113,7 +121,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% if topic.author_id is not null %}
|
{% if topic.author_id is not null %}
|
||||||
<div class="forum__topics__entry__info__author">
|
<div class="forum__topics__entry__info__author">
|
||||||
by <a href="/profile.php?u={{ topic.author_id }}" class="forum__topics__entry__info__author__username" style="color:{{ topic.author_colour|colour_get_css }}">
|
by <a href="/profile.php?u={{ topic.author_id }}" class="forum__topics__entry__info__author__name" style="color:{{ topic.author_colour|colour_get_css }}">
|
||||||
{{ topic.author_name }}
|
{{ topic.author_name }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -129,15 +137,46 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="forum__topics__entry__last-post">
|
<div class="forum__topics__entry__activity">
|
||||||
<div class="forum__topics__entry__last-post__author">
|
<div class="forum__topics__entry__activity__datetime">
|
||||||
by <a href="/profile.php?u={{ topic.author_id }}" class="forum__topics__entry__last-post__author" style="color:{{ topic.author_colour|colour_get_css }}">
|
<a href="/forum/topic.php?p={{ topic.topic_last_post_id }}#p{{ topic.topic_last_post_id }}" class="forum__topics__entry__activity__datetime__link">
|
||||||
{{ topic.author_name }}
|
{{ topic.topic_first_post_created }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="forum__topics__entry__last-post__date">
|
{% if topic.topic_last_user_id is not null %}
|
||||||
5 years ago
|
<div class="forum__topics__entry__activity__author">
|
||||||
</div>
|
by <a href="/profile.php?u={{ topic.topic_last_user_id }}" class="forum__topics__entry__activity__author__name" style="color:{{ topic.author_colour|colour_get_css }}">
|
||||||
|
{{ topic.author_name }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro forum_post_listing(posts, opening_post_id) %}
|
||||||
|
{% from _self import forum_post_entry %}
|
||||||
|
|
||||||
|
{% if posts|length > 0 %}
|
||||||
|
{% for post in posts %}
|
||||||
|
{{ forum_post_entry(post, post.post_id == opening_post_id) }}
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<div class="container">
|
||||||
|
<div class="container__title">Information</div>
|
||||||
|
<div class="container__content">
|
||||||
|
This topic has no associated posts.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro forum_post_entry(post, is_opening_post) %}
|
||||||
|
{% set is_opening_post = is_opening_post|default(false) %}
|
||||||
|
|
||||||
|
<div class="container" id="p{{ post.post_id }}">
|
||||||
|
<div class="container__content">
|
||||||
|
{{ post.post_text }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
{% extends '@mio/forum/master.twig' %}
|
||||||
|
{% from '@mio/macros.twig' import navigation, paginate %}
|
||||||
|
{% from '@mio/forum/macros.twig' import forum_post_listing %}
|
||||||
|
|
||||||
|
{% set title = topic_info.topic_title %}
|
||||||
|
{% set canonical_url = '/forum/topic.php?t=' ~ topic_info.topic_id %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{{ navigation(topic_breadcrumbs, topic_breadcrumbs|last, true, null, 'left') }}
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="container__title">
|
||||||
|
{{ topic_info.topic_title }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{ forum_post_listing(topic_posts, topic_info.topic_first_post_id) }}
|
||||||
|
|
||||||
|
{{ navigation(mio_navigation, '/forum/') }}
|
||||||
|
{% endblock %}
|
|
@ -17,10 +17,13 @@
|
||||||
</ul>
|
</ul>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro pagination_class(className, classPrefix) %}{{ className }}{% if classPrefix|length > 0 %} {{ classPrefix ~ className }}{% endif %}{% endmacro %}
|
||||||
|
|
||||||
{% macro paginate(itemCount, itemRange, currentOffset, baseUrl, classPrefix, alwaysRender, useRanges, offsetParam, pageRange) %}
|
{% macro paginate(itemCount, itemRange, currentOffset, baseUrl, classPrefix, alwaysRender, useRanges, offsetParam, pageRange) %}
|
||||||
{% set alwaysRender = alwaysRender|default(false) %}
|
{% set alwaysRender = alwaysRender|default(false) %}
|
||||||
|
|
||||||
{% if alwaysRender or itemCount > itemRange %}
|
{% if alwaysRender or itemCount > itemRange %}
|
||||||
|
{% from _self import pagination_class %}
|
||||||
{% set classPrefix = classPrefix|default('') %}
|
{% set classPrefix = classPrefix|default('') %}
|
||||||
{% set separator = '%3F' in baseUrl|default('')|url_encode ? '&' : '?' %}
|
{% set separator = '%3F' in baseUrl|default('')|url_encode ? '&' : '?' %}
|
||||||
{% set baseUrl = baseUrl ~ separator %}
|
{% set baseUrl = baseUrl ~ separator %}
|
||||||
|
@ -30,69 +33,69 @@
|
||||||
{% set offsetParam = offsetParam|default(useRanges ? 'o' : 'p') %}
|
{% set offsetParam = offsetParam|default(useRanges ? 'o' : 'p') %}
|
||||||
{% set pageRange = pageRange|default(3) %}
|
{% set pageRange = pageRange|default(3) %}
|
||||||
|
|
||||||
<ul class="{{ classPrefix }}pagination">
|
<ul class="{{ pagination_class('pagination', classPrefix) }}">
|
||||||
{% if currentPage < 1 %}
|
{% if currentPage < 1 %}
|
||||||
<li class="{{ classPrefix }}pagination__option {{ classPrefix }}pagination__option--first {{ classPrefix }}pagination__option--disabled">
|
<li class="{{ pagination_class('pagination__option', classPrefix) }} {{ pagination_class('pagination__option--first', classPrefix) }} {{ pagination_class('pagination__option--disabled', classPrefix) }}">
|
||||||
<span class="{{ classPrefix }}pagination__link {{ classPrefix }}pagination__link--first">
|
<span class="{{ pagination_class('pagination__link', classPrefix) }} {{ pagination_class('pagination__link--first', classPrefix) }}">
|
||||||
«
|
«
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="{{ classPrefix }}pagination__option {{ classPrefix }}pagination__option--prev {{ classPrefix }}pagination__option--disabled">
|
<li class="{{ pagination_class('pagination__option', classPrefix) }} {{ pagination_class('pagination__option--prev', classPrefix) }} {{ pagination_class('pagination__option--disabled', classPrefix) }}">
|
||||||
<span class="{{ classPrefix }}pagination__link {{ classPrefix }}pagination__link--prev">
|
<span class="{{ pagination_class('pagination__link', classPrefix) }} {{ pagination_class('pagination__link--prev', classPrefix) }}">
|
||||||
‹
|
‹
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set firstUrl = baseUrl|slice(0, (baseUrl|length) - (separator|length)) %}
|
{% set firstUrl = baseUrl|slice(0, (baseUrl|length) - (separator|length)) %}
|
||||||
|
|
||||||
<li class="{{ classPrefix }}pagination__option {{ classPrefix }}pagination__option--first">
|
<li class="{{ pagination_class('pagination__option', classPrefix) }} {{ pagination_class('pagination__option--first', classPrefix) }}">
|
||||||
<a href="{{ firstUrl }}" class="{{ classPrefix }}pagination__link {{ classPrefix }}pagination__link--first" rel="first">
|
<a href="{{ firstUrl }}" class="{{ pagination_class('pagination__link', classPrefix) }} {{ pagination_class('pagination__link--first', classPrefix) }}" rel="first">
|
||||||
«
|
«
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="{{ classPrefix }}pagination__option {{ classPrefix }}pagination__option--prev">
|
<li class="{{ pagination_class('pagination__option', classPrefix) }} {{ pagination_class('pagination__option--prev', classPrefix) }}">
|
||||||
<a href="{{ currentPage < 2 ? firstUrl : baseUrl ~ offsetParam ~ '=' ~ (useRanges ? ((currentPage - 1) * itemRange) : currentPage) }}" class="{{ classPrefix }}pagination__link {{ classPrefix }}pagination__link--prev" rel="prev">
|
<a href="{{ currentPage < 2 ? firstUrl : baseUrl ~ offsetParam ~ '=' ~ (useRanges ? ((currentPage - 1) * itemRange) : currentPage) }}" class="{{ pagination_class('pagination__link', classPrefix) }} {{ pagination_class('pagination__link--prev', classPrefix) }}" rel="prev">
|
||||||
‹
|
‹
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<li class="{{ classPrefix }}pagination__separator"></li>
|
<li class="{{ pagination_class('pagination__separator', classPrefix) }}"></li>
|
||||||
|
|
||||||
{% set paginationStart = currentPage - pageRange %}
|
{% set paginationStart = currentPage - pageRange %}
|
||||||
{% set paginationStop = currentPage + pageRange %}
|
{% set paginationStop = currentPage + pageRange %}
|
||||||
|
|
||||||
{% for i in paginationStart..paginationStop %}
|
{% for i in paginationStart..paginationStop %}
|
||||||
{% if i >= 0 and i < pageCount %}
|
{% if i >= 0 and i < pageCount %}
|
||||||
<li class="{{ classPrefix }}pagination__option{{ currentPage == i ? ' ' ~ classPrefix ~ 'pagination__option--active' : '' }}">
|
<li class="{{ pagination_class('pagination__option', classPrefix) }}{{ currentPage == i ? ' ' ~ pagination_class('pagination__option--active', classPrefix) : '' }}">
|
||||||
<a href="{{ baseUrl ~ offsetParam ~ '=' ~ (useRanges ? i * itemRange : i + 1) }}" class="{{ classPrefix }}pagination__link{{ currentPage == i ? ' ' ~ classPrefix ~ 'pagination__link--active' : '' }}">
|
<a href="{{ baseUrl ~ offsetParam ~ '=' ~ (useRanges ? i * itemRange : i + 1) }}" class="{{ pagination_class('pagination__link', classPrefix) }}{{ currentPage == i ? ' ' ~ pagination_class('pagination__link--active', classPrefix) : '' }}">
|
||||||
{{ i + 1 }}
|
{{ i + 1 }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<li class="{{ classPrefix }}pagination__separator"></li>
|
<li class="{{ pagination_class('pagination__separator', classPrefix) }}"></li>
|
||||||
|
|
||||||
{% if currentPage >= pageCount - 1 %}
|
{% if currentPage >= pageCount - 1 %}
|
||||||
<li class="{{ classPrefix }}pagination__option {{ classPrefix }}pagination__option--next {{ classPrefix }}pagination__option--disabled">
|
<li class="{{ pagination_class('pagination__option', classPrefix) }} {{ pagination_class('pagination__option--next', classPrefix) }} {{ pagination_class('pagination__option--disabled', classPrefix) }}">
|
||||||
<span class="{{ classPrefix }}pagination__link {{ classPrefix }}pagination__link--next">
|
<span class="{{ pagination_class('pagination__link', classPrefix) }} {{ pagination_class('pagination__link--next', classPrefix) }}">
|
||||||
›
|
›
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="{{ classPrefix }}pagination__option {{ classPrefix }}pagination__option--last {{ classPrefix }}pagination__option--disabled">
|
<li class="{{ pagination_class('pagination__option', classPrefix) }} {{ pagination_class('pagination__option--last', classPrefix) }} {{ pagination_class('pagination__option--disabled', classPrefix) }}">
|
||||||
<span class="{{ classPrefix }}pagination__link {{ classPrefix }}pagination__link--last">
|
<span class="{{ pagination_class('pagination__link', classPrefix) }} {{ pagination_class('pagination__link--last', classPrefix) }}">
|
||||||
»
|
»
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="{{ classPrefix }}pagination__option {{ classPrefix }}pagination__option--next">
|
<li class="{{ pagination_class('pagination__option', classPrefix) }} {{ pagination_class('pagination__option--next', classPrefix) }}">
|
||||||
<a href="{{ baseUrl ~ offsetParam ~ '=' ~ (useRanges ? ((currentPage + 1) * itemRange) : currentPage + 2) }}" class="{{ classPrefix }}pagination__link {{ classPrefix }}pagination__link--next" rel="next">
|
<a href="{{ baseUrl ~ offsetParam ~ '=' ~ (useRanges ? ((currentPage + 1) * itemRange) : currentPage + 2) }}" class="{{ pagination_class('pagination__link', classPrefix) }} {{ pagination_class('pagination__link--next', classPrefix) }}" rel="next">
|
||||||
›
|
›
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="{{ classPrefix }}pagination__option {{ classPrefix }}pagination__option--last">
|
<li class="{{ pagination_class('pagination__option', classPrefix) }} {{ pagination_class('pagination__option--last', classPrefix) }}">
|
||||||
<a href="{{ baseUrl ~ offsetParam ~ '=' ~ (useRanges ? ((pageCount - 1) * itemRange) : pageCount) }}" class="{{ classPrefix }}pagination__link {{ classPrefix }}pagination__link--last" rel="last">
|
<a href="{{ baseUrl ~ offsetParam ~ '=' ~ (useRanges ? ((pageCount - 1) * itemRange) : pageCount) }}" class="{{ pagination_class('pagination__link', classPrefix) }} {{ pagination_class('pagination__link--last', classPrefix) }}" rel="last">
|
||||||
»
|
»
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ paginate(category.posts_count, posts_take, posts_offset, '/news.php?c=' ~ category.category_id, 'news__') }}
|
{{ paginate(category.posts_count, posts_take, posts_offset, '/news.php?c=' ~ category.category_id) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ paginate(posts_count, posts_take, posts_offset, '/news.php', 'news__') }}
|
{{ paginate(posts_count, posts_take, posts_offset, '/news.php') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue