温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.0正式版源码
1//------------------------------------------------------------------------------ 2
// <copyright company="Tunynet"> 3
// Copyright (c) Tunynet Network Technology Co., Ltd. All rights reserved. 4
// </copyright> 5
//------------------------------------------------------------------------------ 6
7
using System; 8
using System.Collections; 9
using System.Web.UI; 10
using System.Web.UI.HtmlControls; 11
using System.Web.UI.WebControls; 12
13
using SpaceBuilder.Blogs.Components; 14
using SpaceBuilder.Components; 15
using SpaceBuilder.Controls; 16
using SpaceBuilder.Utils; 17
using SpaceBuilder.Controls.Utils; 18
using SpaceBuilder.Posts.Components; 19
using SpaceBuilder.Clubs.Controls; 20
using SpaceBuilder.Clubs.Components; 21
using TunyNet.Utils; 22
using TunyNet.Common; 23
using SpaceBuilder.Tags.Controls; 24
using AjaxControlToolkit; 25
using SpaceBuilder.Blogs.Configuration; 26
using SpaceBuilder.Configuration; 27
using System.Collections.Generic; 28
namespace SpaceBuilder.Blogs.Controls 29
{ 30
/// <summary> 31
/// Enables creating and editing BlogThreads 32
/// </summary> 33
public class CreateEditBlogPost : WeblogAdminThemedControl 34
{ 35
Member Variables 41
42
protected override void OnInit(EventArgs e) 43
{ 44
wlContext = SBContext.Current; 45
//WLEvents.AuthorizePost(); 46
47
if (wlContext.PostID > 0) 48
currentPost = BlogPosts.GetThread(wlContext.PostID, false, true, true); 49
50
if (currentPost == null) 51
PostMode = CreateEditPostMode.NewPost; 52
else if (currentPost.SectionID != CurrentWeblog.SectionID) 53
throw new SBException(SBExceptionType.AccessDenied); 54
else 55
PostMode = CreateEditPostMode.EditPost; 56
57
base.OnInit(e); 58
} 59
60
private Literal pageTitle; 61
TextBox postSubject; 62
BlogPostTypeDropDownList blogPostType; 63
Editor editor = null; 64
65
UserTagsCheckBoxList tags; 66
ModalLink createBlogTag; 67
MyClubsCheckBoxList commendToClubs; 68
HtmlContainerControl commendToClubsBlock; 69
70
TextBox postExcerpt; 71
CommentModerationDropDownList moderationDDL; 72
73
LinkButton postAsPrivateButton; 74
LinkButton postButton; 75
76
LinkButton cancelButton; 77
78
protected override void AttachChildControls() 79
{ 80
postSubject = FindControl("PostSubject") as TextBox; 81
blogPostType = FindControl("BlogPostType") as BlogPostTypeDropDownList; 82
postSubject = FindControl("PostSubject") as TextBox; 83
84
editor = FindControl("PostBody") as Editor; 85
tags = FindControl("Tags") as UserTagsCheckBoxList; 86
createBlogTag = FindControl("CreateBlogTag") as ModalLink; 87
88
commendToClubsBlock = FindControl("CommendToClubsBlock") as HtmlContainerControl; 89
commendToClubs = FindControl("CommendToClubs") as MyClubsCheckBoxList; 90
91
postExcerpt = FindControl("postExcerpt") as TextBox; 92
moderationDDL = FindControl("ModerationDDL") as CommentModerationDropDownList; 93
94
pageTitle = FindControl("PageTitle") as Literal; 95
96
postAsPrivateButton = FindControl("PostAsPrivateButton") as LinkButton; 97
postAsPrivateButton.Text = "保存为私有"; 98
postAsPrivateButton.Click += new EventHandler(PostAsPrivateButton_Click); 99
//OverideConfirmation(previewButton); 100
101
postButton = FindControl("PostButton") as LinkButton; 102
//postButton.Text = ResourceManager.GetString("CreateEditPost_PostButton"); 103
postButton.Text = "发布"; 104
postButton.Click += new System.EventHandler(PostButton_Click); 105
//OverideConfirmation(postButton); 106
107
cancelButton = FindControl("CancelButton") as LinkButton; 108
cancelButton.Text = ResourceManager.GetString("Cancel"); 109
cancelButton.Click += new System.EventHandler(CancelButton_Click); 110
//OverideConfirmation(cancelButton); 111
} 112
113
protected override void OnLoad(EventArgs e) 114
{ 115
base.OnLoad(e); 116
EnsureChildControls(); 117
if (!Page.IsPostBack) 118
Bind(); 119
} 120
121
void Bind() 122
{ 123
switch (PostMode) 124
{ 125
case CreateEditPostMode.NewPost: 126
pageTitle.Text = "发布您的文章"; 127
break; 128
case CreateEditPostMode.EditPost: 129
pageTitle.Text = "编辑您的文章"; 130
break; 131
default: 132
pageTitle.Text = "发布您的文章"; 133
break; 134
} 135
136
//加载博客标签 137
tags.UserID = CurrentDomainUser.UserID; 138
tags.TagType = TagType.Blog; 139
tags.Bind(); 140
141
if (tags.Items.Count == 0) 142
{ 143
Literal noTagsToolTip = FindControl("NoTagsToolTip") as Literal; 144
if (noTagsToolTip != null) 145
{ 146
noTagsToolTip.Visible = true; 147
noTagsToolTip.Text = "您还没有设置博客标签,为了更灵活的对博客进行分类,您现在就可以方便地"; 148
} 149
} 150
151
if (createBlogTag != null) 152
{ 153
createBlogTag.Url = GlobalUrls.Instance().CreateUserTag(wlContext.UserDomainName, CurrentDomainUser.UserType, TagType.Blog); 154
} 155
156
if (SBConfiguration.Instance().EnableClub) 157
{ 158
commendToClubs.UserID = CurrentDomainUser.UserID; 159
commendToClubs.Bind(); 160
} 161
else 162
commendToClubsBlock.Visible = false; 163
164
BlogPostConfig pc = currentPost != null ? currentPost.PostConfig : BlogPostConfig.IsAggregated; 165
if (currentPost == null) 166
{ 167
blogPostType.SelectedValue = ((int)BlogPostType.Post).ToString(); 168
SetYesNo(pc, true, true, true, CurrentWeblog.EnableRatings, CurrentWeblog.EnableTrackbacks); 169
moderationDDL.Items.FindByValue(CurrentWeblog.ModerationType.ToString()).Selected = true; 170
} 171
else 172
{ 173
postSubject.Text = WebUtils.HtmlDecode(currentPost.Subject); 174
editor.Text = currentPost.Body; 175
176
ListItem tempListItem = blogPostType.Items.FindByValue(((int)currentPost.BlogPostType).ToString()); 177
if (tempListItem != null) 178
tempListItem.Selected = true; 179
180
SetYesNo(pc, currentPost.IsPublic, !currentPost.IsLocked, false, currentPost.EnableRatings, currentPost.EnableTrackBacks); 181
182
if (currentPost.Tags.Count > 0) 183
{ 184
foreach (UserTag tag in currentPost.Tags) 185
{ 186
ListItem li = tags.Items.FindByValue(tag.TagID.ToString()); 187
if (li != null) 188
li.Selected = true; 189
} 190
} 191
192
if (SBConfiguration.Instance().EnableClub) 193
{ 194
if (commendToClubs.Items.Count > 0) 195
{ 196
ArrayList commendToClubIDs = CommendedPosts.GetCommendedClubIDs(ApplicationType.Blog, currentPost.PostID, CurrentDomainUser.UserID); 197
if (commendToClubIDs.Count > 0) 198
{ 199
foreach (int clubID in commendToClubIDs) 200
{ 201
ListItem li = commendToClubs.Items.FindByValue(clubID.ToString()); 202
if (li != null) 203
li.Selected = true; 204
} 205
} 206
} 207
} 208
209
if (postExcerpt != null) 210
postExcerpt.Text = currentPost.Excerpt; 211
212
moderationDDL.Items.FindByValue(currentPost.ModerationType.ToString()).Selected = true; 213
} 214
} 215
216
217
218
Events 250
251
252
Supporting Methods




