<%@ Reference VirtualPath="~/bitrix/components/bitrix/blog.post.list/component.ascx" %>
<%@ Control Language="C#" Inherits="Bitrix.Blog.Components.BlogPostListTemplate" EnableViewState="false" %>
<%@ Import Namespace="Bitrix.Blog" %>
<%@ Import Namespace="Bitrix.Blog.Components" %>
<%@ Import Namespace="System.Collections.Generic" %>

<%	if (Component.FatalError != BlogPostListComponent.ErrorCode.None) { %>
	<%= Component.GetErrorHtml(Component.FatalError) %>
<%
	return;
}
else if (Component.Posts.Count < 1)
{
	return;
} 
%>

<div class="blog-list">
	<div class="blog-list-pager">
		<bx:IncludeComponent runat="server" ID="HeaderPager" ComponentName="bitrix:system.pager" Template="<%$ Parameters:PagingTemplate %>"/>
	</div><br />

<%
	BlogPostListComponent.PostInfo post = null;
	int cutNum = 0;	
	Component.RenderHideCut += delegate(object sender, BXBlogCutTagEventArgs e)
	{
		cutNum++;
		string title = !Bitrix.Services.Text.BXStringUtility.IsNullOrTrimEmpty(e.Option) ? e.Option.Trim() : "Подробнее...";
		e.Writer.Write(String.Concat(@"<a href=""", post.PostViewHref, "#cut", cutNum,  @""">", Encode(title), "</a>"));
		
	};			
	for(int i = 0; i < Component.Posts.Count; i++)
	{
		cutNum = 0;
		post = Component.Posts[i];
%>	
	<div class="blog-item">
		<span class="blog-date-time"><%= post.Post.DatePublished.ToString("g") %></span>
		<a href="<%= post.PostViewHref %>"><b><%= post.TitleHtml %></b></a><br />
		<%= post.GetContentHtml() %>
		<br clear="all" />
	</div>
<%
	} 
%>
	<div class="blog-list-pager">
		<bx:IncludeComponent runat="server" ID="FooterPager" ComponentName="bitrix:system.pager" Template="<%$ Parameters:PagingTemplate %>"/>
	</div>
</div>