温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.1源代码
当前文件:
SpaceBuider11/BlogControls/Admin/CreateEditBlogPost.cs,打开代码结构图
SpaceBuider11/BlogControls/Admin/CreateEditBlogPost.cs,打开代码结构图1//------------------------------------------------------------------------------ 2
// <copyright company="Tunynet"> 3
// Copyright (c) Tunynet Inc. 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
/// 发布或编辑文章 32
/// Enables creating and editing BlogThreads 33
/// </summary> 34
public class CreateEditBlogPost : WeblogAdminThemedControl 35
{ 36
Member Variables 42
43
protected override void OnInit(EventArgs e) 44
{ 45
wlContext = SBContext.Current; 46
//WLEvents.AuthorizePost(); 47
48
if (wlContext.PostID > 0) 49
currentPost = BlogPosts.GetThread(wlContext.PostID, false, true, true); 50
51
if (currentPost == null) 52
PostMode = CreateEditPostMode.NewPost; 53
else if (currentPost.SectionID != CurrentWeblog.SectionID) 54
throw new SBException(SBExceptionType.AccessDenied); 55
else 56
PostMode = CreateEditPostMode.EditPost; 57
58
base.OnInit(e); 59
} 60
61
Child Controls 118
119
protected override void AttachChildControls() 120
{ 121
postSubject = FindControl("PostSubject") as TextBox; 122
blogPostType = FindControl("BlogPostType") as BlogPostTypeDropDownList; 123
postSubject = FindControl("PostSubject") as TextBox; 124
125
editor = FindControl("PostBody") as Editor; 126
//tags = FindControl("Tags") as UserTagsCheckBoxList; 127
createBlogTag = FindControl("CreateBlogTag") as ModalLink; 128
129
commendToClubsBlock = FindControl("CommendToClubsBlock") as HtmlContainerControl; 130
commendToClubs = FindControl("CommendToClubs") as MyClubsCheckBoxList; 131
132
postExcerpt = FindControl("postExcerpt") as TextBox; 133
moderationDDL = FindControl("ModerationDDL") as CommentModerationDropDownList; 134
135
pageTitle = FindControl("PageTitle") as Literal; 136
137
postAsPrivateButton = FindControl("PostAsPrivateButton") as LinkButton; 138
postAsPrivateButton.Text = "保存为私有"; 139
postAsPrivateButton.Click += new EventHandler(PostAsPrivateButton_Click); 140
//OverideConfirmation(previewButton); 141
142
postButton = FindControl("PostButton") as LinkButton; 143
//postButton.Text = ResourceManager.GetString("CreateEditPost_PostButton"); 144
postButton.Text = "发布"; 145
postButton.Click += new System.EventHandler(PostButton_Click); 146
//OverideConfirmation(postButton); 147
148
cancelButton = FindControl("CancelButton") as LinkButton; 149
cancelButton.Text = ResourceManager.GetString("Cancel"); 150
cancelButton.Click += new System.EventHandler(CancelButton_Click); 151
//selectedTags = FindControl("selectedTags") as TextBox; 152
//OverideConfirmation(cancelButton); 153
setUserTag = FindControl("SetUserTag") as SetUserTags; 154
} 155
156
protected override void OnLoad(EventArgs e) 157
{ 158
base.OnLoad(e); 159
EnsureChildControls(); 160
if (!Page.IsPostBack) 161
Bind(); 162
} 163
164
void Bind() 165
{ 166
switch (PostMode) 167
{ 168
case CreateEditPostMode.NewPost: 169
pageTitle.Text = "发布您的文章"; 170
break; 171
case CreateEditPostMode.EditPost: 172
pageTitle.Text = "编辑您的文章"; 173
break; 174
default: 175
pageTitle.Text = "发布您的文章"; 176
break; 177
} 178
179
//加载博客标签 180
//tags.UserID = CurrentDomainUser.UserID; 181
//tags.TagType = TagType.Blog; 182
//tags.Bind(); 183
184
//if (tags.Items.Count == 0) 185
//{ 186
// Literal noTagsToolTip = FindControl("NoTagsToolTip") as Literal; 187
// if (noTagsToolTip != null) 188
// { 189
// noTagsToolTip.Visible = true; 190
// noTagsToolTip.Text = "您还没有设置博客标签,为了更灵活的对博客进行分类,您现在就可以方便地"; 191
// } 192
//} 193
194
195
if (SBConfiguration.Instance().EnableClub) 196
{ 197
commendToClubs.UserID = CurrentDomainUser.UserID; 198
commendToClubs.Bind(); 199
} 200
else 201
commendToClubsBlock.Visible = false; 202
203
BlogPostConfig pc = currentPost != null ? currentPost.PostConfig : BlogPostConfig.IsAggregated; 204
if (currentPost == null) 205
{ 206
blogPostType.SelectedValue = ((int)BlogPostType.Post).ToString(); 207
SetYesNo(pc, true, true, true, CurrentWeblog.EnableRatings, CurrentWeblog.EnableTrackbacks); 208
moderationDDL.Items.FindByValue(CurrentWeblog.ModerationType.ToString()).Selected = true; 209
} 210
else 211
{ 212
postSubject.Text = WebUtils.HtmlDecode(currentPost.Subject); 213
editor.Text = currentPost.Body; 214
215
ListItem tempListItem = blogPostType.Items.FindByValue(((int)currentPost.BlogPostType).ToString()); 216
if (tempListItem != null) 217
tempListItem.Selected = true; 218
219
SetYesNo(pc, currentPost.IsPublic, !currentPost.IsLocked, false, currentPost.EnableRatings, currentPost.EnableTrackBacks); 220
221
if (currentPost.Tags.Count > 0) 222
{ 223
string selectedTags = string.Empty; 224
foreach (UserTag tag in currentPost.Tags) 225
{ 226
if (string.IsNullOrEmpty(selectedTags)) 227
selectedTags = tag.TagName; 228
else 229
selectedTags += string.Format(",{0}", tag.TagName); 230
} 231
setUserTag.SetSelectedValues = selectedTags; 232
} 233
234
235
236
if (SBConfiguration.Instance().EnableClub) 237
{ 238
if (commendToClubs.Items.Count > 0) 239
{ 240
ArrayList commendToClubIDs = CommendedPosts.GetCommendedClubIDs(ApplicationType.Blog, currentPost.PostID, CurrentDomainUser.UserID); 241
if (commendToClubIDs.Count > 0) 242
{ 243
foreach (int clubID in commendToClubIDs) 244
{ 245
ListItem li = commendToClubs.Items.FindByValue(clubID.ToString()); 246
if (li != null) 247
li.Selected = true; 248
} 249
} 250
} 251
} 252
253
if (postExcerpt != null) 254
postExcerpt.Text = currentPost.Excerpt; 255
256
moderationDDL.Items.FindByValue(currentPost.ModerationType.ToString()).Selected = true; 257
} 258
259
} 260
261
262
263
Events 291
292
293
Supporting Methods




