温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.1源代码
1//------------------------------------------------------------------------------ 2
// <copyright company="Tunynet"> 3
// Copyright (c) Tunynet Inc. All rights reserved. 4
// </copyright> 5
//------------------------------------------------------------------------------ 6
7
using System.Web.UI; 8
using SpaceBuilder.Blogs.Components; 9
using SpaceBuilder.Components; 10
using SpaceBuilder.Configuration; 11
using SpaceBuilder.Controls.BaseClasses; 12
using SpaceBuilder.Security; 13
using SpaceBuilder.Utils; 14
using SpaceBuilder.Controls; 15
using SpaceBuilder.Posts.Permissions; 16
using System; 17
using TunyNet.Utils; 18
19
namespace SpaceBuilder.Blogs.Controls 20
{ 21
/// <summary> 22
/// 博客中具有换肤功能的控件基类 23
/// </summary> 24
public abstract class WeblogThemedControl : UserDomainThemedControl 25
{ 26
/// <summary> 27
/// 外部Skin文件路径 28
/// </summary> 29
protected override string ExternalSkinFileName 30
{ 31
get 32
{ 33
string name = ValueHelper.IsNullOrEmpty(this.SkinName) ? "Skin-" + this.GetType().Name + ".ascx" : SkinName; 34
return string.Format("Skins/Blogs/{0}", name); 35
} 36
} 37
38
/// <summary> 39
/// 设置Html中的title 40
/// </summary> 41
/// <param name="text">用于在html的title中显示的核心部分内容</param> 42
protected override void SetPageTitle(string text) 43
{ 44
if (ValueHelper.IsNullOrEmpty(text)) 45
text = CurrentWeblog.SectionName; 46
else 47
text = string.Format("{1}{0}{2}", Globals.BrowserTitleSeparator, text, CurrentWeblog.SectionName); 48
49
base.SetPageTitle(text); 50
} 51
52
/// <summary> 53
/// 检查Blog是否存在,并且用户是否有阅读的权限 54
/// </summary> 55
protected virtual void Authorize(Weblog w) 56
{ 57
if (w == null) 58
PermissionBase.RedirectOrExcpetion(SBExceptionType.SectionNotFound, string.Format("Weblog {0} could not be found", SBContext.Current.UserDomainName)); 59
60
Permissions.AccessCheck(w, Permission.View, this.CurrentUser); 61
} 62
63
private Weblog _currentWeblog = null; 64
/// <summary> 65
/// 当前正在访问的Weblog 66
/// </summary> 67
public virtual Weblog CurrentWeblog 68
{ 69
get 70
{ 71
if ((_currentWeblog == null) || (!_currentWeblog.ApplicationKey.Equals(SBContext.Current.UserDomainName, StringComparison.CurrentCultureIgnoreCase))) 72
{ 73
//ApplicationKey 与 UserDomainName 相同 74
_currentWeblog = Weblogs.GetWeblog(SBContext.Current.UserDomainName, true, true); 75
76
if (!this.CurrentUser.IsBlogAdministrator) 77
Authorize(_currentWeblog); 78
} 79
return _currentWeblog; 80
} 81
} 82
83
84
} 85
} 86





}