给ccs1.03部署快速导航栏

 
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.WebControls;

using CommunityServer.Components;


namespace CommunityServer.Controls
{

    [
    ParseChildren(
true)
    ]
    
public class JumpDropDownList : DropDownList 
    
{


        
public JumpDropDownList() 
        
{

            
// Set up some default property values
            
//
            AutoPostBack = true;
            SelectedIndexChanged 
+= new System.EventHandler(Location_Changed);

            
// head of the drop down
            
//
            Items.Add(new ListItem( "快速导航""" ));
            Items.Add(
new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Seperator") ));

            
// 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));

            
// User Options to display, based if the user is signed in or not.
            
//
            if (CSContext.Current.User.IsForumAdministrator || CSContext.Current.User.IsModerator) 
            
{
                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 ));
            }
            

            
// seperator
            
//
            Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Seperator") ));

            
// User Options to display, based if the user is signed in or not.
            
//
            if (!CSContext.Current.User.IsAnonymous) 
            
{
                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 
            
{
                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 ));
            }


            
// seperator
            
//
            Items.Add(new ListItem( ResourceManager.GetString("Navigation_JumpDropDownList_Seperator") ));

            
// 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") ));
//                }
//            }
        }


//        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;
//
//                }
//            }
//        }


        
// *********************************************************************
        
//  Location_Changed
        
//
        /**//// <summary>
        
/// User wants to jump to a new location
        
/// </summary>
        
/// 

        // ********************************************************************/ 
        private void Location_Changed(Object sender, EventArgs e) 
        
{

            DropDownList jumpLocation 
= (DropDownList) sender;
            
string jumpValue = jumpLocation.SelectedItem.Value;

            
if (jumpValue.StartsWith("/")) 
            
{
                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 
            
{
                Page.Response.Redirect(Globals.GetSiteUrls().Home);
            }


            
// End the response
            Page.Response.End();
        }



        
// *********************************************************************
        
//  DisplayText
        
//
        /**//// <summary>
        
/// Text preceding the drop down list of options
        
/// </summary>
        
/// 

        // ********************************************************************/ 
        public virtual String DisplayText 
        
{
            
get 
            
{
                Object state 
= ViewState["DisplayText"];
                
if ( state != null ) 
                
{
                    
return (String)state;
                }

                
return ResourceManager.GetString("Navigation_JumpDropDownList_displayText");
            }

            
set 
            
{
                ViewState[
"DisplayText"= value;
            }

        }


    }

}

posted on 2005-09-11 00:51  hyouhaku  阅读(305)  评论(0编辑  收藏  举报

导航