Example #1
0
        public static async Task <string> GetEachsTemplateStringAsync(string templateString, NameValueCollection selectedItems, NameValueCollection selectedValues, string containerClientId, IParseManager parseManager, ParseType contextType)
        {
            var context = parseManager.ContextInfo;

            var pageInfo      = parseManager.PageInfo;
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);

            parseManager.ContextInfo                   = parseManager.ContextInfo.Clone();
            parseManager.ContextInfo.ContextType       = contextType;
            parseManager.ContextInfo.ContainerClientId = containerClientId;
            parseManager.ContextInfo.ItemContainer     = itemContainer;

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (var itemType in selectedItems.AllKeys)
                {
                    if (IsNumberInRange(itemContainer.SqlItem.Key + 1, itemType))
                    {
                        templateString = selectedItems.Get(itemType);
                        break;
                    }
                }
            }

            var innerBuilder = new StringBuilder(templateString);
            await parseManager.ParseInnerContentAsync(innerBuilder);

            DbItemContainer.PopEachItem(pageInfo);

            parseManager.ContextInfo = context;

            return(innerBuilder.ToString());
        }
        public static string GetEachsTemplateString(string templateString, NameValueCollection selectedItems, NameValueCollection selectedValues, string containerClientId, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef)
        {
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);

            var contextInfo = contextInfoRef.Clone();

            contextInfo.ContextType       = contextType;
            contextInfo.ContainerClientId = containerClientId;
            contextInfo.ItemContainer     = itemContainer;

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (var itemType in selectedItems.AllKeys)
                {
                    if (IsNumberInRange(itemContainer.SqlItem.ItemIndex + 1, itemType))
                    {
                        templateString = selectedItems.Get(itemType);
                        break;
                    }
                }
            }

            var innerBuilder = new StringBuilder(templateString);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            DbItemContainer.PopEachItem(pageInfo);

            return(innerBuilder.ToString());
        }
Example #3
0
        public static async Task <string> GetSitesTemplateStringAsync(string templateString, string containerClientId, IParseManager parseManager, ParseType contextType)
        {
            var context = parseManager.ContextInfo;

            var pageInfo      = parseManager.PageInfo;
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);

            var siteInfo = itemContainer.SiteItem.Value;

            parseManager.ContextInfo = parseManager.ContextInfo.Clone();
            parseManager.ContextInfo.ContainerClientId = containerClientId;
            parseManager.ContextInfo.ItemContainer     = itemContainer;
            parseManager.ContextInfo.ContextType       = contextType;

            var preSite          = pageInfo.Site;
            var prePageChannelId = pageInfo.PageChannelId;
            var prePageContentId = pageInfo.PageContentId;

            pageInfo.ChangeSite(siteInfo, siteInfo.Id, 0, parseManager.ContextInfo);

            var innerBuilder = new StringBuilder(templateString);
            await parseManager.ParseInnerContentAsync(innerBuilder);

            DbItemContainer.PopSiteItems(pageInfo);

            pageInfo.ChangeSite(preSite, prePageChannelId, prePageContentId, parseManager.ContextInfo);

            parseManager.ContextInfo = context;

            return(innerBuilder.ToString());
        }
Example #4
0
        public static string GetSitesTemplateString(string templateString, string containerClientID, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef)
        {
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);

            var publishmentSystemID   = SqlUtils.EvalInt(itemContainer.SiteItem.DataItem, PublishmentSystemAttribute.PublishmentSystemId);
            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemID);

            var contextInfo = contextInfoRef.Clone();

            contextInfo.ContainerClientID = containerClientID;
            contextInfo.ItemContainer     = itemContainer;
            contextInfo.ContextType       = contextType;

            var prePublishmentSystemInfo = pageInfo.PublishmentSystemInfo;
            var prePageNodeID            = pageInfo.PageNodeId;
            var prePageContentID         = pageInfo.PageContentId;

            pageInfo.ChangeSite(publishmentSystemInfo, publishmentSystemInfo.PublishmentSystemId, 0, contextInfo);

            var innerBuilder = new StringBuilder(templateString);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            DbItemContainer.PopInputItem(pageInfo);

            pageInfo.ChangeSite(prePublishmentSystemInfo, prePageNodeID, prePageContentID, contextInfo);

            return(innerBuilder.ToString());
        }
        public static string GetSitesTemplateString(string templateString, string containerClientId, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef)
        {
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);

            var siteId   = SqlUtils.EvalInt(itemContainer.SiteItem.DataItem, SiteAttribute.Id);
            var siteInfo = SiteManager.GetSiteInfo(siteId);

            var contextInfo = contextInfoRef.Clone();

            contextInfo.ContainerClientId = containerClientId;
            contextInfo.ItemContainer     = itemContainer;
            contextInfo.ContextType       = contextType;

            var preSiteInfo      = pageInfo.SiteInfo;
            var prePageChannelId = pageInfo.PageChannelId;
            var prePageContentId = pageInfo.PageContentId;

            pageInfo.ChangeSite(siteInfo, siteInfo.Id, 0, contextInfo);

            var innerBuilder = new StringBuilder(templateString);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            DbItemContainer.PopSiteItems(pageInfo);

            pageInfo.ChangeSite(preSiteInfo, prePageChannelId, prePageContentId, contextInfo);

            return(innerBuilder.ToString());
        }
Example #6
0
        public static string GetContentsItemTemplateString(string templateString, LowerNameValueCollection selectedItems, LowerNameValueCollection selectedValues, string containerClientID, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef)
        {
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);
            var contentInfo   = new BackgroundContentInfo(itemContainer.ContentItem.DataItem);

            var contextInfo = contextInfoRef.Clone();

            contextInfo.ContextType       = contextType;
            contextInfo.ItemContainer     = itemContainer;
            contextInfo.ContainerClientID = containerClientID;
            contextInfo.ChannelID         = contentInfo.NodeId;
            contextInfo.ContentID         = contentInfo.Id;
            contextInfo.ContentInfo       = contentInfo;

            var theTemplateString = string.Empty;

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (string itemTypes in selectedItems.Keys)
                {
                    var itemTypeArrayList = TranslateUtils.StringCollectionToStringList(itemTypes);
                    var isTrue            = true;
                    foreach (string itemType in itemTypeArrayList)
                    {
                        if (!IsContentTemplateString(itemType, itemTypes, ref theTemplateString, selectedItems, selectedValues, pageInfo, contextInfo))
                        {
                            isTrue = false;
                        }
                    }
                    if (isTrue)
                    {
                        break;
                    }
                    else
                    {
                        theTemplateString = string.Empty;
                    }
                }
            }

            if (string.IsNullOrEmpty(theTemplateString))
            {
                theTemplateString = templateString;
            }

            var innerBuilder = new StringBuilder(theTemplateString);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            DbItemContainer.PopContentItem(pageInfo);

            return(innerBuilder.ToString());
        }
Example #7
0
        public static string GetInputContentsTemplateString(string templateString, string containerClientId, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef)
        {
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);

            var contextInfo = contextInfoRef.Clone();
            contextInfo.ContainerClientId = containerClientId;
            contextInfo.ItemContainer = itemContainer;
            contextInfo.ContextType = contextType;

            var innerBuilder = new StringBuilder(templateString);
            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            DbItemContainer.PopInputItem(pageInfo);

            return innerBuilder.ToString();
        }
Example #8
0
        public static async Task <string> GetChannelsItemTemplateStringAsync(string templateString, NameValueCollection selectedItems, NameValueCollection selectedValues, string containerClientId, IParseManager parseManager, ParseType contextType)
        {
            var context = parseManager.ContextInfo;

            var pageInfo      = parseManager.PageInfo;
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);

            var channel = itemContainer.ChannelItem.Value;

            parseManager.ContextInfo                   = parseManager.ContextInfo.Clone();
            parseManager.ContextInfo.ContextType       = contextType;
            parseManager.ContextInfo.ItemContainer     = itemContainer;
            parseManager.ContextInfo.ContainerClientId = containerClientId;
            parseManager.ContextInfo.ChannelId         = channel.Id;

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (var itemType in selectedItems.AllKeys)
                {
                    if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedCurrent))//当前栏目
                    {
                        if (channel.Id == pageInfo.PageChannelId)
                        {
                            templateString = selectedItems.Get(itemType);
                            break;
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedImage))//带有图片的栏目
                    {
                        if (!string.IsNullOrEmpty(channel.ImageUrl))
                        {
                            templateString = selectedItems.Get(itemType);
                            break;
                        }
                    }
                    else if (StringUtils.StartsWithIgnoreCase(itemType, StlItemTemplate.SelectedUp))//当前栏目的上级栏目
                    {
                        var upLevel = StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedUp) ? 1 : TranslateUtils.ToInt(itemType.Substring(2));
                        if (upLevel > 0)
                        {
                            var dataManager  = new StlDataManager(parseManager.DatabaseManager);
                            var theChannelId = await dataManager.GetChannelIdByLevelAsync(pageInfo.SiteId, pageInfo.PageChannelId, upLevel, -1);

                            if (channel.Id == theChannelId)
                            {
                                templateString = selectedItems.Get(itemType);
                                break;
                            }
                        }
                    }
                    else if (StringUtils.StartsWithIgnoreCase(itemType, StlItemTemplate.SelectedTop))//当前栏目从首页向下的上级栏目栏目
                    {
                        var topLevel = StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedTop) ? 1 : TranslateUtils.ToInt(itemType.Substring(3));
                        if (topLevel >= 0)
                        {
                            var dataManager  = new StlDataManager(parseManager.DatabaseManager);
                            var theChannelId = await dataManager.GetChannelIdByLevelAsync(pageInfo.SiteId, pageInfo.PageChannelId, 0, topLevel);

                            if (channel.Id == theChannelId)
                            {
                                templateString = selectedItems.Get(itemType);
                                break;
                            }
                        }
                    }
                    else if (IsNumberInRange(itemContainer.ChannelItem.Key + 1, itemType))
                    {
                        templateString = selectedItems.Get(itemType);
                        break;
                    }
                }
            }

            var innerBuilder = new StringBuilder(templateString);
            await parseManager.ParseInnerContentAsync(innerBuilder);

            DbItemContainer.PopChannelItem(pageInfo);

            parseManager.ContextInfo = context;

            return(innerBuilder.ToString());
        }
Example #9
0
        public static async Task <string> GetContentsItemTemplateStringAsync(string templateString, NameValueCollection selectedItems, NameValueCollection selectedValues, string containerClientId, IParseManager parseManager, ParseType contextType)
        {
            var context = parseManager.ContextInfo;

            var pageInfo      = parseManager.PageInfo;
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);
            var content       = itemContainer.ContentItem.Value;

            parseManager.ContextInfo                   = parseManager.ContextInfo.Clone();
            parseManager.ContextInfo.ContextType       = contextType;
            parseManager.ContextInfo.ItemContainer     = itemContainer;
            parseManager.ContextInfo.ContainerClientId = containerClientId;
            parseManager.ContextInfo.ChannelId         = content.ChannelId;
            parseManager.ContextInfo.ContentId         = content.Id;
            parseManager.ContextInfo.SetContent(content);

            var preSite          = pageInfo.Site;
            var prePageChannelId = pageInfo.PageChannelId;
            var prePageContentId = pageInfo.PageContentId;

            if (content.SiteId != pageInfo.SiteId)
            {
                var siteInfo = await parseManager.DatabaseManager.SiteRepository.GetAsync(content.SiteId);

                parseManager.ContextInfo.Site = siteInfo;
                pageInfo.ChangeSite(siteInfo, siteInfo.Id, 0, parseManager.ContextInfo);
            }

            var theTemplateString = string.Empty;

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (var itemTypes in selectedItems.AllKeys)
                {
                    var itemTypeArrayList = ListUtils.GetStringList(itemTypes);
                    var isTrue            = true;
                    foreach (var itemType in itemTypeArrayList)
                    {
                        var(success, contentTemplateString) = await IsContentTemplateStringAsync(itemType, itemTypes,
                                                                                                 selectedItems, selectedValues, parseManager);

                        if (!success)
                        {
                            isTrue = false;
                        }
                        else
                        {
                            theTemplateString = contentTemplateString;
                        }
                    }
                    if (isTrue)
                    {
                        break;
                    }
                    theTemplateString = string.Empty;
                }
            }

            if (string.IsNullOrEmpty(theTemplateString))
            {
                theTemplateString = templateString;
            }

            var innerBuilder = new StringBuilder(theTemplateString);
            await parseManager.ParseInnerContentAsync(innerBuilder);

            DbItemContainer.PopContentItem(pageInfo);

            if (content.SiteId != pageInfo.SiteId)
            {
                pageInfo.ChangeSite(preSite, prePageChannelId, prePageContentId, parseManager.ContextInfo);
            }

            parseManager.ContextInfo = context;

            return(innerBuilder.ToString());
        }
        public static string GetChannelsItemTemplateString(string templateString, NameValueCollection selectedItems, NameValueCollection selectedValues, string containerClientId, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef)
        {
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);

            var channelId = itemContainer.ChannelItem.ChannelId;

            var contextInfo = contextInfoRef.Clone();

            contextInfo.ContextType       = contextType;
            contextInfo.ItemContainer     = itemContainer;
            contextInfo.ContainerClientId = containerClientId;
            contextInfo.ChannelId         = channelId;

            var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, channelId);

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (var itemType in selectedItems.AllKeys)
                {
                    if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedCurrent))//当前栏目
                    {
                        if (channelId == pageInfo.PageChannelId)
                        {
                            templateString = selectedItems.Get(itemType);
                            break;
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedImage))//带有图片的栏目
                    {
                        if (!string.IsNullOrEmpty(nodeInfo.ImageUrl))
                        {
                            templateString = selectedItems.Get(itemType);
                            break;
                        }
                    }
                    else if (StringUtils.StartsWithIgnoreCase(itemType, StlItemTemplate.SelectedUp))//当前栏目的上级栏目
                    {
                        var upLevel = StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedUp) ? 1 : TranslateUtils.ToInt(itemType.Substring(2));
                        if (upLevel > 0)
                        {
                            var theChannelId = StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, pageInfo.PageChannelId, upLevel, -1);
                            if (channelId == theChannelId)
                            {
                                templateString = selectedItems.Get(itemType);
                                break;
                            }
                        }
                    }
                    else if (StringUtils.StartsWithIgnoreCase(itemType, StlItemTemplate.SelectedTop))//当前栏目从首页向下的上级栏目栏目
                    {
                        var topLevel = StringUtils.EqualsIgnoreCase(itemType, StlItemTemplate.SelectedTop) ? 1 : TranslateUtils.ToInt(itemType.Substring(3));
                        if (topLevel >= 0)
                        {
                            var theChannelId = StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, pageInfo.PageChannelId, 0, topLevel);
                            if (channelId == theChannelId)
                            {
                                templateString = selectedItems.Get(itemType);
                                break;
                            }
                        }
                    }
                    else if (IsNumberInRange(itemContainer.ChannelItem.ItemIndex + 1, itemType))
                    {
                        templateString = selectedItems.Get(itemType);
                        break;
                    }
                }
            }

            var innerBuilder = new StringBuilder(templateString);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            DbItemContainer.PopChannelItem(pageInfo);

            return(innerBuilder.ToString());
        }
        public static string GetContentsItemTemplateString(string templateString, NameValueCollection selectedItems, NameValueCollection selectedValues, string containerClientId, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef)
        {
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);
            //var contentInfo = new BackgroundContentInfo(itemContainer.ContentItem.DataItem);

            ContentItemInfo contentItemInfo = null;

            if (pageInfo.ContentItems.Count > 0)
            {
                contentItemInfo = pageInfo.ContentItems.Peek();
            }
            if (contentItemInfo == null)
            {
                return(string.Empty);
            }
            var contentInfo = ContentManager.GetContentInfo(pageInfo.SiteInfo, contentItemInfo.ChannelId,
                                                            contentItemInfo.ContentId);

            var contextInfo = contextInfoRef.Clone();

            contextInfo.ContextType       = contextType;
            contextInfo.ItemContainer     = itemContainer;
            contextInfo.ContainerClientId = containerClientId;
            contextInfo.ChannelId         = contentInfo.ChannelId;
            contextInfo.ContentId         = contentInfo.Id;
            contextInfo.ContentInfo       = contentInfo;

            var preSiteInfo      = pageInfo.SiteInfo;
            var prePageChannelId = pageInfo.PageChannelId;
            var prePageContentId = pageInfo.PageContentId;

            if (contentInfo.SiteId != pageInfo.SiteId)
            {
                var siteInfo = SiteManager.GetSiteInfo(contentInfo.SiteId);
                if (siteInfo != null)
                {
                    contextInfo.SiteInfo = siteInfo;
                    pageInfo.ChangeSite(siteInfo, siteInfo.Id, 0, contextInfo);
                }
            }

            var theTemplateString = string.Empty;

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (var itemTypes in selectedItems.AllKeys)
                {
                    var itemTypeArrayList = TranslateUtils.StringCollectionToStringList(itemTypes);
                    var isTrue            = true;
                    foreach (var itemType in itemTypeArrayList)
                    {
                        if (!IsContentTemplateString(itemType, itemTypes, ref theTemplateString, selectedItems, selectedValues, pageInfo, contextInfo))
                        {
                            isTrue = false;
                        }
                    }
                    if (isTrue)
                    {
                        break;
                    }
                    theTemplateString = string.Empty;
                }
            }

            if (string.IsNullOrEmpty(theTemplateString))
            {
                theTemplateString = templateString;
            }

            var innerBuilder = new StringBuilder(theTemplateString);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            DbItemContainer.PopContentItem(pageInfo);

            if (contentInfo.SiteId != pageInfo.SiteId)
            {
                pageInfo.ChangeSite(preSiteInfo, prePageChannelId, prePageContentId, contextInfoRef);
            }

            return(innerBuilder.ToString());
        }
Example #12
0
        public static string GetChannelsItemTemplateString(string templateString, LowerNameValueCollection selectedItems, LowerNameValueCollection selectedValues, string containerClientID, PageInfo pageInfo, EContextType contextType, ContextInfo contextInfoRef)
        {
            var itemContainer = DbItemContainer.GetItemContainer(pageInfo);

            var nodeID = SqlUtils.EvalInt(itemContainer.ChannelItem.DataItem, NodeAttribute.NodeId);

            var contextInfo = contextInfoRef.Clone();

            contextInfo.ContextType       = contextType;
            contextInfo.ItemContainer     = itemContainer;
            contextInfo.ContainerClientID = containerClientID;
            contextInfo.ChannelID         = nodeID;

            var nodeInfo = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, nodeID);

            if (selectedItems != null && selectedItems.Count > 0)
            {
                foreach (string itemType in selectedItems.Keys)
                {
                    if (itemType == StlItem.ChannelsItem.Selected_Current)//当前栏目
                    {
                        if (nodeID == pageInfo.PageNodeId)
                        {
                            templateString = selectedItems[itemType];
                            break;
                        }
                    }
                    else if (itemType == StlItem.ChannelsItem.Selected_Image)//带有图片的栏目
                    {
                        if (!string.IsNullOrEmpty(nodeInfo.ImageUrl))
                        {
                            templateString = selectedItems[itemType];
                            break;
                        }
                    }
                    else if (itemType.StartsWith(StlItem.ChannelsItem.Selected_Up))//当前栏目的上级栏目
                    {
                        var upLevel = 1;
                        if (itemType == StlItem.ChannelsItem.Selected_Up)
                        {
                            upLevel = 1;
                        }
                        else
                        {
                            upLevel = TranslateUtils.ToInt(itemType.Substring(2));
                        }
                        if (upLevel > 0)
                        {
                            var theNodeID = StlDataUtility.GetNodeIdByLevel(pageInfo.PublishmentSystemId, pageInfo.PageNodeId, upLevel, -1);
                            if (nodeID == theNodeID)
                            {
                                templateString = selectedItems[itemType];
                                break;
                            }
                        }
                    }
                    else if (itemType.StartsWith(StlItem.ChannelsItem.Selected_Top))//当前栏目从首页向下的上级栏目栏目
                    {
                        var topLevel = 1;
                        if (itemType == StlItem.ChannelsItem.Selected_Top)
                        {
                            topLevel = 1;
                        }
                        else
                        {
                            topLevel = TranslateUtils.ToInt(itemType.Substring(3));
                        }
                        if (topLevel >= 0)
                        {
                            var theNodeID = StlDataUtility.GetNodeIdByLevel(pageInfo.PublishmentSystemId, pageInfo.PageNodeId, 0, topLevel);
                            if (nodeID == theNodeID)
                            {
                                templateString = selectedItems[itemType];
                                break;
                            }
                        }
                    }
                    else if (IsNumberInRange(itemContainer.ChannelItem.ItemIndex + 1, itemType))
                    {
                        templateString = selectedItems[itemType];
                        break;
                    }
                }
            }

            var innerBuilder = new StringBuilder(templateString);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            DbItemContainer.PopChannelItem(pageInfo);

            return(innerBuilder.ToString());
        }