📄 commentpage.cs
字号:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DNNLite.Entites.Modules;
using DNNLite.DesktopModules.Comment;
using NHibernate.Expression;
using DNNLite.Service;
/// <summary>
///CommentPage 的摘要说明
/// </summary>
public class CommentPage : PortalModuleBase
{
protected string key = string.Empty;
protected string subject = string.Empty;
protected bool cancomment;
protected bool needcomment;
protected int sourcetabmoduleid;
protected bool ischecked;
protected override void OnLoad(EventArgs e)
{
Page.RegisterClientScriptBlock("jquery-latest.pack.js", "<script src=\"" + ResolveUrl("~/scripts/jquery-latest.pack.js") + "\" type=\"text/javascript\" language=\"javascript\"></script>");
if (!string.IsNullOrEmpty(Request["sourcecommentkey"]) && !string.IsNullOrEmpty(Request["sourcetabmoduleid"]))
{
ischecked = LoadOptionFromRequest(Request["sourcecommentkey"],
int.Parse(Request["sourcetabmoduleid"])
);
}
else
{
ischecked = LoadOptionFromSetting();
}
base.OnLoad(e);
}
private bool LoadOptionFromRequest(string commentkey, int tabmoduleid)
{
TabModule tm = SystemLoadController.GetTabModule(tabmoduleid);
if (tm == null)
{
return false;
}
foreach (ModuleControlInfo ctl in tm.ModuleDefiniton.ModuleControls)
{
if (string.IsNullOrEmpty(ctl.ControlKey))
{
PortalModuleBase p =
(PortalModuleBase)LoadControl(ctl.ControlSrc);
if (!(p is ICommentAble)) { return false; }
ICommentAble comment = p as ICommentAble;
CommentOption opt = comment.GetCommentOption(commentkey);
key = opt.CommentKey;
subject = opt.Subject;
cancomment = opt.CanComment;
needcomment = opt.NeedComment;
sourcetabmoduleid = tabmoduleid;
return true;
}
}
return false;
}
private bool LoadOptionFromSetting()
{
if (!Settings.ContainsKey("source")) { return false; }
if (Settings["source"] == "module")
{
string tabmoduleid = Settings["tabmoduleid"];
DNNLite.UI.Skins.Skin sk = (DNNLite.UI.Skins.Skin)
HttpContext.Current.Items["portalskin"];
try
{
if (!sk.PortalModules.ContainsKey(int.Parse(tabmoduleid)))
{
return false;
}
}
catch (FormatException)
{
return false;
}
ICommentAble comment = sk.PortalModules[int.Parse(tabmoduleid)] as ICommentAble;
if (comment == null)
{
return false;
}
CommentOption opt = comment.GetCommentOption();
key = opt.CommentKey;
subject = opt.Subject;
cancomment = opt.CanComment;
needcomment = opt.NeedComment;
sourcetabmoduleid = int.Parse(tabmoduleid);
return true;
}
else
{
key = Settings["key"];
subject = Settings["subject"];
cancomment = bool.Parse(Settings["cancomment"]);
needcomment = bool.Parse(Settings["needcomment"]);
sourcetabmoduleid = TabModuleInfo.TabModuleId;
return true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -