📄 forumanchor.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using CommunityServer.Components;
using CommunityServer.Configuration;
using CommunityServer.Discussions.Components;
namespace CommunityServer.Discussions.Controls {
public class ForumAnchor : HtmlAnchor {
CSContext csContext = CSContext.Current;
protected override void CreateChildControls() {
string nbspPadding = "";
// loop through and create the amount of spacing
//
if (this.nbSpacing > 0) {
for (int i = 0; i < nbSpacing; i++) {
nbspPadding += " ";
}
}
switch (AnchorType) {
case ForumAnchorType.ForumSubscriptions:
if (csContext.User.IsAnonymous)
this.Visible = false;
else
{
this.InnerHtml = ResourceManager.GetString("Utility_ForumAnchorType_ForumSubscriptions");
this.HRef = ForumUrls.Instance().ForumSubscriptions;
}
break;
case ForumAnchorType.MenuHome:
this.HRef = Globals.GetSiteUrls().ForumsHome;
if (ShowIcon) {
this.InnerHtml = "<img border=\"0\" onMouseOver=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_home_over.gif'\" onMouseOut=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_home.gif\'\" src=\"" + Globals.GetSkinPath() + "/images/icon_mini_home.gif\">";
this.Title = ResourceManager.GetString("Utility_ForumAnchorType_MenuHome");
} else
this.InnerHtml = ResourceManager.GetString("Utility_ForumAnchorType_MenuHome") + nbspPadding;
break;
case ForumAnchorType.MenuSearch:
this.HRef = Globals.GetSiteUrls().Search;
if (ShowIcon) {
this.InnerHtml = "<img border=\"0\" onMouseOver=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_search_over.gif'\" onMouseOut=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_search.gif\'\" src=\"" + Globals.GetSkinPath() + "/images/icon_mini_search.gif\">";
this.Title = ResourceManager.GetString("Utility_ForumAnchorType_MenuSearch");
} else
this.InnerHtml = ResourceManager.GetString("Utility_ForumAnchorType_MenuSearch") + nbspPadding;
break;
case ForumAnchorType.MenuEditProfile:
this.HRef = Globals.GetSiteUrls().UserEditProfile;
if (ShowIcon) {
this.InnerHtml = "<img border=\"0\" onMouseOver=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_profile_over.gif'\" onMouseOut=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_profile.gif\'\" src=\"" + Globals.GetSkinPath() + "/images/icon_mini_profile.gif\">";
this.Title = ResourceManager.GetString("Utility_ForumAnchorType_MenuEditProfile");
} else
this.InnerHtml = ResourceManager.GetString("Utility_ForumAnchorType_MenuEditProfile") + nbspPadding;
break;
case ForumAnchorType.MenuLogin:
this.HRef = Globals.GetSiteUrls().Login;
if (ShowIcon) {
this.InnerHtml = "<img border=\"0\" onMouseOver=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_login_over.gif'\" onMouseOut=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_login.gif\'\" src=\"" + Globals.GetSkinPath() + "/images/icon_mini_login.gif\">";
this.Title = ResourceManager.GetString("Utility_ForumAnchorType_MenuLogin");
} else
this.InnerHtml = ResourceManager.GetString("Utility_ForumAnchorType_MenuLogin") + nbspPadding;
break;
case ForumAnchorType.MenuLogout:
this.HRef = Globals.GetSiteUrls().Logout;
if (ShowIcon) {
this.InnerHtml = "<img border=\"0\" onMouseOver=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_logoff_over.gif'\" onMouseOut=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_logoff.gif\'\" src=\"" + Globals.GetSkinPath() + "/images/icon_mini_logoff.gif\">";
this.Title = ResourceManager.GetString("Utility_ForumAnchorType_MenuLogout");
} else
this.InnerHtml = ResourceManager.GetString("Utility_ForumAnchorType_MenuLogout") + nbspPadding;
break;
case ForumAnchorType.MenuRegister:
this.HRef = Globals.GetSiteUrls().UserRegister;
if (ShowIcon) {
this.InnerHtml = "<img border=\"0\" onMouseOver=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_profile_over.gif'\" onMouseOut=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_profile.gif\'\" src=\"" + Globals.GetSkinPath() + "/images/icon_mini_profile.gif\">";
this.Title = ResourceManager.GetString("Utility_ForumAnchorType_MenuRegister");
} else
this.InnerHtml = ResourceManager.GetString("Utility_ForumAnchorType_MenuRegister") + nbspPadding;
break;
case ForumAnchorType.MenuMemberList:
this.HRef = Globals.GetSiteUrls().UserList;
if (ShowIcon) {
this.InnerHtml = "<img border=\"0\" onMouseOver=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_memberlist_over.gif'\" onMouseOut=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_memberlist.gif\'\" src=\"" + Globals.GetSkinPath() + "/images/icon_mini_memberlist.gif\">";
this.Title = ResourceManager.GetString("Utility_ForumAnchorType_MenuMemberList");
} else
this.InnerHtml = ResourceManager.GetString("Utility_ForumAnchorType_MenuMemberList") + nbspPadding;
break;
case ForumAnchorType.MenuMyForums:
this.HRef = Globals.GetSiteUrls().UserMyForums;
if (ShowIcon) {
this.InnerHtml = "<img border=\"0\" onMouseOver=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_myforums_over.gif'\" onMouseOut=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_myforums.gif\'\" src=\"" + Globals.GetSkinPath() + "/images/icon_mini_myforums.gif\">";
this.Title = ResourceManager.GetString("Utility_ForumAnchorType_MenuMyForums");
} else
this.InnerHtml = ResourceManager.GetString("Utility_ForumAnchorType_MenuMyForums") + nbspPadding;
break;
case ForumAnchorType.MenuFaq:
this.HRef = Globals.GetSiteUrls().FAQ;
User user = csContext.User;
CSConfiguration config = CSConfiguration.GetConfig();
if( user != null &&
config != null &&
user.Profile.Language != null &&
user.Profile.Language != String.Empty &&
config.DefaultLanguage != null &&
config.DefaultLanguage != String.Empty ) {
this.HRef = this.HRef.Replace(config.DefaultLanguage, csContext.User.Profile.Language );
}
if (ShowIcon) {
this.InnerHtml = "<img border=\"0\" onMouseOver=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_faq_over.gif'\" onMouseOut=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_faq.gif\'\" src=\"" + Globals.GetSkinPath() + "/images/icon_mini_faq.gif\">";
this.Title = ResourceManager.GetString("Utility_ForumAnchorType_MenuFaq");
} else
this.InnerHtml = ResourceManager.GetString("Utility_ForumAnchorType_MenuFaq") + nbspPadding;
break;
case ForumAnchorType.MenuModerate:
this.HRef = Globals.GetSiteUrls().Moderate;
if (ShowIcon) {
this.InnerHtml = "<img border=\"0\" onMouseOver=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_moderate_over.gif'\" onMouseOut=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_moderate.gif\'\" src=\"" + Globals.GetSkinPath() + "/images/icon_mini_moderate.gif\">";
this.Title = ResourceManager.GetString("Utility_ForumAnchorType_MenuModerate");
} else
this.InnerHtml = ResourceManager.GetString("Utility_ForumAnchorType_MenuModerate") + nbspPadding;
break;
case ForumAnchorType.MenuAdmin:
this.HRef = Globals.GetSiteUrls().ControlPanel;
if (ShowIcon) {
this.InnerHtml = "<img border=\"0\" onMouseOver=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_admin_over.gif'\" onMouseOut=\"src='" + Globals.GetSkinPath() + "/images/icon_mini_admin.gif\'\" src=\"" + Globals.GetSkinPath() + "/images/icon_mini_admin.gif\">";
this.Title = ResourceManager.GetString("Utility_ForumAnchorType_MenuAdmin");
} else
this.InnerHtml = ResourceManager.GetString("Utility_ForumAnchorType_MenuAdmin") + nbspPadding;
break;
case ForumAnchorType.PostsActive:
this.HRef = ForumUrls.Instance().PostsActive;
this.InnerText = ResourceManager.GetString("Utility_ForumAnchorType_PostsActive");
break;
case ForumAnchorType.PostsNotRead:
this.HRef = ForumUrls.Instance().PostsNotRead;
this.InnerText = ResourceManager.GetString("Utility_ForumAnchorType_PostsNotRead");
break;
case ForumAnchorType.PostsUnanswered:
this.HRef = ForumUrls.Instance().PostsUnanswered;
this.InnerText = ResourceManager.GetString("Utility_ForumAnchorType_PostsUnanswered");
break;
case ForumAnchorType.PostsVideos:
this.HRef = ForumUrls.Instance().PostsVideos;
this.InnerText = ResourceManager.GetString("Utility_ForumAnchorType_PostsVideos");
break;
case ForumAnchorType.UserForgotPassword:
this.HRef = Globals.GetSiteUrls().UserForgotPassword;
this.InnerText = ResourceManager.GetString("Utility_ForumAnchorType_UserForgotPassword");
break;
case ForumAnchorType.UserRegister:
this.HRef = Globals.GetSiteUrls().UserRegister;
this.InnerText = ResourceManager.GetString("Utility_ForumAnchorType_UserRegister");
break;
case ForumAnchorType.Login:
this.HRef = Globals.GetSiteUrls().Login;
this.InnerText = ResourceManager.GetString("Utility_ForumAnchorType_Login");
break;
case ForumAnchorType.MenuPrivateForum:
this.HRef = Globals.GetSiteUrls().UserPrivateMessages;
this.InnerText = ResourceManager.GetString("PrivateMessages_Title");
break;
}
}
[
System.ComponentModel.DefaultValue( ForumAnchorType.PostsUnanswered ),
]
public virtual ForumAnchorType AnchorType {
get {
Object state = ViewState["AnchorType"];
if ( state != null ) {
return (ForumAnchorType)state;
}
return ForumAnchorType.PostsUnanswered;
}
set {
ViewState["AnchorType"] = value;
}
}
[
System.ComponentModel.DefaultValue( true ),
]
public virtual Boolean ShowIcon {
get {
Object state = ViewState["ShowIcon"];
if ( state != null ) {
return (Boolean)state;
}
return true;
}
set {
ViewState["ShowIcon"] = value;
}
}
// used for inserting s around the text.
// this is because we hide/show them as needed,
// and nbsps don't format properly in the skin.
[
System.ComponentModel.DefaultValue( 0 ),
]
public virtual Int32 nbSpacing {
get {
Object state = ViewState["nbSpacing"];
if ( state != null ) {
return (Int32)state;
}
return 0;
}
set {
ViewState["nbSpacing"] = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -