public static string ParseInDynamicPage(string stlElement, PageInfo pageInfo, string pageUrl, int channelId, int currentPageIndex, int pageCount, int totalNum, bool isPageRefresh, string ajaxDivId) { string parsedContent; try { var stlElementInfo = StlParserUtility.ParseStlElement(stlElement); if (pageCount <= 1) { return(string.Empty); } var index = stlElement.IndexOf(">", StringComparison.Ordinal) + 1; var length = stlElement.LastIndexOf("<", StringComparison.Ordinal) - index; if (index <= 0 || length <= 0) { stlElement = stlElementInfo.InnerHtml; } else { stlElement = stlElement.Substring(index, length); } parsedContent = StlPageElementParser.ParseStlPageItemsInDynamicPage(stlElement, pageInfo, pageUrl, channelId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId); } catch (Exception ex) { parsedContent = LogUtils.AddStlErrorLog(pageInfo, ElementName, stlElement, ex); } return(parsedContent); }
public static string ParseInDynamicPage(string stlElement, PageInfo pageInfo, string pageUrl, int channelId, int currentPageIndex, int pageCount, int totalNum, bool isPageRefresh, string ajaxDivId) { string parsedContent; try { var xmlDocument = StlParserUtility.GetXmlDocument(stlElement, false); XmlNode node = xmlDocument.DocumentElement; node = node?.FirstChild; if (pageCount <= 1) { return(string.Empty); } var index = stlElement.IndexOf(">", StringComparison.Ordinal) + 1; var length = stlElement.LastIndexOf("<", StringComparison.Ordinal) - index; if (index <= 0 || length <= 0) { stlElement = node?.InnerXml; } else { stlElement = stlElement.Substring(index, length); } parsedContent = StlPageElementParser.ParseStlPageItemsInDynamicPage(stlElement, pageInfo, pageUrl, channelId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, stlElement, ex); } return(parsedContent); }
//对“翻页项容器”(stl:pageItems)元素进行解析,此元素在生成页面时单独解析,不包含在ParseStlElement方法中。 public static string Parse(string stlElement, PageInfo pageInfo, int channelId, int contentId, int currentPageIndex, int pageCount, int totalNum, EContextType contextType) { pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.Jquery); string parsedContent; try { var xmlDocument = StlParserUtility.GetXmlDocument(stlElement, false); XmlNode node = xmlDocument.DocumentElement; node = node?.FirstChild; var ie = node?.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (attr == null) { continue; } var name = attr.Name; if (StringUtils.EqualsIgnoreCase(name, Context.Name)) { contextType = EContextTypeUtils.GetEnumType(attr.Value); } } } if (pageCount <= 1) { return(string.Empty); } bool isXmlContent; var index = stlElement.IndexOf(">", StringComparison.Ordinal) + 1; var length = stlElement.LastIndexOf("<", StringComparison.Ordinal) - index; if (index <= 0 || length <= 0) { stlElement = node?.InnerXml; isXmlContent = true; } else { stlElement = stlElement.Substring(index, length); isXmlContent = false; } parsedContent = StlPageElementParser.ParseStlPageItems(stlElement, pageInfo, channelId, contentId, currentPageIndex, pageCount, totalNum, isXmlContent, contextType); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, stlElement, ex); } return(parsedContent); }
//对“翻页项容器”(stl:pageItems)元素进行解析,此元素在生成页面时单独解析,不包含在ParseStlElement方法中。 public static string Parse(string stlElement, PageInfo pageInfo, int nodeId, int contentId, int currentPageIndex, int pageCount, int totalNum, EContextType contextType) { pageInfo.AddPageScriptsIfNotExists(PageInfo.Components.Jquery); string parsedContent; try { var xmlDocument = StlParserUtility.GetXmlDocument(stlElement, false); XmlNode node = xmlDocument.DocumentElement; node = node.FirstChild; var ie = node.Attributes.GetEnumerator(); var autoHide = true; while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(AttributeAutoHide)) { autoHide = TranslateUtils.ToBool(attr.Value); } else if (attributeName.Equals(AttributeContext)) { contextType = EContextTypeUtils.GetEnumType(attr.Value); } } if (pageCount <= 1 && autoHide) { return(string.Empty); } bool isXmlContent; var index = stlElement.IndexOf(">", StringComparison.Ordinal) + 1; var length = stlElement.LastIndexOf("<", StringComparison.Ordinal) - index; if (index <= 0 || length <= 0) { stlElement = node.InnerXml; isXmlContent = true; } else { stlElement = stlElement.Substring(index, length); isXmlContent = false; } parsedContent = StlPageElementParser.ParseStlPageItems(stlElement, pageInfo, nodeId, contentId, currentPageIndex, pageCount, totalNum, isXmlContent, contextType); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
//对“翻页项容器”(stl:pageItems)元素进行解析,此元素在生成页面时单独解析,不包含在ParseStlElement方法中。 public static string Parse(string stlElement, PageInfo pageInfo, int channelId, int contentId, int currentPageIndex, int pageCount, int totalNum, EContextType contextType) { pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.Jquery); string parsedContent; try { var stlElementInfo = StlParserUtility.ParseStlElement(stlElement); if (stlElementInfo.Attributes[Context] != null) { contextType = EContextTypeUtils.GetEnumType(stlElementInfo.Attributes[Context]); } if (pageCount <= 1) { return(string.Empty); } bool isXmlContent; var index = stlElement.IndexOf(">", StringComparison.Ordinal) + 1; var length = stlElement.LastIndexOf("<", StringComparison.Ordinal) - index; if (index <= 0 || length <= 0) { stlElement = stlElementInfo.InnerHtml; isXmlContent = true; } else { stlElement = stlElement.Substring(index, length); isXmlContent = false; } parsedContent = StlPageElementParser.ParseStlPageItems(stlElement, pageInfo, channelId, contentId, currentPageIndex, pageCount, totalNum, isXmlContent, contextType); ContextInfo contextInfo = new ContextInfo(pageInfo) { ContextType = contextType }; var innerBuilder = new StringBuilder(parsedContent); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); parsedContent = innerBuilder.ToString(); } catch (Exception ex) { parsedContent = LogUtils.AddStlErrorLog(pageInfo, ElementName, stlElement, ex); } return(parsedContent); }
public static string ParseInDynamicPage(string stlElement, PageInfo pageInfo, string pageUrl, int nodeId, int currentPageIndex, int pageCount, int totalNum, bool isPageRefresh, string ajaxDivId) { string parsedContent; try { var xmlDocument = StlParserUtility.GetXmlDocument(stlElement, false); XmlNode node = xmlDocument.DocumentElement; node = node.FirstChild; var ie = node.Attributes.GetEnumerator(); var autoHide = true; while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; var attributeName = attr.Name.ToLower(); if (attributeName.Equals(AttributeAutoHide)) { autoHide = TranslateUtils.ToBool(attr.Value); } } if (pageCount <= 1 && autoHide) { return(string.Empty); } var index = stlElement.IndexOf(">", StringComparison.Ordinal) + 1; var length = stlElement.LastIndexOf("<", StringComparison.Ordinal) - index; if (index <= 0 || length <= 0) { stlElement = node.InnerXml; } else { stlElement = stlElement.Substring(index, length); } parsedContent = StlPageElementParser.ParseStlPageItemsInDynamicPage(stlElement, pageInfo, pageUrl, nodeId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public static void ReplacePageElementsInSearchPage(StringBuilder parsedBuilder, PageInfo pageInfo, List <string> labelList, string ajaxDivId, int nodeId, int currentPageIndex, int pageCount, int totalNum) { //替换分页模板 foreach (var labelString in labelList) { if (StlParserUtility.IsSpecifiedStlElement(labelString, StlPageItems.ElementName)) { var stlElement = labelString; var pageHtml = StlPageElementParser.ParseStlPageInSearchPage(stlElement, pageInfo, ajaxDivId, nodeId, currentPageIndex, pageCount, totalNum); parsedBuilder.Replace(stlElement, pageHtml); } else if (StlParserUtility.IsSpecifiedStlElement(labelString, StlPageItem.ElementName)) { var stlElement = labelString; var pageHtml = StlPageElementParser.ParseStlPageItemInSearchPage(stlElement, pageInfo, ajaxDivId, nodeId, currentPageIndex, pageCount, totalNum); parsedBuilder.Replace(stlElement, pageHtml); } } }
public static void ReplacePageElementsInDynamicPage(StringBuilder parsedBuilder, PageInfo pageInfo, List <string> labelList, string pageUrl, int channelId, int currentPageIndex, int pageCount, int totalNum, bool isPageRefresh, string ajaxDivId) { //替换分页模板 foreach (var labelString in labelList) { if (StlParserUtility.IsSpecifiedStlElement(labelString, StlPageItems.ElementName)) { var stlElement = labelString; var pageHtml = StlPageElementParser.ParseStlPageInDynamicPage(stlElement, pageInfo, pageUrl, channelId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId); parsedBuilder.Replace(stlElement, pageHtml); } else if (StlParserUtility.IsSpecifiedStlElement(labelString, StlPageItem.ElementName)) { var stlElement = labelString; var pageHtml = StlPageElementParser.ParseStlPageItemInDynamicPage(stlElement, pageInfo, pageUrl, channelId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId); parsedBuilder.Replace(stlElement, pageHtml); } } }
public static void ReplacePageElementsInContentPage(StringBuilder parsedBuilder, PageInfo pageInfo, List <string> labelList, int channelId, int contentId, int currentPageIndex, int pageCount) { //替换分页模板 foreach (var labelString in labelList) { if (StlParserUtility.IsSpecifiedStlElement(labelString, StlPageItems.ElementName)) { var stlElement = labelString; var pageHtml = StlPageElementParser.ParseStlPageInContentPage(stlElement, pageInfo, channelId, contentId, currentPageIndex, pageCount); parsedBuilder.Replace(StlEncrypt(stlElement), pageHtml); } else if (StlParserUtility.IsSpecifiedStlElement(labelString, StlPageItem.ElementName)) { var stlElement = labelString; var pageHtml = StlPageElementParser.ParseStlPageItemInContentPage(stlElement, pageInfo, channelId, contentId, currentPageIndex, pageCount, pageCount); parsedBuilder.Replace(stlElement, pageHtml); } } }
public static string ParseInSearchPage(string stlElement, PageInfo pageInfo, string ajaxDivId, int channelId, int currentPageIndex, int pageCount, int totalNum) { string parsedContent; try { var stlElementInfo = StlParserUtility.ParseStlElement(stlElement); if (pageCount <= 1) { return(string.Empty); } //bool isXmlContent; var index = stlElement.IndexOf(">", StringComparison.Ordinal) + 1; var length = stlElement.LastIndexOf("<", StringComparison.Ordinal) - index; if (index <= 0 || length <= 0) { stlElement = stlElementInfo.InnerHtml; //isXmlContent = true; } else { stlElement = stlElement.Substring(index, length); //isXmlContent = false; } parsedContent = StlPageElementParser.ParseStlPageItemsInSearchPage(stlElement, pageInfo, ajaxDivId, channelId, currentPageIndex, pageCount, totalNum); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, stlElement, ex); } return(parsedContent); }