misuzu/templates/forum/topic.twig

121 lines
5 KiB
Twig

{% extends 'forum/master.twig' %}
{% from 'macros.twig' import pagination %}
{% from 'forum/macros.twig' import forum_post_listing, forum_topic_buttons, forum_topic_notice, forum_header %}
{% set title = topic_info.title %}
{% set canonical_url = url('forum-topic', {
'topic': topic_info.id,
'page': topic_pagination.page > 1 ? topic_pagination.page : 0,
}) %}
{% set topic_actions = [
{
html: '<i class="fas fa-trash-alt fa-fw"></i> <span class="js-action-text">Delete</span>',
display: topic_can_delete,
method: 'DELETE',
url: url('forum-topic-delete', { topic: topic_info.id }),
confirm: 'Are you sure you want to delete this topic?',
disableWith: 'Deleting...',
disableWithTarget: '.js-action-text',
withCsrf: true,
refreshOnSuccess: topic_can_delete_any,
redirectOnSuccess: (topic_can_delete_any ? false : url('forum-category', { forum: category_info.id })),
},
{
html: '<i class="fas fa-magic fa-fw"></i> <span class="js-action-text">Restore</span>',
display: topic_can_nuke_or_restore,
method: 'POST',
url: url('forum-topic-restore', { topic: topic_info.id }),
confirm: 'Are you sure you want to restore this topic?',
disableWith: 'Restoring...',
disableWithTarget: '.js-action-text',
withCsrf: true,
refreshOnSuccess: true,
},
{
html: '<i class="fas fa-radiation-alt fa-fw"></i> <span class="js-action-text">Permanently Delete</span>',
display: topic_can_nuke_or_restore,
method: 'POST',
url: url('forum-topic-nuke', { topic: topic_info.id }),
confirm: 'Are you sure you want to PERMANENTLY DELETE this topic?',
disableWith: 'Nuking...',
disableWithTarget: '.js-action-text',
withCsrf: true,
redirectOnSuccess: url('forum-category', { forum: category_info.id }),
},
{
html: '<i class="fas fa-arrow-alt-circle-up fa-fw"></i> <span class="js-action-text">Bump</span>',
display: topic_can_bump,
method: 'POST',
url: url('forum-topic-bump', { topic: topic_info.id }),
disableWith: 'Bumping...',
disableWithTarget: '.js-action-text',
withCsrf: true,
},
{
html: '<i class="fas fa-lock fa-fw"></i> <span class="js-action-text">Lock</span>',
display: topic_can_lock and not topic_info.locked,
method: 'POST',
url: url('forum-topic-lock', { topic: topic_info.id }),
disableWith: 'Locking...',
disableWithTarget: '.js-action-text',
withCsrf: true,
refreshOnSuccess: true,
},
{
html: '<i class="fas fa-lock-open fa-fw"></i> <span class="js-action-text">Unlock</span>',
display: topic_can_lock and topic_info.locked,
method: 'POST',
url: url('forum-topic-unlock', { topic: topic_info.id }),
disableWith: 'Unlocking...',
disableWithTarget: '.js-action-text',
withCsrf: true,
refreshOnSuccess: true,
},
] %}
{% block content %}
<div class="forum-float forum-float-top">
{{ forum_header(topic_info.title, topic_breadcrumbs, false, canonical_url, topic_actions) }}
{% if topic_info.locked or category_info.archived %}
{% set body %}
{% if category_info.archived %}
This topic has been <span class="forum__status__emphasis">archived</span>.
{% else %}
This topic was locked
<time class="forum__status__emphasis" datetime="{{ topic_info.lockedTime|date('c') }}"
title="{{ topic_info.lockedTime|date('r') }}">{{ topic_info.lockedTime|time_format }}</time>.
{% endif %}
{% endset %}
{{ forum_topic_notice(category_info.archived ? 'archive' : 'lock', body) }}
{% endif %}
{% if topic_redir_info is defined %}
{% set body %}
This topic redirects to <span class="forum__status__emphasis"><a href="{{ topic_redir_info.linkTarget }}" class="link">{{ topic_redir_info.linkTarget }}</a></span>.
{% endset %}
{{ forum_topic_notice('share', body) }}
{% endif %}
</div>
{{ forum_post_listing(topic_posts, topic_user_id, topic_perms) }}
<div class="forum-float forum-float-bottom">
{% set posts_pagination = pagination(topic_pagination, 'forum-topic', {'topic': topic_info.id}) %}
{% if can_reply or posts_pagination|trim|length > 0 %}
<div class="container forum__actions">
<div class="forum__actions__buttons">
{% if can_reply %}
<a href="{{ url('forum-reply-new', {'topic': topic_info.id}) }}" class="input__button">Reply</a>
{% endif %}
</div>
<div class="forum__actions__pagination">
{{ posts_pagination }}
</div>
</div>
{% endif %}
</div>
{% endblock %}