public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { 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>"; foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, AttributeChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeUpLevel)) { upLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeTopLevel)) { topLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupChannel)) { groupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupChannelNot)) { groupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeTitle)) { title = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsLoading)) { isLoading = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsShowContentNum)) { isShowContentNum = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsShowTreeLine)) { isShowTreeLine = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, AttributeCurrentFormatString)) { currentFormatString = value; if (!StringUtils.Contains(currentFormatString, "{0}")) { currentFormatString += "{0}"; } } } return(isLoading ? ParseImplAjax(pageInfo, contextInfo, channelIndex, channelName, upLevel, topLevel, groupChannel, groupChannelNot, title, isShowContentNum, isShowTreeLine, currentFormatString, pageInfo.IsLocal) : ParseImplNotAjax(pageInfo, contextInfo, channelIndex, channelName, upLevel, topLevel, groupChannel, groupChannelNot, title, isShowContentNum, isShowTreeLine, currentFormatString)); }
internal static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var channelIndex = string.Empty; var channelName = string.Empty; var groupChannel = string.Empty; var groupChannelNot = string.Empty; var isShowChildren = false; var styleName = string.Empty; var menuWidth = string.Empty; var menuHeight = string.Empty; var xPosition = string.Empty; var yPosition = string.Empty; var childMenuDisplay = string.Empty; var childMenuWidth = string.Empty; var childMenuHeight = string.Empty; var target = 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, AttributeStyleName)) { styleName = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeGroupChannel)) { groupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeGroupChannelNot)) { groupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsShowChildren)) { isShowChildren = TranslateUtils.ToBool(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeMenuWidth)) { menuWidth = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeMenuHeight)) { menuHeight = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeXPosition)) { xPosition = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeYPosition)) { yPosition = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChildMenuDisplay)) { childMenuDisplay = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChildMenuWidth)) { childMenuWidth = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChildMenuHeight)) { childMenuHeight = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTarget)) { target = 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, channelIndex, channelName, groupChannel, groupChannelNot, isShowChildren, styleName, menuWidth, menuHeight, xPosition, yPosition, childMenuDisplay, childMenuWidth, childMenuHeight, target); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static object Parse(PageInfo pageInfo, ContextInfo contextInfo) { var leftText = string.Empty; var rightText = string.Empty; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var type = 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; foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, ChannelIndex.Name)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, ChannelName.Name)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, Parent.Name)) { if (TranslateUtils.ToBool(value)) { upLevel = 1; } } else if (StringUtils.EqualsIgnoreCase(name, UpLevel.Name)) { upLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, TopLevel.Name)) { topLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Type.Name)) { type = value; } else if (StringUtils.EqualsIgnoreCase(name, LeftText.Name)) { leftText = value; } else if (StringUtils.EqualsIgnoreCase(name, RightText.Name)) { rightText = value; } else if (StringUtils.EqualsIgnoreCase(name, FormatString.Name)) { formatString = value; } else if (StringUtils.EqualsIgnoreCase(name, Separator.Name)) { separator = value; } else if (StringUtils.EqualsIgnoreCase(name, StartIndex.Name)) { startIndex = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Length.Name)) { length = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, WordNum.Name)) { wordNum = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Ellipsis.Name)) { ellipsis = value; } else if (StringUtils.EqualsIgnoreCase(name, Replace.Name)) { replace = value; } else if (StringUtils.EqualsIgnoreCase(name, To.Name)) { to = value; } else if (StringUtils.EqualsIgnoreCase(name, IsClearTags.Name)) { isClearTags = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsReturnToBr.Name)) { isReturnToBr = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsLower.Name)) { isLower = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, IsUpper.Name)) { isUpper = TranslateUtils.ToBool(value, true); } } 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); if (contextInfo.IsStlEntity && string.IsNullOrEmpty(type)) { return(channel); } return(ParseImpl(pageInfo, contextInfo, leftText, rightText, type, formatString, separator, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper, channel, channelId)); }
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.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, Id.Name)) { htmlId = value; } else if (StringUtils.EqualsIgnoreCase(name, ChannelIndex.Name)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelIndex)) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, ChannelName.Name)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, Parent.Name)) { if (TranslateUtils.ToBool(value)) { upLevel = 1; contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, UpLevel.Name)) { upLevel = TranslateUtils.ToInt(value); if (upLevel > 0) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, TopLevel.Name)) { topLevel = TranslateUtils.ToInt(value); if (topLevel >= 0) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, Context.Name)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(value); } else if (StringUtils.EqualsIgnoreCase(name, Href.Name)) { href = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, QueryString.Name)) { queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, Host.Name)) { 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 ListInfo GetListInfoByXmlNode(PageInfo pageInfo, ContextInfo contextInfo, EContextType contextType) { var listInfo = new ListInfo { _contextType = contextType }; var innerXml = contextInfo.InnerXml; var itemTemplate = string.Empty; if (!string.IsNullOrEmpty(innerXml)) { var stlElementList = StlParserUtility.GetStlElementList(innerXml); if (stlElementList.Count > 0) { foreach (var theStlElement in stlElementList) { if (StlParserUtility.IsSpecifiedStlElement(theStlElement, StlItemTemplate.ElementName)) { var attributes = new LowerNameValueCollection(); var templateString = StlParserUtility.GetInnerXml(theStlElement, true, attributes); if (!string.IsNullOrEmpty(templateString)) { foreach (var key in attributes.Keys) { if (!StringUtils.EqualsIgnoreCase(key, StlItemTemplate.Type.Name)) { continue; } var type = attributes.Get(key); if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeItem)) { itemTemplate = templateString; } else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeHeader)) { listInfo.HeaderTemplate = templateString; } else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeFooter)) { listInfo.FooterTemplate = templateString; } else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeAlternatingItem)) { listInfo.AlternatingItemTemplate = templateString; } else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeSelectedItem)) { if (!string.IsNullOrEmpty(attributes.Get(StlItemTemplate.Selected.Name))) { var selected = attributes.Get(StlItemTemplate.Selected.Name); var arraylist = new ArrayList(); if (selected.IndexOf(',') != -1) { arraylist.AddRange(selected.Split(',')); } else { if (selected.IndexOf('-') != -1) { var first = TranslateUtils.ToInt(selected.Split('-')[0]); var second = TranslateUtils.ToInt(selected.Split('-')[1]); for (var i = first; i <= second; i++) { arraylist.Add(i.ToString()); } } else { arraylist.Add(selected); } } foreach (string val in arraylist) { listInfo.SelectedItems.Set(val, templateString); } if (!string.IsNullOrEmpty(attributes.Get(StlItemTemplate.SelectedValue.Name))) { var selectedValue = attributes.Get(StlItemTemplate.SelectedValue.Name); listInfo.SelectedValues.Set(selectedValue, templateString); } } } else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeSeparator)) { var selectedValue = TranslateUtils.ToInt(attributes.Get(StlItemTemplate.SelectedValue.Name), 1); if (selectedValue <= 1) { listInfo.SeparatorTemplate = templateString; } else { listInfo.SeparatorRepeatTemplate = templateString; listInfo.SeparatorRepeat = selectedValue; } } } } innerXml = innerXml.Replace(theStlElement, string.Empty); } else if (StlParserUtility.IsSpecifiedStlElement(theStlElement, StlLoading.ElementName)) { var innerBuilder = new StringBuilder(StlParserUtility.GetInnerXml(theStlElement, true)); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); StlParserUtility.XmlToHtml(innerBuilder); listInfo.LoadingTemplate = innerBuilder.ToString(); innerXml = innerXml.Replace(theStlElement, string.Empty); } else if (contextType == EContextType.SqlContent && StlParserUtility.IsSpecifiedStlElement(theStlElement, StlQueryString.ElementName)) { var innerBuilder = new StringBuilder(StlParserUtility.GetInnerXml(theStlElement, true)); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); StlParserUtility.XmlToHtml(innerBuilder); listInfo.QueryString = innerBuilder.ToString(); innerXml = innerXml.Replace(theStlElement, string.Empty); } } } } if (string.IsNullOrEmpty(itemTemplate)) { listInfo.ItemTemplate = !string.IsNullOrEmpty(innerXml) ? innerXml : "<stl:a target=\"_blank\"></stl:a>"; } else { listInfo.ItemTemplate = itemTemplate; } var isSetDirection = false;//是否设置了direction属性 foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, StlListBase.ChannelIndex.Name)) { listInfo.ChannelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.ChannelName.Name)) { listInfo.ChannelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.UpLevel.Name)) { listInfo.UpLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.TopLevel.Name)) { listInfo.TopLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Scope.Name)) { listInfo.Scope = EScopeTypeUtils.GetEnumType(value); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsTop.Name)) { listInfo.IsTop = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsRecommend.Name)) { listInfo.IsRecommend = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsHot.Name)) { listInfo.IsHot = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsColor.Name)) { listInfo.IsColor = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Where.Name)) { listInfo.Where = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.TotalNum.Name)) { listInfo.TotalNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo)); } else if (StringUtils.EqualsIgnoreCase(name, StlPageContents.PageNum.Name)) { listInfo.PageNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo)); } else if (StringUtils.EqualsIgnoreCase(name, StlPageContents.MaxPage.Name)) { listInfo.MaxPage = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo)); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.StartNum.Name)) { listInfo.StartNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo)); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Order.Name)) { if (contextType == EContextType.Content) { listInfo.OrderByString = StlDataUtility.GetContentOrderByString(pageInfo.SiteId, value, ETaxisType.OrderByTaxisDesc); } else if (contextType == EContextType.Channel) { listInfo.OrderByString = StlDataUtility.GetChannelOrderByString(pageInfo.SiteId, value, ETaxisType.OrderByTaxis); } //else if (contextType == EContextType.InputContent) //{ // listInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.SiteId, value, ETableStyle.InputContent, ETaxisType.OrderByTaxisDesc); //} else { listInfo.OrderByString = value; } } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.GroupChannel.Name)) { listInfo.GroupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (string.IsNullOrEmpty(listInfo.GroupChannel)) { listInfo.GroupChannel = "__Empty__"; } } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.GroupChannelNot.Name)) { listInfo.GroupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (string.IsNullOrEmpty(listInfo.GroupChannelNot)) { listInfo.GroupChannelNot = "__Empty__"; } } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.GroupContent.Name) || StringUtils.EqualsIgnoreCase(name, StlListBase.Group.Name)) { listInfo.GroupContent = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (string.IsNullOrEmpty(listInfo.GroupContent)) { listInfo.GroupContent = "__Empty__"; } } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.GroupContentNot.Name) || StringUtils.EqualsIgnoreCase(name, StlListBase.GroupNot.Name)) { listInfo.GroupContentNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (string.IsNullOrEmpty(listInfo.GroupContentNot)) { listInfo.GroupContentNot = "__Empty__"; } } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Tags.Name)) { listInfo.Tags = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Columns.Name)) { listInfo.Columns = TranslateUtils.ToInt(value); listInfo.Layout = ELayout.Table; if (listInfo.Columns > 1 && isSetDirection == false) { listInfo.Direction = RepeatDirection.Horizontal; } } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Direction.Name)) { listInfo.Layout = ELayout.Table; listInfo.Direction = TranslateUtils.ToRepeatDirection(value); isSetDirection = true; } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Height.Name)) { try { listInfo.Height = Unit.Parse(value); } catch { // ignored } } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Width.Name)) { try { listInfo.Width = Unit.Parse(value); } catch { // ignored } } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Align.Name)) { listInfo.Align = value; } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.ItemHeight.Name)) { try { listInfo.ItemHeight = Unit.Parse(value); } catch { // ignored } } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.ItemWidth.Name)) { try { listInfo.ItemWidth = Unit.Parse(value); } catch { // ignored } } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.ItemAlign.Name)) { listInfo.ItemAlign = value; } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.ItemVerticalAlign.Name)) { listInfo.ItemVerticalAlign = value; } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.ItemClass.Name)) { listInfo.ItemClass = value; } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsImage.Name)) { listInfo.IsImage = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsVideo.Name)) { listInfo.IsVideo = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsFile.Name)) { listInfo.IsFile = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.IsRelatedContents.Name)) { listInfo.IsRelatedContents = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, StlListBase.Layout.Name)) { listInfo.Layout = ELayoutUtils.GetEnumType(value); } else if (contextType == EContextType.SqlContent && StringUtils.EqualsIgnoreCase(name, StlSqlContents.ConnectionString.Name)) { listInfo.ConnectionString = value; } else if (contextType == EContextType.SqlContent && StringUtils.EqualsIgnoreCase(name, StlSqlContents.ConnectionStringName.Name)) { listInfo.ConnectionString = WebConfigUtils.GetConnectionStringByName(value); if (string.IsNullOrEmpty(listInfo.ConnectionString)) { listInfo.ConnectionString = WebConfigUtils.ConnectionString; } } else { listInfo.Others.Set(name, value); } } return(listInfo); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { var selectControl = new HtmlSelect(); var isChannel = true; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var scopeTypeString = string.Empty; var groupChannel = string.Empty; var groupChannelNot = string.Empty; var groupContent = string.Empty; var groupContentNot = string.Empty; var tags = string.Empty; var order = string.Empty; var totalNum = 0; var titleWordNum = 0; var where = string.Empty; var queryString = 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 displayTitle = string.Empty; var openWin = true; foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, IsChannel.Name)) { isChannel = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, ChannelIndex.Name)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, ChannelName.Name)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, UpLevel.Name)) { upLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, TopLevel.Name)) { topLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Scope.Name)) { scopeTypeString = value; } else if (StringUtils.EqualsIgnoreCase(name, GroupChannel.Name)) { groupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, GroupChannelNot.Name)) { groupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, GroupContent.Name)) { groupContent = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, GroupContentNot.Name)) { groupContentNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, Tags.Name)) { tags = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, Order.Name)) { order = value; } else if (StringUtils.EqualsIgnoreCase(name, TotalNum.Name)) { totalNum = TranslateUtils.ToInt(value, totalNum); } else if (StringUtils.EqualsIgnoreCase(name, Where.Name)) { where = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, QueryString.Name)) { queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, IsTop.Name)) { isTopExists = true; isTop = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, IsRecommend.Name)) { isRecommendExists = true; isRecommend = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, IsHot.Name)) { isHotExists = true; isHot = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, IsColor.Name)) { isColorExists = true; isColor = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, TitleWordNum.Name)) { titleWordNum = TranslateUtils.ToInt(value, titleWordNum); } else if (StringUtils.EqualsIgnoreCase(name, Title.Name)) { displayTitle = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, OpenWin.Name)) { openWin = TranslateUtils.ToBool(value); } else { selectControl.Attributes[name] = value; } } return(ParseImpl(pageInfo, contextInfo, selectControl, isChannel, channelIndex, channelName, upLevel, topLevel, scopeTypeString, groupChannel, groupChannelNot, groupContent, groupContentNot, tags, order, totalNum, titleWordNum, where, queryString, isTop, isTopExists, isRecommend, isRecommendExists, isHot, isHotExists, isColor, isColorExists, displayTitle, openWin)); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var connectionString = string.Empty; var queryString = string.Empty; var leftText = string.Empty; var rightText = string.Empty; var formatString = string.Empty; 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 ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeConnectionString)) { connectionString = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeConnectionStringName)) { if (string.IsNullOrEmpty(connectionString)) { connectionString = WebConfigUtils.ConnectionString; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeQueryString)) { queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else 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, 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); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(contextInfo, connectionString, queryString, leftText, rightText, formatString, 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(PageInfo pageInfo, ContextInfo contextInfo) { 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; foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, AttributeChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelIndex)) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeParent)) { if (TranslateUtils.ToBool(value)) { upLevel = 1; isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeUpLevel)) { upLevel = TranslateUtils.ToInt(value); if (upLevel > 0) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeTopLevel)) { topLevel = TranslateUtils.ToInt(value); if (topLevel >= 0) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeType)) { type = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributePlayUrl)) { playUrl = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeImageUrl)) { imageUrl = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributePlayBy)) { playBy = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeStretching)) { stretching = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeWidth)) { width = TranslateUtils.ToInt(value, width); } else if (StringUtils.EqualsIgnoreCase(name, AttributeHeight)) { height = TranslateUtils.ToInt(value, height); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsAutoPlay)) { isAutoPlay = TranslateUtils.ToBool(value, true); } } return(ParseImpl(pageInfo, contextInfo, isGetPicUrlFromAttribute, channelIndex, channelName, upLevel, topLevel, playUrl, imageUrl, playBy, stretching, width, height, type, isAutoPlay)); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var ie = node.Attributes?.GetEnumerator(); var attributes = new StringDictionary(); var leftText = string.Empty; var rightText = string.Empty; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var type = NodeAttribute.Title; 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 isDynamic = false; if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeParent)) { if (TranslateUtils.ToBool(attr.Value)) { upLevel = 1; } } 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, AttributeType)) { type = attr.Value; } 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, false); } else { attributes.Add(attr.Name, attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(stlElement, node, pageInfo, contextInfo, attributes, leftText, rightText, channelIndex, channelName, upLevel, topLevel, type, formatString, separator, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static ContentsDisplayInfo GetContentsDisplayInfoByXmlNode(XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, EContextType contextType) { var displayInfo = new ContentsDisplayInfo { _contextType = contextType }; var innerXml = node.InnerXml; var itemTemplate = string.Empty; if (!string.IsNullOrEmpty(innerXml)) { var stlElementList = StlParserUtility.GetStlElementList(innerXml); if (stlElementList.Count > 0) { foreach (var theStlElement in stlElementList) { if (StlParserUtility.IsSpecifiedStlElement(theStlElement, StlItem.ElementName) || StlParserUtility.IsSpecifiedStlElement(theStlElement, StlItem.ElementName2) ) { var attributes = new LowerNameValueCollection(); var templateString = StlParserUtility.GetInnerXml(theStlElement, true, attributes); if (!string.IsNullOrEmpty(templateString)) { foreach (string key in attributes.Keys) { if (key == StlItem.Attribute_Type) { var type = attributes[key]; if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_Item)) { itemTemplate = templateString; } else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_Header)) { displayInfo._headerTemplate = templateString; } else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_Footer)) { displayInfo._footerTemplate = templateString; } else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_AlternatingItem)) { displayInfo._alternatingItemTemplate = templateString; } else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_SelectedItem)) { if (!string.IsNullOrEmpty(attributes[StlItem.Attribute_Selected])) { var selected = attributes[StlItem.Attribute_Selected]; var arraylist = new ArrayList(); if (selected.IndexOf(',') != -1) { arraylist.AddRange(selected.Split(',')); } else { if (selected.IndexOf('-') != -1) { var first = TranslateUtils.ToInt(selected.Split('-')[0]); var second = TranslateUtils.ToInt(selected.Split('-')[1]); for (var i = first; i <= second; i++) { arraylist.Add(i.ToString()); } } else { arraylist.Add(selected); } } foreach (string val in arraylist) { displayInfo._selectedItems[val] = templateString; } if (!string.IsNullOrEmpty(attributes[StlItem.Attribute_SelectedValue])) { var selectedValue = attributes[StlItem.Attribute_SelectedValue]; displayInfo._selectedValues[selectedValue] = templateString; } } } else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_Separator)) { var selectedValue = TranslateUtils.ToInt(attributes[StlItem.Attribute_SelectedValue], 1); if (selectedValue <= 1) { displayInfo._separatorTemplate = templateString; } else { displayInfo._separatorRepeatTemplate = templateString; displayInfo._separatorRepeat = selectedValue; } } } } } innerXml = innerXml.Replace(theStlElement, string.Empty); } else if (StlParserUtility.IsSpecifiedStlElement(theStlElement, StlLoading.ElementName)) { var innerBuilder = new StringBuilder(StlParserUtility.GetInnerXml(theStlElement, true)); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); StlParserUtility.XmlToHtml(innerBuilder); displayInfo._loadingTemplate = innerBuilder.ToString(); innerXml = innerXml.Replace(theStlElement, string.Empty); } else if (contextType == EContextType.SqlContent && StlParserUtility.IsSpecifiedStlElement(theStlElement, StlQueryString.ElementName)) { var innerBuilder = new StringBuilder(StlParserUtility.GetInnerXml(theStlElement, true)); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); StlParserUtility.XmlToHtml(innerBuilder); displayInfo.QueryString = innerBuilder.ToString(); innerXml = innerXml.Replace(theStlElement, string.Empty); } } } } if (string.IsNullOrEmpty(itemTemplate)) { displayInfo.ItemTemplate = !string.IsNullOrEmpty(innerXml) ? innerXml : "<stl:a target=\"_blank\"></stl:a>"; } else { displayInfo._itemTemplate = itemTemplate; } var ie = node.Attributes.GetEnumerator(); var isSetDirection = false;//是否设置了direction属性 while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(StlContents.Attribute_ChannelIndex)) { displayInfo.ChannelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(StlContents.Attribute_ChannelName)) { displayInfo.ChannelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(StlContents.Attribute_UpLevel)) { displayInfo.UpLevel = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_TopLevel)) { displayInfo.TopLevel = TranslateUtils.ToInt(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_Scope)) { displayInfo.Scope = EScopeTypeUtils.GetEnumType(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_IsTop)) { displayInfo.IsTop = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_IsRecommend)) { displayInfo.IsRecommend = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_IsHot)) { displayInfo.IsHot = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_IsColor)) { displayInfo.IsColor = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_Where)) { displayInfo.Where = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(StlContents.Attribute_IsDynamic)) { displayInfo.IsDynamic = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_TotalNum)) { displayInfo.TotalNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo)); } else if (attributeName.Equals(StlPageContents.AttributePageNum)) { displayInfo.PageNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo)); } else if (attributeName.Equals(StlPageContents.AttributeMaxPage)) { displayInfo.MaxPage = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo)); } else if (attributeName.Equals(StlContents.Attribute_TitleWordNum)) { displayInfo.TitleWordNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo)); } else if (attributeName.Equals(StlContents.Attribute_StartNum)) { displayInfo.StartNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo)); } else if (attributeName.Equals(StlContents.Attribute_Order)) { if (contextType == EContextType.Content) { displayInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.BackgroundContent, ETaxisType.OrderByTaxisDesc); } else if (contextType == EContextType.Channel) { displayInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.Channel, ETaxisType.OrderByTaxis); } else if (contextType == EContextType.InputContent) { displayInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.InputContent, ETaxisType.OrderByTaxisDesc); } else { displayInfo.OrderByString = attr.Value; } } else if (attributeName.Equals(StlContents.Attribute_GroupChannel)) { displayInfo.GroupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (string.IsNullOrEmpty(displayInfo.GroupChannel)) { displayInfo.GroupChannel = "__Empty__"; } } else if (attributeName.Equals(StlContents.Attribute_GroupChannelNot)) { displayInfo.GroupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (string.IsNullOrEmpty(displayInfo.GroupChannelNot)) { displayInfo.GroupChannelNot = "__Empty__"; } } else if (attributeName.Equals(StlContents.Attribute_GroupContent) || attributeName.Equals(StlContents.Attribute_Group)) { displayInfo.GroupContent = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (string.IsNullOrEmpty(displayInfo.GroupContent)) { displayInfo.GroupContent = "__Empty__"; } } else if (attributeName.Equals(StlContents.Attribute_GroupContentNot) || attributeName.Equals(StlContents.Attribute_GroupNot)) { displayInfo.GroupContentNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (string.IsNullOrEmpty(displayInfo.GroupContentNot)) { displayInfo.GroupContentNot = "__Empty__"; } } else if (attributeName.Equals(StlContents.Attribute_Tags)) { displayInfo.Tags = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (attributeName.Equals(StlContents.Attribute_Columns)) { displayInfo.Columns = TranslateUtils.ToInt(attr.Value); displayInfo.Layout = ELayout.Table; if (displayInfo.Columns > 1 && isSetDirection == false) { displayInfo.Direction = RepeatDirection.Horizontal; } } else if (attributeName.Equals(StlContents.Attribute_Direction)) { displayInfo.Layout = ELayout.Table; displayInfo.Direction = Converter.ToRepeatDirection(attr.Value); isSetDirection = true; } else if (attributeName.Equals(StlContents.Attribute_Height)) { try { displayInfo.Height = Unit.Parse(attr.Value); } catch { // ignored } } else if (attributeName.Equals(StlContents.Attribute_Width)) { try { displayInfo.Width = Unit.Parse(attr.Value); } catch { // ignored } } else if (attributeName.Equals(StlContents.Attribute_Align)) { displayInfo.Align = attr.Value; } else if (attributeName.Equals(StlContents.Attribute_ItemHeight)) { try { displayInfo.ItemHeight = Unit.Parse(attr.Value); } catch { // ignored } } else if (attributeName.Equals(StlContents.Attribute_ItemWidth)) { try { displayInfo.ItemWidth = Unit.Parse(attr.Value); } catch { // ignored } } else if (attributeName.Equals(StlContents.Attribute_ItemAlign)) { displayInfo.ItemAlign = attr.Value; } else if (attributeName.Equals(StlContents.Attribute_ItemVerticalAlign)) { displayInfo.ItemVerticalAlign = attr.Value; } else if (attributeName.Equals(StlContents.Attribute_ItemClass)) { displayInfo.ItemClass = attr.Value; } else if (attributeName.Equals(StlContents.Attribute_IsImage)) { displayInfo.IsImage = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_IsVideo)) { displayInfo.IsVideo = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_IsFile)) { displayInfo.IsFile = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_IsNoDup)) { displayInfo.IsNoDup = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_IsRelatedContents)) { displayInfo.IsRelatedContents = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(StlContents.Attribute_Layout)) { displayInfo.Layout = ELayoutUtils.GetEnumType(attr.Value); } else if (contextType == EContextType.SqlContent && attributeName.Equals(StlSqlContents.Attribute_ConnectionString)) { displayInfo.ConnectionString = attr.Value; } else if (contextType == EContextType.SqlContent && attributeName.Equals(StlSqlContents.Attribute_ConnectionStringName)) { if (string.IsNullOrEmpty(displayInfo.ConnectionString)) { displayInfo.ConnectionString = WebConfigUtils.ConnectionString; } } else { displayInfo.OtherAttributes.Add(attributeName, attr.Value); } } return(displayInfo); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { var connectionString = string.Empty; var queryString = string.Empty; var leftText = string.Empty; var rightText = string.Empty; var formatString = string.Empty; 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; foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, AttributeConnectionString)) { connectionString = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeConnectionStringName)) { if (string.IsNullOrEmpty(connectionString)) { connectionString = WebConfigUtils.ConnectionString; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeQueryString)) { queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeType)) { type = value.ToLower(); } else if (StringUtils.EqualsIgnoreCase(name, AttributeLeftText)) { leftText = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeRightText)) { rightText = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeFormatString)) { formatString = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeStartIndex)) { startIndex = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeLength)) { length = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeWordNum)) { wordNum = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeEllipsis)) { ellipsis = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeReplace)) { replace = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeTo)) { to = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsClearTags)) { isClearTags = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsReturnToBr)) { isReturnToBr = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsLower)) { isLower = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsUpper)) { isUpper = TranslateUtils.ToBool(value, true); } } return(ParseImpl(pageInfo, contextInfo, connectionString, queryString, leftText, rightText, formatString, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper, type)); }
public static object Parse(PageInfo pageInfo, ContextInfo contextInfo) { var leftText = string.Empty; var rightText = string.Empty; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var type = string.Empty; var formatString = string.Empty; string separator = null; var startIndex = 0; var length = 0; var wordNum = 0; var ellipsis = Constants.Ellipsis; var replace = string.Empty; var to = string.Empty; var isClearTags = false; var isReturnToBr = false; var isLower = false; var isUpper = false; 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, Type)) { type = value; } else if (StringUtils.EqualsIgnoreCase(name, LeftText)) { leftText = value; } else if (StringUtils.EqualsIgnoreCase(name, RightText)) { rightText = value; } else if (StringUtils.EqualsIgnoreCase(name, FormatString)) { formatString = value; } else if (StringUtils.EqualsIgnoreCase(name, Separator)) { separator = value; } else if (StringUtils.EqualsIgnoreCase(name, StartIndex)) { startIndex = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Length)) { length = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, WordNum)) { wordNum = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Ellipsis)) { ellipsis = value; } else if (StringUtils.EqualsIgnoreCase(name, Replace)) { replace = value; } else if (StringUtils.EqualsIgnoreCase(name, To)) { to = value; } else if (StringUtils.EqualsIgnoreCase(name, IsClearTags)) { isClearTags = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsReturnToBr)) { isReturnToBr = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsLower)) { isLower = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, IsUpper)) { isUpper = TranslateUtils.ToBool(value, true); } } var channelId = StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, contextInfo.ChannelId, upLevel, topLevel); channelId = ChannelManager.GetChannelId(pageInfo.SiteId, channelId, channelIndex, channelName); var channel = ChannelManager.GetChannelInfo(pageInfo.SiteId, channelId); if (contextInfo.IsStlEntity && string.IsNullOrEmpty(type)) { return(channel.ToDictionary()); } var parsedContent = ParseImpl(pageInfo, contextInfo, leftText, rightText, type, formatString, separator, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper, channel, channelId); var innerBuilder = new StringBuilder(parsedContent); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); parsedContent = innerBuilder.ToString(); if (!StringUtils.EqualsIgnoreCase(type, ChannelAttribute.PageContent)) { parsedContent = parsedContent.Replace(ContentUtility.PagePlaceHolder, string.Empty); } return(parsedContent); }
//对“下拉列表”(stl:select)元素进行解析 public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var selectControl = new HtmlSelect(); var isChannel = true; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var scopeTypeString = string.Empty; var groupChannel = string.Empty; var groupChannelNot = string.Empty; var groupContent = string.Empty; var groupContentNot = string.Empty; var tags = string.Empty; var order = string.Empty; var totalNum = 0; var titleWordNum = 0; var where = string.Empty; var queryString = 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 displayTitle = string.Empty; var openWin = true; var isDynamic = false; var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsChannel)) { isChannel = TranslateUtils.ToBool(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } 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)) { scopeTypeString = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeGroupChannel)) { groupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeGroupChannelNot)) { groupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeGroupContent)) { groupContent = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeGroupContentNot)) { groupContentNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTags)) { tags = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeOrder)) { order = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTotalNum)) { totalNum = TranslateUtils.ToInt(attr.Value, totalNum); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeWhere)) { where = 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, AttributeIsTop)) { isTopExists = true; isTop = TranslateUtils.ToBool(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsRecommend)) { isRecommendExists = true; isRecommend = TranslateUtils.ToBool(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsHot)) { isHotExists = true; isHot = TranslateUtils.ToBool(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsColor)) { isColorExists = true; isColor = TranslateUtils.ToBool(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTitleWordNum)) { titleWordNum = TranslateUtils.ToInt(attr.Value, titleWordNum); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTitle)) { displayTitle = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeOpenWin)) { openWin = TranslateUtils.ToBool(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { selectControl.Attributes[attr.Name] = attr.Value; } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(pageInfo, contextInfo, selectControl, isChannel, channelIndex, channelName, upLevel, topLevel, scopeTypeString, groupChannel, groupChannelNot, groupContent, groupContentNot, tags, order, totalNum, titleWordNum, where, queryString, isTop, isTopExists, isRecommend, isRecommendExists, isHot, isHotExists, isColor, isColorExists, displayTitle, openWin); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“栏目链接”(stl:flash)元素进行解析 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.ImageUrl; var src = string.Empty; var altSrc = string.Empty; var width = "100%"; var height = "180"; 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_Src)) { src = attr.Value; } else if (attributeName.Equals(Attribute_AltSrc)) { altSrc = attr.Value; } else if (attributeName.Equals(Attribute_Width)) { width = attr.Value; } else if (attributeName.Equals(Attribute_Height)) { height = attr.Value; } else if (attributeName.Equals(Attribute_IsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value, false); } 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, type, src, altSrc, width, height, parameters); } } 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 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 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)) { isGetUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_ChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { isGetUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_Parent)) { if (TranslateUtils.ToBool(attr.Value)) { upLevel = 1; isGetUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_UpLevel)) { upLevel = TranslateUtils.ToInt(attr.Value); if (upLevel > 0) { isGetUrlFromAttribute = true; } } else if (attributeName.Equals(Attribute_TopLevel)) { topLevel = TranslateUtils.ToInt(attr.Value); if (topLevel >= 0) { isGetUrlFromAttribute = 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_Width)) { width = TranslateUtils.ToInt(attr.Value, width); } else if (attributeName.Equals(Attribute_Height)) { height = TranslateUtils.ToInt(attr.Value, height); } else if (attributeName.Equals(Attribute_IsAutoPlay)) { isAutoPlay = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(Attribute_IsControls)) { isControls = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(Attribute_IsPreLoad)) { isPreLoad = TranslateUtils.ToBool(attr.Value, true); } else if (attributeName.Equals(Attribute_IsLoop)) { isLoop = TranslateUtils.ToBool(attr.Value, false); } 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, isGetUrlFromAttribute, channelIndex, channelName, upLevel, topLevel, type, playUrl, imageUrl, width, height, isAutoPlay, isControls, isPreLoad, isLoop, parameters); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { 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.SiteInfo.Additional.ConfigVideoContentInsertWidth; var height = pageInfo.SiteInfo.Additional.ConfigVideoContentInsertHeight; var isAutoPlay = true; var isControls = true; var isPreLoad = true; var isLoop = false; foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, ChannelIndex.Name)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelIndex)) { isGetUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, ChannelName.Name)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { isGetUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, Parent.Name)) { if (TranslateUtils.ToBool(value)) { upLevel = 1; isGetUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, UpLevel.Name)) { upLevel = TranslateUtils.ToInt(value); if (upLevel > 0) { isGetUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, TopLevel.Name)) { topLevel = TranslateUtils.ToInt(value); if (topLevel >= 0) { isGetUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, Type.Name)) { type = value; } else if (StringUtils.EqualsIgnoreCase(name, PlayUrl.Name)) { playUrl = value; } else if (StringUtils.EqualsIgnoreCase(name, ImageUrl.Name)) { imageUrl = value; } else if (StringUtils.EqualsIgnoreCase(name, Width.Name)) { width = TranslateUtils.ToInt(value, width); } else if (StringUtils.EqualsIgnoreCase(name, Height.Name)) { height = TranslateUtils.ToInt(value, height); } else if (StringUtils.EqualsIgnoreCase(name, IsAutoPlay.Name)) { isAutoPlay = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, IsControls.Name)) { isControls = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, IsPreload.Name)) { isPreLoad = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, IsLoop.Name)) { isLoop = TranslateUtils.ToBool(value, false); } } return(ParseImpl(pageInfo, contextInfo, isGetUrlFromAttribute, channelIndex, channelName, upLevel, topLevel, type, playUrl, imageUrl, width, height, isAutoPlay, isControls, isPreLoad, isLoop)); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { var leftText = string.Empty; var rightText = string.Empty; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var type = ChannelAttribute.Title; 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; foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, AttributeChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeParent)) { if (TranslateUtils.ToBool(value)) { upLevel = 1; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeUpLevel)) { upLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeTopLevel)) { topLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeType)) { type = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeLeftText)) { leftText = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeRightText)) { rightText = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeFormatString)) { formatString = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeSeparator)) { separator = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeStartIndex)) { startIndex = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeLength)) { length = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeWordNum)) { wordNum = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeEllipsis)) { ellipsis = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeReplace)) { replace = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeTo)) { to = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsClearTags)) { isClearTags = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsReturnToBr)) { isReturnToBr = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsLower)) { isLower = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsUpper)) { isUpper = TranslateUtils.ToBool(value, true); } } return(ParseImpl(pageInfo, contextInfo, leftText, rightText, channelIndex, channelName, upLevel, topLevel, type, formatString, separator, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper)); }
//对“flash滚动焦点图”(stl:focusViewer)元素进行解析 public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { // 如果是实体标签则返回空 if (contextInfo.IsStlEntity) { return(string.Empty); } 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.GetContentOrderByString(ETaxisType.OrderByTaxisDesc); 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 genericControl = new HtmlGenericControl("div"); foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, AttributeChannelIndex)) { channelIndex = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeChannelName)) { channelName = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeScope)) { scopeType = EScopeTypeUtils.GetEnumType(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupChannel)) { groupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupChannelNot)) { groupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupContent)) { groupContent = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupContentNot)) { groupContentNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeTags)) { tags = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AttributeOrder)) { orderByString = StlDataUtility.GetContentOrderByString(pageInfo.SiteId, value, ETaxisType.OrderByTaxisDesc); } else if (StringUtils.EqualsIgnoreCase(name, AttributeStartNum)) { startNum = TranslateUtils.ToInt(value, 1); } else if (StringUtils.EqualsIgnoreCase(name, AttributeTotalNum)) { totalNum = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeTitleWordNum)) { titleWordNum = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeWhere)) { where = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsTop)) { isTopExists = true; isTop = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsRecommend)) { isRecommendExists = true; isRecommend = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsHot)) { isHotExists = true; isHot = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsColor)) { isColorExists = true; isColor = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeTheme)) { theme = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeWidth)) { if (StringUtils.EndsWithIgnoreCase(value, "px")) { value = value.Substring(0, value.Length - 2); } imageWidth = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeHeight)) { if (StringUtils.EndsWithIgnoreCase(value, "px")) { value = value.Substring(0, value.Length - 2); } imageHeight = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeBgColor)) { bgColor = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsShowText)) { isShowText = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsTopText)) { isTopText = value; } else { genericControl.Attributes[name] = value; } } return(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)); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { 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; 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, AttributeChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } 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, AttributeGroupChannel)) { groupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeGroupChannelNot)) { groupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTitle)) { title = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsLoading)) { isLoading = TranslateUtils.ToBool(attr.Value, false); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsShowContentNum)) { isShowContentNum = TranslateUtils.ToBool(attr.Value, false); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsShowTreeLine)) { isShowTreeLine = TranslateUtils.ToBool(attr.Value, true); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeCurrentFormatString)) { currentFormatString = attr.Value; if (!StringUtils.Contains(currentFormatString, "{0}")) { currentFormatString += "{0}"; } } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { attributes.Set(attr.Name, attr.Value); } } } if (isDynamic) { parsedContent = StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo); } else { parsedContent = isLoading ? ParseImplAjax(pageInfo, contextInfo, channelIndex, channelName, upLevel, topLevel, groupChannel, groupChannelNot, title, isShowContentNum, isShowTreeLine, currentFormatString) : ParseImplNotAjax(pageInfo, contextInfo, channelIndex, channelName, upLevel, topLevel, groupChannel, groupChannelNot, title, isShowContentNum, isShowTreeLine, currentFormatString); } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
internal static object Parse(PageInfo pageInfo, ContextInfo contextInfo) { var siteName = string.Empty; var siteDir = string.Empty; var type = 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; foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, SiteName.Name)) { siteName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, SiteDir.Name)) { siteDir = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, Type.Name)) { type = value; } else if (StringUtils.EqualsIgnoreCase(name, FormatString.Name)) { formatString = value; } else if (StringUtils.EqualsIgnoreCase(name, Separator.Name)) { separator = value; } else if (StringUtils.EqualsIgnoreCase(name, StartIndex.Name)) { startIndex = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Length.Name)) { length = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, WordNum.Name)) { wordNum = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Ellipsis.Name)) { ellipsis = value; } else if (StringUtils.EqualsIgnoreCase(name, Replace.Name)) { replace = value; } else if (StringUtils.EqualsIgnoreCase(name, To.Name)) { to = value; } else if (StringUtils.EqualsIgnoreCase(name, IsClearTags.Name)) { isClearTags = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsReturnToBr.Name)) { isReturnToBr = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsLower.Name)) { isLower = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, IsUpper.Name)) { isUpper = TranslateUtils.ToBool(value, true); } } var siteInfo = contextInfo.SiteInfo; if (!string.IsNullOrEmpty(siteName)) { siteInfo = SiteManager.GetSiteInfoBySiteName(siteName); } else if (!string.IsNullOrEmpty(siteDir)) { siteInfo = SiteManager.GetSiteInfoByDirectory(siteDir); } if (contextInfo.IsStlEntity && string.IsNullOrEmpty(type)) { return(siteInfo); } return(ParseImpl(pageInfo, contextInfo, siteInfo, type, formatString, separator, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper)); }
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 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"; foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, AttributeChannelIndex)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelIndex)) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeParent)) { if (TranslateUtils.ToBool(value)) { upLevel = 1; isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeUpLevel)) { upLevel = TranslateUtils.ToInt(value); if (upLevel > 0) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeTopLevel)) { topLevel = TranslateUtils.ToInt(value); if (topLevel >= 0) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeType)) { type = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeSrc)) { src = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeAltSrc)) { altSrc = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeWidth)) { width = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeHeight)) { height = value; } } return(ParseImpl(pageInfo, contextInfo, isGetPicUrlFromAttribute, channelIndex, channelName, upLevel, topLevel, type, src, altSrc, width, height)); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { var isGetPicUrlFromAttribute = false; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var type = BackgroundContentAttribute.ImageUrl; var no = 0; var isOriginal = false; var src = string.Empty; var altSrc = string.Empty; var stlImage = new HtmlImage(); 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)) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, ChannelName)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, Parent)) { if (TranslateUtils.ToBool(value)) { upLevel = 1; isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, UpLevel)) { upLevel = TranslateUtils.ToInt(value); if (upLevel > 0) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, TopLevel)) { topLevel = TranslateUtils.ToInt(value); if (topLevel >= 0) { isGetPicUrlFromAttribute = true; } } else if (StringUtils.EqualsIgnoreCase(name, Type)) { type = value; } else if (StringUtils.EqualsIgnoreCase(name, No)) { no = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, IsOriginal)) { isOriginal = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, Src)) { src = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, AltSrc)) { altSrc = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else { stlImage.Attributes[name] = value; } } return(ParseImpl(pageInfo, contextInfo, stlImage, isGetPicUrlFromAttribute, channelIndex, channelName, upLevel, topLevel, type, no, isOriginal, src, altSrc)); }
public static object Parse(PageInfo pageInfo, ContextInfo contextInfo) { var connectionString = string.Empty; var queryString = string.Empty; var leftText = string.Empty; var rightText = string.Empty; var formatString = string.Empty; 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; foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, ConnectionString.Name)) { connectionString = value; } else if (StringUtils.EqualsIgnoreCase(name, ConnectionStringName.Name)) { if (string.IsNullOrEmpty(connectionString)) { connectionString = WebConfigUtils.ConnectionString; } } else if (StringUtils.EqualsIgnoreCase(name, QueryString.Name)) { queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, Type.Name)) { type = value.ToLower(); } else if (StringUtils.EqualsIgnoreCase(name, LeftText.Name)) { leftText = value; } else if (StringUtils.EqualsIgnoreCase(name, RightText.Name)) { rightText = value; } else if (StringUtils.EqualsIgnoreCase(name, FormatString.Name)) { formatString = value; } else if (StringUtils.EqualsIgnoreCase(name, StartIndex.Name)) { startIndex = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Length.Name)) { length = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, WordNum.Name)) { wordNum = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Ellipsis.Name)) { ellipsis = value; } else if (StringUtils.EqualsIgnoreCase(name, Replace.Name)) { replace = value; } else if (StringUtils.EqualsIgnoreCase(name, To.Name)) { to = value; } else if (StringUtils.EqualsIgnoreCase(name, IsClearTags.Name)) { isClearTags = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsReturnToBr.Name)) { isReturnToBr = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsLower.Name)) { isLower = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, IsUpper.Name)) { isUpper = TranslateUtils.ToBool(value, true); } } if (contextInfo.IsStlEntity && string.IsNullOrEmpty(type)) { object dataItem = null; if (contextInfo.ItemContainer?.SqlItem != null) { dataItem = contextInfo.ItemContainer?.SqlItem.DataItem; } else if (!string.IsNullOrEmpty(queryString)) { var dataTable = Database.GetDataTable(connectionString, queryString); var dictList = TranslateUtils.DataTableToDictionaryList(dataTable); if (dictList != null && dictList.Count >= 1) { dataItem = dictList[0]; } } return(dataItem); } return(ParseImpl(contextInfo, connectionString, queryString, leftText, rightText, formatString, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper, type)); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; try { var ie = node.Attributes?.GetEnumerator(); var isGetUrlFromAttribute = false; var channelIndex = string.Empty; var channelName = string.Empty; var type = TypePageView; var scope = ScopePage; var isAverage = false; var style = string.Empty; var addNum = 0; var since = string.Empty; var isDynamic = false; 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, AttributeType)) { type = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeScope)) { scope = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsAverage)) { isAverage = TranslateUtils.ToBool(attr.Value, false); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeStyle)) { style = ETrackerStyleUtils.GetValue(ETrackerStyleUtils.GetEnumType(attr.Value)); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeAddNum)) { addNum = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeSince)) { since = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(pageInfo, contextInfo, isGetUrlFromAttribute, channelIndex, channelName, type, scope, isAverage, style, addNum, since); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }