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

<xf:pageaction>
	<xf:button href="{{ link('tags/add') }}" icon="add">{{ phrase('add_tag') }}</xf:button>
</xf:pageaction>

<xf:form action="{{ link('tags') }}" class="block">
	<div class="block-outer">
		<span class="filterBlock">
			<xf:textbox name="containing" value="{$filters.containing}" placeholder="{{ phrase('tag_contains...') }}"
				class="input--inline filterBlock-input" />
			<span>
				<span class="filterBlock-label">{{ phrase('ordered_by:') }}</span>
				<xf:select name="order" value="{{ $filters.order ? $filters.order : 'tag' }}" class="input--inline filterBlock-input">
					<xf:option value="tag">{{ phrase('tag') }}</xf:option>
					<xf:option value="use_count">{{ phrase('total') }}</xf:option>
					<xf:option value="last_use_date">{{ phrase('last_used') }}</xf:option>
				</xf:select>
			</span>
			<xf:button type="submit">{{ phrase('go') }}</xf:button>
		</span>
	</div>
	<div class="block-container">
		<xf:if is="$tags is not empty">
			<div class="block-body">
				<xf:datalist data-xf-init="responsive-data-list">
					<xf:datarow rowtype="header">
						<xf:cell>{{ phrase('tag') }}</xf:cell>
						<xf:cell>{{ phrase('total') }}</xf:cell>
						<xf:cell>{{ phrase('last_used') }}</xf:cell>
						<xf:cell class="dataList-cell--min">&nbsp;</xf:cell>
						<xf:cell class="dataList-cell--min">&nbsp;</xf:cell>
						<xf:cell class="dataList-cell--min">&nbsp;</xf:cell>
					</xf:datarow>
					<xf:foreach loop="$tags" value="$tag">
						<xf:datarow>
							<xf:cell href="{{ link('tags/edit', $tag) }}">{$tag.tag}</xf:cell>
							<xf:cell href="{{ link('tags/edit', $tag) }}">{$tag.use_count|number}</xf:cell>
							<xf:cell href="{{ link('tags/edit', $tag) }}">
								<xf:if is="$tag.last_use_date">
									<xf:date time="{$tag.last_use_date}" />
									<xf:else />
									&nbsp;
								</xf:if>
							</xf:cell>
							<xf:action href="{{ link_type('public', 'tags', $tag) }}">{{ phrase('view') }}</xf:action>
							<xf:action href="{{ link('tags/merge', $tag) }}" overlay="true">{{ phrase('merge') }}</xf:action>
							<xf:delete href="{{ link('tags/delete', $tag) }}" />
						</xf:datarow>
					</xf:foreach>
				</xf:datalist>
			</div>
			<div class="block-footer">
				<span class="block-footer-counter">{{ display_totals($tags, $total) }}</span>
			</div>
		<xf:else />
			<div class="block-body block-row">{{ phrase('no_results_found') }}</div>
		</xf:if>
	</div>

	<xf:pagenav page="{$page}" perpage="{$perPage}" total="{$total}"
		link="tags" params="{$filters}"
		wrapperclass="block-outer block-outer--after" />
</xf:form>