protected override void OnDataBinding(EventArgs e) { ROYcms.Sys.BLL.ROYcms_class ___ROYcms_class = new ROYcms.Sys.BLL.ROYcms_class(); if (ClassKind != null) { if (Div != 00) { dataSource = (IList)(new DataView(((DataSet)(___ROYcms_class.GetClassList(Convert.ToInt32(ClassKind), Div))).Tables[0])); } else { dataSource = (IList)(new DataView(((DataSet)(___ROYcms_class.GetClassList(Convert.ToInt32(ClassKind)))).Tables[0])); } } if (Class != null) { dataSource = (IList)(new DataView(((DataSet)(___ROYcms_class.GetSubClassList(___ROYcms_class.GetClassId(Convert.ToInt32(Class))))).Tables[0])); } if (Path != null) { dataSource = (IList)(new DataView(((DataSet)(___ROYcms_class.GetSubClassList(___ROYcms_class.GetClassId(Convert.ToInt32(___ROYcms_class.GetId("{cmspath}/" + Path + "/")))))).Tables[0])); } //if (base.DataSource != null) //{ intItemCount = dataSource.Count; base.DataSource = dataSource; base.OnDataBinding(e); //} }
///// <summary> ///// loop标签的匹配替换 ///// </summary> ///// <param name="template">模板内容</param> public string LoopClass(string template) { string Attributes = ""; string Text = ""; string AllText = ""; Regex r = new Regex(@"(\[SG:class\s+(?<attributes>[^\]]*?)\](?<text>[\s\S]*?)\[/SG:class\])", RegexOptions.Compiled | RegexOptions.IgnoreCase); foreach (Match m in r.Matches(template)) { Attributes = m.Groups["attributes"].ToString(); //循环属性集 Text = m.Groups["text"].ToString(); //循环的内容不包含SG:Loop AllText = m.Groups[0].Value.ToString(); //整个匹配的内容包含SG:Loop #region 取得相关属性 string Count = null; //调用数量 string classID = null; string Templet = null; // 模板ID Templet = TagVal(Attributes, "Templet"); Count = TagVal(Attributes, "Count"); classID = TagVal(Attributes, "classID"); #endregion #region 对循环的内容进行替换 string content = ""; ROYcms.Sys.BLL.ROYcms_class bll = new ROYcms.Sys.BLL.ROYcms_class(); DataSet dt = bll.GetClassList(0); if (classID != null) { dt = bll.GetSubClassList(bll.GetClassId(Convert.ToInt32(classID))); } if (dt.Tables[0].Rows.Count > 0) { int rowsCount = dt.Tables[0].Rows.Count; if (Count != null && rowsCount > Convert.ToInt32(Count)) { rowsCount = Convert.ToInt32(Count); } for (int n = 0; n < rowsCount; n++) { string str = Text; str = Replace(str, @"\[SG:ClassName\]", dt.Tables[0].Rows[n]["ClassName"].ToString()); str = Replace(str, @"\[SG:Link\]", config.web_host + TemplateZone.Zpath(this.pageHost) + "list" + Templet + "-" + dt.Tables[0].Rows[n]["Id"].ToString() + config.web_forge); str = Replace(str, @"\[SG:_Link\]", "list-" + dt.Tables[0].Rows[n]["Id"].ToString() + config.web_forge); content += str; } } else { content = ""; } #endregion template = template.Replace(AllText, content); } return(template); }
/// <summary> /// 生成所有栏目 News all HTML. /// </summary> /// <returns></returns> public bool NewAllHtml(int?ClassKind) { ROYcms.Sys.BLL.ROYcms_class BLL = new ROYcms.Sys.BLL.ROYcms_class(); ROYcms.Sys.Model.ROYcms_class Model = new ROYcms.Sys.Model.ROYcms_class(); DataSet ds = new DataSet(); ds = BLL.GetClassList(Convert.ToInt32(ClassKind)); DataTable dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { Model = BLL.GetModel(dr["ClassId"].ToString()); NewHtml(Model); err = true; } return(err); }