📄 posticons.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.WebControls;
using System.Web.UI;
using CommunityServer.Components;
using System.IO;
using System.Collections;
namespace CommunityServer.Controls {
public class PostIcons: PlaceHolder {
#region Member variables
CSContext csContext = CSContext.Current;
bool isCloakedUser = false;
#endregion
#region Render functions
protected override void Render(HtmlTextWriter writer)
{
string img = "<br><img title=\"{0}\" alt=\"{0}\" src=\"" + Globals.GetSkinPath() + "/images/rankicons/{1}.gif" + "\">";
if (this.User.IsAnonymous || IsCloakedUser)
return;
switch (this.User.PostRank[0]) {
case 1:
writer.Write( string.Format(img, CommunityServer.Components.ResourceManager.GetString("User_PostIcons_Top10"), "rankTop10"));
break;
case 2:
writer.Write( string.Format(img, CommunityServer.Components.ResourceManager.GetString("User_PostIcons_Top25"), "rankTop25"));
break;
case 4:
writer.Write( string.Format(img, CommunityServer.Components.ResourceManager.GetString("User_PostIcons_Top50"), "rankTop50"));
break;
case 8:
writer.Write( string.Format(img, CommunityServer.Components.ResourceManager.GetString("User_PostIcons_Top75"), "rankTop75"));
break;
case 16:
writer.Write( string.Format(img, CommunityServer.Components.ResourceManager.GetString("User_PostIcons_Top100"), "rankTop100"));
break;
case 32:
writer.Write( string.Format(img, CommunityServer.Components.ResourceManager.GetString("User_PostIcons_Top150"), "rankTop150"));
break;
case 64:
writer.Write( string.Format(img, CommunityServer.Components.ResourceManager.GetString("User_PostIcons_Top200"), "rankTop200"));
break;
case 128:
writer.Write( string.Format(img, CommunityServer.Components.ResourceManager.GetString("User_PostIcons_Top500"), "rankTop500"));
break;
default:
writer.Write( string.Format(img, CommunityServer.Components.ResourceManager.GetString("User_PostIcons_NotRanked"), "rank0"));
break;
}
// Do we have a gender for the this.User?
//
if ((CSContext.Current.SiteSettings.AllowGender) && (this.User.Profile.Gender != Gender.NotSet))
if (this.User.Profile.Gender == Gender.Male)
writer.Write( string.Format(img, CommunityServer.Components.ResourceManager.GetString("Male"), "GenderMale"));
else
writer.Write( string.Format(img, CommunityServer.Components.ResourceManager.GetString("Female"), "GenderFemale"));
}
#endregion
#region Private methods
private bool FileExists (string filename) {
string cacheKey = "fileExistsLookupTable";
Hashtable fileLookup = CSCache.Get(cacheKey) as Hashtable;
if (fileLookup == null) {
fileLookup= new Hashtable();
CSCache.Max(cacheKey,fileLookup);
}
if(!fileLookup.ContainsKey(filename))
{
fileLookup[filename] = File.Exists(filename);
}
return (bool) fileLookup[filename];
}
#endregion
#region Public properties
public User User {
get {
if ( _user == null ) {
Object state = ViewState[ "UserID" ];
if ( state != null ) {
Int32 userID = (Int32)state;
_user = Users.GetUser( userID, false );
}
}
return _user;
}
set {
_user = value;
if ( _user != null ) {
ViewState[ "UserID" ] = _user.UserID;
} else {
ViewState.Remove( "UserID" );
}
}
}
User _user;
/// <summary>
/// Added to specify if this user should be displayed as anonymous
/// </summary>
public bool IsCloakedUser {
get { return isCloakedUser; }
set { isCloakedUser = value; }
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -