📄 postflatview.cs
字号:
#region Post Stats
string[] info = new string[3];
if (threadStats != null)
{
// Quick access to the first post, and only access
// data we have (no trips to the DP).
//
if (postSet.TotalRecords > 0)
{
ForumPost topPost;
if (Int32.Parse(sortOrder.SelectedValue) == (int)SortOrder.Ascending)
topPost = (ForumPost) postSet.Posts[0];
else
topPost = (ForumPost) postSet.Posts[postSet.Posts.Count-1];
info[0] = topPost.Username;
info[1] = Formatter.FormatDate(topPost.PostDate, true);
info[2] = Convert.ToString(postSet.TotalRecords - 1);
}
threadStats.Text = String.Format( ResourceManager.GetString("PostFlatView_BriefInfo"), info);
}
#endregion
}
private void postRepeater_ItemDataBound(Object sender, RepeaterItemEventArgs e) {
if( e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem )
{
ForumPost post = e.Item.DataItem as ForumPost;
User user = post.User;
switch ( e.Item.ItemType )
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
ForumImageButton replyButton = (ForumImageButton) e.Item.FindControl("ReplyButton");
ForumImageButton quoteButton = (ForumImageButton) e.Item.FindControl("QuoteButton");
ForumImageButton deleteButton = (ForumImageButton) e.Item.FindControl("DeleteButton");
ForumImageButton editButton = (ForumImageButton) e.Item.FindControl("EditButton");
ModerationMenu modMenu = (ModerationMenu)e.Item.FindControl( "ModerationMenu" );
UserOnlineStatus onlineStatus = (UserOnlineStatus)e.Item.FindControl( "OnlineStatus" );
UserAvatar avatar = (UserAvatar)e.Item.FindControl( "Avatar" );
Literal username = (Literal)e.Item.FindControl( "Username" );
PostIcons postIcon = (PostIcons)e.Item.FindControl( "PostIcon" );
RoleIcons roleIcon = (RoleIcons)e.Item.FindControl( "RoleIcon" );
UserAttribute joinedAttribute = (UserAttribute)e.Item.FindControl( "JoinedAttribute" );
UserAttribute locationAttribute = (UserAttribute)e.Item.FindControl( "LocationAttribute" );
UserAttribute postsAttribute = (UserAttribute)e.Item.FindControl( "PostsAttribute" );
Literal emoticon = (Literal)e.Item.FindControl( "Emoticon" );
Literal subject = (Literal)e.Item.FindControl( "Subject" );
PostAttachment postAttachment = (PostAttachment)e.Item.FindControl( "PostAttachment" );
PostView postView = (PostView)e.Item.FindControl( "PostView" );
HtmlAnchor postAnchor = (HtmlAnchor)e.Item.FindControl( "PostAnchor" );
PostImageButtons buttonsForPoster = (PostImageButtons)e.Item.FindControl( "ButtonsForPoster" );
Literal postIPAddress = (Literal)e.Item.FindControl( "PostIPAddress" );
HyperLink reportLink = (HyperLink)e.Item.FindControl( "ReportLink" );
StatusDropDownList threadStatus = e.Item.FindControl( "ThreadStatus" ) as StatusDropDownList;
ResourceLabel threadStatusLabel = e.Item.FindControl( "ThreadStatusLabel" ) as ResourceLabel;
Boolean userCanReply = UserCanReply();
if (replyButton != null)
{
replyButton.Post = post;
replyButton.Visible = userCanReply;
}
if (quoteButton != null)
{
quoteButton.Post = post;
quoteButton.Visible = userCanReply;
}
if (deleteButton != null)
{
deleteButton.Post = post;
deleteButton.Visible = permission.Delete;
}
if (editButton != null)
{
editButton.Post = post;
editButton.Visible = permission.Edit;
}
if (threadStatus != null) {
// set it ready for postback
threadStatus.AutoPostBack = true;
threadStatus.StatusChanged += new ThreadStatusEventHandler( ThreadStatus_Changed );
threadStatus.ThreadID = post.ThreadID;
// Check if it is visible
bool isVisible = ( (post.PostLevel == 1) &&
(CSContext.Current.SiteSettings.EnableThreadStatus) &&
(CSContext.Current.User.IsAdministrator ||
(CSContext.Current.User.UserID == post.User.UserID))
) ? true : false;
// Set controls if they are visible
threadStatus.Visible = isVisible;
threadStatusLabel.Visible = isVisible;
// Only if visible get thread details. Thas happens only one time per thread listing.
if (isVisible) {
Thread postThread = Threads.GetThread( post.ThreadID );
if (postThread != null) {
threadStatus.SelectedValue = postThread.Status;
}
}
}
if (modMenu != null)
{
modMenu.Post = post;
modMenu.Forum = forum;
// Set it to watch for thread lock/unlock events to refresh the page
modMenu.PostModerateRefresh += new EventHandler(ModerationMenu_PostModerateRefresh);
}
// Notice the following controls that the user should be seen as anonymous
//
bool swowUserAsAnonymous = (post.IsAnonymousPost && siteEnableUserPostingAsAnonymous && forumEnableUserPostingAsAnonymous);
if (onlineStatus != null)
{
onlineStatus.User = user;
onlineStatus.IsCloakedUser = swowUserAsAnonymous;
}
if (avatar != null)
{
avatar.User = user;
avatar.IsCloakedUser = swowUserAsAnonymous;
}
if (username != null)
username.Text = Formatter.FormatUsername ( user.UserID, post.Username, swowUserAsAnonymous );
if (postIcon != null)
{
postIcon.User = user;
postIcon.IsCloakedUser = swowUserAsAnonymous;
}
if (roleIcon != null)
{
roleIcon.User = user;
roleIcon.IsCloakedUser = swowUserAsAnonymous;
}
if (joinedAttribute != null)
{
joinedAttribute.User = user;
joinedAttribute.IsCloakedUser = swowUserAsAnonymous;
}
if (locationAttribute != null)
{
locationAttribute.User = user;
locationAttribute.IsCloakedUser = swowUserAsAnonymous;
}
if (postsAttribute != null)
{
postsAttribute.User = user;
postsAttribute.IsCloakedUser = swowUserAsAnonymous;
}
if (emoticon != null)
emoticon.Text = Formatter.GetEmotionMarkup( post.EmoticonID );
if (subject != null)
subject.Text = post.Subject;
if (postAttachment!= null)
postAttachment.Post = post;
if (postView != null)
postView.Post = post;
if (postAnchor != null)
postAnchor.Name = post.PostID.ToString();
if (buttonsForPoster != null)
{
buttonsForPoster.User = user;
buttonsForPoster.IsCloakedUser = swowUserAsAnonymous;
}
if (postIPAddress != null)
postIPAddress.Text = Formatter.PostIPAddress( post );
if (reportLink != null)
{
reportLink.Visible = !user.IsAnonymous;
ForumUrls forumUrls = new ForumUrls();
reportLink.NavigateUrl = forumUrls.Report(reportForum.SectionID) + "&ReportPostID=" + post.PostID.ToString();
reportLink.Text = ResourceManager.GetString("Report");
}
break;
}
}
}
private Boolean UserCanReply()
{
if (user.IsAnonymous)
return true;
Boolean permissionToReply = permission.Reply;
Boolean anonUserCanPost = ( CSContext.Current.SiteSettings.EnableAnonymousUserPosting && forum.EnableAnonymousPosting );
return ( permissionToReply && ( !user.IsAnonymous || anonUserCanPost ) );
}
private Boolean UserCanPost()
{
if (user.IsAnonymous)
return true;
Boolean permissionToPost = permission.Post;
Boolean anonUserCanPost = ( CSContext.Current.SiteSettings.EnableAnonymousUserPosting && forum.EnableAnonymousPosting );
return ( permissionToPost && ( !user.IsAnonymous || anonUserCanPost ) );
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -