//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
![](/Images/OutliningIndicators/None.gif)
using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.WebControls;
![](/Images/OutliningIndicators/None.gif)
using CommunityServer.Components;
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
namespace CommunityServer.Controls
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
![](/Images/OutliningIndicators/InBlock.gif)
[
ParseChildren(true)
]
public class JumpDropDownList : DropDownList
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
public JumpDropDownList()
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](/Images/OutliningIndicators/InBlock.gif)
// Set up some default property values
//
AutoPostBack = true;
SelectedIndexChanged += new System.EventHandler(Location_Changed);
![](/Images/OutliningIndicators/InBlock.gif)
// head of the drop down
//
Items.Add(new ListItem( "快速导航", "" ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Seperator") ));
![](/Images/OutliningIndicators/InBlock.gif)
// standard "home" links
//
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Home"), Globals.GetSiteUrls().ForumsHome));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + ResourceManager.GetString("Navigation_JumpDropDownList_Search"), Globals.GetSiteUrls().Search));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + ResourceManager.GetString("ViewActiveThreads_Title"), Globals.GetSiteUrls().PostsActive));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + ResourceManager.GetString("ViewUnansweredThreads_Title"), Globals.GetSiteUrls().PostsUnanswered));
if(!CSContext.Current.User.IsAnonymous)
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + ResourceManager.GetString("ViewNotReadThreads_Title"), Globals.GetSiteUrls().PostsNotRead));
![](/Images/OutliningIndicators/InBlock.gif)
// User Options to display, based if the user is signed in or not.
//
if (CSContext.Current.User.IsForumAdministrator || CSContext.Current.User.IsModerator)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Seperator") ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_AdminOptions") ));
if ( CSContext.Current.User.IsForumAdministrator )
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + ResourceManager.GetString("Navigation_JumpDropDownList_AdminHome"), Globals.GetSiteUrls().AdminHome ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + ResourceManager.GetString("Navigation_JumpDropDownList_ModeratorHome"), Globals.GetSiteUrls().ModerationHome ));
}
![](/Images/OutliningIndicators/InBlock.gif)
// seperator
//
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Seperator") ));
![](/Images/OutliningIndicators/InBlock.gif)
// User Options to display, based if the user is signed in or not.
//
if (!CSContext.Current.User.IsAnonymous)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_UserOptions") ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + ResourceManager.GetString("Navigation_JumpDropDownList_Profile"), Globals.GetSiteUrls().UserEditProfile ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + ResourceManager.GetString("Navigation_JumpDropDownList_PrivateMessages"), Globals.GetSiteUrls().UserPrivateMessages ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + ResourceManager.GetString("Navigation_JumpDropDownList_MyThreads"), Globals.GetSiteUrls().UserMyForums ));
//added by blogs
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Seperator") ));
Items.Add(new ListItem( "我的博客", Globals.GetSiteUrls().Home + "blogs" + "/" + CSContext.Current.User.Username + "/" + "default.aspx" ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") +"新建随笔", Globals.GetSiteUrls().Home + "admin/blogs/posteditor.aspx?App=" + CSContext.Current.User.Username + "&BPT=Post" ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") +"新建文章", Globals.GetSiteUrls().Home + "admin/blogs/posteditor.aspx?App=" + CSContext.Current.User.Username + "&BPT=Article" ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") +"管理评论", Globals.GetSiteUrls().Home + "admin/blogs/feedback.aspx?App=" + CSContext.Current.User.Username ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") +"管理链接", Globals.GetSiteUrls().Home + "admin/blogs/manageblogroll.aspx?App=" + CSContext.Current.User.Username ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") +"管理博客", Globals.GetSiteUrls().Home + "admin/blogs/weblogsettings.aspx?App=" + CSContext.Current.User.Username + "&Url=blog_myblogs&Args=" ));
//added by photos
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Seperator") ));
Items.Add(new ListItem( "我的相册", Globals.GetSiteUrls().Home + "photos" + "/" + CSContext.Current.User.Username + "/" + "default.aspx" ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") +"添加图片", Globals.GetSiteUrls().Home + "admin/gallery/PictureAdmin.aspx?App="+ CSContext.Current.User.Username + "&CategoryID=-1&PostID=-1" ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") +"管理图片", Globals.GetSiteUrls().Home + "admin/gallery/ManagePictures.aspx?App=" + CSContext.Current.User.Username + "&CategoryID=-1" ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") +"管理分类", Globals.GetSiteUrls().Home + "admin/gallery/ManageCategories.aspx?App=" + CSContext.Current.User.Username ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") +"管理相册", Globals.GetSiteUrls().Home + "admin/gallery/galleryadmin.aspx?App="+ CSContext.Current.User.Username +"&Url=gallery_ViewGallery&Args=" + CSContext.Current.User.Username ));
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_UserOptions") ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + ResourceManager.GetString("Navigation_JumpDropDownList_Login"), Globals.GetSiteUrls().Login ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + ResourceManager.GetString("Navigation_JumpDropDownList_CreateAccount"), Globals.GetSiteUrls().UserRegister ));
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + ResourceManager.GetString("Navigation_JumpDropDownList_ForgotPassword"), Globals.GetSiteUrls().UserForgotPassword ));
}
![](/Images/OutliningIndicators/InBlock.gif)
// seperator
//
Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Seperator") ));
![](/Images/OutliningIndicators/InBlock.gif)
// Get all forum groups and the remaining items are displayed
// as ForumGroups and Forums.
//
// ArrayList forumGroups = ForumGroups.GetForumGroups(true);
//
// foreach (Group group in forumGroups)
// {
// //lazy load sections
// if(!group.HasSections)
// group.Sections = Forums.GetForumsByForumGroupID(group.GroupID);
//
// //Only add if we have sections. We do not display groups that have no sections
// if(group.HasSections)
// {
//
// // Add the forum group
// //
// Items.Add(new ListItem(group.Name, "g-" + group.GroupID));
//
//
// // Add all forums recursively.
// //
// RecursiveAddForum (0, group.Sections);
//
// // Add the forum group
// //
// Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Seperator") ));
// }
// }
}
![](/Images/OutliningIndicators/InBlock.gif)
// void RecursiveAddForum (int depth, ArrayList forums)
// {
//
// foreach (Forum forum in forums)
// {
// // We only go 3 deep
// //
//
// switch (depth)
// {
// case 0:
//
// Items.Add(new ListItem(ResourceManager.GetString("Navigation_JumpDropDownList_Indent1") + forum.Name, "f-" + forum.SectionID.ToString()));
// if (forum.Sections.Count > 0)
// RecursiveAddForum((depth + 1), forum.Sections);
// break;
//
// case 1:
// Items.Add(new ListItem(ResourceManager.GetString("Navigation_JumpDropDownList_Indent2") + forum.Name, "f-" + forum.SectionID.ToString()));
// if (forum.Sections.Count > 0)
// RecursiveAddForum((depth + 1), forum.Sections);
// break;
//
// case 2:
// Items.Add(new ListItem(ResourceManager.GetString("Navigation_JumpDropDownList_Indent3") + forum.Name, "f-" + forum.SectionID.ToString()));
// if (forum.Sections.Count > 0)
// RecursiveAddForum((depth + 1), forum.Sections);
// break;
//
// default:
// return;
//
// }
// }
// }
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
// *********************************************************************
// Location_Changed
//
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//**//**//// <summary>
/// User wants to jump to a new location
/// </summary>
///
// ********************************************************************/
private void Location_Changed(Object sender, EventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](/Images/OutliningIndicators/InBlock.gif)
DropDownList jumpLocation = (DropDownList) sender;
string jumpValue = jumpLocation.SelectedItem.Value;
![](/Images/OutliningIndicators/InBlock.gif)
if (jumpValue.StartsWith("/"))
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Page.Response.Redirect(jumpValue);
}
// else if (jumpValue.StartsWith("g"))
// {
// int forumGroupId = 0;
// forumGroupId = Convert.ToInt32(jumpValue.Substring(jumpValue.IndexOf("-") + 1));
// Page.Response.Redirect(Globals.GetSiteUrls().ForumGroup( forumGroupId) );
// }
// else if (jumpValue.StartsWith("f"))
// {
// int forumId = 0;
// forumId = Convert.ToInt32(jumpValue.Substring(jumpValue.IndexOf("-") + 1));
// Page.Response.Redirect(ForumUrls.Instance().Forum(forumId) );
// }
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Page.Response.Redirect(Globals.GetSiteUrls().Home);
}
![](/Images/OutliningIndicators/InBlock.gif)
// End the response
Page.Response.End();
}
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
// *********************************************************************
// DisplayText
//
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//**//**//// <summary>
/// Text preceding the drop down list of options
/// </summary>
///
// ********************************************************************/
public virtual String DisplayText
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Object state = ViewState["DisplayText"];
if ( state != null )
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return (String)state;
}
return ResourceManager.GetString("Navigation_JumpDropDownList_displayText");
}
set
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState["DisplayText"] = value;
}
}
![](/Images/OutliningIndicators/InBlock.gif)
}
}
![](/Images/OutliningIndicators/None.gif)