📄 baseblogpage.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Web;
using CommunityServer.Blogs.Components;
using CommunityServer.Components;
namespace CommunityServer.ControlPanel.UI
{
/// <summary>
/// Summary description for BaseBlogPage.
/// </summary>
public class BaseBlogPage : PanelPage
{
public BaseBlogPage()
{
}
protected override void Authorize()
{
base.Authorize ();
Weblog w = WeblogLookUp();
Permissions.AccessCheck(w,Permission.Post,CSContext.Current.User);
SetLocation();
}
public void SetCookie(Weblog w)
{
if(w == null)
return;
CSContext context = CSContext.Current;
HttpCookie cookie = context.Context.Request.Cookies[CreateApplicationCookieName(context,"weblog")];
if(cookie == null)
{
cookie = new HttpCookie(CreateApplicationCookieName(context,"weblog"));
}
cookie.Values["BlogID"] = w.SectionID.ToString();
cookie.Expires = DateTime.Now.AddDays(30);
context.Context.Response.Cookies.Add(cookie);
}
protected virtual Weblog WeblogLookUp()
{
if(_weblog == null)
{
CSContext context = CSContext.Current;
if(context.SectionID > 0)
{
_weblog = Weblogs.GetWeblog(context.SectionID,true,false);
SetCookie(_weblog);
}
else
{
HttpCookie cookie = context.Context.Request.Cookies[CreateApplicationCookieName(context,"weblog")];
if(cookie != null)
{
if(!Globals.IsNullorEmpty(cookie.Values["BlogID"]))
{
int bid = Int32.Parse(cookie.Values["BlogID"]);
try
{
_weblog = Weblogs.GetWeblog(bid,true,false);
}
catch{}
}
}
}
if(_weblog == null)
{
ArrayList blogs = Weblogs.GetWeblogs(true,false,false);
blogs = Sections.FilterByAccessControl(blogs,Permission.Post,context.User);
if(blogs != null && blogs.Count == 1)
{
_weblog = blogs[0] as Weblog;
SetCookie(_weblog);
}
}
if(_weblog == null)
Response.Redirect("switch.aspx");
}
return _weblog;
}
private Weblog _weblog = null;
public Weblog CurrentWeblog
{
get{ return _weblog;}
}
public BlogPostType FetchBlogPostType
{
get
{
string bpt = Request.QueryString["BPT"];
if(Globals.IsNullorEmpty(bpt))
return BlogPostType.Post;
else
return (BlogPostType)Enum.Parse(typeof(BlogPostType),bpt);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -