{% include 'mcp_header.html' %}
{% set CUSTOM_FIELDSET_CLASS = 'forum-selection2' %}

<section class="iz-card iz-card--mcp" aria-labelledby="iz-mcp-forum-title">
	<header class="iz-card__header">
		<h2 class="iz-card__title" id="iz-mcp-forum-title">
			<a class="iz-link" href="{{ U_VIEW_FORUM }}">{{ L_FORUM }}{{ L_COLON }}&nbsp;{{ FORUM_NAME }}</a>
		</h2>
	</header>

	<div class="iz-card__body">
		<div class="iz-toolbar" role="region" aria-label="{{ L_FORUM }}">
			<div class="iz-toolbar__left">
				{% include 'jumpbox_options.html' %}
			</div>

			<div class="iz-toolbar__right">
				<nav class="iz-pagination" aria-label="{{ L_PAGINATION }}">
					<span class="iz-pagination__meta">{{ TOTAL_TOPICS }}</span>

					{% if pagination %}
						{% include 'pagination.html' %}
					{% else %}
						<span class="iz-pagination__current" aria-current="page">{{ PAGE_NUMBER }}</span>
					{% endif %}
				</nav>
			</div>
		</div>
	</div>
</section>

<form method="post" id="mcp" class="iz-form" action="{{ S_MCP_ACTION }}">
	<div class="iz-mcp">
		{% if topicrow %}
			<section class="iz-card iz-card--mcp" aria-labelledby="iz-mcp-topics-title">
				<header class="iz-card__header">
					<h2 class="iz-card__title" id="iz-mcp-topics-title">{{ L_TOPICS }}</h2>
				</header>

				<div class="iz-card__body">
					<div class="iz-table" role="region" aria-label="{{ L_TOPICS }}">
						<table class="iz-table__table">
							<thead class="iz-table__head">
								<tr class="iz-table__row">
									<th scope="col" class="iz-table__th iz-table__th--grow">{{ L_TITLE }}</th>
									<th scope="col" class="iz-table__th iz-table__th--num">{{ L_REPLIES }}</th>
									<th scope="col" class="iz-table__th">{{ L_LAST_POST }}</th>
									{% if not S_MERGE_SELECT %}
										<th scope="col" class="iz-table__th iz-table__th--choice">{{ L_MARK }}</th>
									{% endif %}
								</tr>
							</thead>

							<tbody class="iz-table__body">
								{% set VAR = {{ L_VIEW_TOPIC_LOCKED }} %}
								{% for topicrow in topicrow %}
									<tr class="iz-table__row">
										<td class="iz-table__td">
											<div class="iz-topicline">
												<div class="iz-topicline__title">
													{% if topicrow.TOPIC_ICON_IMG %}
														<span class="iz-topicline__icon"
															  aria-hidden="true"
															  style="background-image:url({{ T_ICONS_PATH }}{{ topicrow.TOPIC_ICON_IMG }}); background-repeat:no-repeat;"></span>
													{% endif %}

													{% if topicrow.S_SELECT_TOPIC %}
														<a class="iz-link iz-link--muted" href="{{ topicrow.U_SELECT_TOPIC }}">
															&#91;&nbsp;{{ L_SELECT_MERGE }}&nbsp;&#93;
														</a>
														&nbsp;
													{% endif %}

													{% EVENT mcp_forum_topic_title_before %}
													<a class="iz-link iz-link--strong" href="{{ topicrow.U_VIEW_TOPIC }}">{{ topicrow.TOPIC_TITLE }}</a>
													{% EVENT mcp_forum_topic_title_after %}

													<!-- Status indicators (no Font Awesome; rely on text + title for accessibility) -->
													{% if topicrow.S_TOPIC_UNAPPROVED or topicrow.S_POSTS_UNAPPROVED %}
														<a class="iz-badge iz-badge--warn" href="{{ topicrow.U_MCP_QUEUE }}" title="{{ L_TOPICS_ROW_NOT_APPROVED }}">{{ L_TOPICS_ROW_NOT_APPROVED }}</a>
													{% endif %}
													{% if topicrow.S_TOPIC_DELETED or topicrow.S_POSTS_DELETED %}
														<a class="iz-badge iz-badge--danger" href="{{ topicrow.U_MCP_QUEUE }}" title="{{ L_TOPICS_ROW_DELETED }}">{{ L_TOPICS_ROW_DELETED }}</a>
													{% endif %}
													{% if topicrow.S_TOPIC_REPORTED %}
														<a class="iz-badge iz-badge--danger" href="{{ topicrow.U_MCP_REPORT }}" title="{{ L_TOPICS_ROW_REPORTED }}">{{ L_TOPICS_ROW_REPORTED }}</a>
													{% endif %}

													{% if topicrow.S_MOVED_TOPIC and S_CAN_DELETE %}
														&nbsp;
														<a class="iz-link iz-link--danger" href="{{ topicrow.U_DELETE_TOPIC }}">
															&#91;&nbsp;{{ L_DELETE_SHADOW_TOPIC }}&nbsp;&#93;
														</a>
													{% endif %}
												</div>

												<div class="iz-topicline__meta">
													<span>{{ L_POST_BY_AUTHOR }}&nbsp;{{ topicrow.TOPIC_AUTHOR_FULL }}&nbsp;&#45;&nbsp;<time>{{ topicrow.FIRST_POST_TIME }}</time></span>
													{% if topicrow.ATTACH_ICON_IMG %}
														<span class="iz-badge iz-badge--neutral" title="{{ L_ATTACH_FORUM }}">{{ L_ATTACH_FORUM }}</span>
													{% endif %}
												</div>

												{% if topicrow.pagination %}
													<nav class="iz-pagination iz-pagination--compact" aria-label="{{ L_PAGINATION }}">
														<ul class="iz-pagination__list">
															{% for pagination in pagination %}
																{% if topicrow.pagination.S_IS_PREV %}
																	<li class="iz-pagination__item iz-pagination__item--ellipsis" aria-hidden="true">{{ L_ELLIPSIS }}</li>
																{% elseif topicrow.pagination.S_IS_CURRENT %}
																	<li class="iz-pagination__item">
																		<span class="iz-pagination__current" aria-current="page">{{ topicrow.pagination.PAGE_NUMBER }}</span>
																	</li>
																{% elseif topicrow.pagination.S_IS_ELLIPSIS %}
																	<li class="iz-pagination__item iz-pagination__item--ellipsis">{{ L_ELLIPSIS }}</li>
																{% elseif topicrow.pagination.S_IS_NEXT %}
																	<li class="iz-pagination__item iz-pagination__item--ellipsis" aria-hidden="true">{{ L_ELLIPSIS }}</li>
																{% else %}
																	<li class="iz-pagination__item">
																		<a class="iz-pagination__link" href="{{ topicrow.pagination.PAGE_URL }}">{{ topicrow.pagination.PAGE_NUMBER }}</a>
																	</li>
																{% endif %}
															{% endfor %}
														</ul>
													</nav>
												{% endif %}
											</div>
										</td>

										<td class="iz-table__td iz-table__td--num">
											<span class="iz-num">{{ topicrow.REPLIES }}</span>
										</td>

										<td class="iz-table__td">
											<div class="iz-lastpost">
												<div>{{ L_POST_BY_AUTHOR }}&nbsp;{{ topicrow.LAST_POST_AUTHOR_FULL }}</div>
												<div><small><time>{{ topicrow.LAST_POST_TIME }}</time></small></div>
											</div>
										</td>

										{% if not S_MERGE_SELECT %}
											<td class="iz-table__td iz-table__td--choice">
												{% if not topicrow.S_MOVED_TOPIC %}
													<label class="iz-choice" for="topic_{{ topicrow.TOPIC_ID }}">
														<input class="iz-choice__input"
															   type="checkbox"
															   name="topic_id_list[]"
															   id="topic_{{ topicrow.TOPIC_ID }}"
															   value="{{ topicrow.TOPIC_ID }}"{% if topicrow.S_TOPIC_CHECKED %} checked="checked"{% endif %}>
														<span class="iz-choice__label">{{ L_MARK }}</span>
													</label>
												{% else %}
													<span class="iz-muted" aria-hidden="true">&mdash;</span>
												{% endif %}
											</td>
										{% endif %}
									</tr>
								{% endfor %}
							</tbody>
						</table>
					</div>
				</div>
			</section>
		{% else %}
			<section class="iz-card iz-card--mcp" aria-labelledby="iz-mcp-none-title">
				<header class="iz-card__header">
					<h2 class="iz-card__title" id="iz-mcp-none-title">{{ L_INFO_BOX }}</h2>
				</header>
				<div class="iz-card__body">
					<p class="iz-help">{{ L_NO_TOPICS }}</p>
				</div>
			</section>
		{% endif %}

		<section class="iz-card iz-card--mcp" aria-labelledby="iz-mcp-actions-title">
			<header class="iz-card__header">
				<h2 class="iz-card__title" id="iz-mcp-actions-title">{{ L_OPTIONS }}</h2>
			</header>

			<div class="iz-card__body">
				{% EVENT mcp_forum_actions_before %}

				{% if not S_MERGE_SELECT %}
					<div class="iz-field">
						<label class="iz-label" for="mcp_action">{{ L_SELECT_ACTION }}{{ L_COLON }}</label>
						<div class="iz-field__row iz-field__row--actions">
							<select class="iz-select" name="action" id="mcp_action">
								<option value="" selected="selected">{{ L_SELECT_ACTION }}</option>
								{% if S_CAN_DELETE %}<option value="delete_topic">{{ L_DELETE }}</option>{% endif %}
								{% if S_CAN_MERGE %}<option value="merge_topics">{{ L_MERGE }}</option>{% endif %}
								{% if S_CAN_MOVE %}<option value="move">{{ L_MOVE }}</option>{% endif %}
								{% if S_CAN_FORK %}<option value="fork">{{ L_FORK }}</option>{% endif %}
								{% if S_CAN_LOCK %}<option value="lock">{{ L_LOCK }}</option><option value="unlock">{{ L_UNLOCK }}</option>{% endif %}
								{% if S_CAN_SYNC %}<option value="resync">{{ L_RESYNC }}</option>{% endif %}
								{% if S_CAN_MAKE_NORMAL %}<option value="make_normal">{{ L_MAKE_NORMAL }}</option>{% endif %}
								{% if S_CAN_MAKE_STICKY %}<option value="make_sticky">{{ L_MAKE_STICKY }}</option>{% endif %}
								{% if S_CAN_MAKE_ANNOUNCE %}<option value="make_announce">{{ L_MAKE_ANNOUNCE }}</option>{% endif %}
								{% if S_CAN_MAKE_ANNOUNCE_GLOBAL %}<option value="make_global">{{ L_MAKE_GLOBAL }}</option>{% endif %}
								{% EVENT mcp_forum_actions_append %}
							</select>

							<div class="iz-actions iz-actions--inline" aria-label="{{ L_MARK }}">
								<button class="iz-btn iz-btn--secondary"
										type="button"
										onclick="marklist('mcp', 'topic_id_list', true); return false;"
										title="{{ L_MARK_ALL }}">
									{{ L_MARK_ALL }}
								</button>

								<button class="iz-btn iz-btn--secondary"
										type="button"
										onclick="marklist('mcp', 'topic_id_list', false); return false;"
										title="{{ L_UNMARK_ALL }}">
									{{ L_UNMARK_ALL }}
								</button>

								<button class="iz-btn iz-btn--primary" type="submit" value="{{ L_SUBMIT }}">{{ L_SUBMIT }}</button>
							</div>
						</div>
					</div>
				{% endif %}

				{{ S_FORM_TOKEN }}

				{% EVENT mcp_forum_actions_after %}
			</div>
		</section>

		{% include 'display_options.html' %}
	</div>
</form>

{% include 'mcp_footer.html' %}
