📄 forumformatter.cs
字号:
#endregion
#region Format sub-forum listings
public static string FormatSubForum (Forum forum)
{
string stringToFormat = "<br><b>" + ResourceManager.GetString("Subforums") + "</b>";
string subForumSeparator = ResourceManager.GetString("CommaSeperator");
// If there are no sub forums, return
//
if (forum.Sections.Count == 0)
return null;
foreach (Forum f in forum.Sections)
{
stringToFormat = stringToFormat + " <a href=\"" + ForumUrls.Instance().Forum(f.SectionID) + "\">" + Formatter.CheckStringLength(f.Name, 20) + "</a>" + subForumSeparator;
}
stringToFormat = stringToFormat.Remove( stringToFormat.LastIndexOf(subForumSeparator), 1);
return stringToFormat;
}
public static string FormatSubForumAdmin( Section section )
{
string stringToFormat = "<br><b>" + ResourceManager.GetString("Subforums") + "</b>";
string subForumSeparator = ResourceManager.GetString("CommaSeperator");
// If there are no sub forums, return
//
if (section.Sections.Count == 0)
return null;
Forum forum = section as Forum;
if(forum != null || section.Sections.Count == 0)
{
return null;
}
foreach (Forum f in section.Sections)
{
stringToFormat = stringToFormat + " <a href=\"" + Globals.GetSiteUrls().AdminForumEdit(f.SectionID) + "\">" + Formatter.CheckStringLength(f.Name, 16) + "</a>" + subForumSeparator;
}
stringToFormat = stringToFormat.Remove( stringToFormat.LastIndexOf(subForumSeparator), 1);
return stringToFormat;
}
#endregion
#region Formatting for read/unread status icon for Forums & Threads
public static string StatusIcon (int status)
{
string imagePath = Globals.GetSkinPath() +"/images/";
string imageName = "";
string imageTitle = "";
string openWindow = "javascript:OpenWindow('" + Globals.GetSiteUrls().HelpThreadIcons + "')";
switch (status)
{
case 1:
imageName = "topic-announce.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicAnnounce");
break;
case 2:
imageName = "topic-announce_notread.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicAnnounceNotRead");
break;
case 3:
imageName = "topic-pinned_popular.gif";
imageTitle = ResourceManager.GetString("IconAlt_PopularPost");
break;
case 4:
imageName = "topic-pinned_popular_notread.gif";
imageTitle = ResourceManager.GetString("IconAlt_PopularPost");
break;
case 5:
imageName = "topic-pinned.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicPinned");
break;
case 6:
imageName = "topic-pinned_notread.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicPinnedNotRead");
break;
case 7:
imageName = "topic-locked.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicNoReplies");
break;
case 8:
imageName = "topic-locked_notread.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicNoRepliesNotRead");
break;
case 9:
imageName = "topic-popular.gif";
imageTitle = ResourceManager.GetString("IconAlt_PopularPost");
break;
case 10:
imageName = "topic-popular_notread.gif";
imageTitle = ResourceManager.GetString("IconAlt_PopularPost");
break;
case 11:
imageName = "topic.gif";
imageTitle = ResourceManager.GetString("IconAlt_Topic");
break;
case 12:
imageName = "topic_notread.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicNotRead");
break;
}
imageName = imagePath + imageName;
return String.Format(threadStatusIcon, openWindow, imageTitle, imageName);
}
public static string StatusIcon (Thread thread)
{
string imagePath = Globals.GetSkinPath() +"/images/";
string imageName = "";
string imageTitle = "";
string openWindow = "javascript:OpenWindow('" + Globals.GetSiteUrls().HelpThreadIcons + "')";
bool hasRead = thread.HasRead;
if (CSContext.Current.User.IsAnonymous)
hasRead = true;
if (thread.IsAnnouncement)
{
if (hasRead)
{
imageName = "topic-announce.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicAnnounce");
}
else
{
imageName = "topic-announce_notread.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicAnnounceNotRead");
}
}
else if ((thread.IsSticky) && (thread.IsPopular))
{
if (hasRead)
{
imageName = "topic-pinned_popular.gif";
imageTitle = ResourceManager.GetString("IconAlt_PopularPost");
}
else
{
imageName = "topic-pinned_popular_notread.gif";
imageTitle = ResourceManager.GetString("IconAlt_PopularPost");
}
}
else if (thread.IsSticky)
{
if (hasRead)
{
imageName = "topic-pinned.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicPinned");
}
else
{
imageName = "topic-pinned_notread.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicPinnedNotRead");
}
}
else if (thread.IsLocked)
{
if (hasRead)
{
imageName = "topic-locked.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicNoReplies");
}
else
{
imageName = "topic-locked_notread.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicNoRepliesNotRead");
}
}
else if (thread.IsPopular)
{
if (hasRead)
{
imageName = "topic-popular.gif";
imageTitle = ResourceManager.GetString("IconAlt_PopularPost");
}
else
{
imageName = "topic-popular_notread.gif";
imageTitle = ResourceManager.GetString("IconAlt_PopularPost");
}
}
else
{
if (hasRead)
{
imageName = "topic.gif";
imageTitle = ResourceManager.GetString("IconAlt_Topic");
}
else
{
imageName = "topic_notread.gif";
imageTitle = ResourceManager.GetString("IconAlt_TopicNotRead");
}
}
imageName = imagePath + imageName;
return String.Format(threadStatusIcon, openWindow, imageTitle, imageName);
}
public static string StatusIcon (Forum forum)
{
string imagePath = Globals.GetSkinPath() +"/images/";
string icon = string.Empty;
string alt = string.Empty;
bool unreadPosts = true;
User u = CSContext.Current.User;
// Setup the read/unread status
if (!u.IsAnonymous) {
HybridDictionary d = Sections.GetSectionsRead(u.UserID, false);
if (d[forum.SectionID] != null) {
DateTime lastActivity = (DateTime) d[forum.SectionID];
if (forum.MostRecentPostDate <= lastActivity)
unreadPosts = false;
}
if (forum.TotalPosts == 0)
unreadPosts = false;
if (forum.MostRecentPostDate <= DateTime.Now.AddDays(-25))
unreadPosts = false;
}
switch (forum.ForumType)
{
case ForumType.KB:
if (u.IsAnonymous)
{
icon = "forum_kb.gif";
alt = ResourceManager.GetString("IconAlt_PrivateForums");
break;
}
if (unreadPosts)
{
icon = "forum_kb_new.gif";
alt = ResourceManager.GetString("IconAlt_PrivateForumsNewPosts");
}
else
{
icon = "forum_kb.gif";
alt = ResourceManager.GetString("IconAlt_PrivateForums");
}
break;
case ForumType.Newsletter:
if (u.IsAnonymous)
{
icon = "forum_newsletter.gif";
alt = ResourceManager.GetString("IconAlt_PrivateForums");
break;
}
if (unreadPosts)
{
icon = "forum_newsletter.gif";
alt = ResourceManager.GetString("IconAlt_PrivateForumsNewPosts");
}
else
{
icon = "forum_newsletter.gif";
alt = ResourceManager.GetString("IconAlt_PrivateForums");
}
break;
case ForumType.Link:
icon = "forum_link.gif";
alt = ResourceManager.GetString("IconAlt_PrivateForums");
break;
default:
if (u.IsAnonymous)
{
icon = "forum_status.gif";
alt = ResourceManager.GetString("NoUnreadPosts");
break;
}
if (forum.IsPrivate)
{
if (unreadPosts)
{
icon = "forum_private_newposts.gif";
alt = ResourceManager.GetString("IconAlt_PrivateForumsNewPosts");
}
else
{
icon = "forum_private.gif";
alt = ResourceManager.GetString("IconAlt_PrivateForums");
}
}
else
{
if (unreadPosts)
{
icon = "forum_status_new.gif";
alt = ResourceManager.GetString("IconAlt_NewPosts");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -