📄 postmoderateview.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
// TODO: Remove code that display help...
using System;using System.Web.UI;using System.Web.UI.WebControls;using CommunityServer.Components;using CommunityServer.Controls;
using CommunityServer.Discussions.Components;
namespace CommunityServer.Discussions.Controls
{
// *********************************************************************
// PostModerateView
//
/// <summary>
/// This server control is used to display top level threads. Note, a thread
/// is a post with more information. The Thread class inherits from the Post
/// class.
/// </summary>
///
// ********************************************************************/
public class PostModerateView : TemplatedWebControl
{
CSContext csContext = CSContext.Current;
Repeater postRepeater;
/// <summary>
/// If not a page back, calls DataBind()
/// </summary>
/// <param name="e"></param>
protected override void OnLoad(EventArgs e)
{
if ( !Page.IsPostBack )
{
this.DataBind();
}
base.OnLoad (e);
}
/// <summary>
/// Sets a default Skin name. All Applications should reuse this control and
/// hopefully this skin as well.
/// </summary>
protected override String ExternalSkinFileName
{
get
{
return "/Moderation/View-ModerateForum.ascx";
}
}
protected override void AttachChildControls()
{
// Get the cached forum information
//
Forum forum = (Forum) Forums.GetForum(csContext.ForumID);
// Set the title
//
((Literal) FindControl("ForumDescription")).Text = string.Format(ResourceManager.GetString("Moderate_PostsToModerateDescription"), ForumGroups.GetForumGroup(forum.GroupID).Name + "->" + forum.Name);
((Literal) FindControl("ForumDetailDescription")).Text = "Forum Description: " + forum.Description;
// Find the post repeater
//
postRepeater = (Repeater) FindControl("PostRepeater");
postRepeater.ItemDataBound += new RepeaterItemEventHandler(postRepeater_ItemDataBound);
}
public void Pager_IndexChanged (Object sender, EventArgs e)
{
DataBind();
}
public override void DataBind()
{
base.DataBind();
// Get a populated thread set
//
PostSet p = Moderate.GetPosts(csContext.ForumID, 0, 25, 0, 0);
if (p.Posts.Count == 0)
{
csContext.Context.Response.Redirect(Globals.GetSiteUrls().Moderate, true);
}
else
{
postRepeater.DataSource = p.Posts;
postRepeater.DataBind();
}
}
private void postRepeater_ItemDataBound(Object sender, RepeaterItemEventArgs e)
{
ForumPost post = e.Item.DataItem as ForumPost;
switch ( e.Item.ItemType )
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
HyperLink threadLink = new HyperLink();
threadLink = (HyperLink) e.Item.FindControl("ThreadLink");
if(post.PostID != post.ParentID)
threadLink.NavigateUrl = Globals.GetSiteUrls().Post(post.ParentID);
else
threadLink.NavigateUrl = "";
break;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -