405 lines
18 KiB
Twig
405 lines
18 KiB
Twig
{% macro forum_category_listing(forums, title, colour) %}
|
|
{% from _self import forum_category_entry %}
|
|
{% from 'macros.twig' import container_title %}
|
|
|
|
<div class="container forum__categories"{% if colour is not null %} style="{{ colour|html_colour('--accent-colour') }}"{% endif %}>
|
|
{{ container_title('<i class="fas fa-folder fa-fw"></i> ' ~ title) }}
|
|
|
|
{% if forums|length > 0 %}
|
|
<div class="forum__categories__list">
|
|
{% for forum in forums %}
|
|
{{ forum_category_entry(forum) }}
|
|
{% endfor %}
|
|
</div>
|
|
{% else %}
|
|
<div class="forum__categories__empty">
|
|
This category is empty.
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro forum_header(title, breadcrumbs, omit_last_breadcrumb) %}
|
|
<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 %}
|
|
|
|
{% 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 %}
|
|
<div class="forum__header__title">
|
|
{{ title }}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro forum_category_tools(info, perms, take, offset) %}
|
|
{% from 'macros.twig' import pagination %}
|
|
|
|
{% set can_topic = perms|perms_check(constant('MSZ_FORUM_PERM_CREATE_TOPIC')) %}
|
|
{% set pag = pagination(
|
|
info.forum_topic_count,
|
|
take,
|
|
offset,
|
|
url_construct('/forum/forum.php', {'f':info.forum_id}),
|
|
false,
|
|
null,
|
|
5
|
|
) %}
|
|
|
|
{% if can_topic or pag|trim|length > 0 %}
|
|
<div class="container forum__actions">
|
|
<div class="forum__actions__buttons">
|
|
{% if can_topic %}
|
|
<a href="{{ url_construct('/forum/posting.php', {'f':info.forum_id}) }}" class="input__button">New Topic</a>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="forum__actions__pagination">
|
|
{{ pag }}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro forum_topic_tools(info, take, offset, can_reply) %}
|
|
{% from 'macros.twig' import pagination %}
|
|
|
|
{% set pag = pagination(
|
|
info.topic_post_count,
|
|
take,
|
|
offset,
|
|
url_construct('/forum/topic.php', {'t':info.topic_id}),
|
|
false,
|
|
null,
|
|
5
|
|
) %}
|
|
|
|
{% if can_reply or pag|trim|length > 0 %}
|
|
<div class="container forum__actions">
|
|
<div class="forum__actions__buttons">
|
|
{% if can_reply %}
|
|
<a href="/forum/posting.php?t={{ info.topic_id }}" class="input__button">Reply</a>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="forum__actions__pagination">
|
|
{{ pag }}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro forum_category_entry(forum, forum_unread, forum_type) %}
|
|
{% set forum_type = forum_type|default(null) %}
|
|
{% set forum_unread = forum_unread|default(forum.forum_unread|default(false)) ? 'unread' : 'read' %}
|
|
|
|
{% if forum_type is null %}
|
|
{% if forum.forum_archived is defined and forum.forum_archived %}
|
|
{% set forum_type = 'fas fa-archive' %}
|
|
{% elseif forum.forum_type is defined and forum.forum_type != 0 %}
|
|
{% if forum.forum_type == 2 %}
|
|
{% set forum_type = 'fas fa-link' %}
|
|
{% elseif forum.forum_type == 1 %}
|
|
{% set forum_type = 'fas fa-folder' %}
|
|
{% endif %}
|
|
{% else %}
|
|
{% set forum_type = 'fas fa-comments' %}
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
<div class="forum__category">
|
|
<a href="/forum/forum.php?f={{ forum.forum_id }}" class="forum__category__link"></a>
|
|
|
|
<div class="forum__category__container">
|
|
<div class="forum__category__icon forum__category__icon--{{ forum_unread }}">
|
|
<i class="{{ forum_type }}"></i>
|
|
</div>
|
|
|
|
<div class="forum__category__details">
|
|
<div class="forum__category__title">
|
|
{{ forum.forum_name }}
|
|
</div>
|
|
|
|
<div class="forum__category__description">
|
|
{{ forum.forum_description|nl2br }}
|
|
</div>
|
|
|
|
{% if forum.forum_subforums is defined and forum.forum_subforums|length > 0 %}
|
|
<div class="forum__category__subforums">
|
|
{% for subforum in forum.forum_subforums %}
|
|
<a href="/forum/forum.php?f={{ subforum.forum_id }}"
|
|
class="forum__category__subforum{% if subforum.forum_unread %} forum__category__subforum--unread{% endif %}">
|
|
{{ subforum.forum_name }}
|
|
</a>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if forum.forum_type == 2 %}
|
|
{% if forum.forum_link_clicks is not null %}
|
|
<div class="forum__category__stats">
|
|
<div class="forum__category__stat" title="Clicks">{{ forum.forum_link_clicks|number_format }}</div>
|
|
</div>
|
|
{% endif %}
|
|
{% elseif forum.forum_type != 1 %}
|
|
<div class="forum__category__stats">
|
|
<div class="forum__category__stat" title="Topics">{{ forum.forum_topic_count|number_format }}</div>
|
|
<div class="forum__category__stat" title="Posts">{{ forum.forum_post_count|number_format }}</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if forum.forum_type == 0 or forum.forum_link_clicks is not null %}
|
|
<div class="forum__category__activity{% if forum.forum_link_clicks is not null %} forum__category__activity--empty{% endif %}">
|
|
{% if forum.forum_type != 2 %}
|
|
{% if forum.recent_topic_id is null %}
|
|
<div class="forum__category__activity__none">
|
|
There are no posts in this forum yet.
|
|
</div>
|
|
{% else %}
|
|
<div class="forum__category__activity__details">
|
|
<a class="forum__category__activity__post"
|
|
href="/forum/topic.php?p={{ forum.recent_post_id }}#p{{ forum.recent_post_id }}">
|
|
{{ forum.recent_topic_title }}
|
|
</a>
|
|
|
|
<div class="forum__category__activity__info">
|
|
<time datetime="{{ forum.recent_post_created|date('c') }}"
|
|
title="{{ forum.recent_post_created|date('r') }}">{{ forum.recent_post_created|time_diff }}</time>
|
|
{% if forum.recent_post_user_id is not null %}
|
|
by
|
|
<a href="/profile.php?u={{ forum.recent_post_user_id }}" class="forum__category__username"
|
|
style="{{ forum.recent_post_user_colour|html_colour }}">
|
|
{{ forum.recent_post_username }}
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
{% if forum.recent_post_user_id is not null %}
|
|
<a href="/profile.php?u={{ forum.recent_post_user_id }}"
|
|
class="avatar forum__category__avatar"
|
|
style="background-image:url('/profile.php?u={{ forum.recent_post_user_id }}&m=avatar')">
|
|
</a>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro forum_topic_locked(locked, archived) %}
|
|
{% if locked is not null or archived %}
|
|
<div class="container forum__status">
|
|
<div class="forum__status__icon">
|
|
<i class="fas fa-{{ archived ? 'archive' : 'lock' }}"></i>
|
|
</div>
|
|
<div class="forum__status__text">
|
|
{% if archived %}
|
|
This topic has been <span class="forum__status__emphasis">archived</span>.
|
|
{% else %}
|
|
This topic was locked
|
|
<time class="forum__status__emphasis"
|
|
datetime="{{ locked|date('c') }}"
|
|
title="{{ locked|date('r') }}">{{ locked|time_diff }}</time>.
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro forum_topic_listing(topics) %}
|
|
{% from _self import forum_topic_entry %}
|
|
{% from 'macros.twig' import container_title %}
|
|
|
|
<div class="container forum__topics">
|
|
{{ container_title('<i class="fas fa-comments fa-fw"></i> Topics') }}
|
|
|
|
<div class="forum__topics__list">
|
|
{% if topics|length > 0 %}
|
|
{% for topic in topics %}
|
|
{{ forum_topic_entry(topic) }}
|
|
{% endfor %}
|
|
{% else %}
|
|
<div class="forum__topics__empty">
|
|
There are no topics in this forum.
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro forum_topic_entry(topic, topic_type, topic_unread) %}
|
|
{% set topic_type = topic_type|default(null) %}
|
|
{% set topic_unread = topic_unread|default(topic.topic_unread|default(false)) ? 'unread' : 'read' %}
|
|
|
|
{% if topic_type is null %}
|
|
{% if topic.topic_deleted is defined and topic.topic_deleted is not null %}
|
|
{% set topic_type = 'fas fa-trash-alt' %}
|
|
{% elseif topic.topic_type is defined and topic.topic_type != 0 %}
|
|
{% if topic.topic_type == 2 %}
|
|
{% set topic_type = 'fas fa-bullhorn' %}
|
|
{% elseif topic.topic_type == 1 %}
|
|
{% set topic_type = 'fas fa-thumbtack' %}
|
|
{% endif %}
|
|
{% elseif topic.topic_locked is defined and topic.topic_locked is not null %}
|
|
{% set topic_type = 'fas fa-lock' %}
|
|
{% else %}
|
|
{% set topic_type = 'fas fa-comment' %}
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
<div class="forum__topic{% if topic.topic_deleted is not null %} forum__topic--deleted{% endif %}">
|
|
<a href="/forum/topic.php?t={{ topic.topic_id }}" class="forum__topic__link"></a>
|
|
|
|
<div class="forum__topic__container">
|
|
<div class="forum__topic__icon forum__topic__icon--{{ topic_unread }}">
|
|
<i class="{{ topic_type }}"></i>
|
|
</div>
|
|
|
|
<div class="forum__topic__details">
|
|
<div class="forum__topic__title">
|
|
<span class="forum__topic__title__inner">
|
|
{{ topic.topic_title }}
|
|
</span>
|
|
</div>
|
|
|
|
<div class="forum__topic__info">
|
|
{% if topic.author_id is not null %}
|
|
by <a
|
|
href="/profile.php?u={{ topic.author_id }}"
|
|
class="forum__topic__username"
|
|
style="{{ topic.author_colour|html_colour }}">{{ topic.author_name }}</a>,
|
|
|
|
{% endif %}
|
|
<time datetime="{{ topic.topic_created|date('c') }}" title="{{ topic.topic_created|date('r') }}">{{ topic.topic_created|time_diff }}</time>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="forum__topic__stats">
|
|
<div class="forum__topic__stat" title="Posts">{{ topic.topic_post_count|number_format }}</div>
|
|
<div class="forum__topic__stat" title="Views">{{ topic.topic_view_count|number_format }}</div>
|
|
</div>
|
|
|
|
<div class="forum__topic__activity">
|
|
<div class="forum__topic__activity__details">
|
|
{% if topic.respondent_id is not null %}
|
|
<a href="/profile.php?u={{ topic.respondent_id }}" class="forum__topic__username"
|
|
style="{{ topic.respondent_colour|html_colour }}">{{ topic.respondent_name }}</a>
|
|
{% endif %}
|
|
|
|
<a class="forum__topic__activity__post"
|
|
href="/forum/topic.php?p={{ topic.response_id }}#p{{ topic.response_id }}">
|
|
<time datetime="{{ topic.response_created|date('c') }}"
|
|
title="{{ topic.response_created|date('r') }}">{{ topic.response_created|time_diff }}</time>
|
|
</a>
|
|
</div>
|
|
|
|
{% if topic.respondent_id is not null %}
|
|
<a href="/profile.php?u={{ topic.respondent_id }}"
|
|
class="avatar forum__topic__avatar"
|
|
style="background-image:url('/profile.php?u={{ topic.respondent_id }}&m=avatar')">
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro forum_post_listing(posts, opening_post_id, user_id, perms) %}
|
|
{% from _self import forum_post_entry %}
|
|
|
|
{% for post in posts %}
|
|
{{ forum_post_entry(
|
|
post,
|
|
post.post_id == opening_post_id,
|
|
perms|perms_check(constant('MSZ_FORUM_PERM_CREATE_POST')),
|
|
perms|perms_check(constant(user_id == post.poster_id ? 'MSZ_FORUM_PERM_EDIT_POST' : 'MSZ_FORUM_PERM_EDIT_ANY_POST')),
|
|
perms|perms_check(constant(user_id == post.poster_id ? 'MSZ_FORUM_PERM_DELETE_POST' : 'MSZ_FORUM_PERM_DELETE_ANY_POST'))
|
|
) }}
|
|
{% endfor %}
|
|
{% endmacro %}
|
|
|
|
{% macro forum_post_entry(post, is_original_post, can_post, can_edit, can_delete) %}
|
|
{% set is_deleted = post.post_deleted is not null %}
|
|
|
|
<div class="container forum__post{% if is_deleted %} forum__post--deleted{% endif %}" id="p{{ post.post_id }}" style="{{ post.poster_colour|html_colour('--accent-colour') }}">
|
|
<div class="forum__post__info">
|
|
<div class="forum__post__info__background"></div>
|
|
<div class="forum__post__info__content">
|
|
{% if post.poster_id is not null %}
|
|
<a class="avatar forum__post__avatar"
|
|
style="background-image:url('/profile.php?u={{ post.poster_id }}&m=avatar');"
|
|
href="/profile.php?u={{ post.poster_id }}">
|
|
</a>
|
|
|
|
<a class="forum__post__username" href="/profile.php?u={{ post.poster_id }}">{{ post.poster_name }}</a>
|
|
|
|
<div class="forum__post__icons">
|
|
<div class="flag flag--{{ post.poster_country|lower }}" title="{{ post.poster_country|country_name }}"></div>
|
|
<div class="forum__post__posts-count">{{ post.poster_post_count|number_format }} posts</div>
|
|
</div>
|
|
|
|
<div class="forum__post__joined">
|
|
joined <time datetime="{{ post.poster_joined|date('c') }}" title="{{ post.poster_joined|date('r') }}">{{ post.poster_joined|time_diff }}</time>
|
|
</div>
|
|
{% else %}
|
|
<div class="forum__post__username">Deleted User</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="forum__post__content">
|
|
<div class="forum__post__details">
|
|
<a class="forum__post__datetime" href="/forum/topic.php?t={{ post.topic_id }}#p{{ post.post_id }}">
|
|
<time datetime="{{ post.post_created|date('c') }}" title="{{ post.post_created|date('r') }}">{{ post.post_created|time_diff }}</time>
|
|
{% if post.post_edited is not null %}
|
|
(edited <time datetime="{{ post.post_edited|date('c') }}" title="{{ post.post_edited|date('r') }}">{{ post.post_edited|time_diff }}</time>)
|
|
{% endif %}
|
|
</a>
|
|
|
|
<a class="forum__post__id" href="/forum/topic.php?p={{ post.post_id }}#p{{ post.post_id }}">
|
|
#{{ post.post_id }}
|
|
</a>
|
|
</div>
|
|
|
|
<div class="forum__post__text{% if post.post_parse == constant('MSZ_PARSER_MARKDOWN') %} markdown{% endif %}">
|
|
{{ post.post_text|escape|parse_text(post.post_parse)|raw }}
|
|
</div>
|
|
|
|
{% if can_post or can_edit or can_delete %}
|
|
<div class="forum__post__actions">
|
|
{% if is_deleted %}
|
|
<a href="/forum/posting.php?p={{ post.post_id }}&m=restore" class="forum__post__action"><i class="fas fa-magic fa-fw"></i> Restore</a>
|
|
<a href="/forum/posting.php?p={{ post.post_id }}&m=nuke" class="forum__post__action"><i class="fas fa-radiation-alt fa-fw"></i> Permanently Delete</a>
|
|
{% else %}
|
|
{# if can_post %}
|
|
<a href="/forum/posting.php?p={{ post.post_id }}&m=quote" class="forum__post__action"><i class="fas fa-quote-left fa-fw"></i> Quote</a>
|
|
{% endif #}
|
|
{% if can_edit %}
|
|
<a href="/forum/posting.php?p={{ post.post_id }}&m=edit" class="forum__post__action"><i class="fas fa-edit fa-fw"></i> Edit</a>
|
|
{% endif %}
|
|
{# if can_delete %}
|
|
<a href="/forum/posting.php?p={{ post.post_id }}&m=delete" class="forum__post__action"><i class="far fa-trash-alt fa-fw"></i> Delete</a>
|
|
{% endif #}
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|