温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载: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.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
/// <remarks> 暂时去掉主题功能</remarks> 25
public abstract class WeblogThemedControl : UserDomainThemedControl 26
{ 27
public WeblogThemedControl() 28
: base() 29
{} 30
31
/// <summary> 32
/// All skins should be found in the skin directory and named after the control. 33
/// </summary> 34
protected override string ExternalSkinFileName 35
{ 36
get 37
{ 38
string name = ValueHelper.IsNullOrEmpty(this.SkinName) ? "Skin-" + this.GetType().Name + ".ascx" : SkinName; 39
return string.Format("Skins/Blogs/{0}", name); 40
} 41
} 42
43
protected override void SetPageTitle(string text) 44
{ 45
if (ValueHelper.IsNullOrEmpty(text)) 46
text = CurrentWeblog.SectionName; 47
else 48
text = string.Format("{1}{0}{2}",SBContext.Current.BrowserTitleSeparator, text, CurrentWeblog.SectionName); 49
50
base.SetPageTitle(text); 51
} 52
53
/// <summary> 54
/// 检查Blog是否存在,并且用户是否有阅读的权限 55
/// </summary> 56
protected virtual void Authorize(Weblog w) 57
{ 58
if (w == null) 59
PermissionBase.RedirectOrExcpetion(SBExceptionType.SectionNotFound, string.Format("Weblog {0} could not be found", SBContext.Current.UserDomainName)); 60
61
Permissions.AccessCheck(w, Permission.View, this.CurrentUser); 62
} 63
64
private Weblog _currentWeblog = null; 65
public virtual Weblog CurrentWeblog 66
{ 67
get 68
{ 69
if ((_currentWeblog == null) || (!_currentWeblog.ApplicationKey.Equals(SBContext.Current.UserDomainName, StringComparison.CurrentCultureIgnoreCase))) 70
{ 71
//ApplicationKey 与 UserDomainName 相同 72
_currentWeblog = Weblogs.GetWeblog(SBContext.Current.UserDomainName, true, true); 73
74
if (!this.CurrentUser.IsBlogAdministrator) 75
Authorize(_currentWeblog); 76
} 77
return _currentWeblog; 78
} 79
} 80
81
82
} 83
} 84





}