protected void Page_Load(object sender, EventArgs e)
        {
            if (ItemID < 1)
            {
                ErrToClient("没有指定专题类别ID,调用方法:/Special_节点ID/List");
            }
            string TemplateDir = "";

            if (string.IsNullOrEmpty(TemplateDir))
            {
                Response.Write("该专题类别列表页未指定模板");
            }
            else
            {
                TemplateDir = SiteConfig.SiteOption.TemplateDir + TemplateDir;
                TemplateDir = base.Request.PhysicalApplicationPath + "/" + TemplateDir;
                TemplateDir = TemplateDir.Replace("/", @"\");
                TemplateDir = TemplateDir.Replace(@"\\", @"\");
                string Templatestr = FileSystemObject.ReadFile(TemplateDir);
                string ContentHtml = this.bll.CreateHtml(Templatestr, Cpage, ItemID, "3");
                if (SiteConfig.SiteOption.IsSensitivity == 1)
                {
                    Response.Write(B_Sensitivity.Process(ContentHtml));
                }
                else
                {
                    Response.Write(ContentHtml);
                }
            }
        }
Esempio n. 2
0
    /// <summary>
    /// 每个页面必须实现,用于将模板解析为html
    /// </summary>
    public virtual string TemplateToHtml(string templateUrl)
    {
        string html        = "";
        string vpath       = (SiteConfig.SiteOption.TemplateDir + "/" + templateUrl);
        string TemplateDir = function.VToP(vpath);

        if (!File.Exists(TemplateDir))
        {
            return("[产生错误的可能原因:(" + vpath + ")文件不存在]");
        }
        html = FileSystemObject.ReadFile(TemplateDir);
        html = bll.CreateHtml(html, Cpage, ItemID, "1");
        if (SiteConfig.SiteOption.IsSensitivity == 1)
        {
            html = B_Sensitivity.Process(html);
        }
        return(html);
    }
Esempio n. 3
0
        public override string TemplateToHtml(string TemplateDir)
        {
            string Templatestrstr = FileSystemObject.ReadFile(function.VToP(SiteConfig.SiteOption.TemplateDir + "/" + TemplateDir));
            string ContentHtml    = bll.CreateHtml(Templatestrstr, Cpage, ItemID, "0");//Templatestrstr:模板页面字符串,页码,该文章ID

            /* --------------------判断是否分页 并做处理------------------------------------------------*/
            if (!string.IsNullOrEmpty(ContentHtml))
            {
                string infoContent = ""; //进行处理的内容字段
                string pagelabel   = "";
                string infotmp     = "";
                #region 分页符分页
                string pattern = @"{\#PageCode}([\s\S])*?{\/\#PageCode}";  //查找要分页的内容
                if (Regex.IsMatch(ContentHtml, pattern, RegexOptions.IgnoreCase))
                {
                    infoContent = Regex.Match(ContentHtml, pattern, RegexOptions.IgnoreCase).Value;
                    infotmp     = infoContent;
                    infoContent = infoContent.Replace("{#PageCode}", "").Replace("{/#PageCode}", "");
                    //查找分页标签
                    bool   isPage   = false;
                    string pattern1 = @"{ZL\.Page([\s\S])*?\/}";

                    if (Regex.IsMatch(ContentHtml, pattern1, RegexOptions.IgnoreCase))
                    {
                        pagelabel = Regex.Match(ContentHtml, pattern1, RegexOptions.IgnoreCase).Value;
                        isPage    = true;
                    }
                    if (isPage)
                    {
                        if (string.IsNullOrEmpty(infoContent)) //没有设定要分页的字段内容
                        {
                            ContentHtml = ContentHtml.Replace(pagelabel, "");
                        }
                        else   //进行内容分页处理
                        {
                            //文件名
                            string file1 = "Content.aspx?ID=" + ItemID.ToString();
                            //取分页标签处理结果 返回字符串数组 根据数组元素个数生成几页
                            string         ilbl       = pagelabel.Replace("{ZL.Page ", "").Replace("/}", "").Replace(" ", ",");
                            string         lblContent = "";
                            IList <string> ContentArr = new List <string>();

                            if (string.IsNullOrEmpty(ilbl))
                            {
                                lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}"; //默认格式的分页导航
                                ContentArr = bll.GetContentPage(infoContent);
                            }
                            else
                            {
                                string[] paArr = ilbl.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                if (paArr.Length == 0)
                                {
                                    lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}"; //默认格式的分页导航
                                    ContentArr = bll.GetContentPage(infoContent);
                                }
                                else
                                {
                                    string  lblname = paArr[0].Split(new char[] { '=' })[1].Replace("\"", "");
                                    B_Label blbl    = new B_Label();
                                    lblContent = blbl.GetLabelXML(lblname).Content;
                                    if (string.IsNullOrEmpty(lblContent))
                                    {
                                        lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}"; //默认格式的分页导航
                                    }
                                    ContentArr = bll.GetContentPage(infoContent);
                                }
                            }
                            if (ContentArr.Count > 0) //存在分页数据
                            {
                                string curCPage = B_Route.GetParam("cpage", this);
                                bool   isAll    = !(string.IsNullOrEmpty(curCPage)) && curCPage.Equals("0");
                                if (isAll)//必须明确传值,才显示全部
                                {
                                    ContentHtml = ContentHtml.Replace(infotmp, infoContent);
                                    ContentHtml = ContentHtml.Replace("[PageCode/]", "");
                                }
                                else
                                {
                                    int _cpage = PageHelper.GetCPage(Cpage, 1, ContentArr.Count) - 1;
                                    ContentHtml = ContentHtml.Replace(infotmp, ContentArr[_cpage]);
                                    ContentHtml = ContentHtml.Replace("{#Content}", "").Replace("{/#Content}", "");
                                }
                                ContentHtml = ContentHtml.Replace(pagelabel, bll.GetPage(lblContent, ItemID, Cpage, ContentArr.Count, ContentArr.Count));//输出分页
                            }
                            else
                            {
                                ContentHtml = ContentHtml.Replace(infotmp, infoContent);
                                ContentHtml = ContentHtml.Replace(pagelabel, "");
                            }
                        }
                    }
                    else  //没有分页标签
                    {
                        //如果设定了分页内容字段 将该字段内容的分页标志清除
                        if (!string.IsNullOrEmpty(infoContent))
                        {
                            ContentHtml = ContentHtml.Replace(infotmp, infoContent);
                        }
                    }
                }
                #endregion
                #region  查找要分页的内容
                pattern = @"{\#Content}([\s\S])*?{\/\#Content}";
                if (Regex.IsMatch(ContentHtml, pattern, RegexOptions.IgnoreCase))
                {
                    infoContent = Regex.Match(ContentHtml, pattern, RegexOptions.IgnoreCase).Value;
                    infotmp     = infoContent;
                    infoContent = infoContent.Replace("{#Content}", "").Replace("{/#Content}", "");
                    //查找分页标签
                    bool   isPage   = false;
                    string pattern1 = @"{ZL\.Page([\s\S])*?\/}";
                    if (Regex.IsMatch(ContentHtml, pattern1, RegexOptions.IgnoreCase))
                    {
                        pagelabel = Regex.Match(ContentHtml, pattern1, RegexOptions.IgnoreCase).Value;
                        isPage    = true;
                    }
                    if (isPage)                                //包含分页
                    {
                        if (string.IsNullOrEmpty(infoContent)) //没有设定要分页的字段内容
                        {
                            ContentHtml = ContentHtml.Replace(pagelabel, "");
                        }
                        else   //进行内容分页处理
                        {
                            //文件名
                            string file1 = "Content.aspx?ID=" + ItemID.ToString();
                            //取分页标签处理结果 返回字符串数组 根据数组元素个数生成几页
                            string         ilbl       = pagelabel.Replace("{ZL.Page ", "").Replace("/}", "").Replace(" ", ",");
                            string         lblContent = "";
                            int            NumPerPage = 500;
                            IList <string> ContentArr = new List <string>();

                            if (string.IsNullOrEmpty(ilbl))
                            {
                                lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}"; //默认格式的分页导航
                                ContentArr = bll.GetContentPage(infoContent, NumPerPage);
                            }
                            else
                            {
                                string[] paArr = ilbl.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                if (paArr.Length == 0)
                                {
                                    lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}"; //默认格式的分页导航
                                    ContentArr = bll.GetContentPage(infoContent, NumPerPage);
                                }
                                else
                                {
                                    string lblname = paArr[0].Split(new char[] { '=' })[1].Replace("\"", "");
                                    if (paArr.Length > 1)
                                    {
                                        NumPerPage = DataConverter.CLng(paArr[1].Split(new char[] { '=' })[1].Replace("\"", ""));
                                    }
                                    B_Label blbl = new B_Label();
                                    lblContent = blbl.GetLabelXML(lblname).Content;
                                    if (string.IsNullOrEmpty(lblContent))
                                    {
                                        lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}"; //默认格式的分页导航
                                    }
                                    ContentArr = bll.GetContentPage(infoContent, NumPerPage);
                                }
                            }
                            if (ContentArr.Count > 0) //存在分页数据
                            {
                                int _cpage = PageHelper.GetCPage(Cpage, 0, ContentArr.Count - 1);
                                ContentHtml = ContentHtml.Replace(infotmp, ContentArr[_cpage]);
                                ContentHtml = ContentHtml.Replace(pagelabel, bll.GetPage(lblContent, ItemID, Cpage, ContentArr.Count, NumPerPage));
                            }
                            else
                            {
                                ContentHtml = ContentHtml.Replace(infotmp, infoContent);
                                ContentHtml = ContentHtml.Replace(pagelabel, "");
                            }
                        }
                    }
                    else//没有分页标签
                    {
                        //如果设定了分页内容字段 将该字段内容的分页标志清除
                        if (!string.IsNullOrEmpty(infoContent))
                        {
                            ContentHtml = ContentHtml.Replace(infotmp, infoContent);
                        }
                    }
                }
                #endregion
            }
            //替换默认分页标签
            string patterns   = @"{ZL\.Page([\s\S])*?\/}";
            string pagelabels = Regex.Match(ContentHtml, patterns, RegexOptions.IgnoreCase).Value;
            if (!string.IsNullOrEmpty(pagelabels))
            {
                ContentHtml = ContentHtml.Replace(pagelabels, "");
            }
            if (nodeMod.SafeGuard == 1 && File.Exists(Server.MapPath("/JS/Guard.js")))
            {
                ContentHtml = ContentHtml + SafeSC.ReadFileStr("/JS/Guard.js");
            }
            if (SiteConfig.SiteOption.IsSensitivity == 1)
            {
                ContentHtml = B_Sensitivity.Process(ContentHtml);
            }
            return(ContentHtml);
        }