// further removals
This commit is contained in:
parent
419e9b3e0a
commit
7ea5e9414d
15 changed files with 200 additions and 230 deletions
public/forum
src
Forum
Http/Handlers/Forum
Users
templates/forum
|
@ -274,6 +274,6 @@ switch($postMode) {
|
|||
|
||||
url_redirect('forum-topic', [
|
||||
'topic' => $postFind['topic_id'],
|
||||
'page' => floor($postFind['preceeding_post_count'] / MSZ_FORUM_POSTS_PER_PAGE) + 1,
|
||||
'page' => floor($postFind['preceeding_post_count'] / \Misuzu\Forum\ForumPost::PER_PAGE) + 1,
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -107,17 +107,13 @@ if(!$forumInfo->canHaveTopics()) {
|
|||
$topicTypes = [];
|
||||
|
||||
if($mode === 'create' || $mode === 'edit') {
|
||||
$topicTypes[MSZ_TOPIC_TYPE_DISCUSSION] = 'Normal discussion';
|
||||
|
||||
if(perms_check($perms, MSZ_FORUM_PERM_STICKY_TOPIC)) {
|
||||
$topicTypes[MSZ_TOPIC_TYPE_STICKY] = 'Sticky topic';
|
||||
}
|
||||
if(perms_check($perms, MSZ_FORUM_PERM_ANNOUNCE_TOPIC)) {
|
||||
$topicTypes[MSZ_TOPIC_TYPE_ANNOUNCEMENT] = 'Announcement';
|
||||
}
|
||||
if(perms_check($perms, MSZ_FORUM_PERM_GLOBAL_ANNOUNCE_TOPIC)) {
|
||||
$topicTypes[MSZ_TOPIC_TYPE_GLOBAL_ANNOUNCEMENT] = 'Global Announcement';
|
||||
}
|
||||
$topicTypes[ForumTopic::TYPE_DISCUSSION] = 'Normal discussion';
|
||||
if(perms_check($perms, MSZ_FORUM_PERM_STICKY_TOPIC))
|
||||
$topicTypes[ForumTopic::TYPE_STICKY] = 'Sticky topic';
|
||||
if(perms_check($perms, MSZ_FORUM_PERM_ANNOUNCE_TOPIC))
|
||||
$topicTypes[ForumTopic::TYPE_ANNOUNCEMENT] = 'Announcement';
|
||||
if(perms_check($perms, MSZ_FORUM_PERM_GLOBAL_ANNOUNCE_TOPIC))
|
||||
$topicTypes[ForumTopic::TYPE_GLOBAL_ANNOUNCEMENT] = 'Global Announcement';
|
||||
}
|
||||
|
||||
// edit mode stuff
|
||||
|
@ -254,13 +250,10 @@ if($mode === 'edit') { // $post is pretty much sure to be populated at this poin
|
|||
Template::set('posting_post', $post);
|
||||
}
|
||||
|
||||
$displayInfo = forum_posting_info($currentUserId);
|
||||
|
||||
Template::render('forum.posting', [
|
||||
'posting_breadcrumbs' => forum_get_breadcrumbs($forumInfo->getId()),
|
||||
'global_accent_colour' => $forumInfo->getColour(),
|
||||
'posting_forum' => $forumInfo,
|
||||
'posting_info' => $displayInfo,
|
||||
'posting_user' => $currentUser,
|
||||
'posting_notices' => $notices,
|
||||
'posting_mode' => $mode,
|
||||
'posting_types' => $topicTypes,
|
||||
|
|
|
@ -328,7 +328,7 @@ if(in_array($moderationMode, $validModerationModes, true)) {
|
|||
return;
|
||||
}
|
||||
|
||||
$topicPagination = new Pagination($topicInfo->getActualPostCount($canDeleteAny), MSZ_FORUM_POSTS_PER_PAGE, 'page');
|
||||
$topicPagination = new Pagination($topicInfo->getActualPostCount($canDeleteAny), \Misuzu\Forum\ForumPost::PER_PAGE, 'page');
|
||||
|
||||
if(isset($postInfo['preceeding_post_count'])) {
|
||||
$preceedingPosts = $postInfo['preceeding_post_count'];
|
||||
|
@ -351,7 +351,6 @@ forum_topic_mark_read($topicUserId, $topicInfo->getId(), $topicInfo->getCategory
|
|||
|
||||
Template::render('forum.topic', [
|
||||
'topic_perms' => $perms,
|
||||
'topic_breadcrumbs' => forum_get_breadcrumbs($topicInfo->getCategory()->getId()),
|
||||
'topic_info' => $topicInfo,
|
||||
'can_reply' => $canReply,
|
||||
'topic_pagination' => $topicPagination,
|
||||
|
|
|
@ -107,11 +107,17 @@ class ForumCategory {
|
|||
public function getParentTree(): array {
|
||||
$current = $this;
|
||||
$parents = [];
|
||||
while($current->hasParent())
|
||||
$parents[] = $current = $this->getParent();
|
||||
while(!$current->isRoot())
|
||||
$parents[] = $current = $current->getParent();
|
||||
return array_reverse($parents);
|
||||
}
|
||||
|
||||
public function getUrl(): string {
|
||||
if($this->isRoot())
|
||||
return url('forum-index');
|
||||
return url('forum-category', ['forum' => $this->getId()]);
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->forum_name;
|
||||
}
|
||||
|
@ -321,6 +327,12 @@ class ForumCategory {
|
|||
return 0;
|
||||
return ForumTopic::countByCategory($this, $includeDeleted);
|
||||
}
|
||||
public function getActualPostCount(bool $includeDeleted = false): int {
|
||||
if(!$this->canHaveTopics())
|
||||
return 0;
|
||||
return ForumPost::countByCategory($this, $includeDeleted);
|
||||
}
|
||||
|
||||
public function getTopics(bool $includeDeleted = false, ?Pagination $pagination = null): array {
|
||||
if(!$this->canHaveTopics())
|
||||
return [];
|
||||
|
@ -363,6 +375,63 @@ class ForumCategory {
|
|||
return $lastTopic;
|
||||
}
|
||||
|
||||
// This function is really fucking expensive and should only be called by cron
|
||||
// Optimise this as much as possible at some point
|
||||
public function synchronise(bool $save = true): array {
|
||||
$topics = 0; $posts = 0; $topicStats = [];
|
||||
|
||||
$children = $this->getChildren();
|
||||
foreach($children as $child) {
|
||||
$stats = $child->synchronise($save);
|
||||
$topics += $stats['topics'];
|
||||
$posts += $stats['posts'];
|
||||
if(empty($topicStats) || (!empty($stats['topic_stats']) && $stats['topic_stats']['last_post_time'] > $topicStats['last_post_time']))
|
||||
$topicStats = $stats['topic_stats'];
|
||||
}
|
||||
|
||||
$getCounts = DB::prepare(
|
||||
'SELECT :forum as `target_forum_id`, ('
|
||||
. ' SELECT COUNT(`topic_id`)'
|
||||
. ' FROM `msz_forum_topics`'
|
||||
. ' WHERE `forum_id` = `target_forum_id`'
|
||||
. ' AND `topic_deleted` IS NULL'
|
||||
. ') AS `topics`, ('
|
||||
. ' SELECT COUNT(`post_id`)'
|
||||
. ' FROM `msz_forum_posts`'
|
||||
. ' WHERE `forum_id` = `target_forum_id`'
|
||||
. ' AND `post_deleted` IS NULL'
|
||||
. ') AS `posts`'
|
||||
);
|
||||
$getCounts->bind('forum', $this->getId());
|
||||
$counts = $getCounts->fetch();
|
||||
$topics += $counts['topics'];
|
||||
$posts += $counts['posts'];
|
||||
|
||||
foreach($this->getTopics() as $topic) {
|
||||
$stats = $topic->synchronise($save);
|
||||
if(empty($topicStats) || $stats['last_post_time'] > $topicStats['last_post_time'])
|
||||
$topicStats = $stats;
|
||||
}
|
||||
|
||||
if($save && !$this->isRoot()) {
|
||||
$setCounts = \Misuzu\DB::prepare(
|
||||
'UPDATE `msz_forum_categories`'
|
||||
. ' SET `forum_count_topics` = :topics, `forum_count_posts` = :posts'
|
||||
. ' WHERE `forum_id` = :forum'
|
||||
);
|
||||
$setCounts->bind('forum', $this->getId());
|
||||
$setCounts->bind('topics', $topics);
|
||||
$setCounts->bind('posts', $posts);
|
||||
$setCounts->execute();
|
||||
}
|
||||
|
||||
return [
|
||||
'topics' => $topics,
|
||||
'posts' => $posts,
|
||||
'topic_stats' => $topicStats,
|
||||
];
|
||||
}
|
||||
|
||||
public static function root(): self {
|
||||
static $root = null;
|
||||
if($root === null) {
|
||||
|
|
|
@ -13,6 +13,8 @@ class ForumPostNotFoundException extends ForumPostException {}
|
|||
class ForumPostCreationFailedException extends ForumPostException {}
|
||||
|
||||
class ForumPost {
|
||||
public const PER_PAGE = 10;
|
||||
|
||||
// Database fields
|
||||
private $post_id = -1;
|
||||
private $topic_id = -1;
|
||||
|
|
|
@ -15,6 +15,13 @@ class ForumTopic {
|
|||
public const TYPE_ANNOUNCEMENT = 2;
|
||||
public const TYPE_GLOBAL_ANNOUNCEMENT = 3;
|
||||
|
||||
public const TYPES = [
|
||||
self::TYPE_DISCUSSION,
|
||||
self::TYPE_STICKY,
|
||||
self::TYPE_ANNOUNCEMENT,
|
||||
self::TYPE_GLOBAL_ANNOUNCEMENT,
|
||||
];
|
||||
|
||||
public const TYPE_ORDER = [
|
||||
self::TYPE_GLOBAL_ANNOUNCEMENT,
|
||||
self::TYPE_ANNOUNCEMENT,
|
||||
|
@ -297,6 +304,39 @@ class ForumTopic {
|
|||
return $this->getCategory()->canView($user);
|
||||
}
|
||||
|
||||
public function synchronise(bool $save = true): array {
|
||||
$stats = DB::prepare(
|
||||
'SELECT :topic AS `topic`, ('
|
||||
. 'SELECT MIN(`post_id`) FROM `msz_forum_posts` WHERE `topic_id` = `topic`' // this shouldn't be deleteable without nuking the topic
|
||||
. ') AS `first_post`, ('
|
||||
. 'SELECT MAX(`post_id`) FROM `msz_forum_posts` WHERE `topic_id` = `topic` AND `post_deleted` IS NULL'
|
||||
. ') AS `last_post`, ('
|
||||
. 'SELECT COUNT(*) FROM `msz_forum_posts` WHERE `topic_id` = `topic` AND `post_deleted` IS NULL'
|
||||
. ') AS `posts`, ('
|
||||
. 'SELECT UNIX_TIMESTAMP(`post_created`) FROM `msz_forum_posts` WHERE `post_id` = `last_post`'
|
||||
. ') AS `last_post_time`'
|
||||
)->bind('topic', $this->getId())->fetch();
|
||||
|
||||
if($save) {
|
||||
$this->topic_post_first = $stats['first_post'];
|
||||
$this->topic_post_last = $stats['last_post'];
|
||||
$this->topic_count_posts = $stats['posts'];
|
||||
DB::prepare(
|
||||
'UPDATE `msz_forum_topics`'
|
||||
. ' SET `topic_post_first` = :first'
|
||||
. ', `topic_post_last` = :last'
|
||||
. ', `topic_count_posts` = :posts'
|
||||
. ' WHERE `topic_id` = :topic'
|
||||
) ->bind('first', $this->topic_post_first)
|
||||
->bind('last', $this->topic_post_last)
|
||||
->bind('posts', $this->topic_count_posts)
|
||||
->bind('topic', $this->getId())
|
||||
->execute();
|
||||
}
|
||||
|
||||
return $stats;
|
||||
}
|
||||
|
||||
private static function countQueryBase(): string {
|
||||
return sprintf(self::QUERY_SELECT, sprintf('COUNT(*)', self::TABLE));
|
||||
}
|
||||
|
|
|
@ -1,38 +1,4 @@
|
|||
<?php
|
||||
function forum_get_breadcrumbs(
|
||||
int $forumId,
|
||||
string $linkFormat = '/forum/forum.php?f=%d',
|
||||
string $rootFormat = '/forum/#f%d',
|
||||
array $indexLink = ['Forums' => '/forum/']
|
||||
): array {
|
||||
$breadcrumbs = [];
|
||||
$getBreadcrumb = \Misuzu\DB::prepare('
|
||||
SELECT `forum_id`, `forum_name`, `forum_type`, `forum_parent`
|
||||
FROM `msz_forum_categories`
|
||||
WHERE `forum_id` = :forum_id
|
||||
');
|
||||
|
||||
while($forumId > 0) {
|
||||
$getBreadcrumb->bind('forum_id', $forumId);
|
||||
$breadcrumb = $getBreadcrumb->fetch();
|
||||
|
||||
if(empty($breadcrumb)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$breadcrumbs[$breadcrumb['forum_name']] = sprintf(
|
||||
$breadcrumb['forum_parent'] === \Misuzu\Forum\ForumCategory::ROOT_ID
|
||||
&& $breadcrumb['forum_type'] === \Misuzu\Forum\ForumCategory::TYPE_CATEGORY
|
||||
? $rootFormat
|
||||
: $linkFormat,
|
||||
$breadcrumb['forum_id']
|
||||
);
|
||||
$forumId = $breadcrumb['forum_parent'];
|
||||
}
|
||||
|
||||
return array_reverse($breadcrumbs + $indexLink);
|
||||
}
|
||||
|
||||
function forum_get_parent_id(int $forumId): int {
|
||||
if($forumId < 1) {
|
||||
return 0;
|
||||
|
@ -172,94 +138,10 @@ function forum_mark_read(?int $forumId, int $userId): void {
|
|||
$doMark->execute();
|
||||
}
|
||||
|
||||
function forum_posting_info(int $userId): array {
|
||||
$getPostingInfo = \Misuzu\DB::prepare('
|
||||
SELECT
|
||||
u.`user_country`, u.`user_created`,
|
||||
(
|
||||
SELECT COUNT(`post_id`)
|
||||
FROM `msz_forum_posts`
|
||||
WHERE `user_id` = u.`user_id`
|
||||
AND `post_deleted` IS NULL
|
||||
) AS `user_forum_posts`,
|
||||
(
|
||||
SELECT `post_parse`
|
||||
FROM `msz_forum_posts`
|
||||
WHERE `user_id` = u.`user_id`
|
||||
AND `post_deleted` IS NULL
|
||||
ORDER BY `post_id` DESC
|
||||
LIMIT 1
|
||||
) AS `user_post_parse`
|
||||
FROM `msz_users` as u
|
||||
WHERE `user_id` = :user_id
|
||||
');
|
||||
$getPostingInfo->bind('user_id', $userId);
|
||||
return $getPostingInfo->fetch();
|
||||
}
|
||||
|
||||
function forum_count_synchronise(int $forumId = \Misuzu\Forum\ForumCategory::ROOT_ID, bool $save = true): array {
|
||||
static $getChildren = null;
|
||||
static $getCounts = null;
|
||||
static $setCounts = null;
|
||||
|
||||
if(is_null($getChildren)) {
|
||||
$getChildren = \Misuzu\DB::prepare('
|
||||
SELECT `forum_id`, `forum_parent`
|
||||
FROM `msz_forum_categories`
|
||||
WHERE `forum_parent` = :parent
|
||||
');
|
||||
try {
|
||||
return \Misuzu\Forum\ForumCategory::byId($forumId)->synchronise($save);
|
||||
} catch(\Misuzu\Forum\ForumCategoryNotFoundException $ex) {
|
||||
return ['topics' => 0, 'posts' => 0];
|
||||
}
|
||||
|
||||
if(is_null($getCounts)) {
|
||||
$getCounts = \Misuzu\DB::prepare('
|
||||
SELECT :forum as `target_forum_id`,
|
||||
(
|
||||
SELECT COUNT(`topic_id`)
|
||||
FROM `msz_forum_topics`
|
||||
WHERE `forum_id` = `target_forum_id`
|
||||
AND `topic_deleted` IS NULL
|
||||
) AS `count_topics`,
|
||||
(
|
||||
SELECT COUNT(`post_id`)
|
||||
FROM `msz_forum_posts`
|
||||
WHERE `forum_id` = `target_forum_id`
|
||||
AND `post_deleted` IS NULL
|
||||
) AS `count_posts`
|
||||
');
|
||||
}
|
||||
|
||||
if($save && is_null($setCounts)) {
|
||||
$setCounts = \Misuzu\DB::prepare('
|
||||
UPDATE `msz_forum_categories`
|
||||
SET `forum_count_topics` = :topics,
|
||||
`forum_count_posts` = :posts
|
||||
WHERE `forum_id` = :forum_id
|
||||
');
|
||||
}
|
||||
|
||||
$getChildren->bind('parent', $forumId);
|
||||
$children = $getChildren->fetchAll();
|
||||
|
||||
$topics = 0;
|
||||
$posts = 0;
|
||||
|
||||
foreach($children as $child) {
|
||||
$childCount = forum_count_synchronise($child['forum_id'], $save);
|
||||
$topics += $childCount['topics'];
|
||||
$posts += $childCount['posts'];
|
||||
}
|
||||
|
||||
$getCounts->bind('forum', $forumId);
|
||||
$counts = $getCounts->fetch();
|
||||
$topics += $counts['count_topics'];
|
||||
$posts += $counts['count_posts'];
|
||||
|
||||
if($forumId > 0 && $save) {
|
||||
$setCounts->bind('forum_id', $forumId);
|
||||
$setCounts->bind('topics', $topics);
|
||||
$setCounts->bind('posts', $posts);
|
||||
$setCounts->execute();
|
||||
}
|
||||
|
||||
return compact('topics', 'posts');
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
define('MSZ_FORUM_POSTS_PER_PAGE', 10);
|
||||
|
||||
function forum_post_create(
|
||||
int $topicId,
|
||||
int $forumId,
|
||||
|
|
|
@ -1,32 +1,11 @@
|
|||
<?php
|
||||
define('MSZ_TOPIC_TYPE_DISCUSSION', 0);
|
||||
define('MSZ_TOPIC_TYPE_STICKY', 1);
|
||||
define('MSZ_TOPIC_TYPE_ANNOUNCEMENT', 2);
|
||||
define('MSZ_TOPIC_TYPE_GLOBAL_ANNOUNCEMENT', 3);
|
||||
define('MSZ_TOPIC_TYPES', [
|
||||
MSZ_TOPIC_TYPE_DISCUSSION,
|
||||
MSZ_TOPIC_TYPE_STICKY,
|
||||
MSZ_TOPIC_TYPE_ANNOUNCEMENT,
|
||||
MSZ_TOPIC_TYPE_GLOBAL_ANNOUNCEMENT,
|
||||
]);
|
||||
|
||||
define('MSZ_TOPIC_TYPE_ORDER', [ // in which order to display topics, only add types here that should appear above others
|
||||
MSZ_TOPIC_TYPE_GLOBAL_ANNOUNCEMENT,
|
||||
MSZ_TOPIC_TYPE_ANNOUNCEMENT,
|
||||
MSZ_TOPIC_TYPE_STICKY,
|
||||
]);
|
||||
|
||||
function forum_topic_is_valid_type(int $type): bool {
|
||||
return in_array($type, MSZ_TOPIC_TYPES, true);
|
||||
}
|
||||
|
||||
function forum_topic_create(
|
||||
int $forumId,
|
||||
int $userId,
|
||||
string $title,
|
||||
int $type = MSZ_TOPIC_TYPE_DISCUSSION
|
||||
int $type = \Misuzu\Forum\ForumTopic::TYPE_DISCUSSION
|
||||
): int {
|
||||
if(empty($title) || !forum_topic_is_valid_type($type)) {
|
||||
if(empty($title) || !in_array($type, \Misuzu\Forum\ForumTopic::TYPES)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -54,7 +33,7 @@ function forum_topic_update(int $topicId, ?string $title, ?int $type = null): bo
|
|||
$title = null;
|
||||
}
|
||||
|
||||
if($type !== null && !forum_topic_is_valid_type($type)) {
|
||||
if($type !== null && !in_array($type, \Misuzu\Forum\ForumTopic::TYPES)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -220,15 +199,15 @@ function forum_topic_listing_user(
|
|||
ON lr.`role_id` = lu.`display_role`
|
||||
WHERE au.`user_id` = :author_id
|
||||
%1$s
|
||||
ORDER BY FIELD(t.`topic_type`, %4$s) DESC, t.`topic_bumped` DESC
|
||||
ORDER BY FIELD(t.`topic_type`, %4$s), t.`topic_bumped` DESC
|
||||
%2$s
|
||||
',
|
||||
$showDeleted ? '' : 'AND t.`topic_deleted` IS NULL',
|
||||
$hasPagination ? 'LIMIT :offset, :take' : '',
|
||||
MSZ_TOPIC_TYPE_GLOBAL_ANNOUNCEMENT,
|
||||
implode(',', array_reverse(MSZ_TOPIC_TYPE_ORDER)),
|
||||
\Misuzu\Forum\ForumTopic::TYPE_GLOBAL_ANNOUNCEMENT,
|
||||
implode(',', \Misuzu\Forum\ForumTopic::TYPE_ORDER),
|
||||
$showDeleted ? '' : 'AND `post_deleted` IS NULL',
|
||||
MSZ_FORUM_POSTS_PER_PAGE
|
||||
\Misuzu\Forum\ForumPost::PER_PAGE
|
||||
));
|
||||
$getTopics->bind('author_id', $authorId);
|
||||
$getTopics->bind('user_id', $userId);
|
||||
|
|
|
@ -46,7 +46,6 @@ class ForumCategoryHandler extends ForumHandler {
|
|||
|
||||
$response->setTemplate('forum.forum', [
|
||||
'forum_perms' => $perms,
|
||||
'forum_breadcrumbs' => forum_get_breadcrumbs($categoryInfo->getId()),
|
||||
'forum_info' => $categoryInfo,
|
||||
'forum_pagination' => $pagination,
|
||||
'can_view_deleted' => $canViewDeleted,
|
||||
|
|
|
@ -348,6 +348,17 @@ class User implements HasRankInterface, JsonSerializable {
|
|||
return intval($this->getBirthdate()->diff(new DateTime('now', new DateTimeZone('UTC')))->format('%y'));
|
||||
}
|
||||
|
||||
private $preferredParser = null;
|
||||
public function getPreferredParser(): int {
|
||||
if($this->preferredParser === null)
|
||||
$this->preferredParser = DB::prepare(
|
||||
'SELECT `post_parse` FROM `msz_forum_posts`'
|
||||
. ' WHERE `user_id` = :user AND `post_deleted` IS NULL'
|
||||
. ' ORDER BY `post_id` DESC LIMIT 1'
|
||||
)->bind('user', $this->getId())->fetchColumn() ?? Parser::BBCODE;
|
||||
return $this->preferredParser;
|
||||
}
|
||||
|
||||
public function profileFields(bool $filterEmpty = true): array {
|
||||
if(($userId = $this->getId()) < 1)
|
||||
return [];
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
}) %}
|
||||
|
||||
{% block content %}
|
||||
{{ forum_header(forum_info.name, forum_breadcrumbs, true, canonical_url, [
|
||||
{{ forum_header(forum_info, true, canonical_url, [
|
||||
{
|
||||
'html': '<i class="far fa-check-circle"></i> Mark as Read',
|
||||
'url': url('forum-mark-single', {'forum': forum_info.id}),
|
||||
|
@ -26,5 +26,5 @@
|
|||
{{ category_tools }}
|
||||
{% endif %}
|
||||
|
||||
{{ forum_header('', forum_breadcrumbs) }}
|
||||
{{ forum_header(forum_info, false) }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -13,29 +13,28 @@
|
|||
{% from 'macros.twig' import container_title %}
|
||||
|
||||
{% if category.canView(user) %}
|
||||
{% set children = category.children(user) %}
|
||||
|
||||
{% set children = category.children(user) %}
|
||||
{% if children is not empty or category.isCategoryForum %}
|
||||
{% set icon = title is not empty ? 'fas fa-folder fa-fw' : category.icon %}
|
||||
<div class="container forum__categories"
|
||||
{% if not category.colour.inherit %}style="--accent-colour: {{ category.colour }}"{% endif %}
|
||||
{% if not category.isRoot %}id="{{ category.id }}"{% endif %}>
|
||||
{{ container_title('<span class="' ~ icon ~ '"></span> ' ~ title|default(category.name)) }}
|
||||
|
||||
{% if children is not empty or category.isCategoryForum %}
|
||||
{% set icon = title is not empty ? 'fas fa-folder fa-fw' : category.icon %}
|
||||
<div class="container forum__categories"
|
||||
{% if not category.colour.inherit %}style="--accent-colour: {{ category.colour }}"{% endif %}
|
||||
{% if not category.isRoot %}id="{{ category.id }}"{% endif %}>
|
||||
{{ container_title('<span class="' ~ icon ~ '"></span> ' ~ title|default(category.name)) }}
|
||||
|
||||
{% if children is empty %}
|
||||
<div class="forum__categories__empty">
|
||||
This category is empty.
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="forum__categories__list">
|
||||
{% for category in children %}
|
||||
{{ forum_category_entry(category, user) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if children is empty %}
|
||||
<div class="forum__categories__empty">
|
||||
This category is empty.
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="forum__categories__list">
|
||||
{% for category in children %}
|
||||
{{ forum_category_entry(category, user) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
@ -62,32 +61,29 @@
|
|||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro forum_header(title, breadcrumbs, omit_last_breadcrumb, title_url, actions) %}
|
||||
{% macro forum_header(info, is_top, title_url, actions, is_topic, title) %}
|
||||
<div class="container forum__header">
|
||||
{% if breadcrumbs is iterable and breadcrumbs|length > 0 %}
|
||||
<div class="forum__header__breadcrumbs">
|
||||
{% for name, url in breadcrumbs %}
|
||||
{% if url != breadcrumbs|first %}
|
||||
<div class="forum__header__breadcrumb__separator">
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% set parents = info.parentTree %}
|
||||
<div class="forum__header__breadcrumbs">
|
||||
{% for parent in parents %}
|
||||
<a href="{{ parent.url }}" class="forum__header__breadcrumb">{{ parent.name }}</a>
|
||||
<div class="forum__header__breadcrumb__separator">
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if not is_top or is_topic %}
|
||||
<a href="{{ info.url }}" class="forum__header__breadcrumb">{{ info.name }}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if not (omit_last_breadcrumb|default(false) and url == breadcrumbs|last) %}
|
||||
<a href="{{ url }}" class="forum__header__breadcrumb">{{ name }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if title|length > 0 %}
|
||||
{% if is_top %}
|
||||
{% if title_url|length > 0 %}
|
||||
<a class="forum__header__title" href="{{ title_url }}">
|
||||
{{ title }}
|
||||
{{ title|default(info.name) }}
|
||||
</a>
|
||||
{% else %}
|
||||
<div class="forum__header__title forum__header__title--fill">
|
||||
{{ title }}
|
||||
{{ title|default(info.name) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
@ -495,16 +491,16 @@
|
|||
{% macro forum_topic_entry_old(topic, topic_icon, topic_unread) %}
|
||||
{% from 'macros.twig' import avatar %}
|
||||
{% set topic_unread = topic_unread|default(topic.topic_unread|default(false)) %}
|
||||
{% set topic_important = topic.topic_type == constant('MSZ_TOPIC_TYPE_STICKY') or topic.topic_type == constant('MSZ_TOPIC_TYPE_ANNOUNCEMENT') or topic.topic_type == constant('MSZ_TOPIC_TYPE_GLOBAL_ANNOUNCEMENT') %}
|
||||
{% set topic_important = topic.topic_type == constant('\\Misuzu\\Forum\\ForumTopic::TYPE_STICKY') or topic.topic_type == constant('\\Misuzu\\Forum\\ForumTopic::TYPE_ANNOUNCEMENT') or topic.topic_type == constant('\\Misuzu\\Forum\\ForumTopic::TYPE_GLOBAL_ANNOUNCEMENT') %}
|
||||
{% set has_priority_voting = topic.forum_type in constant('\\Misuzu\\Forum\\ForumCategory::HAS_PRIORITY_VOTES') %}
|
||||
|
||||
{% if topic_icon is null %}
|
||||
{% if topic.topic_deleted is defined and topic.topic_deleted is not null %}
|
||||
{% set topic_icon = 'fas fa-trash-alt' %}
|
||||
{% elseif topic.topic_type is defined and topic.topic_type != constant('MSZ_TOPIC_TYPE_DISCUSSION') %}
|
||||
{% if topic.topic_type == constant('MSZ_TOPIC_TYPE_ANNOUNCEMENT') or topic.topic_type == constant('MSZ_TOPIC_TYPE_GLOBAL_ANNOUNCEMENT') %}
|
||||
{% elseif topic.topic_type is defined and topic.topic_type != constant('\\Misuzu\\Forum\\ForumTopic::DISCUSSION') %}
|
||||
{% if topic.topic_type == constant('\\Misuzu\\Forum\\ForumTopic::TYPE_ANNOUNCEMENT') or topic.topic_type == constant('\\Misuzu\\Forum\\ForumTopic::GLOBAL_ANNOUNCEMENT') %}
|
||||
{% set topic_icon = 'fas fa-bullhorn' %}
|
||||
{% elseif topic.topic_type == constant('MSZ_TOPIC_TYPE_STICKY') %}
|
||||
{% elseif topic.topic_type == constant('\\Misuzu\\Forum\\ForumTopic::STICKY') %}
|
||||
{% set topic_icon = 'fas fa-thumbtack' %}
|
||||
{% endif %}
|
||||
{% elseif topic.topic_locked is defined and topic.topic_locked is not null %}
|
||||
|
|
|
@ -13,6 +13,13 @@
|
|||
{{ input_hidden('post[mode]', posting_mode) }}
|
||||
{{ input_csrf() }}
|
||||
{{ forum_header(
|
||||
posting_forum,
|
||||
true,
|
||||
is_reply and not is_opening
|
||||
? url('forum-topic', {'topic': posting_topic.id})
|
||||
: '',
|
||||
[],
|
||||
true,
|
||||
is_reply and not is_opening
|
||||
? posting_topic.title
|
||||
: input_text(
|
||||
|
@ -21,12 +28,7 @@
|
|||
posting_defaults.title|default(posting_topic.title|default('')),
|
||||
'text',
|
||||
'Enter your title here...'
|
||||
),
|
||||
posting_breadcrumbs,
|
||||
false,
|
||||
is_reply and not is_opening
|
||||
? url('forum-topic', {'topic': posting_topic.id})
|
||||
: ''
|
||||
)
|
||||
) }}
|
||||
|
||||
{% if posting_post is defined %}
|
||||
|
@ -52,12 +54,12 @@
|
|||
<span class="forum__post__username">{{ posting_post.poster_name|default(current_user.username) }}</span>
|
||||
|
||||
<div class="forum__post__icons">
|
||||
<div class="flag flag--{{ posting_post.poster_country|default(posting_info.user_country)|lower }}" title="{{ posting_post.poster_country|default(posting_info.user_country)|country_name }}"></div>
|
||||
<div class="forum__post__posts-count">{{ posting_post.poster_post_count|default(posting_info.user_forum_posts)|number_format }} posts</div>
|
||||
<div class="flag flag--{{ posting_post.poster_country|default(posting_user.country)|lower }}" title="{{ posting_post.poster_country|default(posting_user.country)|country_name }}"></div>
|
||||
<div class="forum__post__posts-count">{{ posting_post.poster_post_count|default(posting_user.forumPostCount)|number_format }} posts</div>
|
||||
</div>
|
||||
|
||||
<div class="forum__post__joined">
|
||||
joined <time datetime="{{ posting_post.poster_joined|default(posting_info.user_created)|date('c') }}" title="{{ posting_post.poster_joined|default(posting_info.user_created)|date('r') }}">{{ posting_post.poster_joined|default(posting_info.user_created)|time_diff }}</time>
|
||||
joined <time datetime="{{ posting_post.poster_joined|default(posting_user.createdTime)|date('c') }}" title="{{ posting_post.poster_joined|default(posting_user.createdTime)|date('r') }}">{{ posting_post.poster_joined|default(posting_user.createdTime)|time_diff }}</time>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -140,7 +142,7 @@
|
|||
{{ input_select(
|
||||
'post[parser]',
|
||||
constant('\\Misuzu\\Parsers\\Parser::NAMES'),
|
||||
posting_defaults.parser|default(posting_post.post_parse|default(posting_info.user_post_parse|default(constant('\\Misuzu\\Parsers\\Parser::BBCODE')))),
|
||||
posting_defaults.parser|default(posting_post.post_parse|default(posting_user.preferredParser)),
|
||||
null, null, false, 'forum__post__dropdown js-forum-posting-parser'
|
||||
) }}
|
||||
{% if is_opening and posting_types|length > 1 %}
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
] %}
|
||||
|
||||
{% block content %}
|
||||
{{ forum_header(topic_info.title, topic_breadcrumbs, false, canonical_url, topic_actions) }}
|
||||
{{ forum_header(topic_info.category, true, canonical_url, topic_actions, true, topic_info.title) }}
|
||||
{{ topic_notice }}
|
||||
{% if topic_info.hasPriorityVoting %}
|
||||
{{ forum_priority_votes(topic_info, current_user|default(null)) }}
|
||||
|
@ -67,5 +67,5 @@
|
|||
{{ forum_post_listing(topic_info.posts(topic_can_view_deleted, topic_pagination), current_user|default(null), topic_perms) }}
|
||||
{{ topic_tools }}
|
||||
{{ topic_notice }}
|
||||
{{ forum_header('', topic_breadcrumbs) }}
|
||||
{{ forum_header(topic_info.category, false) }}
|
||||
{% endblock %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue