internal static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { // 如果是实体标签则返回空 if (contextInfo.IsCurlyBrace) { return(string.Empty); } var isPageRefresh = false; foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, AttributeContext)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsPageRefresh)) { isPageRefresh = TranslateUtils.ToBool(value); } } return(ParseImpl(pageInfo, contextInfo, contextInfo.InnerXml, isPageRefresh)); }
internal static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { var testTypeStr = string.Empty; var testOperate = OperateEquals; var testValue = string.Empty; foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, Type) || StringUtils.EqualsIgnoreCase(name, "testType")) { testTypeStr = value; } else if (StringUtils.EqualsIgnoreCase(name, Op) || StringUtils.EqualsIgnoreCase(name, "operate") || StringUtils.EqualsIgnoreCase(name, "testOperate")) { testOperate = value; } else if (StringUtils.EqualsIgnoreCase(name, Value) || StringUtils.EqualsIgnoreCase(name, "testValue")) { testValue = value; } else if (StringUtils.EqualsIgnoreCase(name, Context)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(value); } } return(ParseImpl(pageInfo, contextInfo, testTypeStr, testOperate, testValue)); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { // 如果是实体标签则返回空 if (contextInfo.IsStlEntity) { return(string.Empty); } if (string.IsNullOrEmpty(contextInfo.InnerHtml)) { return(string.Empty); } foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, Context.Name)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(value); } } var innerHtml = RegexUtils.GetInnerContent(ElementName, contextInfo.OuterHtml); var builder = new StringBuilder(innerHtml); StlParserManager.ParseInnerContent(builder, pageInfo, contextInfo); return(builder.ToString()); }
internal static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { var testTypeStr = string.Empty; var testOperate = string.Empty; var testValue = string.Empty; var onBeforeSend = string.Empty; var onSuccess = string.Empty; var onComplete = string.Empty; var onError = string.Empty; foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, Type) || StringUtils.EqualsIgnoreCase(name, "testType")) { testTypeStr = value; } else if (StringUtils.EqualsIgnoreCase(name, Op) || StringUtils.EqualsIgnoreCase(name, "operate") || StringUtils.EqualsIgnoreCase(name, "testOperate")) { testOperate = value; } else if (StringUtils.EqualsIgnoreCase(name, Value) || StringUtils.EqualsIgnoreCase(name, "testValue")) { testValue = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (string.IsNullOrEmpty(testOperate)) { testOperate = OperateEquals; } } else if (StringUtils.EqualsIgnoreCase(name, Context)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(value); } else if (StringUtils.EqualsIgnoreCase(name, OnBeforeSend)) { onBeforeSend = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, OnSuccess)) { onSuccess = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, OnComplete)) { onComplete = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, OnError)) { onError = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } } if (string.IsNullOrEmpty(testOperate)) { testOperate = OperateNotEmpty; } return(ParseImpl(pageInfo, contextInfo, testTypeStr, testOperate, testValue, onBeforeSend, onSuccess, onComplete, onError)); }
//对“翻页项容器”(stl:pageItems)元素进行解析,此元素在生成页面时单独解析,不包含在ParseStlElement方法中。 public static string Parse(string stlElement, PageInfo pageInfo, int channelId, int contentId, int currentPageIndex, int pageCount, int totalNum, EContextType contextType) { pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.Jquery); string parsedContent; try { var xmlDocument = StlParserUtility.GetXmlDocument(stlElement, false); XmlNode node = xmlDocument.DocumentElement; node = node?.FirstChild; var ie = node?.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (attr == null) { continue; } var name = attr.Name; if (StringUtils.EqualsIgnoreCase(name, Context.Name)) { contextType = EContextTypeUtils.GetEnumType(attr.Value); } } } if (pageCount <= 1) { return(string.Empty); } bool isXmlContent; var index = stlElement.IndexOf(">", StringComparison.Ordinal) + 1; var length = stlElement.LastIndexOf("<", StringComparison.Ordinal) - index; if (index <= 0 || length <= 0) { stlElement = node?.InnerXml; isXmlContent = true; } else { stlElement = stlElement.Substring(index, length); isXmlContent = false; } parsedContent = StlPageElementParser.ParseStlPageItems(stlElement, pageInfo, channelId, contentId, currentPageIndex, pageCount, totalNum, isXmlContent, contextType); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, stlElement, ex); } return(parsedContent); }
//对“翻页项容器”(stl:pageItems)元素进行解析,此元素在生成页面时单独解析,不包含在ParseStlElement方法中。 public static string Parse(string stlElement, PageInfo pageInfo, int nodeId, int contentId, int currentPageIndex, int pageCount, int totalNum, EContextType contextType) { pageInfo.AddPageScriptsIfNotExists(PageInfo.Components.Jquery); string parsedContent; try { var xmlDocument = StlParserUtility.GetXmlDocument(stlElement, false); XmlNode node = xmlDocument.DocumentElement; node = node.FirstChild; var ie = node.Attributes.GetEnumerator(); var autoHide = true; while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(AttributeAutoHide)) { autoHide = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(AttributeContext)) { contextType = EContextTypeUtils.GetEnumType(attr.Value); } } if (pageCount <= 1 && autoHide) { return(string.Empty); } bool isXmlContent; var index = stlElement.IndexOf(">", StringComparison.Ordinal) + 1; var length = stlElement.LastIndexOf("<", StringComparison.Ordinal) - index; if (index <= 0 || length <= 0) { stlElement = node.InnerXml; isXmlContent = true; } else { stlElement = stlElement.Substring(index, length); isXmlContent = false; } parsedContent = StlPageElementParser.ParseStlPageItems(stlElement, pageInfo, nodeId, contentId, currentPageIndex, pageCount, totalNum, isXmlContent, contextType); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
internal static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { // 如果是实体标签则返回空 if (contextInfo.IsStlEntity) { return(string.Empty); } var inline = false; var onBeforeSend = string.Empty; var onSuccess = string.Empty; var onComplete = string.Empty; var onError = string.Empty; foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, Inline)) { inline = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, Context)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(value); } else if (StringUtils.EqualsIgnoreCase(name, OnBeforeSend)) { onBeforeSend = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, OnSuccess)) { onSuccess = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, OnComplete)) { onComplete = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, OnError)) { onError = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } } StlParserUtility.GetLoading(contextInfo.InnerHtml, out var loading, out var template); if (!string.IsNullOrEmpty(loading)) { var innerBuilder = new StringBuilder(loading); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); loading = innerBuilder.ToString(); } return(ParseImpl(pageInfo, contextInfo, loading, template, inline, onBeforeSend, onSuccess, onComplete, onError)); }
internal static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfoRef) { string parsedContent; var contextInfo = contextInfoRef.Clone(); try { var testTypeStr = string.Empty; var testOperate = OperateEquals; var testValue = string.Empty; var isDynamic = false; var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeType) || StringUtils.EqualsIgnoreCase(attr.Name, "testType")) { testTypeStr = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeOperate) || StringUtils.EqualsIgnoreCase(attr.Name, "testOperate")) { testOperate = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeValue) || StringUtils.EqualsIgnoreCase(attr.Name, "testValue")) { testValue = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeContext)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(node, pageInfo, contextInfo, testTypeStr, testOperate, testValue); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“翻页项容器”(stl:pageItems)元素进行解析,此元素在生成页面时单独解析,不包含在ParseStlElement方法中。 public static string Parse(string stlElement, PageInfo pageInfo, int channelId, int contentId, int currentPageIndex, int pageCount, int totalNum, EContextType contextType) { pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.Jquery); string parsedContent; try { var stlElementInfo = StlParserUtility.ParseStlElement(stlElement); if (stlElementInfo.Attributes[Context] != null) { contextType = EContextTypeUtils.GetEnumType(stlElementInfo.Attributes[Context]); } if (pageCount <= 1) { return(string.Empty); } bool isXmlContent; var index = stlElement.IndexOf(">", StringComparison.Ordinal) + 1; var length = stlElement.LastIndexOf("<", StringComparison.Ordinal) - index; if (index <= 0 || length <= 0) { stlElement = stlElementInfo.InnerHtml; isXmlContent = true; } else { stlElement = stlElement.Substring(index, length); isXmlContent = false; } parsedContent = StlPageElementParser.ParseStlPageItems(stlElement, pageInfo, channelId, contentId, currentPageIndex, pageCount, totalNum, isXmlContent, contextType); ContextInfo contextInfo = new ContextInfo(pageInfo) { ContextType = contextType }; var innerBuilder = new StringBuilder(parsedContent); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); parsedContent = innerBuilder.ToString(); } catch (Exception ex) { parsedContent = LogUtils.AddStlErrorLog(pageInfo, ElementName, stlElement, ex); } return(parsedContent); }
internal static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { // 如果是实体标签则返回空 if (contextInfo.IsStlEntity) { return(string.Empty); } var isPageRefresh = false; var onBeforeSend = string.Empty; var onSuccess = string.Empty; var onComplete = string.Empty; var onError = string.Empty; foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, Context)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(value); } else if (StringUtils.EqualsIgnoreCase(name, IsPageRefresh)) { isPageRefresh = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, OnBeforeSend)) { onBeforeSend = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, OnSuccess)) { onSuccess = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, OnComplete)) { onComplete = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, OnError)) { onError = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } } return(ParseImpl(pageInfo, contextInfo, contextInfo.InnerHtml, isPageRefresh, onBeforeSend, onSuccess, onComplete, onError)); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfoRef) { var parsedContent = string.Empty; var contextInfo = contextInfoRef.Clone(); try { var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(AttributeContext)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(attr.Value); } } } if (!string.IsNullOrEmpty(node.InnerXml)) { var innerHtml = RegexUtils.GetInnerContent(ElementName, stlElement); var builder = new StringBuilder(innerHtml); StlParserManager.ParseInnerContent(builder, pageInfo, contextInfo); parsedContent = builder.ToString(); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { var tagLevel = 1; var totalNum = 0; var isOrderByCount = false; var theme = "default"; var isInnerXml = !string.IsNullOrEmpty(contextInfo.InnerXml); foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, TagLevel.Name)) { tagLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, TotalNum.Name)) { totalNum = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, IsOrderByCount.Name)) { isOrderByCount = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, Theme.Name)) { theme = value; } else if (StringUtils.EqualsIgnoreCase(name, Context.Name)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(value); } } return(ParseImpl(isInnerXml, pageInfo, contextInfo, tagLevel, totalNum, isOrderByCount, theme)); }
internal static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfoRef) { string parsedContent; var contextInfo = contextInfoRef.Clone(); try { var isPageRefresh = false; var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(AttributeContext)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(attr.Value); } else if (attributeName.Equals(AttributeIsPageRefresh)) { isPageRefresh = TranslateUtils.ToBool(attr.Value); } } } parsedContent = ParseImpl(pageInfo, contextInfo, node.InnerXml, isPageRefresh); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { if (contextInfo.IsStlEntity || string.IsNullOrWhiteSpace(contextInfo.InnerHtml)) { return(string.Empty); } var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var context = contextInfo.ContextType; foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, ChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, ChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, Parent)) { if (TranslateUtils.ToBool(value)) { upLevel = 1; } } else if (StringUtils.EqualsIgnoreCase(name, UpLevel)) { upLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, TopLevel)) { topLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Context)) { context = EContextTypeUtils.GetEnumType(value); } } var channelId = StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, contextInfo.ChannelId, upLevel, topLevel); channelId = StlDataUtility.GetChannelIdByChannelIdOrChannelIndexOrChannelName(pageInfo.SiteId, channelId, channelIndex, channelName); contextInfo.ContextType = context; contextInfo.ChannelId = channelId; var innerHtml = RegexUtils.GetInnerContent(ElementName, contextInfo.OuterHtml); var builder = new StringBuilder(innerHtml); StlParserManager.ParseInnerContent(builder, pageInfo, contextInfo); return(builder.ToString()); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { var stlAnchor = new HtmlAnchor(); var htmlId = string.Empty; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; const bool removeTarget = false; var href = string.Empty; var queryString = string.Empty; var host = string.Empty; foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, AttributeId)) { htmlId = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelIndex)) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeParent)) { if (TranslateUtils.ToBool(value)) { upLevel = 1; contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeUpLevel)) { upLevel = TranslateUtils.ToInt(value); if (upLevel > 0) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeTopLevel)) { topLevel = TranslateUtils.ToInt(value); if (topLevel >= 0) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeContext)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeHref)) { href = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeQueryString)) { queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeHost)) { host = value; } else { ControlUtils.AddAttributeIfNotExists(stlAnchor, name, value); } } var parsedContent = ParseImpl(pageInfo, contextInfo, stlAnchor, htmlId, channelIndex, channelName, upLevel, topLevel, removeTarget, href, queryString, host); return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfoRef) { string parsedContent; var contextInfo = contextInfoRef.Clone(); try { var tagLevel = 1; var totalNum = 0; var isOrderByCount = false; var theme = "default"; var isDynamic = false; var isInnerXml = !string.IsNullOrEmpty(node.InnerXml); var attributes = new LowerNameValueCollection(); var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTagLevel)) { tagLevel = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTotalNum)) { totalNum = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsOrderByCount)) { isOrderByCount = TranslateUtils.ToBool(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTheme)) { theme = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeContext)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { attributes.Set(attr.Name, attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(stlElement, isInnerXml, pageInfo, contextInfo, tagLevel, totalNum, isOrderByCount, theme); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { var attributes = new Dictionary <string, string>(); var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; const bool removeTarget = false; var href = string.Empty; var queryString = string.Empty; var host = string.Empty; foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, ChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelIndex)) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, ChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, Parent)) { if (TranslateUtils.ToBool(value)) { upLevel = 1; contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, UpLevel)) { upLevel = TranslateUtils.ToInt(value); if (upLevel > 0) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, TopLevel)) { topLevel = TranslateUtils.ToInt(value); if (topLevel >= 0) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, Context)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(value); } else if (StringUtils.EqualsIgnoreCase(name, Href)) { href = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, QueryString)) { queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, Host)) { host = value; } else { attributes[name] = value; } } var parsedContent = ParseImpl(pageInfo, contextInfo, channelIndex, channelName, upLevel, topLevel, removeTarget, href, queryString, host, attributes); return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfoRef) { var parsedContent = string.Empty; var cols = string.Empty; var marginTop = 5; var marginBottom = 5; var contextInfo = contextInfoRef.Clone(); try { var ie = node.Attributes.GetEnumerator(); while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_Cols)) { cols = attr.Value; } else if (attributeName.Equals(Attribute_Margin_Top)) { marginTop = TranslateUtils.ToInt(attr.Value, 5); } else if (attributeName.Equals(Attribute_Margin_Bottom)) { marginBottom = TranslateUtils.ToInt(attr.Value, 5); } else if (attributeName.Equals(Attribute_Context)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(attr.Value); } } if (!string.IsNullOrEmpty(node.InnerXml)) { var innerHtml = RegexUtils.GetInnerContent(ElementName, stlElement); var containerList = RegexUtils.GetTagContents(StlContainer.ElementName, innerHtml); var widthList = new List <string>(); for (var i = 0; i < containerList.Count; i++) { if (!string.IsNullOrEmpty(cols) && cols.Split(',').Length == i + 1) { var width = cols.Split(',')[i]; if (width == "*") { width = string.Empty; } widthList.Add(width); } else { widthList.Add(string.Empty); } } var builder = new StringBuilder(); var style = string.Empty; if (marginTop > 0) { style += $"margin-top:{marginTop}px;"; } if (marginBottom > 0) { style += $"margin-bottom:{marginTop}px;"; } if (!string.IsNullOrEmpty(style)) { style = $@"style=""{style}"""; } builder.Append($@"<table width=""100%"" cellspacing=""0"" cellpadding=""0"" {style}><tr>"); for (var i = 0; i < widthList.Count; i++) { var container = containerList[i]; var width = widthList[i]; if (!string.IsNullOrEmpty(width)) { width = $@" width=""{width}"""; } builder.Append($@"<td{width} valign=""top"">{container}</td>"); } builder.Append(@"</tr></table>"); StlParserManager.ParseInnerContent(builder, pageInfo, contextInfo); parsedContent = builder.ToString(); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfoRef) { string parsedContent; var contextInfo = contextInfoRef.Clone(); try { var stlAnchor = new HtmlAnchor(); var htmlId = string.Empty; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; const bool removeTarget = false; var href = string.Empty; var queryString = string.Empty; var isDynamic = false; var host = string.Empty; var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeId)) { htmlId = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelIndex)) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeParent)) { if (TranslateUtils.ToBool(attr.Value)) { upLevel = 1; contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeUpLevel)) { upLevel = TranslateUtils.ToInt(attr.Value); if (upLevel > 0) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTopLevel)) { topLevel = TranslateUtils.ToInt(attr.Value); if (topLevel >= 0) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeContext)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeHref)) { href = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeQueryString)) { queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value, false); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeHost)) { host = attr.Value; } else { ControlUtils.AddAttributeIfNotExists(stlAnchor, attr.Name, attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(pageInfo, contextInfo, node, stlAnchor, htmlId, channelIndex, channelName, upLevel, topLevel, removeTarget, href, queryString, host); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }