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_Content:System.Web.UI.Page
    {
       // public_select ps = new public_select();
        protected void Page_Load(object sender, EventArgs e)
        {

            //获取栏目ID
            int docid = 0;
            //int pid = 0;
            if (Request.QueryString["docid"] != null )
            {
                docid = int.Parse(Request.QueryString["docid"].ToString());
                //pid = int.Parse(Request.QueryString["page"].ToString());
            }
            int pid=1;
            if (Request.QueryString["page"] != null)
            {
                pid = int.Parse(Request.QueryString["page"].ToString());
            }
            string temp = Server.MapPath("./templates/");
            Response.Write(Get_Content(docid,temp,pid,"/article.aspx?docid="+docid));
        }
        public string Get_Content(int docid,string temp,int pid,string src)
        {
            //实例化相关操作类
            ATL.IO.IOStream stream = new ATL.IO.IOStream();//加载Ayong工具库
            GlobalTags gb = new GlobalTags();//公共标签类
            ArticleTags at = new ArticleTags();//内容页标签
            public_select ps = new public_select();

            DataView dw = ps.Getps("Fm_model_main","*","docid="+docid+"");
            //获取栏目信息
            int cid = int.Parse(dw[0]["colid"].ToString());
            DataView column = ps.Getps("Fm_column", "cl_temp_cont", "cl_id=" + cid + "");

          
            string content = stream.ReadFile(temp + column[0]["cl_temp_cont"].ToString());
            //解析页面导入标签
            content = gb.Analysis_Include(content, temp);
            // string content = index;
            //栏目标签解析
            content = gb.Analysis_Column(content, cid);
            //导航
            string sitemap = gb.Analysis_Sitemap(cid)+">文章浏览:"+dw[0]["title"].ToString();
            //获取头部三个标签(标题,关键字,描述)数据
            content = gb.Analysis_Global(dw[0]["title"].ToString(), dw[0]["keyword"].ToString(), dw[0]["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 = at.Analysis_Content(content,docid,pid,src);
            //广告标签
            Fm.Tags.AdTags ad = new AdTags();
            content = ad.Analysis_Ad(content);
            return content;
        }
    }
}
