⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aggregatebloglist.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Runtime.Remoting.Contexts;
using System.Web.UI;
using System.Web.UI.WebControls;
using CommunityServer.Blogs.Components;
using CommunityServer.Components;
using CommunityServer.Controls;

namespace CommunityServer.Blogs.Controls
{
    /// <summary>
    /// Summary description for AggregateBlogList.
    /// </summary>
    public class AggregateBlogList : WeblogBaseTemplatedWebControl
    {
        Repeater GroupList = null;
        public AggregateBlogList()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        protected override void AttachChildControls()
        {
            GroupList = FindControl( "GroupList" ) as Repeater;
            GroupList.ItemCreated +=new RepeaterItemEventHandler(Groups_ItemCreated);

            DataBind();
        }

        public override void DataBind()
        {
            base.DataBind ();

            int groupID =  Globals.SafeInt(Context.Request.QueryString["GroupID"],-1);
            

            if(groupID > 0)
            {

                Group g = WeblogGroups.GetWeblogGroup(groupID,true,false);
                if(g != null)
                    GroupList.DataSource = new Group[]{g};
            }
            else
            {
                GroupList.DataSource = WeblogGroups.GetWeblogGroups(true,false,false);
            }

            GroupList.DataBind();			
        }



        private void Groups_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            switch ( e.Item.ItemType ) 
            {
                case ListItemType.Item:
                case ListItemType.AlternatingItem:
                case ListItemType.SelectedItem:

                    Group g = e.Item.DataItem as Group;
                    ArrayList blogs = Weblogs.GetWeblogsByGroupID(g.GroupID,false,true,false);

                    Repeater BlogList = e.Item.FindControl( "BlogList" ) as Repeater;
                    BlogList.ItemCreated +=new RepeaterItemEventHandler(BlogList_ItemCreated);
                    BlogList.DataSource = blogs;
                    BlogList.DataBind();

                    Literal groupName = e.Item.FindControl("GroupName") as Literal;
                    groupName.Text = g.Name;


                    break;
            }
        }

        private void BlogList_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            switch ( e.Item.ItemType ) 
            {
                case ListItemType.Item:
                case ListItemType.AlternatingItem:
                case ListItemType.SelectedItem:

                    Weblog blog = e.Item.DataItem as Weblog;

                    HyperLink name = e.Item.FindControl("BlogName") as HyperLink;
					PlaceHolder authors = e.Item.FindControl("Author") as PlaceHolder;
                    Literal desc = e.Item.FindControl("BlogDesc") as Literal;
                    HyperLink recentPost = e.Item.FindControl("recentPost") as HyperLink;
                    Literal pc = e.Item.FindControl("PostCount") as Literal;
                    Literal ac = e.Item.FindControl("ArticleCount") as Literal;
                    Literal cc = e.Item.FindControl("CommentCount") as Literal;
                    Literal tc = e.Item.FindControl("TrackbackCount") as Literal;

                    name.NavigateUrl = BlogUrls.Instance().HomePage(blog.ApplicationKey);
                    name.Text = blog.Name;

                    desc.Text = blog.Description;
                    recentPost.NavigateUrl = BlogUrls.Instance().ShortLink(blog.MostRecentPostID);
                    recentPost.Text = blog.MostRecentPostSubject;

                    pc.Text = blog.PostCount.ToString();
                    ac.Text = blog.ArticleCount.ToString();
                    cc.Text = blog.CommentCount.ToString();
                    tc.Text = blog.TrackbackCount.ToString();

					string[] owners = blog.Owners.Split(';');
					for (int i = 0; i<owners.Length; i++) {
						authors.Controls.Add(new LiteralControl( "<a href=\"" + SiteUrls.Instance().UserProfile(owners[i].Trim()) + " \">" + owners[i].Trim() + "</a>" ));

						if (i+1 != owners.Length)
							authors.Controls.Add(new LiteralControl( ", " ));
					}

                    break;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -