<div id="forum">
{include file="forum/forum_bar.tpl"}
{if $smarty.get.search}<div class="forum-search">{t}Вы искали{/t}: <em class="muted">{$smarty.get.search|escape}</em></div>{/if}
{if $pager.pages}
<div>
	<ul class="pagination">
	{foreach $pager.pages as $page}
		{if !$page}
			<li class="disabled"><a>...</a></li>
		{else}
			<li{if $page==$pager.current} class="active"{/if}><a href="{url action=$smarty.get.action var1=$smarty.get.var1|default:0 var2=$page var3=$smarty.get.search}">{$page}</a></li>
		{/if}
		</li>
	{/foreach}
	</ul>
</div>
{/if}

<table class="table table-striped">
{if $themes}
<thead>
	<tr class="no-wrap">
		<th></th>
		<th>{t}Тема{/t}</th>
		<th>{t}Автор{/t}</th>
		<th>{t}Сбщ.{/t}</th>
		<th>{t}Последний ответ{/t}</th>
		{if !$forum->id}<th>{t}Форум{/t}</th>{/if}
		{if access('moderator')}<th></th>{/if}</tr>
</thead>
<tbody>
{else}
<thead>
	<tr>
		<th>{if $smarty.get.search}{t}К сожалению, ничего не найдено!{/t}{else}{t}Пока нет ни одной темы{/t}{/if}</th>
	</tr>
</thead>
<tbody>
{/if}
{foreach $themes as $theme}
<tr class="{if $theme->last_post_date>$_user->last_visit && $smarty.session.forum.themes[$theme->id]<$theme->last_post_date} warning{/if}{if $theme->hidden_by} label-warning{/if}">
<td>
	{if $theme->pinup}
		<i class="glyphicon glyphicon-flag" title="{t}Тема прикреплена{/t}"></i>	
	{/if}
</td>
<td><a href="{url action='theme' var1=$theme->id var2=1 var3=$smarty.get.search}">{$theme->subject|escape}</a>
{if $theme->total_pages>1}
	{$start=$theme->total_pages-3}
	{if $start<2}{$start=2}{/if}
	<div>
		<ul class="pagination pagination-sm no-margin">
			{if $start!=2}<li class="disabled"><a href="">...</a></li>{/if}
			{for $page=$start to $theme->total_pages}
				<li><a href="{url action='theme' var1=$theme->id var2=$page var3=$smarty.get.search}">{$page}</a></li>
			{/for}
		</ul>
	</div>
{/if}
{if $theme->hidden_by}<small><b>[удалена <a href="{url action="profile" href=getModulePath($_cfg.core.auth_module) var1=$theme->hidden_by->id}" title="">{$theme->hidden_by->login|escape}</a>]</b></small>{/if}
</td>
<td>
	{include file="login/user_item_small.tpl" user=$theme->author}
</td>
<td>{$theme->total_posts}</td>
<td>
	{if $theme->last_post_date}
		<a href="{url action='theme' var1=$theme->id var2=999 var3=$smarty.get.search}#last" title="{t}последнее сообщение{/t}">
			<small class="no-wrap">{$theme->last_post_date|date_format:"%H:%M %d.%m.%Y"}</small>
		</a>
		{include file="login/user_item_small.tpl" user=$theme->last_user}
	{/if}
</td>
{if !$forum->id}<td><a href="{url var1=$theme->forum->id}">{$theme->forum->name|escape}</a></td>{/if}
{if access('admin, moderator')}<td>
	<div style="width:82px;" class="btn-group">
		{if $theme->hidden_by}
			<a href="{url action='unhide_theme' var1=$theme->id redirect=$smarty.server.REQUEST_URI token=1}" title='{t}Восстановить тему{/t}' class="btn btn-xs btn-default"><img class="icon" src="/skins/default/images/icons/simple_component.png" alt="{t}восстановить тему{/t}" /></a>
		{else}
			{if $theme->pinup}
				<a class="btn btn-xs btn-default" title="{t}Открепить{/t}" href="{url action="toggle" var1=$theme->id redirect=$smarty.server.REQUEST_URI token=1}"><img class="icon" src="/skins/default/images/icons/simple_pin.png" alt="{t}Открепить{/t}" /></a>
			{else}
				<a class="btn btn-xs btn-default" title="{t}Прикрепить{/t}" href="{url action="toggle" var1=$theme->id redirect=$smarty.server.REQUEST_URI token=1}"><img class="icon" src="/skins/default/images/icons/simple_doc.png" alt="{t}Прикрепить{/t}" /></a>
			{/if}
			<a class="btn btn-xs btn-default" href="{url action='hide_theme' var1=$theme->id redirect=$smarty.server.REQUEST_URI token=1}" title="{t}Скрыть тему{/t}"  onclick="return confirm('{t}Вы уверены?{/t}');"><img class="icon" src="/skins/default/images/icons/simple_noaccess.png" alt="{t}скрыть тему{/t}" /></a>
		{/if}
		{if access('admin')}
		<a class="btn btn-xs btn-default" href="{url action='delete_theme' var1=$theme->id redirect=$smarty.server.REQUEST_URI token=1}" title="{t}Удалить тему{/t}"  onclick="return confirm('{t}Вы уверены?{/t}');"><img src="/skins/default/images/icons/simple_delete.png" alt="{t}Удалить тему{/t}" /></a>
		{/if}
	</div>
	
</td>{/if}
</tr>
{/foreach}
</tbody>
</table>

{if $pager.pages}
<div>
	<ul class="pagination">
	{foreach $pager.pages as $page}
		{if !$page}
			<li class="disabled"><a>...</a></li>
		{else}
			<li{if $page==$pager.current} class="active"{/if}><a href="{url action=$smarty.get.action var1=$smarty.get.var1|default:0 var2=$page var3=$smarty.get.search}">{$page}</a></li>
		{/if}
	{/foreach}
	</ul>
</div>
{/if}
</div>