using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Data;
using System.Configuration;
using Fm.Bussiness;
using Fm.DataAccess;
using System.Web;
using System.Collections;

namespace Fm.Tags
{
    public class SingleTags:System.Web.UI.Page
    {
        public bool Analysis_Single(int sid)
        {
            //获取数据
            public_select ps = new public_select();
            DataView dv = ps.Getps("Fm_singlepage", "*", "sid="+sid+"");

            GlobalTags gb = new GlobalTags();

            string path = Server.MapPath("../templates/");
            ATL.IO.IOStream stream = new ATL.IO.IOStream();

            string content = stream.ReadFile(path+dv[0]["stemplates"].ToString());
            //解析页面导入标签
            content = gb.Analysis_Include(content, path);
            // string content = index;
            //栏目标签解析
            content = gb.Analysis_Column(content, 0);
           
            //导航解析
            string sitemap = gb.Analysis_Sitemap(0)+">"+dv[0]["stitle"].ToString();
            //公共独立标签解析

            content = gb.Analysis_Global(dv[0]["stitle"].ToString(), dv[0]["skeywords"].ToString(), dv[0]["sintro"].ToString(), content, sitemap);
            content = gb.Analysis_Link(content);

            //广告标签
            Fm.Tags.AdTags ad = new AdTags();
            content = ad.Analysis_Ad(content);

            content = content.Replace("{fm:single.title}",dv[0]["stitle"].ToString());
            content = content.Replace("{fm:single.intro}",dv[0]["sintro"].ToString());
            content = content.Replace("{fm:single.content}",dv[0]["scontent"].ToString());

            if (stream.WriteFile(Server.MapPath(dv[0]["spath"].ToString()), content))
            {
                return true;
            }
            else
            {
                return false;
            }

        }
    }
}
