{% macro forum_category_listing(forums, title, colour, id, icon) %} {% from _self import forum_category_entry %} {% from 'macros.twig' import container_title %}
0 %}id="{{ id }}"{% 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 %}
{% for name, url in breadcrumbs %} {% if url != breadcrumbs|first %}
{% endif %} {% if not (omit_last_breadcrumb|default(false) and url == breadcrumbs|last) %} {{ 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 %} {% set is_locked = info.forum_archived != 0 %} {% set can_topic = not is_locked and perms|perms_check(constant('MSZ_FORUM_PERM_CREATE_TOPIC')) %} {% set pag = pagination(pagination_info, url('forum-category'), null, {'f': info.forum_id}) %} {% if can_topic or pag|trim|length > 0 %}
{% if can_topic %} {{ info.forum_type == constant('MSZ_FORUM_TYPE_FEATURE') ? 'New Request' : '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, url('forum-topic'), null, {'t': info.topic_id}, 'page') %} {% 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 %} {% set forum_unread = forum_unread|default(forum.forum_unread|default(false)) ? 'unread' : 'read' %} {% if forum_icon is empty %} {% if forum.forum_icon is defined and forum.forum_icon is not empty %} {% set forum_icon = forum.forum_icon %} {% elseif forum.forum_archived is defined and forum.forum_archived %} {% set forum_icon = 'fas fa-archive fa-fw' %} {% elseif forum.forum_type is defined and forum.forum_type != constant('MSZ_FORUM_TYPE_DISCUSSION') %} {% if forum.forum_type == constant('MSZ_FORUM_TYPE_FEATURE') %} {% set forum_icon = 'fas fa-star fa-fw' %} {% elseif forum.forum_type == constant('MSZ_FORUM_TYPE_LINK') %} {% set forum_icon = 'fas fa-link fa-fw' %} {% elseif forum.forum_type == constant('MSZ_FORUM_TYPE_CATEGORY') %} {% set forum_icon = 'fas fa-folder fa-fw' %} {% endif %} {% else %} {% set forum_icon = 'fas fa-comments fa-fw' %} {% endif %} {% endif %}
{{ forum.forum_name }}
{{ forum.forum_description|nl2br }}
{% if forum.forum_subforums is defined and forum.forum_subforums|length > 0 %}
{% for subforum in forum.forum_subforums %} {{ subforum.forum_name }} {% endfor %}
{% endif %}
{% if forum.forum_type == constant('MSZ_FORUM_TYPE_LINK') %} {% if forum.forum_link_clicks is not null %}
{{ forum.forum_link_clicks|number_format }}
{% endif %} {% elseif forum_may_have_children(forum.forum_type) %}
{{ forum.forum_count_topics|number_format }}
{{ forum.forum_count_posts|number_format }}
{% endif %} {% if forum_may_have_topics(forum.forum_type) or forum.forum_link_clicks is not null %} {% endif %}
{% endmacro %} {% macro forum_topic_locked(locked, archived) %} {% if locked is not null or archived %}
{% if archived %} This topic has been archived. {% else %} This topic was locked . {% endif %}
{% 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_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 has_priority_voting = forum_has_priority_voting(topic.forum_type) %} {% 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') %} {% set topic_icon = 'fas fa-bullhorn' %} {% elseif topic.topic_type == constant('MSZ_TOPIC_TYPE_STICKY') %} {% set topic_icon = 'fas fa-thumbtack' %} {% endif %} {% elseif topic.topic_locked is defined and topic.topic_locked is not null %} {% set topic_icon = 'fas fa-lock' %} {% elseif has_priority_voting %} {% set topic_icon = 'far fa-star' %} {% else %} {% set topic_icon = (topic_unread ? 'fas' : 'far') ~ ' fa-comment' %} {% endif %} {% endif %}
{% if has_priority_voting %}
{{ topic.topic_priority|number_format }}
{% endif %} {% if topic.topic_participated %}
{% endif %}
{{ topic.topic_title }}
{% if topic.author_id is not null %} by {{ topic.author_name }}, {% endif %}
{% if topic.topic_pages|default(0) > 1 %}
{% for i in 1..topic.topic_pages|clamp(0, 3) %} {{ i }} {% endfor %} {% if topic.topic_pages > 3 %} {% if topic.topic_pages > 6 %}
{% endif %} {% for i in (topic.topic_pages - 2)|clamp(4, topic.topic_pages)..topic.topic_pages %} {{ i }} {% endfor %} {% endif %}
{% endif %}
{{ topic.topic_count_posts|number_format }}
{{ topic.topic_count_views|number_format }}
{% if topic.respondent_id is not null %} {{ topic.respondent_name }} {% endif %}
{% if topic.respondent_id is not null %} {{ avatar(topic.respondent_id, 30, topic.respondent_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 is_deleted = post.post_deleted is not null %} {% set can_post = perms|perms_check(constant('MSZ_FORUM_PERM_CREATE_POST')) %} {% set can_edit = perms|perms_check(constant('MSZ_FORUM_PERM_EDIT_ANY_POST')) or ( user_id == post.poster_id and perms|perms_check(constant('MSZ_FORUM_PERM_EDIT_POST')) ) %} {% set can_delete = not post.is_opening_post and ( perms|perms_check(constant('MSZ_FORUM_PERM_DELETE_ANY_POST')) or ( user_id == post.poster_id and perms|perms_check(constant('MSZ_FORUM_PERM_DELETE_POST')) and post.post_created|date('U') > ''|date('U') - constant('MSZ_FORUM_POST_DELETE_LIMIT') ) ) %}
{% set post_link = url(post.is_opening_post ? 'forum-topic' : 'forum-post', {'topic': post.topic_id, 'post': post.post_id, 'post_fragment': 'p%d'|format(post.post_id)}) %}
#{{ post.post_id }}
{{ post.post_text|escape|parse_text(post.post_parse)|raw }}
{% if can_post or can_edit or can_delete %}
{% if is_deleted %} Restore Permanently Delete {% else %} {# if can_post %} Quote {% endif #} {% if can_edit %} Edit {% endif %} {% if can_delete %} Delete {% endif %} {% endif %}
{% endif %} {% if post.post_display_signature and post.poster_signature_content|length > 0 %}
{{ post.poster_signature_content|escape|parse_text(post.poster_signature_parser)|raw }}
{% endif %}
{% endmacro %} {% macro forum_poll(poll, options, user_answers, topic_id, can_vote, preview_results) %} {% from '_layout/input.twig' import input_csrf, input_hidden, input_checkbox, input_checkbox_raw %} {% set user_answers = user_answers is empty or user_answers is not iterable ? [] : user_answers %} {% set user_answered = user_answers|length > 0 %} {% set results_available = preview_results or user_answered or poll.poll_expired or poll.poll_preview_results %} {% set options_available = not poll.poll_expired and (poll.poll_change_vote or not user_answered) %} {% set display_results = user_answered or poll.poll_expired %} {% if options is iterable and options|length > 0 %}
{% if results_available %} {% if options_available %} {{ input_checkbox_raw('', display_results, 'forum__poll__toggle', '', false, {'id':'forum-poll-toggle'}) }} {% endif %}
{% for option in options %} {% set percent = poll.poll_votes < 1 ? 0 : (option.option_votes / poll.poll_votes) * 100 %}
{{ option.option_text }}
{{ option.option_votes|number_format }}
{{ percent|number_format(2) }}%
{% endfor %}
This poll got {{ poll.poll_votes|number_format }} vote{{ poll.poll_votes == 1 ? '' : 's' }}
{% if poll.poll_expires is not null %}
Polling {{ poll.poll_expired ? 'closed' : 'will close' }} .
{% endif %} {% if options_available %}
{% endif %}
{% endif %} {% if options_available %}
{{ input_csrf() }} {{ input_hidden('poll[id]', poll.poll_id) }}
{% for option in options %} {{ input_checkbox( 'poll[answers][]', option.option_text, option.option_id in user_answers, 'forum__poll__option', option.option_id, poll.poll_max_votes <= 1, null, not can_vote ) }} {% endfor %}
{% if can_vote and poll.poll_max_votes > 1 %}
You have {{ poll.poll_max_votes }} votes remaining.
{% endif %} {% if poll.poll_expires is not null %}
Polling {{ poll.poll_expired ? 'closed' : 'will close' }} .
{% endif %}
{% if can_vote %} {% endif %} {% if results_available %} {% endif %}
{% endif %}
{% endif %} {% endmacro %} {% macro forum_priority_votes(topic, votes, can_vote) %}
{% for vote in votes %}
{% for i in 1..vote.topic_priority %} {% endfor %}
{% endfor %}
{% if can_vote %}
Vote for this feature
{% endif %}
{% endmacro %}