This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/resources/views/yuuno/forum/topic.twig

289 lines
14 KiB
Twig
Raw Normal View History

2017-03-23 15:01:53 +00:00
{% extends '@yuuno/master.twig' %}
2016-11-12 01:52:51 +00:00
{% set forumBackLink = route('forums.forum', forum.id) %}
{% set title = topic is defined ? topic.title : 'Creating topic in ' ~ forum.name %}
2016-07-30 13:48:09 +00:00
{% if topic is defined %}
2016-11-02 18:58:51 +00:00
{% if forum.perms.reply
and (
2016-07-30 13:48:09 +00:00
topic.status != 1
2016-11-02 18:58:51 +00:00
or forum.perms.changeStatus
) %}
{% set forumReplyLink %}#reply{% endset %}
{% endif %}
2016-11-02 18:58:51 +00:00
{% if forum.perms.changeType
or forum.perms.changeStatus
or forum.perms.topicMove
or forum.perms.deleteAny %}
{% set showMod = true %}
{% endif %}
2016-11-02 18:58:51 +00:00
{% if forum.perms.changeType %}
2016-07-30 13:48:09 +00:00
{% set forumSticky = topic.type == 1 ? true : false %}
{% set forumAnnounce = topic.type == 2 ? true : false %}
{% endif %}
2016-11-02 18:58:51 +00:00
{% if forum.perms.changeStatus %}
2016-07-30 13:48:09 +00:00
{% set forumLock = topic.status == 1 ? true : false %}
{% endif %}
2016-11-02 18:58:51 +00:00
{% if forum.perms.topicMove %}
2016-12-11 01:00:47 +00:00
{% set forumMove = true %}
2016-07-30 13:48:09 +00:00
{% if topic.oldForum %}
{% set forumRestore = true %}
{% endif %}
2016-07-31 01:32:37 +00:00
{% if topic.forum != config('forum.trash') %}
{% set forumTrash = true %}
{% endif %}
{% endif %}
2016-11-02 18:58:51 +00:00
{% if forum.perms.deleteAny %}
2016-07-31 01:32:37 +00:00
{% if topic.forum == config('forum.trash') %}
{% set forumPrune = true %}
{% endif %}
{% endif %}
2016-07-30 13:48:09 +00:00
{% set posts = topic.posts|batch(10) %}
2016-12-12 22:22:09 +00:00
{% set pagination_pages = posts %}
{% set pagination_url = route('forums.topic', topic.id) %}
{% endif %}
{% block js %}
<script type="text/javascript">
2016-09-19 18:32:24 +00:00
function deletePost(id) {
var confirm = new Sakura.Dialogue;
confirm.SetType(Sakura.DialogueType.Confirm);
2016-12-11 01:00:47 +00:00
confirm.Title = "Deleting post " + id;
2016-09-19 18:32:24 +00:00
confirm.Text = "Are you sure?";
confirm.AddCallback(Sakura.DialogueButton.Yes, function () {
var deleter = new Sakura.AJAX;
deleter.SetUrl("{{ route('forums.post.delete', 1) }}".replace('1', id));
deleter.AddCallback(200, function () {
Sakura.DOM.Remove(Sakura.DOM.ID('p' + id));
});
deleter.AddCallback(0, function () {
var error = new Sakura.Dialogue;
2016-12-08 23:10:56 +00:00
error.Title = "Error";
2016-09-19 18:32:24 +00:00
error.Text = "Deletion failed!";
error.Display();
});
deleter.Start(Sakura.HTTPMethod.DELETE);
this.Close();
});
confirm.Display();
}
2016-12-11 01:00:47 +00:00
{% if forumMove is defined %}
function yuunoMoveTopic() {
var btn = Sakura.DOM.ID('topic-move-btn'),
moveDiag = new Sakura.Dialogue,
client = new Sakura.AJAX,
title = "Moving topic '{{ topic.title }}'",
unsetSpinner = function () {
Sakura.DOM.RemoveClass(btn, ['input__button--disabled']);
btn.innerHTML = '<i class="fa fa-arrow-circle-o-right"></i>';
};
Sakura.DOM.AddClass(btn, ['input__button--disabled']);
btn.innerHTML = '<i class="fa fa-spinner fa-spin"></i>';
moveDiag.Title = title;
client.SetUrl("{{ route('forums.move-destinations') }}");
client.AddCallback(200, function () {
unsetSpinner();
moveDiag.SetType(Sakura.DialogueType.OKCancel);
moveDiag.Text = "Select a destination...";
moveDiag.DropDownItems.AddObject(client.JSON());
moveDiag.AddCallback(Sakura.DialogueButton.Ok, function () {
var returnDiag = new Sakura.Dialogue;
client.Reset();
client.SetUrl("{{ route('forums.topic.move', topic.id) }}");
client.Form();
client.SetSend({
"session": Sakura.Config.SessionId,
"destination": moveDiag.DropDownSelected.Key
});
client.AddCallback(200, function () {
window.location.assign(client.Response());
});
client.AddCallback(404, function () {
returnDiag.Title = "Error";
returnDiag.Text = "Destination forum doesn't exist!";
returnDiag.Display();
});
client.AddCallback(403, function () {
returnDiag.Title = "Error";
returnDiag.Text = "You aren't allowed to move topics!";
returnDiag.Display();
});
client.AddCallback(0, function () {
returnDiag.Title = "Something happened!";
returnDiag.Text = "Something happened!";
returnDiag.Display();
});
client.Start(Sakura.HTTPMethod.POST);
moveDiag.Close();
});
moveDiag.Display();
});
client.AddCallback(0, function () {
unsetSpinner();
moveDiag.Text = "Failed to fetch destinations.";
moveDiag.Display();
});
client.Start(Sakura.HTTPMethod.GET);
}
{% endif %}
hljs.initHighlightingOnLoad();
</script>
{% endblock %}
{% block content %}
2016-11-12 01:52:51 +00:00
<div class="content">
<div class="content__header">
{{ forum.name }} / <span id="topicTitle">
{{ topic.title|default(null) }}
</span>
</div>
2017-03-23 15:01:53 +00:00
{% include '@yuuno/forum/elements/forumBtns.twig' %}
2016-11-12 01:52:51 +00:00
2016-11-12 18:49:38 +00:00
<div class="posts">
2016-11-09 18:32:23 +00:00
{% if topic is defined %}
2016-11-12 01:52:51 +00:00
2016-11-09 18:32:23 +00:00
{% set postingAction = route('forums.topic.reply', topic.id) %}
{% for post in posts[get.page|default(1) - 1] %}
2016-11-12 18:49:38 +00:00
<div class="post" id="p{{ post.id }}">
<div class="post__details">
<div class="post__user">
{% if post.poster.activated or post.poster.restricted %}
<a class="post__username" href="{{ route('user.profile', post.poster.id) }}" style="color: {{ post.poster.colour }}; text-shadow: 0 0 5px {% if post.poster.colour != 'inherit' %}{{ post.poster.colour }}{% else %}#222{% endif %}">
{{ post.poster.username }}
</a>
2016-12-09 19:25:22 +00:00
<div class="avatar avatar--border post__avatar" style="background-image: url('{{ route('user.avatar', post.poster.id) }}')"></div>
2016-11-12 18:49:38 +00:00
<div class="post__usertitle">{{ post.poster.title }}</div>
<img src="/images/tenshi.png" alt="Tenshi"{% if not post.poster.isPremium %} style="opacity: 0;"{% endif %}>
2016-12-09 19:25:22 +00:00
<img src="/images/flags/{{ post.poster.country|lower }}.png" alt="{{ post.poster.country }}" title="{{ post.poster.country(true) }}">
2016-11-12 18:49:38 +00:00
{% if post.poster.id == (topic.posts|first).poster.id %}
<img src="/images/op.png" alt="OP" title="Original Poster">
{% endif %}
{% else %}
<span class="post__username post__username--deleted">deleted user</span>
{% endif %}
</div>
{% if user.isActive %}
<div class="post__actions">
2016-11-09 18:32:23 +00:00
{% if (user.id == post.poster.id and forum.perms.edit) or forum.perms.editAny %}
2016-11-12 18:49:38 +00:00
<a class="post__action fa fa-pencil-square-o" title="Edit this post" href="javascript:void(0);" onclick="editPost({{ post.id }});"></a>
{% endif %}
2016-11-09 18:32:23 +00:00
{% if (user.id == post.poster.id and forum.perms.delete) or forum.perms.deleteAny %}
2016-11-12 18:49:38 +00:00
<a class="post__action fa fa-trash" title="Delete this post" href="javascript:;" onclick="deletePost({{ post.id }})"></a>
2016-11-09 18:32:23 +00:00
{% endif %}
{% if not (post.poster.activated or post.poster.restricted or user.id == post.poster.id) %}
2016-11-12 18:49:38 +00:00
<a class="post__action fa fa-{% if user.isFriends(post.poster.id) == 2 %}heart{% else %}star{% endif %} friend-{{ post.poster.id }}-level" title="You are friends" {% if user.isFriends(post.poster.id) == 0 %}style="display: none;"{% endif %}></a>
<a class="post__action fa fa-user-{% if user.isFriends(post.poster.id) == 0 %}plus{% else %}times{% endif %} forum-friend-toggle friend-{{ post.poster.id }}-toggle" title="{% if user.isFriends(post.poster.id) == 0 %}Add {{ post.poster.username }} as a friend{% else %}Remove friend{% endif %}" href="javascript:void(0);" onclick="Sakura.Friend.{% if user.isFriends(post.poster.id) == 0 %}Add({{ post.poster.id }}){% else %}Remove({{ post.poster.id }}){% endif %}"></a>
<a class="post__action fa fa-flag" title="Report {{ post.poster.username }}" href="{{ route('user.report', post.poster.id) }}"></a>
2016-11-09 18:32:23 +00:00
{% endif %}
2016-11-12 18:49:38 +00:00
<a class="post__action fa fa-reply" title="Quote this post" href="javascript:void(0);" onclick="Sakura.Editor.QuotePost({{ post.id }}, '{{ post.poster.username }}', pText);"></a>
</div>
2016-11-12 18:49:38 +00:00
{% endif %}
</div>
<div class="post__contents">
<div class="post__info">
<a href="#p{{ post.id }}" class="post__title">
{{ post.subject|slice(0, 50) }}{% if post.subject|length > 50 %}...{% endif %}
</a>
<a href="{{ route('forums.post', post.id) }}" class="post__date">
#{{ post.id }} - <time class="time-ago" datetime="{{ post.time|date('r') }}">
{{ post.time|date(config('general.date_format')) }}
</time>
</a>
</div>
2016-11-12 18:49:38 +00:00
<div class="post__text bbcode">
2016-11-09 18:32:23 +00:00
{{ post.parsed|raw }}
</div>
2016-11-12 18:49:38 +00:00
2016-11-09 18:32:23 +00:00
{% if post.poster.signature and post.poster.perms.changeSignature %}
2016-11-12 18:49:38 +00:00
<div class="post__signature bbcode">
2017-03-22 20:54:48 +00:00
{{ post.poster.signature()|raw }}
2016-11-12 18:49:38 +00:00
</div>
{% endif %}
2016-11-12 18:49:38 +00:00
</div>
</div>
2016-11-09 18:32:23 +00:00
{% endfor %}
2016-11-12 01:52:51 +00:00
2016-11-09 18:32:23 +00:00
{% else %}
2016-11-12 01:52:51 +00:00
2016-11-09 18:32:23 +00:00
{% set postingAction = route('forums.new', forum.id) %}
2016-11-12 01:52:51 +00:00
2016-11-09 18:32:23 +00:00
{% endif %}
2016-11-12 01:52:51 +00:00
2016-07-30 13:48:09 +00:00
{% if forumReplyLink is defined or topic is not defined %}
2016-12-09 19:25:22 +00:00
<div class="post" id="postingPreview"{% if topic is defined %} style="display: none;"{% endif %}>
2016-11-12 18:49:38 +00:00
<div class="post__details">
<div class="post__user">
<a class="post__username" href="{{ route('user.profile', user.id) }}" style="color: {{ user.colour }}; text-shadow: 0 0 5px {% if user.colour != 'inherit' %}{{ user.colour }}{% else %}#222{% endif %}">
{{ user.username }}
</a>
2016-12-09 19:25:22 +00:00
<div class="avatar avatar--border post__avatar" style="background-image: url('{{ route('user.avatar', user.id) }}')"></div>
2016-11-12 18:49:38 +00:00
<div class="post__usertitle">{{ user.title }}</div>
<img src="/images/tenshi.png" alt="Tenshi"{% if not user.isPremium %} style="opacity: 0;"{% endif %}>
2016-12-09 19:25:22 +00:00
<img src="/images/flags/{{ user.country|lower }}.png" alt="{{ user.country }}" title="{{ user.country(true) }}">
2016-11-12 18:49:38 +00:00
{% if not topic is defined %}
<img src="/images/op.png" alt="OP" title="Original Poster">
{% endif %}
2016-11-09 18:32:23 +00:00
</div>
2016-11-12 18:49:38 +00:00
</div>
<div class="post__contents">
<div class="post__info">
<span id="previewTitle" class="post__title">
2016-12-09 19:25:22 +00:00
{% if topic is defined %}Re: {{ topic.title }}{% endif %}
2016-11-12 18:49:38 +00:00
</span>
<span id="previewMode" class="post__date">
Preview
</span>
2016-11-09 18:32:23 +00:00
</div>
2016-11-12 18:49:38 +00:00
<div class="post__text bbcode" id="previewText"></div>
2016-11-09 18:32:23 +00:00
{% if user.signature and user.perms.changeSignature %}
2016-11-12 18:49:38 +00:00
<div class="post__signature bbcode">
2017-03-22 20:54:48 +00:00
{{ user.signature()|raw }}
2016-11-09 18:32:23 +00:00
</div>
{% endif %}
2016-11-12 18:49:38 +00:00
</div>
</div>
{% endif %}
2016-11-12 18:49:38 +00:00
</div>
2016-11-12 01:52:51 +00:00
2016-11-09 18:32:23 +00:00
{% if forumReplyLink is defined or topic is not defined %}
2017-03-23 15:01:53 +00:00
{% include '@yuuno/forum/elements/replyForm.twig' %}
2016-11-09 18:32:23 +00:00
{% endif %}
2016-11-12 01:52:51 +00:00
2017-03-23 15:01:53 +00:00
{% include '@yuuno/forum/elements/forumBtns.twig' %}
</div>
{% endblock %}