using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.IO;
using System.Data;
using Fm.Bussiness;
namespace Fm.Tags
{
    public class Temp_List:System.Web.UI.Page
    {
        public_select ps = new public_select();
        protected void Page_Load(object sender, EventArgs e)
        {

                //获取栏目ID
                 int cid = 0;
                 int pid = 0;
                 if (Request.QueryString["cid"] != null&&Request.QueryString["page"] != null)
                 {
                     cid = int.Parse(Request.QueryString["cid"].ToString());
                     pid = int.Parse(Request.QueryString["page"].ToString());
                 }
                 string temp = Server.MapPath("./templates/");
                 Response.Write(Get_List(temp,cid,pid,0));
        }
        public string Get_List(string temp,int cid,int pid,int htmcount)
        {
            //实例化相关操作类
            ATL.IO.IOStream stream = new ATL.IO.IOStream();//加载Ayong工具库
            GlobalTags gb = new GlobalTags();//公共标签类
            ListTags lt = new ListTags();//列表标签类
            public_select ps = new public_select();
            //获取栏目信息
            DataView column = ps.Getps("Fm_column","*","cl_id="+cid+"");
            string content = "";
            if (column[0]["cl_attribute"].ToString() != "2")
            {
                if (column[0]["cl_attribute"].ToString() == "0")
                {
                    content = stream.ReadFile(temp + column[0]["cl_temp_list"].ToString());
                }
                else
                {
                    content = stream.ReadFile(temp+column[0]["cl_temp_index"].ToString());
                }
            }
            
            //解析页面导入标签
            content = gb.Analysis_Include(content, temp);
            // string content = index;
            //栏目标签解析
            content = gb.Analysis_Column(content, cid);
            //导航
            string sitemap = gb.Analysis_Sitemap(cid);
            //获取头部三个标签(标题,关键字,描述)数

            content = gb.Analysis_Global(column[0]["cl_name"].ToString(), column[0]["cl_keyword"].ToString(), column[0]["cl_intro"].ToString(), content,sitemap);
            //公共独立标签解析
            content = gb.Analysis_Channels(content,cid);
            content = gb.Analysis_Article(content, cid);
            content = gb.Analysis_Link(content);
            content = gb.Analysis_Freedom(content);
            //栏目标签解析
            content = lt.Analysis_Page(content,pid,cid,htmcount);
            //Response.Write(temp + "templates/" + column[0]["cl_temp_list"].ToString());
            //广告标签
            Fm.Tags.AdTags ad = new AdTags();
            content = ad.Analysis_Ad(content);

            return content;
           
        }
    }
}
