{% macro forum_category_listing(forums, title, colour, id, icon) %} {% from _self import forum_category_entry %} {% from 'macros.twig' import container_title %} {% if forums.info is defined %} {% set title = forums.info.name|default('Forums') %} {% set icon = forums.info.iconForDisplay|default('fas fa-folder fa-fw') %} {% set colour = forums.colour|default(null) %} {% set id = forums.info.id is defined ? 'f' ~ forums.info.id : '' %} {% set forums = forums.children %} {% elseif forums.children is defined %} {% set title = 'Forums' %} {% set icon = 'fas fa-folder fa-fw' %} {% set colour = null %} {% set id = '' %} {% set forums = forums.children %} {% else %} {% set title = title|default('Forums') %} {% set icon = icon|default('fas fa-folder fa-fw') %} {% set colour = colour|default(null) %} {% set id = id|default('') %} {% endif %}
0 %}id="{{ id }}"{% endif %} {% if colour is not null %}style="--accent-colour: {{ colour }}"{% endif %}> {{ container_title(' ' ~ title) }} {% if forums|length > 0 %}
{% for forum in forums %} {{ forum_category_entry(forum) }} {% endfor %}
{% else %}
This category is empty.
{% endif %}
{% endmacro %} {% macro forum_header(title, breadcrumbs, omit_last_breadcrumb, title_url, actions) %}
{% if breadcrumbs is iterable and breadcrumbs|length > 0 %}
Forums {% for category in breadcrumbs|reverse %}
{% if not (omit_last_breadcrumb|default(false) and category == breadcrumbs|first) %} {{ category.name }} {% endif %} {% endfor %}
{% endif %} {% if title|length > 0 %} {% if title_url|length > 0 %} {{ title }} {% else %}
{{ title }}
{% endif %} {% endif %} {% if actions is iterable and actions|length > 0 %}
{% for action in actions %} {% if action.display is not defined or action.display %} {{ action.html|raw }} {% endif %} {% endfor %}
{% endif %}
{% endmacro %} {% macro forum_category_tools(info, perms, pagination_info) %} {% from 'macros.twig' import pagination %} {% if info.forum_id is defined %} {% set forum_id = info.forum_id %} {% set is_archived = info.forum_archived != 0 %} {% else %} {% set forum_id = info.id %} {% set is_archived = info.isArchived %} {% endif %} {% set is_locked = is_archived %} {% set can_topic = not is_locked and perms.can_create_topic %} {% set pag = pagination(pagination_info, 'forum-category', {'forum': forum_id}) %} {% if can_topic or pag|trim|length > 0 %}
{% if can_topic %} New Topic {% endif %}
{{ pag }}
{% endif %} {% endmacro %} {% macro forum_topic_tools(info, pagination_info, can_reply) %} {% from 'macros.twig' import pagination %} {% set pag = pagination(pagination_info, 'forum-topic', {'topic': info.id}) %} {% if can_reply or pag|trim|length > 0 %}
{% if can_reply %} Reply {% endif %}
{{ pag }}
{% endif %} {% endmacro %} {% macro forum_category_entry(forum, forum_unread, forum_icon) %} {% from 'macros.twig' import avatar %} {% if forum.info is defined %} {% set forum_id = forum.info.id %} {% set forum_name = forum.info.name %} {% set forum_desc = forum.info.description|default('') %} {% set forum_is_link = forum.info.isLink %} {% set forum_may_have_children = forum.info.mayHaveChildren %} {% set forum_link_clicks = forum.info.linkClicks %} {% set forum_count_topics = forum.info.topicsCount %} {% set forum_count_posts = forum.info.postsCount %} {% set forum_show_activity = forum.info.mayHaveTopics or forum.info.hasLinkClicks %} {% set forum_unread = forum.unread %} {% set forum_colour = forum.colour %} {% set forum_has_recent_post = forum.lastPost is defined %} {% set children = forum.children %} {% if forum_has_recent_post %} {% set forum_recent_post_id = forum.lastPost.info.id %} {% set forum_recent_topic_title = forum.lastPost.topicInfo.title %} {% set forum_recent_post_created = forum.lastPost.info.createdTime %} {% set forum_has_recent_post_user = forum_has_recent_post and forum.lastPost.user is defined %} {% if forum_has_recent_post_user %} {% set forum_recent_post_user_id = forum.lastPost.user.id %} {% set forum_recent_post_user_name = forum.lastPost.user.name %} {% set forum_recent_post_user_colour = '--user-colour: ' ~ forum.lastPost.colour %} {% endif %} {% endif %} {% if forum_icon is empty %} {% set forum_icon = forum.info.iconForDisplay %} {% endif %} {% else %} {% set forum_id = null %} {% set forum_name = 'Forums' %} {% set forum_desc = null %} {% set forum_is_link = false %} {% set forum_may_have_children = true %} {% set forum_count_topics = 0 %} {% set forum_count_posts = 0 %} {% set forum_show_activity = false %} {% set forum_unread = false %} {% set forum_colour = null %} {% set forum_has_recent_post = false %} {% set children = forum %} {% endif %}
{{ forum_name }}
{% if forum_desc is not null %}
{{ forum_desc|nl2br }}
{% endif %} {% if children|length > 0 %}
{% for child in children %} {% if child.info is defined %} {% set child_id = child.info.id %} {% set child_name = child.info.name %} {% set child_unread = child.unread %} {% else %} {% set child_id = child.forum_id %} {% set child_name = child.forum_name %} {% set child_unread = child.forum_unread %} {% endif %} {{ child_name }} {% endfor %}
{% endif %}
{% if forum_is_link %} {% if forum_link_clicks is not null %}
{{ forum_link_clicks|number_format }}
{% endif %} {% elseif forum_may_have_children %}
{{ forum_count_topics|number_format }}
{{ forum_count_posts|number_format }}
{% endif %} {% if forum_show_activity %} {% endif %}
{% endmacro %} {% macro forum_topic_notice(icon, body) %}
{{ body|raw }}
{% endmacro %} {% macro forum_topic_redirect(redirect) %} {% from _self import forum_topic_notice %} {% if redirect is not empty %} {% set body %} This topic redirects to {{ redirect.linkTarget }}. {% endset %} {{ forum_topic_notice('share', body) }} {% endif %} {% endmacro %} {% macro forum_topic_locked(locked, archived) %} {% from _self import forum_topic_notice %} {% if locked is not null or archived %} {% set body %} {% if archived %} This topic has been archived. {% else %} This topic was locked . {% endif %} {% endset %} {{ forum_topic_notice(archived ? 'archive' : 'lock', body) }} {% endif %} {% endmacro %} {% macro forum_topic_listing(topics, title) %} {% from _self import forum_topic_entry %} {% from 'macros.twig' import container_title %}
{{ container_title(' ' ~ title|default('Topics')) }}
{% if topics|length > 0 %} {% for topic in topics %} {{ forum_topic_entry(topic) }} {% endfor %} {% else %}
There are no topics in this forum.
{% endif %}
{% endmacro %} {% macro forum_topic_entry(topic, topic_icon, topic_unread) %} {% from 'macros.twig' import avatar %} {% set topic_id = topic.info.id %} {% set topic_title = topic.info.title %} {% set topic_participated = topic.participated %} {% set topic_count_posts = topic.info.postsCount %} {% set topic_count_views = topic.info.viewsCount %} {% set topic_created = topic.info.createdTime %} {% set topic_locked = topic.info.isLocked %} {% set topic_deleted = topic.info.isDeleted %} {% set topic_pages = (topic.info.postsCount / 10)|round(0, 'ceil') %} {% set has_topic_author = topic.user is defined %} {% if has_topic_author %} {% set topic_author_id = topic.user.id %} {% set topic_author_name = topic.user.name %} {% set topic_author_colour = '--user-colour: ' ~ topic.colour %} {% endif %} {% set has_reply = topic.lastPost is defined %} {% if has_reply %} {% set reply_id = topic.lastPost.info.id %} {% set reply_created = topic.lastPost.info.createdTime %} {% set has_reply_author = topic.lastPost.user is defined %} {% if has_reply_author %} {% set reply_author_id = topic.lastPost.user.id %} {% set reply_author_name = topic.lastPost.user.name %} {% set reply_author_colour = '--user-colour: ' ~ topic.lastPost.colour %} {% endif %} {% endif %} {% set topic_unread = topic.unread %} {% set topic_important = topic.info.isImportant %} {% if topic_icon is null %} {% set topic_icon = topic.info.iconForDisplay(topic.unread) %} {% endif %}
{% if topic_participated %}
{% endif %}
{{ topic_title }}
{% if has_topic_author %} by {{ topic_author_name }}, {% endif %}
{% if topic_pages|default(0) > 1 %}
{% set topic_pages_start_end = min(3, topic_pages) %} {% for i in 1..topic_pages_start_end %} {{ i }} {% endfor %} {% if topic_pages > 3 %} {% if topic_pages > 6 %}
{% endif %} {% set topic_pages_end_start = max(4, min(topic_pages, topic_pages - 2)) %} {% for i in topic_pages_end_start..topic_pages %} {{ i }} {% endfor %} {% endif %}
{% endif %}
{{ topic_count_posts|number_format }}
{{ topic_count_views|number_format }}
{% if has_reply %} {% if has_reply_author %} {{ reply_author_name }} {% endif %} {% endif %}
{% if has_reply and has_reply_author %} {{ avatar(reply_author_id, 30, reply_author_name) }} {% endif %}
{% endmacro %} {% macro forum_post_listing(posts, user_id, perms) %} {% from _self import forum_post_entry %} {% for post in posts %} {{ forum_post_entry(post, user_id, perms) }} {% endfor %} {% endmacro %} {% macro forum_post_entry(post, user_id, perms) %} {% from 'macros.twig' import avatar %} {% set post_id = post.info.id %} {% set post_created = post.info.createdTime %} {% set post_edited = post.info.editedTime %} {% set post_is_deleted = post.info.isDeleted %} {% set post_is_op = post.isOriginalPost %} {% set post_body = post.info.body|escape|parse_text(post.info.parser) %} {% set post_is_markdown = post.info.isBodyMarkdown %} {% set post_show_signature = post.info.shouldDisplaySignature %} {% set post_can_be_deleted = post.info.canBeDeleted %} {% set topic_id = post.info.topicId %} {% set has_author = post.user is defined %} {% if has_author %} {% set author_id = post.user.id %} {% set author_name = post.user.name %} {% set author_title = post.user.title %} {% set author_colour = '--accent-colour:' ~ post.colour %} {% set author_country = post.user.countryCode %} {% set author_created = post.user.createdTime %} {% set author_posts_count = post.postsCount %} {% set author_is_op = post.isOriginalPoster %} {% set signature_body = post.user.signatureContent|default('')|escape|parse_text(post.user.signatureParser) %} {% set signature_is_markdown = post.user.isSignatureBodyMarkdown %} {% endif %} {% set viewer_is_author = has_author and user_id == author_id %} {% set can_edit = perms.can_edit_any_post|default(false) or (viewer_is_author and perms.can_edit_post|default(false)) %} {% set can_delete = not post_is_op and (perms.can_delete_any_post|default(false) or (viewer_is_author and perms.can_delete_post|default(false) and post_can_be_deleted)) %}
{% set post_link = url(post_is_op ? 'forum-topic' : 'forum-post', {'topic': topic_id, 'post': post_id, 'post_fragment': 'p%d'|format(post_id)}) %}
#{{ post_id }}
{{ post_body|raw }}
{% if perms.can_create_post|default(false) or can_edit or can_delete %}
{% if post_is_deleted %} Restore Permanently Delete {% else %} {# if perms.can_create_post|default(false) %} Quote {% endif #} {% if can_edit %} Edit {% endif %} {% if can_delete %} Delete {% endif %} {% endif %}
{% endif %} {% if post_show_signature and signature_body is defined and signature_body|length > 0 %}
{{ signature_body|raw }}
{% endif %}
{% endmacro %}