/// <summary> /// 按ID取得详细页的Url /// </summary> /// <param name="id">条目ID</param> /// <returns></returns> public string GetUrl(object id) { if (!ChannelMap.ContainsKey(BindColumnID)) { ChannelMap.Add(BindColumnID, ChannelHelper.GetChannel(BindColumnID, null)); } GeneralConfigInfo si = GeneralConfigs.GetConfig(); string ext = si.UrlFormat; return(String.Format("{0}{1}.{2}", ChannelMap.ContainsKey(BindColumnID) && ChannelMap[BindColumnID] != null ? ChannelMap[BindColumnID].FullUrl : "", We7Helper.GUIDToFormatString(ToStr(id)), ext)); }
/// <summary> /// 按ID取得详细页的Url /// </summary> /// <param name="id">条目ID</param> /// <returns></returns> public string GetUrl(object id, object ChannelID) { if (ChannelID == null) { return(""); } string strChannelID = ChannelID.ToString(); if (!ChannelMap.ContainsKey(strChannelID)) { ChannelMap.Add(strChannelID, ChannelHelper.GetChannel(strChannelID, null)); } GeneralConfigInfo si = GeneralConfigs.GetConfig(); string ext = si.UrlFormat; return(String.Format("{0}{1}.{2}", ChannelMap.ContainsKey(strChannelID) && ChannelMap[strChannelID] != null ? ChannelMap[strChannelID].FullUrl : "", We7Helper.GUIDToFormatString(ToStr(id)), ext)); }
/// <summary> /// 取得当前记录的Url /// </summary> /// <param name="a"></param> /// <returns></returns> public string GetUrl(Article a) { string key = a.ModelName + "$modelchannelurl$const"; if (!ChannelMap.ContainsKey(key)) { lock (Page) { if (!ChannelMap.ContainsKey(key)) { List <Channel> chs = ChannelHelper.GetChannelByModelName(a.ModelName); ChannelMap.Add(key, chs != null && chs.Count > 0 ? chs[0].FullUrl : ""); } } } return(String.Format("{0}{1}", ChannelMap[key], a.FullUrl)); }
void FormatArticle(Article article) { if (IsImage) { article.TagThumbnail = article.GetTagThumbnail(ThumbnailTag); } if (!ChannelMap.ContainsKey(article.OwnerID)) { Channel ch = ChannelHelper.GetChannel(article.OwnerID, null); ChannelMap.Add(article.OwnerID, ch); } if (!String.IsNullOrEmpty(ShowChannel)) { Channel ch = ChannelMap[article.OwnerID]; string channelName = ch.Name; if (ChannelHasLink) { channelName = string.Format("<a href='{1}' target='{2}'>{0}</a>", ch.Name, article.ChannelFullUrl, LinkTarget); } article.FullChannelPath = string.Format(ShowChannel, channelName); } article.Icon = GetIcon(article.State); if (NoLink) { article.LinkUrl = ""; } else { if (article.ContentType == (int)TypeOfArticle.LinkArticle) { article.LinkUrl = article.ContentUrl; } else { if (We7Helper.IsEmptyID(article.OwnerID)) { string key = article.ModelName + "$modelchannelurl$const"; if (!ChannelMap.ContainsKey(key)) { List <Channel> chs = ChannelHelper.GetChannelByModelName(article.ModelName); article.LinkUrl = String.Format("{0}{1}", chs != null && chs.Count > 0?chs[0].FullUrl:"", article.FullUrl); } } else { article.LinkUrl = String.Format("{0}{1}", article.ChannelFullUrl, article.FullUrl); } } } if (DateFormat == null || DateFormat == "") { TimeSpan ts = DateTime.Now - article.Updated; article.TimeNote = GetTimeNote(ts); } else { article.TimeNote = article.Updated.ToString(DateFormat); } if (ShowField("ToolTip")) { article.FullTitle = article.Title; article.FullTitle += "," + article.TimeNote; if (article.Clicks > 0) { article.FullTitle += ",阅读量:" + article.Clicks; } } else { article.FullTitle = article.Title; } if (TitleMaxLength > 0 && article.Title.Length > TitleMaxLength) { article.Title = article.Title.Substring(0, TitleMaxLength) + "..."; } if (!string.IsNullOrEmpty(KeyWord)) { article.Title = article.Title.Replace(KeyWord, "<em>" + KeyWord + "</em>"); } if (Show("Description")) { if (SummaryMaxLength > 0 && article.Description != null && article.Description.Length > SummaryMaxLength) { article.Description = article.Description.Substring(0, SummaryMaxLength) + "..."; } if (string.IsNullOrEmpty(article.Description) && !string.IsNullOrEmpty(article.Content)) { string content = We7Helper.RemoveHtml(article.Content); if (content.Length > summaryMaxLength) { article.Description = content.Substring(0, SummaryMaxLength) + "..."; } else { article.Description = content; } } if (!string.IsNullOrEmpty(KeyWord) && !string.IsNullOrEmpty(article.Description)) { article.Description = article.Description.Replace(KeyWord, "<em>" + KeyWord + "</em>"); } } }