using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Spaces;
using System.Web.Caching;

public partial class Index_Topic : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            BindPage();
    }
    private void BindPage()
    {
        DataView dv = Blogs.UpdatedSpaces(42);  //最近更新的空间
        rprUpdated.DataSource = dv;
        rprUpdated.DataBind();  
        rprTagList.ItemCreated += new RepeaterItemEventHandler(rprTagList_ItemCreated);
        rprTagList.DataSource = SiteTools.GetTagTop(TagType.BlogTopic, 49);//标签
        rprTagList.DataBind();
       
        rprNewTopic.DataSource = Blogs.GetNewPosts(28);//最新主题
        rprNewTopic.DataBind();
        rprHitTopic.DataSource = SiteHelper.GetHitTopicTop(12);
        rprHitTopic.DataBind();
   
    }
    
    void rprTagList_ItemCreated(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            TagItem item = e.Item.DataItem as TagItem;
            if (item != null)
            {
                HyperLink lnkTag = e.Item.FindControl("lnkTag") as HyperLink;
                if (lnkTag != null)
                {
                   // lnkTag.Text = string.Format("<font color=\"#CC3300\">{0}</font>", item.TagName);
                    lnkTag.Text = string.Format("{0}", item.TagName);
                    lnkTag.NavigateUrl = string.Format("TagTopList.aspx?TagName={0}", Server.UrlEncode(item.TagName.TrimStart(' ').TrimEnd(' ')));
                    lnkTag.Target = "_blank";

                }
                Literal RefCount = e.Item.FindControl("RefCount") as Literal;
                if (RefCount != null)
                {
                    RefCount.Text = item.RefCount.ToString();
                }
            }

        }
    }
}
