/// <summary> /// 取得栏目树列表对象 /// </summary> /// <returns>栏目列表</returns> protected List <Channel> GetChannelTree() { if (DesignHelper.IsDesigning) { return(DesignRecords); } StringBuilder sb = new StringBuilder(); sb.Append("ChannelDataProvider$GetChannelTree$"); sb.AppendFormat("ID:{0}$Url:{1}$", ID, We7Helper.GetChannelUrlFromUrl(Request.RawUrl)); return(CacheRecord.Create("channel").GetInstance <List <Channel> >(sb.ToString(), delegate() { channelFlag = false; List <Channel> mainMenu = GetChannels(); if (MaxTreeClass > 1) { foreach (Channel ch in mainMenu) { ch.SubChannels = GetSubChannels(ch.ID, 2); ch.HaveSon = ch.SubChannels != null && ch.SubChannels.Count > 0; ch.MenuIsSelected = We7Helper.GetChannelUrlFromUrl(Request.RawUrl).ToLower().StartsWith(ch.FullUrl.ToLower()); } } channelFlag = true; return mainMenu; })); }
private string GetChannelFullUrl(string level) { string channelUrl = ""; if (We7Helper.IsNumber(level)) { int index = int.Parse(level); if (index > 0) { string url = We7Helper.GetChannelUrlFromUrl(Request.RawUrl); int pos = 0; for (int i = 0, temp = 0; i <= index; i++) { temp = url.IndexOf("/", pos) + 1; if (temp == 0) { break; } else { pos = temp; } } url = url.Substring(0, pos); channelUrl = url; } } return(channelUrl); }
/// <summary> /// 根据栏目层数取得栏目Url名称 /// </summary> /// <param name="level">栏目等级</param> /// <returns>栏目名称</returns> public string GetChannelName(string level) { string channelName = "default"; if (We7Helper.IsNumber(level)) { int index = int.Parse(level); if (index > 0) { string url = We7Helper.GetChannelUrlFromUrl(Request.RawUrl); int pos = 0; for (int i = 0, temp = 0; i <= index; i++) { temp = url.IndexOf("/", pos) + 1; if (temp == 0) { break; } else { pos = temp; } } url = url.Substring(0, pos); channelName = ChannelHelper.GetChannelUrlFromUrl(url, Context.Request.ApplicationPath); } } return(channelName); }
/// <summary> /// 取得子栏目列表 /// </summary> /// <param name="channelID">栏目ID</param> /// <param name="maxClass">最大级别数</param> /// <returns>栏目列表</returns> List <Channel> GetSubChannels(string channelID, int maxClass) { List <Channel> subList = ChannelHelper.GetChannels(channelID, true); if (maxClass <= MaxTreeClass && subList != null) { foreach (Channel ch in subList) { ch.SubChannels = GetSubChannels(ch.ID, maxClass + 1); ch.HaveSon = ch.SubChannels != null && ch.SubChannels.Count > 0; ch.MenuIsSelected = We7Helper.GetChannelUrlFromUrl(Request.RawUrl).ToLower().StartsWith(ch.FullUrl.ToLower()); } } return(subList); }
public string GetHtmlTemplateByHandlers(string ColumnMode, string ColumnID, string SearchWord, string SeSearchWord) { GeneralConfigInfo gi = GeneralConfigs.GetConfig(); if (gi.StartTemplateMap) { HttpContext Context = HttpContext.Current; string channelUrl = We7Helper.GetChannelUrlFromUrl(Context.Request.RawUrl); string htmlTemplate = We7Helper.GetParamValueFromUrl(Context.Request.RawUrl, "template"); if (String.IsNullOrEmpty(htmlTemplate)) { if (channelUrl == "/" && ColumnMode == "") { htmlTemplate = GetHtmlTemplatePath("welcome"); if (!File.Exists(HttpContext.Current.Server.MapPath(htmlTemplate))) { htmlTemplate = GetHtmlTemplatePath("index"); if (!File.Exists(HttpContext.Current.Server.MapPath(htmlTemplate))) { return(GetTemplateByHandlers(ColumnMode, ColumnID, SearchWord, SeSearchWord)); } } } else { htmlTemplate = GetHtmlTemplatePath(channelUrl.Trim('/').Trim('\\') + "/" + (String.IsNullOrEmpty(ColumnMode)?"index":ColumnMode)); if (!File.Exists(HttpContext.Current.Server.MapPath(htmlTemplate))) { return(GetTemplateByHandlers(ColumnMode, ColumnID, SearchWord, SeSearchWord)); } } } return(htmlTemplate); } else { return(GetThisHtmlPageTemplate(ColumnMode, ColumnID, SearchWord, SeSearchWord)); } }
/// <summary> /// 格式化栏目数据 /// </summary> /// <param name="list">栏目列表</param> /// <returns>栏目列表</returns> protected virtual List <Channel> FormatChannelsData(List <Channel> list) { DateTime now = DateTime.Now; foreach (Channel ch in list) { if (ShowToolTip != null && ShowToolTip.Length > 0) { ch.Title = ch.Name; } if (TitleMaxLength > 0 && ch.Name.Length > TitleMaxLength) { ch.Name = ch.Name.Substring(0, TitleMaxLength) + "..."; } if (We7Helper.GetChannelUrlFromUrl(Request.RawUrl).ToLower().StartsWith(ch.RealUrl.ToLower())) { ch.MenuIsSelected = true; } } return(list); }
/// <summary> /// 根据配置选择不同的模板选择器 /// </summary> /// <param name="ColumnMode"></param> /// <param name="ColumnID"></param> /// <param name="SearchWord"></param> /// <param name="SeSearchWord"></param> /// <returns></returns> public string GetTemplateByHandlers(string ColumnMode, string ColumnID, string SearchWord, string SeSearchWord) { GeneralConfigInfo gi = GeneralConfigs.GetConfig(); if (gi.StartTemplateMap) { HttpContext Context = HttpContext.Current; string channelUrl = We7Helper.GetChannelUrlFromUrl(Context.Request.RawUrl); string templatePath = We7Helper.GetParamValueFromUrl(Context.Request.RawUrl, "template"); if (string.IsNullOrEmpty(templatePath)) { if (channelUrl == "/" && ColumnMode == "") { templatePath = TemplateMap.GetTemplateFromMap("welcome", channelUrl); if (string.IsNullOrEmpty(templatePath)) { templatePath = templatePath = TemplateMap.GetTemplateFromMap("home", channelUrl); } } else { templatePath = TemplateMap.GetTemplateFromMap(ColumnMode, channelUrl); } if (!string.IsNullOrEmpty(templatePath)) { GeneralConfigInfo si = GeneralConfigs.GetConfig(); templatePath = GetTemplatePath(si.DefaultTemplateGroupFileName, templatePath); } } return(templatePath); } else { return(GetThisPageTemplate(ColumnMode, ColumnID, SearchWord, SeSearchWord)); } }
/// <summary> /// 获取子栏目列表 /// </summary> /// <returns>栏目列表</returns> protected List <Channel> GetChannels() { List <Channel> list = new List <Channel>(); if (DesignHelper.IsDesigning) { list = DesignRecords; } else { StringBuilder sb = new StringBuilder(); sb.Append("ChannelDataProvider$GetChannels$"); sb.AppendFormat("ID:{0}$Url:{1}$", ID, We7Helper.GetChannelUrlFromUrl(Request.RawUrl)); list = CacheRecord.Create("channel").GetInstance <List <Channel> >(sb.ToString(), delegate() { ChannelQuery query = new ChannelQuery(); if (OrderFields == null || OrderFields == string.Empty) { OrderFields = "Index|Asc"; } query.OrderKeys = OrderFields; query.State = ArticleStates.Started; if (ParentID != null && ParentID.Length > 0) { query.ParentID = ParentID; } else if (Level != null && Level.Length > 0 & We7Helper.IsNumber(Level)) { query.ParentID = GetParentIDByLevel((int.Parse(Level) - 1).ToString()); } else { query.ParentID = ChannelID; } if (Tag != null && Tag.Length > 0) { query.Tag = Tag; } if (IncludeAllSons) { query.IncludeAllSons = true; } if (channelFlag && string.IsNullOrEmpty(level)) { if (ThisChannel == null) { ThisChannel = new Channel(); } ThisChannel.HaveSon = ChannelHelper.HasChild(ChannelID); if (!ThisChannel.HaveSon && noChildsDisplay) { query.ParentID = ThisChannel.ParentID; } } return(ChannelHelper.QueryChannels(query)); }); } return(list != null?FormatChannelsData(list) : new List <Channel>()); }