<xf:title>{{ phrase('threads') }}</xf:title>

<xf:if is="$threads is not empty">
	<xf:form action="{{ link('threads/batch-update/confirm') }}" class="block" ajax="true" data-json-name="json">
		<div class="block-container">
			<div class="block-body">
				<xf:datalist data-xf-init="responsive-data-list">
					<xf:datarow rowtype="header">
						<xf:if is="$showingAll">
							<xf:cell class="dataList-cell--min">
								<xf:checkbox standalone="true"><xf:option check-all=".dataList >" data-xf-init="tooltip" title="{{ phrase('select_all') }}" /></xf:checkbox>
							</xf:cell>
						</xf:if>
						<xf:cell colspan="1">{{ phrase('title') }}</xf:cell>
						<xf:cell class="dataList-cell--min">{{ phrase('type') }}</xf:cell>
						<xf:cell class="dataList-cell--min">{{ phrase('forum') }}</xf:cell>
						<xf:cell class="dataList-cell--min">{{ phrase('thread_starter') }}</xf:cell>
						<xf:cell class="dataList-cell--min">{{ phrase('replies') }}</xf:cell>
						<xf:cell class="dataList-cell--min">{{ phrase('last_message') }}</xf:cell>
					</xf:datarow>
					<xf:foreach loop="$threads" value="$thread">
						<xf:datarow>
							<xf:if is="$showingAll">
								<xf:toggle name="thread_ids[]" value="{$thread.thread_id}" selected="true" />
							</xf:if>
							<xf:main href="{{ link_type('public', 'threads', $thread) }}" label="{$thread.title}" />
							<xf:cell class="dataList-cell--min">
								{{ $thread.TypeHandler.getTypeTitle() }}
							</xf:cell>
							<xf:cell class="dataList-cell--min">
								{$thread.Forum.title}
							</xf:cell>
							<xf:cell class="dataList-cell--min">
								{$thread.username}
							</xf:cell>
							<xf:cell class="dataList-cell--min">
								{$thread.reply_count|number}
							</xf:cell>
							<xf:cell class="dataList-cell--min">
								<xf:date time="{$thread.last_post_date}" />
							</xf:cell>
						</xf:datarow>
					</xf:foreach>
					<xf:if is="$filter AND $total > $perPage">
						<xf:datarow rowclass="dataList-row--note dataList-row--noHover js-filterForceShow">
							<xf:cell colspan="3">{{ phrase('more_records_matching_filter_more_specific') }}</xf:cell>
						</xf:datarow>
					</xf:if>
				</xf:datalist>
			</div>
			<div class="block-footer block-footer--split">
				<span class="block-footer-counter">{{ display_totals($threads, $total) }}</span>
				<span class="block-footer-select"><xf:checkbox standalone="true"><xf:option check-all=".dataList" label="{{ phrase('select_all') }}" /></xf:checkbox></span>
				<xf:if is="$showAll">
					<span class="block-footer-controls">
						<a href="{{ link('threads/list', null, {'criteria': $criteria, 'all': true}) }}">{{ phrase('show_all_matches') }}</a>
					</span>
				<xf:elseif is="$showingAll" />
					<span class="block-footer-controls"><xf:button type="submit">{{ phrase('batch_update') }}</xf:button></span>
				</xf:if>
			</div>
		</div>

		<xf:pagenav page="{$page}" perpage="{$perPage}" total="{$total}"
			link="threads/list"
			params="{{ {'criteria': $criteria, 'order': $order, 'direction': $direction, 'all': $showingAll} }}"
			wrapperclass="js-filterHide block-outer block-outer--after" />
	</xf:form>
<xf:else />
	<div class="blockMessage">{{ phrase('no_records_matched') }}</div>
</xf:if>