private static string GetContentUrlById(SiteInfo siteInfo, int channelId, int contentId, int sourceId, int referenceId, string linkUrl, bool isLocal) { if (isLocal) { return(ApiRoutePreview.GetContentUrl(siteInfo.Id, channelId, contentId)); } var contentInfoCurrent = ContentManager.GetContentInfo(siteInfo, channelId, contentId); if (referenceId > 0 && contentInfoCurrent.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString()) { if (sourceId > 0 && (ChannelManager.IsExists(siteInfo.Id, sourceId) || ChannelManager.IsExists(sourceId))) { var targetChannelId = sourceId; var targetSiteId = StlChannelCache.GetSiteId(targetChannelId); var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId); var targetChannelInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId); var contentInfo = ContentManager.GetContentInfo(targetSiteInfo, targetChannelInfo, referenceId); if (contentInfo == null || contentInfo.ChannelId <= 0) { return(PageUtils.UnclickedUrl); } if (contentInfo.SiteId == targetSiteInfo.Id) { return(GetContentUrlById(targetSiteInfo, contentInfo.ChannelId, contentInfo.Id, contentInfo.SourceId, contentInfo.ReferenceId, contentInfo.GetString(ContentAttribute.LinkUrl), false)); } var siteInfoTmp = SiteManager.GetSiteInfo(contentInfo.SiteId); return(GetContentUrlById(siteInfoTmp, contentInfo.ChannelId, contentInfo.Id, contentInfo.SourceId, contentInfo.ReferenceId, contentInfo.GetString(ContentAttribute.LinkUrl), false)); } else { var tableName = ChannelManager.GetTableName(siteInfo, channelId); channelId = StlContentCache.GetChannelId(tableName, referenceId); linkUrl = StlContentCache.GetValue(tableName, referenceId, ContentAttribute.LinkUrl); return(GetContentUrlById(siteInfo, channelId, referenceId, 0, 0, linkUrl, false)); } } if (!string.IsNullOrEmpty(linkUrl)) { return(ParseNavigationUrl(siteInfo, linkUrl, false)); } var contentUrl = PathUtility.ContentFilePathRules.Parse(siteInfo, channelId, contentId); return(GetSiteUrl(siteInfo, contentUrl, false)); }
internal static string Parse(string stlEntity, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; if (contextInfo.ContentId != 0) { try { if (contextInfo.ContentInfo != null && contextInfo.ContentInfo.ReferenceId > 0 && contextInfo.ContentInfo.SourceId > 0 && contextInfo.ContentInfo.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString()) { var targetChannelId = contextInfo.ContentInfo.SourceId; var targetSiteId = StlChannelCache.GetSiteId(targetChannelId); var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId); var targetNodeInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId); var targetContentInfo = ContentManager.GetContentInfo(targetSiteInfo, targetNodeInfo, contextInfo.ContentInfo.ReferenceId); if (targetContentInfo != null && targetContentInfo.ChannelId > 0) { //标题可以使用自己的 targetContentInfo.Title = contextInfo.ContentInfo.Title; contextInfo.ContentInfo = targetContentInfo; } } var entityName = StlParserUtility.GetNameFromEntity(stlEntity); var attributeName = entityName.Substring(9, entityName.Length - 10); if (StringUtils.EqualsIgnoreCase(ContentAttribute.Id, attributeName))//内容ID { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.ReferenceId > 0 ? contextInfo.ContentInfo.ReferenceId.ToString() : contextInfo.ContentInfo.Id.ToString(); } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Id); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Id); } } else if (StringUtils.EqualsIgnoreCase(Title, attributeName))//内容标题 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.Title; } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title); } } else if (StringUtils.EqualsIgnoreCase(FullTitle, attributeName))//内容标题全称 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.Title; } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title); } } else if (StringUtils.EqualsIgnoreCase(NavigationUrl, attributeName))//内容链接地址 { if (contextInfo.ContentInfo != null) { parsedContent = PageUtility.GetContentUrl(pageInfo.SiteInfo, contextInfo.ContentInfo, pageInfo.IsLocal); } else { var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId); parsedContent = PageUtility.GetContentUrl(pageInfo.SiteInfo, nodeInfo, contextInfo.ContentId, pageInfo.IsLocal); } } else if (StringUtils.EqualsIgnoreCase(ImageUrl, attributeName))//内容图片地址 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.ImageUrl); } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.ImageUrl); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.ImageUrl); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } } else if (StringUtils.EqualsIgnoreCase(VideoUrl, attributeName))//内容视频地址 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.VideoUrl); } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.VideoUrl); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.VideoUrl); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } } else if (StringUtils.EqualsIgnoreCase(FileUrl, attributeName))//内容附件地址 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.FileUrl); } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } } else if (StringUtils.EqualsIgnoreCase(DownloadUrl, attributeName))//内容附件地址(可统计下载量) { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.FileUrl); } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = ApiRouteActionsDownload.GetUrl(pageInfo.ApiUrl, pageInfo.SiteId, contextInfo.ChannelId, contextInfo.ContentId, parsedContent); } } else if (StringUtils.EqualsIgnoreCase(AddDate, attributeName))//内容添加日期 { if (contextInfo.ContentInfo != null) { parsedContent = DateUtils.Format(contextInfo.ContentInfo.AddDate, string.Empty); } } else if (StringUtils.EqualsIgnoreCase(LastEditDate, attributeName))//替换最后修改日期 { if (contextInfo.ContentInfo != null) { parsedContent = DateUtils.Format(contextInfo.ContentInfo.LastEditDate, string.Empty); } } else if (StringUtils.EqualsIgnoreCase(Content, attributeName))//内容正文 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.Content); } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.Content); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.Content); } parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } else if (StringUtils.EqualsIgnoreCase(Group, attributeName))//内容组别 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GroupNameCollection; } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.ContentGroupNameCollection); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, ContentAttribute.GroupNameCollection); } } else if (StringUtils.EqualsIgnoreCase(Tags, attributeName))//标签 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.Tags; } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Tags); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Tags); } } else if (StringUtils.EqualsIgnoreCase(AddUserName, attributeName)) { string addUserName; if (contextInfo.ContentInfo != null) { addUserName = contextInfo.ContentInfo.AddUserName; } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //addUserName = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.AddUserName); addUserName = StlContentCache.GetValue(tableName, contextInfo.ContentId, ContentAttribute.AddUserName); } if (!string.IsNullOrEmpty(addUserName)) { parsedContent = addUserName; } } else if (StringUtils.StartsWithIgnoreCase(attributeName, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ContentItem != null) { parsedContent = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ContentItem.ItemIndex, attributeName, contextInfo).ToString(); } else { int contentChannelId; if (contextInfo.ContentInfo != null) { contentChannelId = contextInfo.ContentInfo.ChannelId; if (contextInfo.ContentInfo.ContainsKey(attributeName)) { parsedContent = contextInfo.ContentInfo.GetString(attributeName); } } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, contextInfo.ChannelId); //contentChannelId = DataProvider.ContentDao.GetChannelId(tableName, contextInfo.ContentId); contentChannelId = StlContentCache.GetChannelId(tableName, contextInfo.ContentId); tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contentChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, attributeName); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, attributeName); } if (!string.IsNullOrEmpty(parsedContent)) { var channelInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, contentChannelId); var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, channelInfo); var relatedIdentities = TableStyleManager.GetRelatedIdentities(channelInfo); var styleInfo = TableStyleManager.GetTableStyleInfo(tableName, attributeName, relatedIdentities); //styleInfo.IsVisible = false 表示此字段不需要显示 styleInfo.TableStyleId = 0 不能排除,因为有可能是直接辅助表字段没有添加显示样式 parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, ",", pageInfo.SiteInfo, styleInfo, string.Empty, null, string.Empty, true); } } } catch { // ignored } } parsedContent = parsedContent.Replace(ContentUtility.PagePlaceHolder, string.Empty); return(parsedContent); }
private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string leftText, string rightText, string formatString, string no, string separator, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, string isReturnToBrStr, bool isLower, bool isUpper, bool isOriginal, string type, ContentInfo contentInfo, int contentId) { if (contentInfo == null) { return(string.Empty); } var parsedContent = string.Empty; if (string.IsNullOrEmpty(type)) { type = ContentAttribute.Title.ToLower(); } var isReturnToBr = false; if (string.IsNullOrEmpty(isReturnToBrStr)) { if (BackgroundContentAttribute.Summary.ToLower().Equals(type)) { isReturnToBr = true; } } else { isReturnToBr = TranslateUtils.ToBool(isReturnToBrStr, true); } if (isOriginal) { if (contentInfo.ReferenceId > 0 && contentInfo.SourceId > 0 && contentInfo.GetString(ContentAttribute.TranslateContentType) == ETranslateContentType.Reference.ToString()) { var targetChannelId = contentInfo.SourceId; //var targetSiteId = DataProvider.ChannelDao.GetSiteId(targetChannelId); var targetSiteId = StlChannelCache.GetSiteId(targetChannelId); var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId); var targetNodeInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId); //var targetContentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentInfo.ReferenceId); var targetContentInfo = ContentManager.GetContentInfo(targetSiteInfo, targetNodeInfo, contentInfo.ReferenceId); if (targetContentInfo != null && targetContentInfo.ChannelId > 0) { //标题可以使用自己的 targetContentInfo.Title = contentInfo.Title; contentInfo = targetContentInfo; } } } if (!string.IsNullOrEmpty(formatString)) { formatString = formatString.Trim(); if (!formatString.StartsWith("{0")) { formatString = "{0:" + formatString; } if (!formatString.EndsWith("}")) { formatString = formatString + "}"; } } if (contentId != 0) { if (ContentAttribute.Title.ToLower().Equals(type)) { var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, contentInfo.ChannelId); var relatedIdentities = TableStyleManager.GetRelatedIdentities(nodeInfo); var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, nodeInfo); var styleInfo = TableStyleManager.GetTableStyleInfo(tableName, type, relatedIdentities); parsedContent = InputParserUtility.GetContentByTableStyle(contentInfo.Title, separator, pageInfo.SiteInfo, styleInfo, formatString, contextInfo.Attributes, contextInfo.InnerHtml, false); parsedContent = InputTypeUtils.ParseString(styleInfo.InputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); if (!isClearTags && !string.IsNullOrEmpty(contentInfo.GetString(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title)))) { parsedContent = ContentUtility.FormatTitle(contentInfo.GetString(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title)), parsedContent); } if (pageInfo.SiteInfo.Additional.IsContentTitleBreakLine) { parsedContent = parsedContent.Replace(" ", !contextInfo.IsInnerElement ? "<br />" : string.Empty); } } else if (BackgroundContentAttribute.SubTitle.ToLower().Equals(type)) { parsedContent = InputTypeUtils.ParseString(InputType.Text, contentInfo.GetString(BackgroundContentAttribute.SubTitle), replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); if (pageInfo.SiteInfo.Additional.IsContentSubTitleBreakLine) { parsedContent = parsedContent.Replace(" ", !contextInfo.IsInnerElement ? "<br />" : string.Empty); } } else if (BackgroundContentAttribute.Summary.ToLower().Equals(type)) { parsedContent = InputTypeUtils.ParseString(InputType.TextArea, contentInfo.GetString(BackgroundContentAttribute.Summary), replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); } else if (BackgroundContentAttribute.Content.ToLower().Equals(type)) { parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.Content), pageInfo.IsLocal); if (isClearTags) { parsedContent = StringUtils.StripTags(parsedContent); } if (!string.IsNullOrEmpty(replace)) { parsedContent = StringUtils.Replace(replace, parsedContent, to); } if (wordNum > 0 && !string.IsNullOrEmpty(parsedContent)) { parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis); } if (!string.IsNullOrEmpty(formatString)) { parsedContent = string.Format(formatString, parsedContent); } parsedContent = EditorUtility.Parse(pageInfo, parsedContent); } else if (ContentAttribute.PageContent.ToLower().Equals(type)) { //if (contextInfo.IsInnerElement) // { parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.Content), pageInfo.IsLocal); if (isClearTags) { parsedContent = StringUtils.StripTags(parsedContent); } if (!string.IsNullOrEmpty(replace)) { parsedContent = StringUtils.Replace(replace, parsedContent, to); } if (wordNum > 0 && !string.IsNullOrEmpty(parsedContent)) { parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis); } if (!string.IsNullOrEmpty(formatString)) { parsedContent = string.Format(formatString, parsedContent); } parsedContent = EditorUtility.Parse(pageInfo, parsedContent); } else if (ContentAttribute.AddDate.ToLower().Equals(type)) { parsedContent = DateUtils.Format(contentInfo.AddDate, formatString); } else if (ContentAttribute.LastEditDate.ToLower().Equals(type)) { parsedContent = DateUtils.Format(contentInfo.LastEditDate, formatString); } else if (ContentAttribute.LastHitsDate.ToLower().Equals(type)) { parsedContent = DateUtils.Format(contentInfo.LastHitsDate, formatString); } else if (BackgroundContentAttribute.ImageUrl.ToLower().Equals(type)) { if (no == "all") { var sbParsedContent = new StringBuilder(); //第一条 sbParsedContent.Append(contextInfo.IsStlEntity ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.ImageUrl), pageInfo.IsLocal) : InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.ImageUrl), contextInfo.Attributes, false)); //第n条 var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { foreach (var extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { var newExtendValue = extendValue; sbParsedContent.Append(contextInfo.IsStlEntity ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, newExtendValue, pageInfo.IsLocal) : InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo, newExtendValue, contextInfo.Attributes, false)); } } parsedContent = sbParsedContent.ToString(); } else { var num = TranslateUtils.ToInt(no); if (num <= 1) { parsedContent = contextInfo.IsStlEntity ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.ImageUrl), pageInfo.IsLocal) : InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.ImageUrl), contextInfo.Attributes, false); } else { var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { var index = 2; foreach (var extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { var newExtendValue = extendValue; if (index == num) { parsedContent = contextInfo.IsStlEntity ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, newExtendValue, pageInfo.IsLocal) : InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo, newExtendValue, contextInfo.Attributes, false); break; } index++; } } } } } else if (BackgroundContentAttribute.VideoUrl.ToLower().Equals(type)) { if (no == "all") { var sbParsedContent = new StringBuilder(); //第一条 sbParsedContent.Append(InputParserUtility.GetVideoHtml(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.VideoUrl), contextInfo.Attributes, contextInfo.IsStlEntity)); //第n条 var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.VideoUrl); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { sbParsedContent.Append(InputParserUtility.GetVideoHtml(pageInfo.SiteInfo, extendValue, contextInfo.Attributes, contextInfo.IsStlEntity)); } } parsedContent = sbParsedContent.ToString(); } else { var num = TranslateUtils.ToInt(no); if (num <= 1) { parsedContent = InputParserUtility.GetVideoHtml(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.VideoUrl), contextInfo.Attributes, contextInfo.IsStlEntity); } else { var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.VideoUrl); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { var index = 2; foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { if (index == num) { parsedContent = InputParserUtility.GetVideoHtml(pageInfo.SiteInfo, extendValue, contextInfo.Attributes, contextInfo.IsStlEntity); break; } index++; } } } } } else if (BackgroundContentAttribute.FileUrl.ToLower().Equals(type)) { if (no == "all") { var sbParsedContent = new StringBuilder(); if (contextInfo.IsStlEntity) { //第一条 sbParsedContent.Append(contentInfo.GetString(BackgroundContentAttribute.FileUrl)); //第n条 var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { sbParsedContent.Append(extendValue); } } } else { //第一条 sbParsedContent.Append(InputParserUtility.GetFileHtmlWithCount(pageInfo.SiteInfo, contentInfo.ChannelId, contentInfo.Id, contentInfo.GetString(BackgroundContentAttribute.FileUrl), contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper)); //第n条 var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { sbParsedContent.Append(InputParserUtility.GetFileHtmlWithCount(pageInfo.SiteInfo, contentInfo.ChannelId, contentInfo.Id, extendValue, contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper)); } } } parsedContent = sbParsedContent.ToString(); } else { var num = TranslateUtils.ToInt(no); if (contextInfo.IsStlEntity) { if (num <= 1) { parsedContent = contentInfo.GetString(BackgroundContentAttribute.FileUrl); } else { var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { var index = 2; foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { if (index == num) { parsedContent = extendValue; break; } index++; } } } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } } else { if (num <= 1) { parsedContent = InputParserUtility.GetFileHtmlWithCount(pageInfo.SiteInfo, contentInfo.ChannelId, contentInfo.Id, contentInfo.GetString(BackgroundContentAttribute.FileUrl), contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper); } else { var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { var index = 2; foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { if (index == num) { parsedContent = InputParserUtility.GetFileHtmlWithCount(pageInfo.SiteInfo, contentInfo.ChannelId, contentInfo.Id, extendValue, contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper); break; } index++; } } } } } } else if (ContentAttribute.NavigationUrl.ToLower().Equals(type)) { parsedContent = PageUtility.GetContentUrl(pageInfo.SiteInfo, contentInfo, pageInfo.IsLocal); } else if (ContentAttribute.Tags.ToLower().Equals(type)) { parsedContent = contentInfo.Tags; } else if (StringUtils.StartsWithIgnoreCase(type, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ContentItem != null) { var itemIndex = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ContentItem.ItemIndex, type, contextInfo); parsedContent = !string.IsNullOrEmpty(formatString) ? string.Format(formatString, itemIndex) : itemIndex.ToString(); } else if (ContentAttribute.AddUserName.ToLower().Equals(type)) { if (!string.IsNullOrEmpty(contentInfo.AddUserName)) { parsedContent = contentInfo.AddUserName; } } else { var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, contentInfo.ChannelId); if (contentInfo.ContainsKey(type)) { if (!StringUtils.ContainsIgnoreCase(ContentAttribute.AllAttributes.Value, type)) { var relatedIdentities = TableStyleManager.GetRelatedIdentities(nodeInfo); var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, nodeInfo); var styleInfo = TableStyleManager.GetTableStyleInfo(tableName, type, relatedIdentities); //styleInfo.IsVisible = false 表示此字段不需要显示 styleInfo.TableStyleId = 0 不能排除,因为有可能是直接辅助表字段没有添加显示样式 var num = TranslateUtils.ToInt(no); parsedContent = InputParserUtility.GetContentByTableStyle(contentInfo, separator, pageInfo.SiteInfo, styleInfo, formatString, num, contextInfo.Attributes, contextInfo.InnerHtml, false); parsedContent = InputTypeUtils.ParseString(styleInfo.InputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); } else { parsedContent = contentInfo.GetString(type); parsedContent = InputTypeUtils.ParseString(InputType.Text, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); } } } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = leftText + parsedContent + rightText; } } return(parsedContent); }
private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, HtmlImage stlImage, bool isGetPicUrlFromAttribute, string channelIndex, string channelName, int upLevel, int topLevel, string type, int no, bool isOriginal, string src, string altSrc) { var parsedContent = string.Empty; var contentId = 0; //判断是否图片地址由标签属性获得 if (!isGetPicUrlFromAttribute) { contentId = contextInfo.ContentId; } var contextType = contextInfo.ContextType; var picUrl = string.Empty; if (!string.IsNullOrEmpty(src)) { picUrl = src; } else { if (contextType == EContextType.Undefined) { contextType = contentId != 0 ? EContextType.Content : EContextType.Channel; } if (contextType == EContextType.Content)//获取内容图片 { var contentInfo = contextInfo.ContentInfo; if (isOriginal) { if (contentInfo != null && contentInfo.ReferenceId > 0 && contentInfo.SourceId > 0) { var targetChannelId = contentInfo.SourceId; //var targetSiteId = DataProvider.ChannelDao.GetSiteId(targetChannelId); var targetSiteId = StlChannelCache.GetSiteId(targetChannelId); var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId); var targetNodeInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId); //var targetContentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentInfo.ReferenceId); var targetContentInfo = ContentManager.GetContentInfo(targetSiteInfo, targetNodeInfo, contentInfo.ReferenceId); if (targetContentInfo != null && targetContentInfo.ChannelId > 0) { contentInfo = targetContentInfo; } } } if (contentInfo == null) { contentInfo = ContentManager.GetContentInfo(pageInfo.SiteInfo, contextInfo.ChannelId, contentId); } if (contentInfo != null) { if (no <= 1) { picUrl = contentInfo.GetString(type); } else { var extendAttributeName = ContentAttribute.GetExtendAttributeName(type); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { var index = 2; foreach (var extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { if (index == no) { picUrl = extendValue; break; } index++; } } } } } else if (contextType == EContextType.Channel)//获取栏目图片 { var channelId = StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, contextInfo.ChannelId, upLevel, topLevel); channelId = StlDataUtility.GetChannelIdByChannelIdOrChannelIndexOrChannelName(pageInfo.SiteId, channelId, channelIndex, channelName); var channel = ChannelManager.GetChannelInfo(pageInfo.SiteId, channelId); picUrl = channel.ImageUrl; } else if (contextType == EContextType.Each) { picUrl = contextInfo.ItemContainer.EachItem.DataItem as string; } } if (string.IsNullOrEmpty(picUrl)) { picUrl = altSrc; } if (!string.IsNullOrEmpty(picUrl)) { var extension = PathUtils.GetExtension(picUrl); if (EFileSystemTypeUtils.IsFlash(extension)) { parsedContent = StlFlash.Parse(pageInfo, contextInfo); } else if (EFileSystemTypeUtils.IsPlayer(extension)) { parsedContent = StlPlayer.Parse(pageInfo, contextInfo); } else { stlImage.Src = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, picUrl, pageInfo.IsLocal); parsedContent = ControlUtils.GetControlRenderHtml(stlImage); } } return(parsedContent); }