public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var isDynamic = false; var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(pageInfo, contextInfo); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var diggType = EDiggType.All; var goodText = "顶一下"; var badText = "踩一下"; var theme = "style1"; var isNumber = false; var isDynamic = 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(AttributeType)) { diggType = EDiggTypeUtils.GetEnumType(attr.Value); } else if (attributeName.Equals(AttributeGoodText)) { goodText = attr.Value; } else if (attributeName.Equals(AttributeBadText)) { badText = attr.Value; } else if (attributeName.Equals(AttributeTheme)) { theme = attr.Value; } else if (attributeName.Equals(AttributeIsNumber)) { isNumber = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } } } pageInfo.AddPageScriptsIfNotExists(PageInfo.Components.Jquery); parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(pageInfo, contextInfo, diggType, goodText, badText, theme, isNumber); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“打印”(stl:printer)元素进行解析 public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var titleId = string.Empty; var bodyId = string.Empty; var logoId = string.Empty; var locationId = string.Empty; var isDynamic = false; var stlAnchor = new HtmlAnchor(); var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTitleId)) { titleId = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeBodyId)) { bodyId = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeLogoId)) { logoId = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeLocationId)) { locationId = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { ControlUtils.AddAttributeIfNotExists(stlAnchor, attr.Name, attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(node, pageInfo, contextInfo, stlAnchor, titleId, bodyId, logoId, locationId); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“当前位置”(stl:location)元素进行解析 public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var separator = " - "; var target = string.Empty; var linkClass = string.Empty; var wordNum = 0; var isDynamic = false; var attributes = new StringDictionary(); var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeSeparator)) { separator = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTarget)) { target = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeLinkClass)) { linkClass = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeWordNum)) { wordNum = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { attributes.Add(attr.Name, attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(node, pageInfo, contextInfo, separator, target, linkClass, wordNum, attributes); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var theme = string.Empty; var isDynamic = false; var inputTemplateString = string.Empty; var successTemplateString = string.Empty; var failureTemplateString = string.Empty; StlParserUtility.GetInnerTemplateStringOfInput(node, out inputTemplateString, out successTemplateString, out failureTemplateString, pageInfo, contextInfo); var ie = node.Attributes.GetEnumerator(); while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_Theme)) { theme = attr.Value; } else if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } } pageInfo.AddPageScriptsIfNotExists(PageInfo.Components.Jquery); pageInfo.AddPageScriptsIfNotExists(PageInfo.JQuery.BjTemplates); pageInfo.AddPageScriptsIfNotExists(PageInfo.JQuery.BShowLoading); pageInfo.AddPageScriptsIfNotExists(PageInfo.JQuery.BValidate); pageInfo.AddPageScriptsIfNotExists("SiteServer.CMS.Parser.StlElement", $@"<link href=""{SiteFilesAssets.Vote.GetStyleUrl(pageInfo.ApiUrl)}"" type=""text/css"" rel=""stylesheet"" /> "); if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(pageInfo, contextInfo, theme, inputTemplateString); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“文字缩放”(stl:zoom)元素进行解析 public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var stlAnchor = new HtmlAnchor(); var ie = node.Attributes.GetEnumerator(); var zoomID = string.Empty; var fontSize = 16; var isDynamic = false; while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_ZoomID)) { zoomID = attr.Value; } else if (attributeName.Equals(Attribute_FontSize)) { fontSize = TranslateUtils.ToInt(attr.Value, 16); } else if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { ControlUtils.AddAttributeIfNotExists(stlAnchor, attributeName, attr.Value); } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(node, pageInfo, contextInfo, stlAnchor, zoomID, fontSize); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
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); }
//循环解析型标签 internal static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfoRef) { var parsedContent = string.Empty; try { if (!string.IsNullOrEmpty(node.InnerXml)) { var contextInfo = contextInfoRef.Clone(); var ie = node.Attributes.GetEnumerator(); var siteName = string.Empty; var directory = string.Empty; var isDynamic = false; while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_SiteName)) { siteName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_Directory)) { directory = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(node, pageInfo, contextInfo, siteName, directory); } } } 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 attributes = new NameValueCollection(); var ie = node.Attributes?.GetEnumerator(); var type = string.Empty; var returnUrl = string.Empty; var isDynamic = false; if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(AttributeType)) { type = attr.Value; } else if (attributeName.Equals(AttributeReturnUrl)) { returnUrl = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value, false); } else { attributes.Add(attributeName, attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(pageInfo, contextInfo, node, attributes, type, returnUrl); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var listInfo = ListInfo.GetListInfoByXmlNode(node, pageInfo, contextInfo, EContextType.Comment); parsedContent = listInfo.IsDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(pageInfo, contextInfo, listInfo); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“包含文件”(stl:include)元素进行解析 public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var ie = node.Attributes.GetEnumerator(); var file = string.Empty; var isContext = !pageInfo.PublishmentSystemInfo.Additional.IsCreateIncludeToSsi; var isDynamic = false; while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_File)) { file = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); file = PageUtility.AddVirtualToUrl(file); } else if (attributeName.Equals(Attribute_IsContext)) { isContext = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(pageInfo, contextInfo, file, isContext); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//循环解析型标签 internal static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfoRef) { var parsedContent = string.Empty; try { if (!string.IsNullOrEmpty(node.InnerXml)) { var contextInfo = contextInfoRef.Clone(); var siteName = string.Empty; var siteDir = 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, AttributeSiteName)) { siteName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeSiteDir)) { siteDir = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(node, pageInfo, contextInfo, siteName, siteDir); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“图片幻灯片”(stl:slide)元素进行解析 public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var ie = node.Attributes.GetEnumerator(); var isDynamic = false; while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(pageInfo, contextInfo); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对不能够翻页的“内容列表”(stl:contents)元素进行解析 public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var displayInfo = ContentsDisplayInfo.GetContentsDisplayInfoByXmlNode(node, pageInfo, contextInfo, EContextType.Content); if (displayInfo.IsDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(pageInfo, contextInfo, displayInfo); } } 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 type = TypeNextContent; var emptyText = string.Empty; var tipText = string.Empty; var wordNum = 0; var isDynamic = false; var isKeyboard = false; var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeType)) { type = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeEmptyText)) { emptyText = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTipText)) { tipText = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeWordNum)) { wordNum = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsKeyboard)) { isKeyboard = TranslateUtils.ToBool(attr.Value); } else { ControlUtils.AddAttributeIfNotExists(stlAnchor, attr.Name, attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(node, pageInfo, contextInfo, stlAnchor, type, emptyText, tipText, wordNum, isKeyboard); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“栏目链接”(stl:image)元素进行解析 public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var stlImage = new HtmlImage(); var ie = node.Attributes.GetEnumerator(); var isGetPicUrlFromAttribute = false; var channelIndex = string.Empty; var channelName = string.Empty; var no = 0; var upLevel = 0; var topLevel = -1; var type = BackgroundContentAttribute.ImageUrl; var isOriginal = false; var src = string.Empty; var altSrc = string.Empty; var isDynamic = false; while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_ChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelIndex)) { isGetPicUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_ChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { isGetPicUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_NO)) { no = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(Attribute_Parent)) { if (TranslateUtils.ToBool(attr.Value)) { upLevel = 1; isGetPicUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_UpLevel)) { upLevel = TranslateUtils.ToInt(attr.Value); if (upLevel > 0) { isGetPicUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_TopLevel)) { topLevel = TranslateUtils.ToInt(attr.Value); if (topLevel >= 0) { isGetPicUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_Type)) { type = attr.Value; } else if (attributeName.Equals(Attribute_IsOriginal)) { isOriginal = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(Attribute_Src)) { src = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_AltSrc)) { altSrc = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { stlImage.Attributes.Remove(attributeName); stlImage.Attributes.Add(attributeName, attr.Value); } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(stlElement, node, pageInfo, contextInfo, stlImage, isGetPicUrlFromAttribute, channelIndex, channelName, no, upLevel, topLevel, type, isOriginal, src, altSrc); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var totalStar = 10; var initStar = 0; var successMessage = string.Empty; var failureMessage = "对不起,不能重复操作!"; var theme = "style1"; var isTextOnly = false; var isDynamic = false; var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTotalStar)) { totalStar = TranslateUtils.ToInt(attr.Value, totalStar); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeInitStar)) { initStar = TranslateUtils.ToInt(attr.Value, 0); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeSuccessMessage)) { successMessage = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeFailureMessage)) { failureMessage = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTheme)) { theme = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsTextOnly)) { isTextOnly = TranslateUtils.ToBool(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } } } pageInfo.AddPageScriptsIfNotExists(PageInfo.Components.Jquery); parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(pageInfo, contextInfo, totalStar, initStar, successMessage, failureMessage, theme, isTextOnly); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“获取内容”(stl:sqlcontent)元素进行解析 public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var ie = node.Attributes.GetEnumerator(); var attributes = new StringDictionary(); var connectionString = string.Empty; var queryString = string.Empty; var leftText = string.Empty; var rightText = string.Empty; var formatString = string.Empty; string separator = null; var startIndex = 0; var length = 0; var wordNum = 0; var ellipsis = StringUtils.Constants.Ellipsis; var replace = string.Empty; var to = string.Empty; var isClearTags = false; var isReturnToBR = false; var isLower = false; var isUpper = false; var type = string.Empty; var isDynamic = false; while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_ConnectionString)) { connectionString = attr.Value; } else if (attributeName.Equals(Attribute_ConnectionStringName)) { if (string.IsNullOrEmpty(connectionString)) { connectionString = WebConfigUtils.ConnectionString; } } else if (attributeName.Equals(Attribute_QueryString)) { queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_Type)) { type = attr.Value.ToLower(); } else if (attributeName.Equals(Attribute_LeftText)) { leftText = attr.Value; } else if (attributeName.Equals(Attribute_RightText)) { rightText = attr.Value; } else if (attributeName.Equals(Attribute_FormatString)) { formatString = attr.Value; } else if (attributeName.Equals(Attribute_Separator)) { separator = attr.Value; } else if (attributeName.Equals(Attribute_StartIndex)) { startIndex = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(Attribute_Length)) { length = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(Attribute_WordNum)) { wordNum = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(Attribute_Ellipsis)) { ellipsis = attr.Value; } else if (attributeName.Equals(Attribute_Replace)) { replace = attr.Value; } else if (attributeName.Equals(Attribute_To)) { to = attr.Value; } else if (attributeName.Equals(Attribute_IsClearTags)) { isClearTags = TranslateUtils.ToBool(attr.Value, false); } else if (attributeName.Equals(Attribute_IsReturnToBR)) { isReturnToBR = TranslateUtils.ToBool(attr.Value, false); } else if (attributeName.Equals(Attribute_IsLower)) { isLower = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(Attribute_IsUpper)) { isUpper = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { attributes.Add(attributeName, attr.Value); } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(node, pageInfo, contextInfo, attributes, connectionString, queryString, leftText, rightText, formatString, separator, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBR, isLower, isUpper, type); } } 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); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var isGetUrlFromAttribute = false; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var type = BackgroundContentAttribute.VideoUrl; var playUrl = string.Empty; var imageUrl = string.Empty; var width = pageInfo.PublishmentSystemInfo.Additional.ConfigVideoContentInsertWidth; var height = pageInfo.PublishmentSystemInfo.Additional.ConfigVideoContentInsertHeight; var isAutoPlay = true; var isControls = true; var isPreLoad = true; var isLoop = false; var isDynamic = false; var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelIndex)) { isGetUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { isGetUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeParent)) { if (TranslateUtils.ToBool(attr.Value)) { upLevel = 1; isGetUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeUpLevel)) { upLevel = TranslateUtils.ToInt(attr.Value); if (upLevel > 0) { isGetUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTopLevel)) { topLevel = TranslateUtils.ToInt(attr.Value); if (topLevel >= 0) { isGetUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeType)) { type = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributePlayUrl)) { playUrl = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeImageUrl)) { imageUrl = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeWidth)) { width = TranslateUtils.ToInt(attr.Value, width); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeHeight)) { height = TranslateUtils.ToInt(attr.Value, height); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsAutoPlay)) { isAutoPlay = TranslateUtils.ToBool(attr.Value, true); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsControls)) { isControls = TranslateUtils.ToBool(attr.Value, true); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsPreLoad)) { isPreLoad = TranslateUtils.ToBool(attr.Value, true); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsLoop)) { isLoop = TranslateUtils.ToBool(attr.Value, false); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(pageInfo, contextInfo, isGetUrlFromAttribute, channelIndex, channelName, upLevel, topLevel, type, playUrl, imageUrl, width, height, isAutoPlay, isControls, isPreLoad, isLoop); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
internal static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var tabName = string.Empty; var isHeader = true; var action = ActionMouseOver; var classActive = "active"; var classNormal = string.Empty; var current = 0; var isDynamic = false; var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTabName)) { tabName = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsHeader)) { isHeader = TranslateUtils.ToBool(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeAction)) { action = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeClassActive)) { classActive = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeClassNormal)) { classNormal = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeCurrent)) { current = TranslateUtils.ToInt(attr.Value, 1); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } } } pageInfo.AddPageScriptsIfNotExists(PageInfo.Components.Jquery); parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(node, pageInfo, contextInfo, tabName, isHeader, action, classActive, classNormal, current); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“导航”(stl:navigation)元素进行解析 public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfoRef) { var parsedContent = string.Empty; var contextInfo = contextInfoRef.Clone(); try { var stlAnchor = new HtmlAnchor(); var ie = node.Attributes.GetEnumerator(); var type = Type_NextContent; var emptyText = string.Empty; var tipText = string.Empty; var wordNum = 0; var isDisplayIfEmpty = false; var isDynamic = false; var isKeyboard = false; while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_Type)) { type = attr.Value; } else if (attributeName.Equals(Attribute_EmptyText)) { emptyText = attr.Value; } else if (attributeName.Equals(Attribute_TipText)) { tipText = attr.Value; } else if (attributeName.Equals(Attribute_WordNum)) { wordNum = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(Attribute_IsDisplayIfEmpty)) { isDisplayIfEmpty = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(Attribute_IsKeyboard)) { isKeyboard = TranslateUtils.ToBool(attr.Value); } else { ControlUtils.AddAttributeIfNotExists(stlAnchor, attributeName, attr.Value); } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(node, pageInfo, contextInfo, stlAnchor, type, emptyText, tipText, wordNum, isDisplayIfEmpty, isKeyboard); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“内容属性”(stl:content)元素进行解析 public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var attributes = new StringDictionary(); var leftText = string.Empty; var rightText = string.Empty; var formatString = string.Empty; var no = "0"; string separator = null; var startIndex = 0; var length = 0; var wordNum = 0; var ellipsis = StringUtils.Constants.Ellipsis; var replace = string.Empty; var to = string.Empty; var isClearTags = false; var isReturnToBrStr = string.Empty; var isLower = false; var isUpper = false; var isOriginal = true;//引用的时候,默认使用原来的数据 var isDynamic = false; var imageType = string.Empty; var type = ContentAttribute.Title.ToLower(); var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(AttributeType)) { type = attr.Value.ToLower(); } else if (attributeName.Equals(AttributeLeftText)) { leftText = attr.Value; } else if (attributeName.Equals(AttributeRightText)) { rightText = attr.Value; } else if (attributeName.Equals(AttributeFormatString)) { formatString = attr.Value; } else if (attributeName.Equals(AttributeNo)) { no = attr.Value; } else if (attributeName.Equals(AttributeSeparator)) { separator = attr.Value; } else if (attributeName.Equals(AttributeStartIndex)) { startIndex = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(AttributeLength)) { length = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(AttributeWordNum)) { wordNum = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(AttributeEllipsis)) { ellipsis = attr.Value; } else if (attributeName.Equals(AttributeReplace)) { replace = attr.Value; } else if (attributeName.Equals(AttributeTo)) { to = attr.Value; } else if (attributeName.Equals(AttributeIsClearTags)) { isClearTags = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(AttributeIsReturnToBr)) { isReturnToBrStr = attr.Value; } else if (attributeName.Equals(AttributeIsLower)) { isLower = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(AttributeIsUpper)) { isUpper = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(AttributeIsOriginal)) { isOriginal = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(AttributeImageType)) { imageType = attr.Value; } else { attributes.Add(attributeName, attr.Value); } } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(node, pageInfo, contextInfo, leftText, rightText, formatString, no, separator, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBrStr, isLower, isUpper, isOriginal, type, attributes, imageType); var innerBuilder = new StringBuilder(parsedContent); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); parsedContent = innerBuilder.ToString(); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var ie = node.Attributes.GetEnumerator(); var isGetPicUrlFromAttribute = false; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var type = BackgroundContentAttribute.VideoUrl; var playUrl = string.Empty; var stretching = string.Empty; var imageUrl = string.Empty; var playBy = string.Empty; var width = 450; var height = 350; var isAutoPlay = true; var isDynamic = false; var parameters = new NameValueCollection(); while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_ChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelIndex)) { isGetPicUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_ChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { isGetPicUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_Parent)) { if (TranslateUtils.ToBool(attr.Value)) { upLevel = 1; isGetPicUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_UpLevel)) { upLevel = TranslateUtils.ToInt(attr.Value); if (upLevel > 0) { isGetPicUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_TopLevel)) { topLevel = TranslateUtils.ToInt(attr.Value); if (topLevel >= 0) { isGetPicUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_Type)) { type = attr.Value; } else if (attributeName.Equals(Attribute_PlayUrl)) { playUrl = attr.Value; } else if (attributeName.Equals(Attribute_ImageUrl)) { imageUrl = attr.Value; } else if (attributeName.Equals(Attribute_PlayBy)) { playBy = attr.Value; } else if (attributeName.Equals(Attribute_Stretching)) { stretching = attr.Value; } else if (attributeName.Equals(Attribute_Width)) { try { width = int.Parse(attr.Value); } catch { } } else if (attributeName.Equals(Attribute_Height)) { try { height = int.Parse(attr.Value); } catch { } } else if (attributeName.Equals(Attribute_IsAutoPlay)) { isAutoPlay = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { parameters.Add(attr.Name, attr.Value); } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(stlElement, node, pageInfo, contextInfo, isGetPicUrlFromAttribute, channelIndex, channelName, upLevel, topLevel, playUrl, imageUrl, playBy, stretching, width, height, type, isAutoPlay, parameters); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“flash滚动焦点图”(stl:focusViewer)元素进行解析 public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var genericControl = new HtmlGenericControl("div"); var ie = node.Attributes.GetEnumerator(); var channelIndex = string.Empty; var channelName = string.Empty; var scopeType = EScopeType.Self; var groupChannel = string.Empty; var groupChannelNot = string.Empty; var groupContent = string.Empty; var groupContentNot = string.Empty; var tags = string.Empty; var orderByString = ETaxisTypeUtils.GetOrderByString(ETableStyle.BackgroundContent, ETaxisType.OrderByTaxisDesc, string.Empty, null); var startNum = 1; var totalNum = 0; var isShowText = true; var isTopText = string.Empty; var titleWordNum = 0; var where = string.Empty; var isTop = false; var isTopExists = false; var isRecommend = false; var isRecommendExists = false; var isHot = false; var isHotExists = false; var isColor = false; var isColorExists = false; var theme = string.Empty; var imageWidth = 260; var imageHeight = 182; var textHeight = 25; var bgColor = string.Empty; var isDynamic = false; while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_ChannelIndex)) { channelIndex = attr.Value; } else if (attributeName.Equals(Attribute_ChannelName)) { channelName = attr.Value; } else if (attributeName.Equals(Attribute_Scope)) { scopeType = EScopeTypeUtils.GetEnumType(attr.Value); } else if (attributeName.Equals(Attribute_GroupChannel)) { groupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_GroupChannelNot)) { groupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_GroupContent)) { groupContent = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_GroupContentNot)) { groupContentNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_Tags)) { tags = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_Order)) { orderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.BackgroundContent, ETaxisType.OrderByTaxisDesc); } else if (attributeName.Equals(Attribute_StartNum)) { startNum = TranslateUtils.ToInt(attr.Value, 1); } else if (attributeName.Equals(Attribute_TotalNum)) { totalNum = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(Attribute_TitleWordNum)) { titleWordNum = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(Attribute_Where)) { where = attr.Value; } else if (attributeName.Equals(Attribute_IsTop)) { isTopExists = true; isTop = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(Attribute_IsRecommend)) { isRecommendExists = true; isRecommend = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(Attribute_IsHot)) { isHotExists = true; isHot = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(Attribute_IsColor)) { isColorExists = true; isColor = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(Attribute_Theme)) { theme = attr.Value; } else if (attributeName.Equals(Attribute_Width)) { if (StringUtils.EndsWithIgnoreCase(attr.Value, "px")) { attr.Value = attr.Value.Substring(0, attr.Value.Length - 2); } imageWidth = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(Attribute_Height)) { if (StringUtils.EndsWithIgnoreCase(attr.Value, "px")) { attr.Value = attr.Value.Substring(0, attr.Value.Length - 2); } imageHeight = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(Attribute_BgColor)) { bgColor = attr.Value; } else if (attributeName.Equals(Attribute_IsShowText)) { isShowText = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(Attribute_IsTopText)) { isTopText = attr.Value; } else if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { genericControl.Attributes.Remove(attributeName); genericControl.Attributes.Add(attributeName, attr.Value); } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(pageInfo, contextInfo, genericControl, channelIndex, channelName, scopeType, groupChannel, groupChannelNot, groupContent, groupContentNot, tags, orderByString, startNum, totalNum, isShowText, isTopText, titleWordNum, where, isTop, isTopExists, isRecommend, isRecommendExists, isHot, isHotExists, isColor, isColorExists, theme, imageWidth, imageHeight, textHeight, bgColor); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var ie = node.Attributes.GetEnumerator(); var no = 0; var src = string.Empty; var isFilesize = false; var isCount = true; var type = BackgroundContentAttribute.FileUrl; var leftText = string.Empty; var rightText = string.Empty; var isDynamic = false; var attributes = new StringDictionary(); while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_NO)) { no = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(Attribute_Src)) { src = attr.Value; } else if (attributeName.Equals(Attribute_IsFilesize)) { isFilesize = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(Attribute_IsCount)) { isCount = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(Attribute_Type)) { type = attr.Value; } else if (attributeName.Equals(Attribute_LeftText)) { leftText = attr.Value; } else if (attributeName.Equals(Attribute_RightText)) { rightText = attr.Value; } else if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { attributes.Remove(attributeName); attributes.Add(attributeName, attr.Value); } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = ParseImpl(node, pageInfo, contextInfo, type, no, src, isFilesize, isCount, leftText, rightText, attributes); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var attributes = new LowerNameValueCollection(); var ie = node.Attributes.GetEnumerator(); var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var groupChannel = string.Empty; var groupChannelNot = string.Empty; var title = string.Empty; var isLoading = false; var isShowContentNum = false; var isShowTreeLine = true; var currentFormatString = "<strong>{0}</strong>"; var isDynamic = false; while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(Attribute_ChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_ChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_UpLevel)) { upLevel = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(Attribute_TopLevel)) { topLevel = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(Attribute_GroupChannel)) { groupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_GroupChannelNot)) { groupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_Title)) { title = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(Attribute_IsLoading)) { isLoading = TranslateUtils.ToBool(attr.Value, false); } else if (attributeName.Equals(Attribute_IsShowContentNum)) { isShowContentNum = TranslateUtils.ToBool(attr.Value, false); } else if (attributeName.Equals(Attribute_IsShowTreeLine)) { isShowTreeLine = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(Attribute_CurrentFormatString)) { currentFormatString = attr.Value; if (!StringUtils.Contains(currentFormatString, "{0}")) { currentFormatString += "{0}"; } } else if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { attributes[attributeName] = attr.Value; } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { if (isLoading) { parsedContent = ParseImplAjax(pageInfo, contextInfo, channelIndex, channelName, upLevel, topLevel, groupChannel, groupChannelNot, title, isShowContentNum, isShowTreeLine, currentFormatString); } else { parsedContent = ParseImplNotAjax(pageInfo, contextInfo, channelIndex, channelName, upLevel, topLevel, groupChannel, groupChannelNot, title, isShowContentNum, isShowTreeLine, currentFormatString); } } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; if (contextInfo.ItemContainer?.InputItem == null) { return(string.Empty); } try { var leftText = string.Empty; var rightText = string.Empty; var formatString = string.Empty; string separator = null; var startIndex = 0; var length = 0; var wordNum = 0; var ellipsis = StringUtils.Constants.Ellipsis; var replace = string.Empty; var to = string.Empty; var isClearTags = false; var isReturnToBr = false; var isLower = false; var isUpper = false; var type = string.Empty; var isDynamic = false; var attributes = new StringDictionary(); var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeType)) { type = attr.Value.ToLower(); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeLeftText)) { leftText = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeRightText)) { rightText = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeFormatString)) { formatString = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeSeparator)) { separator = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeStartIndex)) { startIndex = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeLength)) { length = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeWordNum)) { wordNum = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeEllipsis)) { ellipsis = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeReplace)) { replace = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTo)) { to = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsClearTags)) { isClearTags = TranslateUtils.ToBool(attr.Value, false); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsReturnToBr)) { isReturnToBr = TranslateUtils.ToBool(attr.Value, false); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsLower)) { isLower = TranslateUtils.ToBool(attr.Value, true); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsUpper)) { isUpper = TranslateUtils.ToBool(attr.Value, true); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { attributes.Add(attr.Name, attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(node, pageInfo, contextInfo, attributes, leftText, rightText, formatString, separator, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper, type); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var type = string.Empty; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var scope = EScopeType.Self; var since = 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)) { type = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelIndex)) { channelIndex = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelName)) { channelName = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeUpLevel)) { upLevel = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTopLevel)) { topLevel = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeScope)) { scope = EScopeTypeUtils.GetEnumType(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeSince)) { since = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value, false); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(pageInfo, contextInfo, type, channelIndex, channelName, upLevel, topLevel, scope, since); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var isGetPicUrlFromAttribute = false; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var type = BackgroundContentAttribute.ImageUrl; var src = string.Empty; var altSrc = string.Empty; var width = "100%"; var height = "180"; var isDynamic = false; var parameters = new NameValueCollection(); var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelIndex)) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeParent)) { if (TranslateUtils.ToBool(attr.Value)) { upLevel = 1; isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeUpLevel)) { upLevel = TranslateUtils.ToInt(attr.Value); if (upLevel > 0) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTopLevel)) { topLevel = TranslateUtils.ToInt(attr.Value); if (topLevel >= 0) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeType)) { type = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeSrc)) { src = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeAltSrc)) { altSrc = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeWidth)) { width = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeHeight)) { height = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value, false); } else { parameters.Add(attr.Name, attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(stlElement, node, pageInfo, contextInfo, isGetPicUrlFromAttribute, channelIndex, channelName, upLevel, topLevel, type, src, altSrc, width, height, parameters); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }