📄 aggregatepostlist.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.IO;
using System.Web.UI.WebControls;
using CommunityServer.Blogs.Components;
using CommunityServer.Components;
using CommunityServer.Configuration;
using CommunityServer.Controls;
namespace CommunityServer.Blogs.Controls
{
/// <summary>
/// Summary description for AggregatePostList.
/// </summary>
public class AggregatePostList : WeblogBaseTemplatedWebControl
{
public AggregatePostList()
{
//
// TODO: Add constructor logic here
//
}
AggregateList posts = null;
Literal title = null;
private int pageSize = -1;
/// <summary>
/// Property to control the number of elements that are rendered for each page in the repeater
/// </summary>
public int PageSize {
get{ return pageSize;}
set{ pageSize = value; }
}
protected override void AttachChildControls()
{
posts = FindControl("Posts") as AggregateList;
title = FindControl("title") as Literal;
posts.PagerIndexChanged +=new EventHandler(posts_PagerIndexChanged);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if ( !Page.IsPostBack || !EnableViewState )
{
DataBind();
}
}
public override void DataBind()
{
base.DataBind ();
int GroupID = Globals.SafeInt(Context.Request.QueryString["GroupID"],-1);
int day = Globals.SafeInt(Context.Request.QueryString["d"], -1);
int month = Globals.SafeInt(Context.Request.QueryString["m"], -1);
int year = Globals.SafeInt(Context.Request.QueryString["y"], -1 );
BlogThreadQuery query = new BlogThreadQuery();
if(GroupID > -1)
{
query.BlogGroupID = GroupID;
title.Text = string.Format( ResourceManager.GetString("LatestPostsTo"), WeblogGroups.GetWeblogGroup(GroupID,true,false).Name);
}
else
{
title.Text = ResourceManager.GetString("LatestPosts");
}
if( month > 0 && month < 13 &&
day > 0 && day < 32 &&
year > DateTime.MinValue.Year && year <= DateTime.MaxValue.Year ) {
try {
query.DateFilter = new DateTime( year, month, day );
}
catch{}
}
query.BlogPostType = BlogPostType.Post;
query.BlogThreadType = BlogThreadType.Recent;
query.IncludeCategories = false;
query.IsPublished = true;
query.PageIndex = posts.PageIndex;
query.PageSize = this.PageSize == -1 ? WeblogConfiguration.Instance().AggregatePostCount : this.PageSize;
query.IgnorePaging = true;
query.SortBy = BlogThreadSortBy.MostRecent;
query.SortOrder = SortOrder.Descending;
query.PostConfig = BlogPostConfig.IsCommunityAggregated | BlogPostConfig.IsAggregated;
query.FilterByList = Sections.FilterByAccessControl(Weblogs.GetWeblogs(false,true,false),Permission.View);
ThreadSet ts = WeblogPosts.GetBlogThreads(query,true,true);
posts.TotalRecords = ts.TotalRecords;
posts.PageSize = query.PageSize;
posts.DataSource = ts.Threads;
posts.DataBind();
}
private void posts_PagerIndexChanged(object sender, EventArgs e)
{
DataBind();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -